Can’t get links plugin to work
-
I’m trying to write a plugin for a widget that gives expandable link lists via javascript. The JS itself has worked when implemented directly into the template. This JS uses hides or shows the content – I don’t want to use dropdown forms that can only open in the same window or tab.
What I want is something that gets the category id dynamically so that I (or anyone else using) don’t have to put a new section into my code when I make a new category of lists. The technique for doing that was taken from here.
Not only does what I’ve written not work, but it makes all the pages blank, completely kills the site.
My plugin is as follows:
<?php /* Plugin Name: Expandable Links Version: 0.1 Plugin URI: Description: Creates a widget for expandable links and blogroll. Author: Author URI: https://www.kristarella.com/ */ ?> <script language="javascript" type="text/javascript"> function $() { var elements = new Array(); for (var i = 0; i < arguments.length; i++) { var element = arguments[i]; if (typeof element == 'string') element = document.getElementById(element); if (arguments.length == 1) return element; elements.push(element); } return elements; } function toggleSec(id, toggleid) { var obj = $(id); var toggle = $(toggleid); if (obj.className == 'sechide') { obj.className = 'secshow'; toggle.innerHTML = ' [-]'; } else { obj.className = 'sechide'; toggle.innerHTML = ' [+]'; } } </script> <?php function widget_expandlinks_init() { if ( !function_exists('register_sidebar_widget') ) return; } function widget_expandlinks($args) { extract($args); $options = get_option('widget_links'); $title = $options[$number]['title']; if (empty($options[$number]['title'])) { $title = __('Links'); } $cats = get_categories("type=link&orderby=$order&order=$direction&hierarchical=0&exclude=$exclusions&include=$inclusions"); echo $before_widget; ?> <?php echo $before_title . $title . $after_title; ?> <?php if ($cats) { foreach ( (array) $cats as $cat) { echo '<h4><a>cat_ID . '', 'toggle-' . $cat->cat_ID . '');"class="toggle">' . $cat->cat_name . '<span id="toggle-' . $cat->cat_ID . '"> [+]</span></a></h4>'; echo '<ul class="sechide" id="sec-' . $cat->cat_ID . '">'; get_links(' . $cat->cat_ID . ', ' <li>', '</li> ', '', TRUE, 'name', FALSE, TRUE, -1, FALSE, TRUE); echo '</ul> '; } } else { if (!$category) { get_links_list(); } ?> <?php echo $after_widget; ?> <?php } register_sidebar_widget('Expandable Links', 'widget_expandlinks'); ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Can’t get links plugin to work’ is closed to new replies.