Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 38.22 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * Widget Class for displaying categories. Extended version of the dfeault categories.
  5.  *
  6.  */
  7. class WP_Widget_AVH_ExtendedCategories_Normal extends WP_Widget
  8. {
  9.     /**
  10.      *
  11.      * @var AVH_EC_Core
  12.      */
  13.     var $core;
  14.  
  15.     /**
  16.      * PHP 5 Constructor
  17.      *
  18.      */
  19.     function __construct ()
  20.     {
  21.         $this->core = & AVH_EC_Singleton::getInstance('AVH_EC_Core');
  22.  
  23.         //Convert the old option widget_extended_categories to widget_extended-categories
  24.         $old = get_option('widget_extended_categories');
  25.         if (! (FALSE === $old)) {
  26.             update_option('widget_extended-categories', $old);
  27.             delete_option('widget_extended_categories');
  28.         }
  29.         $widget_ops = array ( 'description' => __("An extended version of the default Categories widget.", 'avh-ec') );
  30.         WP_Widget::__construct('extended-categories', 'AVH Extended Categories', $widget_ops);
  31.  
  32.         add_action('wp_print_styles', array ( &$this, 'actionWpPrintStyles' ));
  33.  
  34.     }
  35.  
  36.     function WP_Widget_AVH_ExtendedCategories_Normal ()
  37.     {
  38.         $this->__construct();
  39.     }
  40.  
  41.     function actionWpPrintStyles ()
  42.     {
  43.  
  44.         if (! (FALSE === is_active_widget(FALSE, FALSE, $this->id_base, TRUE))) {
  45.             wp_register_style('avhec-widget', AVHEC_PLUGIN_URL . '/css/avh-ec.widget.css', array (), $this->core->version);
  46.             wp_enqueue_style('avhec-widget');
  47.         }
  48.     }
  49.  
  50.     /**
  51.      * Display the widget
  52.      *
  53.      * @param unknown_type $args
  54.      * @param unknown_type $instance
  55.      */
  56.     function widget ($args, $instance)
  57.     {
  58.  
  59.         extract($args);
  60.  
  61.         $selectedonly = $instance['selectedonly'] ? TRUE : FALSE;
  62.         $c = $instance['count'] ? TRUE : FALSE;
  63.         $h = $instance['hierarchical'] ? TRUE : FALSE;
  64.         $d = $instance['depth'] ? $instance['depth'] : 0;
  65.         $e = $instance['hide_empty'] ? TRUE : FALSE;
  66.         $use_desc_for_title = $instance['use_desc_for_title'] ? TRUE : FALSE;
  67.         $s = $instance['sort_column'] ? $instance['sort_column'] : 'name';
  68.         $o = $instance['sort_order'] ? $instance['sort_order'] : 'asc';
  69.         $r = $instance['rssfeed'] ? 'RSS' : '';
  70.         $i = $instance['rssimage'] ? $instance['rssimage'] : '';
  71.         $invert = $instance['invert_included'] ? TRUE : FALSE;
  72.  
  73.         if (empty($r)) {
  74.             $i = '';
  75.         }
  76.  
  77.         if (empty($d)) {
  78.             $d = 0;
  79.         }
  80.  
  81.         $title = apply_filters('widget_title', empty($instance['title']) ? __('Categories', 'avh-ec') : $instance['title']);
  82.         $style = empty($instance['style']) ? 'list' : $instance['style'];
  83.  
  84.         $included_cats = '';
  85.         if ($instance['post_category']) {
  86.             $post_category = unserialize($instance['post_category']);
  87.             $children = array ();
  88.             if (! $instance['selectedonly']) {
  89.                 foreach ($post_category as $cat_id) {
  90.                     $children = array_merge($children, get_term_children($cat_id, 'category'));
  91.                 }
  92.             }
  93.             $included_cats = implode(",", array_merge($post_category, $children));
  94.         }
  95.  
  96.         if ($invert) {
  97.             $inc_exc = 'exclude';
  98.         } else {
  99.             $inc_exc = 'include';
  100.         }
  101.  
  102.         $options = $this->core->getOptions();
  103.         $show_option_none = __('Select Category', 'avh-ec');
  104.         if ($options['general']['alternative_name_select_category']) {
  105.             $show_option_none = $options['general']['alternative_name_select_category'];
  106.         }
  107.  
  108.         $cat_args = array ( $inc_exc => $included_cats, 'orderby' => $s, 'order' => $o, 'show_count' => $c, 'use_desc_for_title' => $use_desc_for_title, 'hide_empty' => $e, 'hierarchical' => $h, 'depth' => $d, 'title_li' => '', 'show_option_none' => $show_option_none, 'feed' => $r, 'feed_image' => $i, 'name' => 'extended-categories-select-' . $this->number );
  109.         echo $before_widget;
  110.         echo $this->core->comment;
  111.         echo $before_title . $title . $after_title;
  112.  
  113.         if ($style == 'list') {
  114.             echo '<ul>';
  115.             $this->core->avh_wp_list_categories($cat_args, $selectedonly);
  116.             echo '</ul>';
  117.         } else {
  118.             $this->core->avh_wp_dropdown_categories($cat_args, $selectedonly);
  119.             echo '<script type=\'text/javascript\'>' . "\n";
  120.             echo '/* <![CDATA[ */' . "\n";
  121.             echo '            var ec_dropdown_' . $this->number . ' = document.getElementById("extended-categories-select-' . $this->number . '");' . "\n";
  122.             echo '            function ec_onCatChange_' . $this->number . '() {' . "\n";
  123.             echo '                if ( ec_dropdown_' . $this->number . '.options[ec_dropdown_' . $this->number . '.selectedIndex].value > 0 ) {' . "\n";
  124.             echo '                    location.href = "' .home_url() . '/?cat="+ec_dropdown_' . $this->number . '.options[ec_dropdown_' . $this->number . '.selectedIndex].value;' . "\n";
  125.             echo '                }' . "\n";
  126.             echo '            }' . "\n";
  127.             echo '            ec_dropdown_' . $this->number . '.onchange = ec_onCatChange_' . $this->number . ';' . "\n";
  128.             echo '/* ]]> */' . "\n";
  129.             echo '</script>' . "\n";
  130.         }
  131.         echo $after_widget;
  132.     }
  133.  
  134.     /**
  135.      * When Widget Control Form Is Posted
  136.      *
  137.      * @param unknown_type $new_instance
  138.      * @param unknown_type $old_instance
  139.      * @return unknown
  140.      */
  141.     function update ($new_instance, $old_instance)
  142.     {
  143.         // update the instance's settings
  144.         if (! isset($new_instance['submit'])) {
  145.             return FALSE;
  146.         }
  147.  
  148.         $instance = $old_instance;
  149.  
  150.         $instance['title'] = strip_tags(stripslashes($new_instance['title']));
  151.         $instance['selectedonly'] = $new_instance['selectedonly'] ? TRUE : FALSE;
  152.         $instance['count'] = $new_instance['count'] ? TRUE : FALSE;
  153.         $instance['hierarchical'] = $new_instance['hierarchical'] ? TRUE : FALSE;
  154.         $instance['hide_empty'] = $new_instance['hide_empty'] ? TRUE : FALSE;
  155.         $instance['use_desc_for_title'] = $new_instance['use_desc_for_title'] ? TRUE : FALSE;
  156.         $instance['sort_column'] = strip_tags(stripslashes($new_instance['sort_column']));
  157.         $instance['sort_order'] = strip_tags(stripslashes($new_instance['sort_order']));
  158.         $instance['style'] = strip_tags(stripslashes($new_instance['style']));
  159.         $instance['rssfeed'] = $new_instance['rssfeed'] ? TRUE : FALSE;
  160.         $instance['rssimage'] = strip_tags(stripslashes($new_instance['rssimage']));
  161.         if (array_key_exists('all', $new_instance['post_category'])) {
  162.             $instance['post_category'] = FALSE;
  163.         } else {
  164.             $instance['post_category'] = serialize($new_instance['post_category']);
  165.         }
  166.         $instance['depth'] = (int) $new_instance['depth'];
  167.         if ($instance['depth'] < 0 || 11 < $instance['depth']) {
  168.             $instance['depth'] = 0;
  169.         }
  170.         $instance['invert_included'] = $new_instance['invert_included'] ? TRUE : FALSE;
  171.  
  172.         return $instance;
  173.     }
  174.  
  175.     /**
  176.      * Display Widget Control Form
  177.      *
  178.      * @param unknown_type $instance
  179.      */
  180.     function form ($instance)
  181.     {
  182.         // displays the widget admin form
  183.         $instance = wp_parse_args((array) $instance, array ( 'title' => '', 'rssimage' => '', 'depth' => 0 ));
  184.  
  185.         // Prepare data for display
  186.         $depth = (int) $instance['depth'];
  187.         if ($depth < 0 || 11 < $depth) {
  188.             $depth = 0;
  189.         }
  190.         $selected_cats = (isset($instance['post_category']) && $instance['post_category'] != '') ? unserialize($instance['post_category']) : FALSE;
  191.  
  192.         echo '<p>';
  193.         avh_doWidgetFormText($this->get_field_id('title'), $this->get_field_name('title'), __('Title', 'avh-ec'), $instance['title']);
  194.         echo '</p>';
  195.  
  196.         echo '<p>';
  197.         avh_doWidgetFormCheckbox($this->get_field_id('selectedonly'), $this->get_field_name('selectedonly'), __('Show selected categories only', 'avh-ec'), !empty($instance['selectedonly']));
  198.  
  199.         avh_doWidgetFormCheckbox($this->get_field_id('count'), $this->get_field_name('count'), __('Show post counts', 'avh-ec'), !empty($instance['count']));
  200.  
  201.         avh_doWidgetFormCheckbox($this->get_field_id('hierarchical'), $this->get_field_name('hierarchical'), __('Show hierarchy', 'avh-ec'), !empty($instance['hierarchical']));
  202.  
  203.         $options = array ( 0 => __('All Levels', 'avh-ec'), 1 => __('Toplevel only', 'avh-ec') );
  204.         for ($i = 2; $i <= 11; $i ++) {
  205.             $options[$i] = __('Child ', 'avh-ec') . ($i - 1);
  206.         }
  207.         avh_doWidgetFormSelect($this->get_field_id('depth'), $this->get_field_name('depth'), __('How many levels to show', 'avh-ec'), $options, $depth);
  208.         unset($options);
  209.  
  210.         avh_doWidgetFormCheckbox($this->get_field_id('hide_empty'), $this->get_field_name('hide_empty'), __('Hide empty categories', 'avh-ec'), !empty($instance['hide_empty']));
  211.  
  212.         avh_doWidgetFormCheckbox($this->get_field_id('use_desc_for_title'), $this->get_field_name('use_desc_for_title'), __('Use description for title', 'avh-ec'), !empty($instance['use_desc_for_title']));
  213.         echo '</p>';
  214.  
  215.         echo '<p>';
  216.         $options['ID'] = __('ID', 'avh-ec');
  217.         $options['name'] = __('Name', 'avh-ec');
  218.         $options['count'] = __('Count', 'avh-ec');
  219.         $options['slug'] = __('Slug', 'avh-ec');
  220.         $options['avhec_manualorder'] = 'AVH EC ' . __('Manual Order', 'avh-ec');
  221.         if (is_plugin_active('my-category-order/mycategoryorder.php')) {
  222.             $options['avhec_3rdparty_mycategoryorder'] = 'My Category Order';
  223.         }
  224.  
  225.         avh_doWidgetFormSelect($this->get_field_id('sort_column'), $this->get_field_name('sort_column'), __('Sort by', 'avh-ec'), $options, @$instance['sort_column']);
  226.         unset($options);
  227.  
  228.         $options['asc'] = __('Ascending', 'avh-ec');
  229.         $options['desc'] = __('Descending', 'avh-ec');
  230.         avh_doWidgetFormSelect($this->get_field_id('sort_order'), $this->get_field_name('sort_order'), __('Sort order', 'avh-ec'), $options, @$instance['sort_order']);
  231.         unset($options);
  232.  
  233.         $options['list'] = __('List', 'avh-ec');
  234.         $options['drop'] = __('Drop down', 'avh-ec');
  235.         avh_doWidgetFormSelect($this->get_field_id('style'), $this->get_field_name('style'), __('Display style', 'avh-ec'), $options, @$instance['style']);
  236.         unset($options);
  237.         echo '</p>';
  238.  
  239.         echo '<p>';
  240.  
  241.         avh_doWidgetFormCheckbox($this->get_field_id('rssfeed'), $this->get_field_name('rssfeed'), __('Show RSS Feed', 'avh-ec'), !empty($instance['rssfeed']));
  242.  
  243.         avh_doWidgetFormText($this->get_field_id('rssimage'), $this->get_field_name('rssimage'), __('Path (URI) to RSS image', 'avh-ec'), @$instance['rssimage']);
  244.  
  245.         echo '</p>';
  246.  
  247.         echo '<p>';
  248.         echo '<b>' . __('Select categories', 'avh-ec') . '</b><hr />';
  249.         echo '<ul id="categorychecklist" class="list:category categorychecklist form-no-clear" style="list-style-type: none; margin-left: 5px; padding-left: 0px; margin-bottom: 20px;">';
  250.         echo '<li id="' . $this->get_field_id('category--1') . '" class="popular-category">';
  251.         echo '<label for="' . $this->get_field_id('post_category') . '" class="selectit">';
  252.         echo '<input value="all" id="' . $this->get_field_id('post_category') . '" name="' . $this->get_field_name('post_category') . '[all]" type="checkbox" ' . (FALSE === $selected_cats ? ' CHECKED' : '') . '> ';
  253.         _e('All Categories', 'avh-ec');
  254.         echo '</label>';
  255.         echo '</li>';
  256.         ob_start();
  257.         $this->avh_wp_category_checklist($selected_cats, $this->number);
  258.         ob_end_flush();
  259.         echo '</ul>';
  260.         echo '</p>';
  261.  
  262.         echo '<p>';
  263.         avh_doWidgetFormCheckbox($this->get_field_id('invert_included'), $this->get_field_name('invert_included'), __('Exclude the selected categories', 'avh-ec'), !empty($instance['invert_included']));
  264.         echo '</p>';
  265.  
  266.         echo '<input type="hidden" id="' . $this->get_field_id('submit') . '" name="' . $this->get_field_name('submit') . '" value="1" />';
  267.     }
  268.  
  269.     /**
  270.      * Creates the categories checklist
  271.      *
  272.      * @param int $post_id
  273.      * @param int $descendants_and_self
  274.      * @param array $selected_cats
  275.      * @param array $popular_cats
  276.      * @param int $number
  277.      */
  278.     function avh_wp_category_checklist ($selected_cats, $number)
  279.     {
  280.  
  281.         $walker = new AVH_Walker_Category_Checklist();
  282.         $walker->number = $number;
  283.         $walker->input_id = $this->get_field_id('post_category');
  284.         $walker->input_name = $this->get_field_name('post_category');
  285.         $walker->li_id = $this->get_field_id('category--1');
  286.  
  287.         $args = array ( 'taxonomy' => 'category', 'descendants_and_self' => 0, 'selected_cats' => $selected_cats, 'popular_cats' => array (), 'walker' => $walker, 'checked_ontop' => true, 'popular_cats' => array () );
  288.  
  289.         if (is_array($selected_cats))
  290.             $args['selected_cats'] = $selected_cats;
  291.         else
  292.             $args['selected_cats'] = array ();
  293.  
  294.         $categories = $this->core->getCategories();
  295.         $_categories_id = $this->core->getCategoriesId($categories);
  296.  
  297.         // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache)
  298.         $checked_categories = array ();
  299.         foreach ($args['selected_cats'] as $key => $value) {
  300.             if (isset($_categories_id[$key])) {
  301.                 $category_key = $_categories_id[$key];
  302.                 $checked_categories[] = $categories[$category_key];
  303.                 unset($categories[$category_key]);
  304.             }
  305.         }
  306.  
  307.         // Put checked cats on top
  308.         echo $walker->walk($checked_categories, 0, array ( $args ));
  309.         // Then the rest of them
  310.         echo $walker->walk($categories, 0, array ( $args ));
  311.     }
  312. }
  313.  
  314. /**
  315.  * Widget Class for displaying the top categories
  316.  *
  317.  */
  318. class WP_Widget_AVH_ExtendedCategories_Top extends WP_Widget
  319. {
  320.     /**
  321.      *
  322.      * @var AVH_EC_Core
  323.      */
  324.     var $core;
  325.  
  326.     /**
  327.      * PHP 5 Constructor
  328.      *
  329.      */
  330.     function __construct ()
  331.     {
  332.         $this->core = & AVH_EC_Singleton::getInstance('AVH_EC_Core');
  333.  
  334.         $widget_ops = array ( 'description' => __("Shows the top categories.", 'avh-ec') );
  335.         WP_Widget::__construct(FALSE, 'AVH Extended Categories: ' . __('Top Categories'), $widget_ops);
  336.         add_action('wp_print_styles', array ( &$this, 'actionWpPrintStyles' ));
  337.  
  338.     }
  339.  
  340.     function WP_Widget_AVH_ExtendedCategories_Top ()
  341.     {
  342.         $this->__construct();
  343.     }
  344.  
  345.     function actionWpPrintStyles ()
  346.     {
  347.         if (! (FALSE === is_active_widget(FALSE, FALSE, $this->id_base, TRUE))) {
  348.             wp_register_style('avhec-widget', AVHEC_PLUGIN_URL . '/css/avh-ec.widget.css', array (), $this->core->version);
  349.             wp_enqueue_style('avhec-widget');
  350.         }
  351.     }
  352.  
  353.     /** Echo the widget content.
  354.      *
  355.      * Subclasses should over-ride this function to generate their widget code.
  356.      *
  357.      * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
  358.      * @param array $instance The settings for the particular instance of the widget
  359.      */
  360.     function widget ($args, $instance)
  361.     {
  362.         extract($args);
  363.  
  364.         $title = apply_filters('widget_title', empty($instance['title']) ? __('Categories', 'avh-ec') : $instance['title']);
  365.         $style = empty($instance['style']) ? 'list' : $instance['style'];
  366.         if (! $a = (int) $instance['amount']) {
  367.             $a = 5;
  368.         } elseif ($a < 1) {
  369.             $a = 1;
  370.         }
  371.         $c = $instance['count'] ? TRUE : FALSE;
  372.         $use_desc_for_title = $instance['use_desc_for_title'] ? TRUE : FALSE;
  373.         $s = $instance['sort_column'] ? $instance['sort_column'] : 'name';
  374.         $o = $instance['sort_order'] ? $instance['sort_order'] : 'asc';
  375.         $r = $instance['rssfeed'] ? 'RSS' : '';
  376.         $i = $instance['rssimage'] ? $instance['rssimage'] : '';
  377.         if (empty($r)) {
  378.             $i = '';
  379.         }
  380.         if (! empty($i)) {
  381.             if (! file_exists(ABSPATH . '/' . $i)) {
  382.                 $i = '';
  383.             }
  384.         }
  385.  
  386.         $options = $this->core->getOptions();
  387.         $show_option_none = __('Select Category', 'avh-ec');
  388.         if ($options['general']['alternative_name_select_category']) {
  389.             $show_option_none = $options['general']['alternative_name_select_category'];
  390.         }
  391.  
  392.         $top_cats = get_terms('category', array ( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => $a, 'hierarchical' => FALSE ));
  393.         $included_cats = implode(",", $top_cats);
  394.  
  395.         $cat_args = array ( 'include' => $included_cats, 'orderby' => $s, 'order' => $o, 'show_count' => $c, 'use_desc_for_title' => $use_desc_for_title, 'hide_empty' => FALSE, 'hierarchical' => FALSE, 'depth' => - 1, 'title_li' => '', 'show_option_none' => $show_option_none, 'feed' => $r, 'feed_image' => $i, 'name' => 'extended-categories-top-select-' . $this->number );
  396.         echo $before_widget;
  397.         echo $this->core->comment;
  398.         echo $before_title . $title . $after_title;
  399.         echo '<ul>';
  400.  
  401.         if ($style == 'list') {
  402.             wp_list_categories($cat_args);
  403.         } else {
  404.             wp_dropdown_categories($cat_args);
  405.             echo '<script type=\'text/javascript\'>' . "\n";
  406.             echo '/* <![CDATA[ */' . "\n";
  407.             echo '            var ec_dropdown_top_' . $this->number . ' = document.getElementById("extended-categories-top-select-' . $this->number . '");' . "\n";
  408.             echo '            function ec_top_onCatChange_' . $this->number . '() {' . "\n";
  409.             echo '                if ( ec_dropdown_top_' . $this->number . '.options[ec_dropdown_top_' . $this->number . '.selectedIndex].value > 0 ) {' . "\n";
  410.             echo '                    location.href = "' . get_option('home') . '/?cat="+ec_dropdown_top_' . $this->number . '.options[ec_dropdown_top_' . $this->number . '.selectedIndex].value;' . "\n";
  411.             echo '                }' . "\n";
  412.             echo '            }' . "\n";
  413.             echo '            ec_dropdown_top_' . $this->number . '.onchange = ec_top_onCatChange_' . $this->number . ';' . "\n";
  414.             echo '/* ]]> */' . "\n";
  415.             echo '</script>' . "\n";
  416.         }
  417.         echo '</ul>';
  418.         echo $after_widget;
  419.     }
  420.  
  421.     /** Update a particular instance.
  422.      *
  423.      * This function should check that $new_instance is set correctly.
  424.      * The newly calculated value of $instance should be returned.
  425.      * If "FALSE" is returned, the instance won't be saved/updated.
  426.      *
  427.      * @param array $new_instance New settings for this instance as input by the user via form()
  428.      * @param array $old_instance Old settings for this instance
  429.      * @return array Settings to save or bool FALSE to cancel saving
  430.      */
  431.     function update ($new_instance, $old_instance)
  432.     {
  433.         // update the instance's settings
  434.         if (! isset($new_instance['submit'])) {
  435.             return FALSE;
  436.         }
  437.  
  438.         $instance = $old_instance;
  439.  
  440.         $instance['title'] = strip_tags(stripslashes($new_instance['title']));
  441.         $instance['amount'] = (int) $new_instance['amount'];
  442.         $instance['count'] = $new_instance['count'] ? TRUE : FALSE;
  443.         $instance['use_desc_for_title'] = $new_instance['use_desc_for_title'] ? TRUE : FALSE;
  444.         $instance['sort_column'] = strip_tags(stripslashes($new_instance['sort_column']));
  445.         $instance['sort_order'] = strip_tags(stripslashes($new_instance['sort_order']));
  446.         $instance['style'] = strip_tags(stripslashes($new_instance['style']));
  447.         $instance['rssfeed'] = $new_instance['rssfeed'] ? TRUE : FALSE;
  448.         $instance['rssimage'] = strip_tags(stripslashes($new_instance['rssimage']));
  449.  
  450.         return $instance;
  451.     }
  452.  
  453.     /** Echo the settings update form
  454.      *
  455.      * @param array $instance Current settings
  456.      */
  457.     function form ($instance)
  458.     {
  459.         // displays the widget admin form
  460.         $instance = wp_parse_args((array) $instance, array ( 'title' => '', 'rssimage' => '' ));
  461.  
  462.         // Prepare data for display
  463.         if (!isset($instance['amount']) || !($amount = (int) $instance['amount']) ) {
  464.             $amount = 5;
  465.         }
  466.  
  467.         if ($amount < 1) {
  468.             $amount = 1;
  469.         }
  470.         echo '<p>';
  471.         avh_doWidgetFormText($this->get_field_id('title'), $this->get_field_name('title'), __('Title', 'avh-ec'), $instance['title']);
  472.         echo '</p>';
  473.  
  474.         echo '<p>';
  475.         avh_doWidgetFormText($this->get_field_id('amount'), $this->get_field_name('amount'), __('How many categories to show', 'avh-ec'), $amount);
  476.         echo '</p>';
  477.  
  478.         echo '<p>';
  479.         avh_doWidgetFormCheckbox($this->get_field_id('count'), $this->get_field_name('count'), __('Show post counts', 'avh-ec'), !empty($instance['count']));
  480.         echo '<br />';
  481.  
  482.         avh_doWidgetFormCheckbox($this->get_field_id('use_desc_for_title'), $this->get_field_name('use_desc_for_title'), __('Use description for title', 'avh-ec'), !empty($instance['use_desc_for_title']));
  483.         echo '</p>';
  484.  
  485.         echo '<p>';
  486.         $options['ID'] = __('ID', 'avh-ec');
  487.         $options['name'] = __('Name', 'avh-ec');
  488.         $options['count'] = __('Count', 'avh-ec');
  489.         $options['slug'] = __('Slug', 'avh-ec');
  490.         avh_doWidgetFormSelect($this->get_field_id('sort_column'), $this->get_field_name('sort_column'), __('Sort by', 'avh-ec'), $options, @$instance['sort_column']);
  491.         unset($options);
  492.  
  493.         $options['asc'] = __('Ascending', 'avh-ec');
  494.         $options['desc'] = __('Descending', 'avh-ec');
  495.         avh_doWidgetFormSelect($this->get_field_id('sort_order'), $this->get_field_name('sort_order'), __('Sort order', 'avh-ec'), $options, @$instance['sort_order']);
  496.         unset($options);
  497.  
  498.         $options['list'] = __('List', 'avh-ec');
  499.         $options['drop'] = __('Drop down', 'avh-ec');
  500.         avh_doWidgetFormSelect($this->get_field_id('style'), $this->get_field_name('style'), __('Display style', 'avh-ec'), $options, @$instance['style']);
  501.         unset($options);
  502.         echo '</p>';
  503.  
  504.         echo '<p>';
  505.  
  506.         avh_doWidgetFormCheckbox($this->get_field_id('rssfeed'), $this->get_field_name('rssfeed'), __('Show RSS Feed', 'avh-ec'), !empty($instance['rssfeed']));
  507.  
  508.         avh_doWidgetFormText($this->get_field_id('rssimage'), $this->get_field_name('rssimage'), __('Path (URI) to RSS image', 'avh-ec'), @$instance['rssimage']);
  509.  
  510.         echo '</p>';
  511.  
  512.         echo '<input type="hidden" id="' . $this->get_field_id('submit') . '" name="' . $this->get_field_name('submit') . '" value="1" />';
  513.     }
  514. }
  515.  
  516. /**
  517.  * Widget Class for displaying the grouped categories
  518.  *
  519.  */
  520. class WP_Widget_AVH_ExtendedCategories_Category_Group extends WP_Widget
  521. {
  522.     /**
  523.      *
  524.      * @var AVH_EC_Core
  525.      */
  526.     var $core;
  527.  
  528.     /**
  529.      *
  530.      * @var AVH_EC_Category_Group
  531.      */
  532.     var $catgrp;
  533.  
  534.     /**
  535.      * PHP 5 Constructor
  536.      *
  537.      */
  538.     function __construct ()
  539.     {
  540.         $this->core = & AVH_EC_Singleton::getInstance('AVH_EC_Core');
  541.         $this->catgrp = & AVH_EC_Singleton::getInstance('AVH_EC_Category_Group');
  542.  
  543.         $widget_ops = array ( 'description' => __("Shows grouped categories.", 'avh-ec') );
  544.         WP_Widget::__construct(FALSE, 'AVH Extended Categories: ' . __('Category Group'), $widget_ops);
  545.         add_action('wp_print_styles', array ( &$this, 'actionWpPrintStyles' ));
  546.  
  547.     }
  548.  
  549.     function WP_Widget_AVH_ExtendedCategories_Category_Group ()
  550.     {
  551.         $this->__construct();
  552.     }
  553.  
  554.     function actionWpPrintStyles ()
  555.     {
  556.         if (! (FALSE === is_active_widget(FALSE, FALSE, $this->id_base, TRUE))) {
  557.             wp_register_style('avhec-widget', AVHEC_PLUGIN_URL . '/css/avh-ec.widget.css', array (), $this->core->version);
  558.             wp_enqueue_style('avhec-widget');
  559.         }
  560.     }
  561.  
  562.     /**
  563.      * Display the widget
  564.      *
  565.      * @param unknown_type $args
  566.      * @param unknown_type $instance
  567.      */
  568.     function widget ($args, $instance)
  569.     {
  570.         global $post, $wp_query;
  571.  
  572.         $catgrp = & AVH_EC_Singleton::getInstance('AVH_EC_Category_Group');
  573.         $options = $this->core->getOptions();
  574.  
  575.         $row = array ();
  576.  
  577.         if (is_home()) {
  578.             $special_page = 'home_group';
  579.         } elseif (is_category()) {
  580.             $special_page = 'category_group';
  581.         } elseif (is_day()) {
  582.             $special_page = 'day_group';
  583.         } elseif (is_month()) {
  584.             $special_page = 'month_group';
  585.         } elseif (is_year()) {
  586.             $special_page = 'year_group';
  587.         } elseif (is_author()) {
  588.             $special_page = 'author_group';
  589.         } elseif (is_search()) {
  590.             $special_page = 'search_group';
  591.         } else {
  592.             $special_page = 'none';
  593.         }
  594.  
  595.         $toDisplay = FALSE;
  596.         if ('none' == $special_page) {
  597.             $terms = wp_get_object_terms($post->ID, $catgrp->taxonomy_name);
  598.             if (! empty($terms)) {
  599.                 $selected_catgroups = unserialize($instance['post_group_category']);
  600.                 foreach ($terms as $key => $value) {
  601.                     if ($selected_catgroups === FALSE || array_key_exists($value->term_id, $selected_catgroups)) {
  602.                         if (! ($this->getWidgetDoneCatGroup($value->term_id))) {
  603.                             $row = $value;
  604.                             $group_found = TRUE;
  605.                             break;
  606.                         }
  607.                     }
  608.                 }
  609.             } else {
  610.                 $options = $this->core->options;
  611.                 $no_cat_group = $options['cat_group']['no_group'];
  612.                 $row = get_term_by('id', $no_cat_group, $catgrp->taxonomy_name);
  613.                 $group_found = TRUE;
  614.             }
  615.         } else {
  616.             if ('category_group' == $special_page) {
  617.                 $tax_meta = get_option($this->core->db_options_tax_meta);
  618.                 $term = $wp_query->get_queried_object();
  619.                 if (isset($tax_meta[$term->taxonomy][$term->term_id]['category_group_term_id'])) {
  620.                     $sp_category_group_id = $tax_meta[$term->taxonomy][$term->term_id]['category_group_term_id'];
  621.                 } else {
  622.                     $sp_category_group = $this->catgrp->getGroupByCategoryID($term->term_id);
  623.                     $sp_category_group_id = $sp_category_group->term_id;
  624.                 }
  625.             } else {
  626.                 $sp_category_group_id = $options['sp_cat_group'][$special_page];
  627.             }
  628.             $row = get_term_by('id', $sp_category_group_id, $catgrp->taxonomy_name); // Returns FALSE when non-existance. (empty(FALSE)=TRUE)
  629.             $group_found = TRUE;
  630.         }
  631.  
  632.         if ($group_found) {
  633.             $toDisplay = TRUE;
  634.             $category_group_id_none = $this->catgrp->getTermIDBy('slug', 'none');
  635.             $selected_catgroups = unserialize($instance['post_group_category']);
  636.  
  637.             if ($category_group_id_none == $row->term_id) {
  638.                 $toDisplay = FALSE;
  639.             } elseif (! (FALSE == $selected_catgroups || array_key_exists($row->term_id, $selected_catgroups))) {
  640.                 $toDisplay = FALSE;
  641.             } elseif ($special_page != 'none' && $this->getWidgetDoneCatGroup($sp_category_group_id)) {
  642.                 $toDisplay = FALSE;
  643.             }
  644.         }
  645.  
  646.         if ($toDisplay) {
  647.             extract($args);
  648.  
  649.             $c = $instance['count'] ? TRUE : FALSE;
  650.             $e = $instance['hide_empty'] ? TRUE : FALSE;
  651.             $h = $instance['hierarchical'] ? TRUE : FALSE;
  652.             $use_desc_for_title = $instance['use_desc_for_title'] ? TRUE : FALSE;
  653.             $s = $instance['sort_column'] ? $instance['sort_column'] : 'name';
  654.             $o = $instance['sort_order'] ? $instance['sort_order'] : 'asc';
  655.             $r = $instance['rssfeed'] ? 'RSS' : '';
  656.             $i = $instance['rssimage'] ? $instance['rssimage'] : '';
  657.  
  658.             if (empty($r)) {
  659.                 $i = '';
  660.             }
  661.  
  662.             $style = empty($instance['style']) ? 'list' : $instance['style'];
  663.             $group_id = $row->term_id;
  664.             $cats = $catgrp->getCategoriesFromGroup($group_id);
  665.             if (empty($instance['title'])) {
  666.                 $title = $catgrp->getWidgetTitleForGroup($group_id);
  667.                 if (! $title) {
  668.                     $title = __('Categories', 'avh-ec');
  669.                 }
  670.             } else {
  671.                 $title = $instance['title'];
  672.             }
  673.             $title = apply_filters('widget_title', $title);
  674.  
  675.             $included_cats = implode(',', $cats);
  676.  
  677.             $show_option_none = __('Select Category', 'avh-ec');
  678.             if ($options['general']['alternative_name_select_category']) {
  679.                 $show_option_none = $options['general']['alternative_name_select_category'];
  680.             }
  681.  
  682.             $cat_args = array ( 'include' => $included_cats, 'orderby' => $s, 'order' => $o, 'show_count' => $c, 'use_desc_for_title' => $use_desc_for_title, 'hide_empty' => $e, 'hierarchical' => $h, 'title_li' => '', 'show_option_none' => $show_option_none, 'feed' => $r, 'feed_image' => $i, 'name' => 'extended-categories-select-group-' . $this->number );
  683.             echo $before_widget;
  684.             echo $this->core->comment;
  685.             echo $before_title . $title . $after_title;
  686.  
  687.             if ($style == 'list') {
  688.                 echo '<ul>';
  689.                 $this->core->avh_wp_list_categories($cat_args, TRUE);
  690.                 echo '</ul>';
  691.             } else {
  692.                 $this->core->avh_wp_dropdown_categories($cat_args, TRUE);
  693.                 echo '<script type=\'text/javascript\'>' . "\n";
  694.                 echo '/* <![CDATA[ */' . "\n";
  695.                 echo '            var ec_dropdown_' . $this->number . ' = document.getElementById("extended-categories-select-group-' . $this->number . '");' . "\n";
  696.                 echo '            function ec_onCatChange_' . $this->number . '() {' . "\n";
  697.                 echo '                if ( ec_dropdown_' . $this->number . '.options[ec_dropdown_' . $this->number . '.selectedIndex].value > 0 ) {' . "\n";
  698.                 echo '                    location.href = "' . get_option('home') . '/?cat="+ec_dropdown_' . $this->number . '.options[ec_dropdown_' . $this->number . '.selectedIndex].value;' . "\n";
  699.                 echo '                }' . "\n";
  700.                 echo '            }' . "\n";
  701.                 echo '            ec_dropdown_' . $this->number . '.onchange = ec_onCatChange_' . $this->number . ';' . "\n";
  702.                 echo '/* ]]> */' . "\n";
  703.                 echo '</script>' . "\n";
  704.             }
  705.             echo $after_widget;
  706.         }
  707.     }
  708.  
  709.     /**
  710.      * When Widget Control Form Is Posted
  711.      *
  712.      * @param unknown_type $new_instance
  713.      * @param unknown_type $old_instance
  714.      * @return unknown
  715.      */
  716.     function update ($new_instance, $old_instance)
  717.     {
  718.         // update the instance's settings
  719.         if (! isset($new_instance['submit'])) {
  720.             return FALSE;
  721.         }
  722.  
  723.         $instance = $old_instance;
  724.  
  725.         $instance['title'] = strip_tags(stripslashes($new_instance['title']));
  726.         $instance['count'] = $new_instance['count'] ? TRUE : FALSE;
  727.         $instance['hierarchical'] = $new_instance['hierarchical'] ? TRUE : FALSE;
  728.         $instance['hide_empty'] = $new_instance['hide_empty'] ? TRUE : FALSE;
  729.         $instance['use_desc_for_title'] = $new_instance['use_desc_for_title'] ? TRUE : FALSE;
  730.         $instance['sort_column'] = strip_tags(stripslashes($new_instance['sort_column']));
  731.         $instance['sort_order'] = strip_tags(stripslashes($new_instance['sort_order']));
  732.         $instance['style'] = strip_tags(stripslashes($new_instance['style']));
  733.         $instance['rssfeed'] = $new_instance['rssfeed'] ? TRUE : FALSE;
  734.         $instance['rssimage'] = strip_tags(stripslashes($new_instance['rssimage']));
  735.         if (array_key_exists('all', $new_instance['post_group_category'])) {
  736.             $instance['post_group_category'] = FALSE;
  737.         } else {
  738.             $instance['post_group_category'] = serialize($new_instance['post_group_category']);
  739.         }
  740.         return $instance;
  741.     }
  742.  
  743.     /**
  744.      * Display Widget Control Form
  745.      *
  746.      * @param unknown_type $instance
  747.      */
  748.     function form ($instance)
  749.     {
  750.         // displays the widget admin form
  751.         $instance = wp_parse_args((array) $instance, array ( 'title' => '', 'rssimage' => '' ));
  752.  
  753.         // Prepare data for display
  754.         $title = esc_attr($instance['title']);
  755.         $count = !empty($instance['count']);
  756.         $hierarchical = !empty($instance['hierarchical']);
  757.         $hide_empty = !empty($instance['hide_empty']);
  758.         $use_desc_for_title = !empty($instance['use_desc_for_title']);
  759.         $sort_id = (isset($instance['sort_column']) && $instance['sort_column'] == 'ID') ? ' SELECTED' : '';
  760.         $sort_name = (isset($instance['sort_column']) && $instance['sort_column'] == 'name') ? ' SELECTED' : '';
  761.         $sort_count = (isset($instance['sort_column']) && $instance['sort_column'] == 'count') ? ' SELECTED' : '';
  762.         $sort_order_a = (isset($instance['sort_order']) && $instance['sort_order'] == 'asc') ? ' SELECTED' : '';
  763.         $sort_order_d = (isset($instance['sort_order']) && $instance['sort_order'] == 'desc') ? ' SELECTED' : '';
  764.         $style_list = (isset($instance['sort_column']) && $instance['style'] == 'list') ? ' SELECTED' : '';
  765.         $style_drop = (isset($instance['sort_column']) && $instance['style'] == 'drop') ? ' SELECTED' : '';
  766.         $rssfeed = !empty($instance['rssfeed']);
  767.         $rssimage = esc_attr($instance['rssimage']);
  768.  
  769.         $selected_cats = (isset($instance['post_group_category']) && $instance['post_group_category'] != '') ? unserialize($instance['post_group_category']) : FALSE;
  770.         ob_start();
  771.         echo '<p>';
  772.         avh_doWidgetFormText($this->get_field_id('title'), $this->get_field_name('title'), __('Title', 'avh-ec'), $instance['title']);
  773.         echo '</p>';
  774.  
  775.         echo '<p>';
  776.  
  777.         avh_doWidgetFormCheckbox($this->get_field_id('count'), $this->get_field_name('count'), __('Show post counts', 'avh-ec'), !empty($instance['count']));
  778.  
  779.         avh_doWidgetFormCheckbox($this->get_field_id('hierarchical'), $this->get_field_name('hierarchical'), __('Show hierarchy', 'avh-ec'), !empty($instance['hierarchical']));
  780.  
  781.         avh_doWidgetFormCheckbox($this->get_field_id('hide_empty'), $this->get_field_name('hide_empty'), __('Hide empty categories', 'avh-ec'), !empty($instance['hide_empty']));
  782.  
  783.         avh_doWidgetFormCheckbox($this->get_field_id('use_desc_for_title'), $this->get_field_name('use_desc_for_title'), __('Use description for title', 'avh-ec'), !empty($instance['use_desc_for_title']));
  784.         echo '</p>';
  785.  
  786.         echo '<p>';
  787.         $options['ID'] = __('ID', 'avh-ec');
  788.         $options['name'] = __('Name', 'avh-ec');
  789.         $options['count'] = __('Count', 'avh-ec');
  790.         $options['slug'] = __('Slug', 'avh-ec');
  791.         avh_doWidgetFormSelect($this->get_field_id('sort_column'), $this->get_field_name('sort_column'), __('Sort by', 'avh-ec'), $options, @$instance['sort_column']);
  792.         unset($options);
  793.  
  794.         $options['asc'] = __('Ascending', 'avh-ec');
  795.         $options['desc'] = __('Descending', 'avh-ec');
  796.         avh_doWidgetFormSelect($this->get_field_id('sort_order'), $this->get_field_name('sort_order'), __('Sort order', 'avh-ec'), $options, @$instance['sort_order']);
  797.         unset($options);
  798.  
  799.         $options['list'] = __('List', 'avh-ec');
  800.         $options['drop'] = __('Drop down', 'avh-ec');
  801.         avh_doWidgetFormSelect($this->get_field_id('style'), $this->get_field_name('style'), __('Display style', 'avh-ec'), $options, @$instance['style']);
  802.         unset($options);
  803.         echo '</p>';
  804.  
  805.         echo '<p>';
  806.  
  807.         avh_doWidgetFormCheckbox($this->get_field_id('rssfeed'), $this->get_field_name('rssfeed'), __('Show RSS Feed', 'avh-ec'), !empty($instance['rssfeed']));
  808.  
  809.         avh_doWidgetFormText($this->get_field_id('rssimage'), $this->get_field_name('rssimage'), __('Path (URI) to RSS image', 'avh-ec'), $instance['rssimage']);
  810.         echo '</p>';
  811.  
  812.         echo '<p>';
  813.         echo '<b>' . __('Select Groups', 'avh-ec') . '</b><hr />';
  814.         echo '<ul id="categorychecklist" class="list:category categorychecklist form-no-clear" style="list-style-type: none; margin-left: 5px; padding-left: 0px; margin-bottom: 20px;">';
  815.         echo '<li id="' . $this->get_field_id('group_category--1') . '" class="popular-group_category">';
  816.         echo '<label for="' . $this->get_field_id('group_post_category') . '" class="selectit">';
  817.         echo '<input value="all" id="' . $this->get_field_id('group_post_category') . '" name="' . $this->get_field_name('post_group_category') . '[all]" type="checkbox" ' . (FALSE === $selected_cats ? ' CHECKED' : '') . '> ';
  818.         _e('Any Group', 'avh-ec');
  819.         echo '</label>';
  820.         echo '</li>';
  821.  
  822.         $this->avh_wp_group_category_checklist($selected_cats, $this->number);
  823.  
  824.         echo '</ul>';
  825.         echo '</p>';
  826.  
  827.         echo '<input type="hidden" id="' . $this->get_field_id('submit') . '" name="' . $this->get_field_name('submit') . '" value="1" />';
  828.         ob_end_flush();
  829.     }
  830.  
  831.     function avh_wp_group_category_checklist ($selected_cats, $number)
  832.     {
  833.  
  834.         $walker = new AVH_Walker_Category_Checklist();
  835.         $walker->number = $number;
  836.         $walker->input_id = $this->get_field_id('post_group_category');
  837.         $walker->input_name = $this->get_field_name('post_group_category');
  838.         $walker->li_id = $this->get_field_id('group_category--1');
  839.  
  840.         $args = array ( 'taxonomy' => 'avhec_catgroup', 'descendants_and_self' => 0, 'selected_cats' => array (), 'popular_cats' => array (), 'walker' => $walker, 'checked_ontop' => true );
  841.  
  842.         if (is_array($selected_cats))
  843.             $args['selected_cats'] = $selected_cats;
  844.         else
  845.             $args['selected_cats'] = array ();
  846.  
  847.         $categories = (array) get_terms($args['taxonomy'], array ( 'get' => 'all' ));
  848.  
  849.         // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache)
  850.         $checked_categories = array ();
  851.         $keys = array_keys($categories);
  852.  
  853.         foreach ($keys as $k) {
  854.             if (in_array($categories[$k]->term_id, $args['selected_cats'])) {
  855.                 $checked_categories[] = $categories[$k];
  856.                 unset($categories[$k]);
  857.             }
  858.         }
  859.  
  860.         // Put checked cats on top
  861.         echo $walker->walk($checked_categories, 0, array ( $args ));
  862.         // Then the rest of them
  863.         echo $walker->walk($categories, 0, array ( $args ));
  864.     }
  865.  
  866.     function getWidgetDoneCatGroup ($id)
  867.     {
  868.         $catgrp = & AVH_EC_Singleton::getInstance('AVH_EC_Category_Group');
  869.         if (is_array($catgrp->widget_done_catgroup) && array_key_exists($id, $catgrp->widget_done_catgroup)) {
  870.             return TRUE;
  871.         }
  872.         $catgrp->widget_done_catgroup[$id] = TRUE;
  873.         return FALSE;
  874.     }
  875. }
  876.  
  877. /**
  878.  * Class that will display the categories
  879.  *
  880.  */
  881. class AVH_Walker_Category_Checklist extends Walker
  882. {
  883.     var $tree_type = 'category';
  884.     var $db_fields = array ( 'parent' => 'parent', 'id' => 'term_id' ); //TODO: decouple this
  885.     var $number;
  886.     var $input_id;
  887.     var $input_name;
  888.     var $li_id;
  889.  
  890.     /**
  891.      * Display array of elements hierarchically.
  892.      *
  893.      * It is a generic function which does not assume any existing order of
  894.      * elements. max_depth = -1 means flatly display every element. max_depth =
  895.      * 0 means display all levels. max_depth > 0  specifies the number of
  896.      * display levels.
  897.      *
  898.      * @since 2.1.0
  899.      *
  900.      * @param array $elements
  901.      * @param int $max_depth
  902.      * @param array $args;
  903.      * @return string
  904.      */
  905.     function walk ($elements, $max_depth, $args)
  906.     {
  907.  
  908.         $output = '';
  909.  
  910.         if ($max_depth < - 1) //invalid parameter
  911.             return $output;
  912.  
  913.         if (empty($elements)) //nothing to walk
  914.             return $output;
  915.  
  916.         $id_field = $this->db_fields['id'];
  917.         $parent_field = $this->db_fields['parent'];
  918.  
  919.         // flat display
  920.         if (- 1 == $max_depth) {
  921.             $empty_array = array ();
  922.             foreach ($elements as $e)
  923.                 $this->display_element($e, $empty_array, 1, 0, $args, $output);
  924.             return $output;
  925.         }
  926.  
  927.         /*
  928.          * need to display in hierarchical order
  929.          * separate elements into two buckets: top level and children elements
  930.          * children_elements is two dimensional array, eg.
  931.          * children_elements[10][] contains all sub-elements whose parent is 10.
  932.          */
  933.         $top_level_elements = array ();
  934.         $children_elements = array ();
  935.         foreach ($elements as $e) {
  936.             if (0 == $e->$parent_field)
  937.                 $top_level_elements[] = $e;
  938.             else
  939.                 $children_elements[$e->$parent_field][] = $e;
  940.         }
  941.  
  942.         /*
  943.          * when none of the elements is top level
  944.          * assume the first one must be root of the sub elements
  945.          */
  946.         if (empty($top_level_elements)) {
  947.  
  948.             $first = array_slice($elements, 0, 1);
  949.             $root = $first[0];
  950.  
  951.             $top_level_elements = array ();
  952.             $children_elements = array ();
  953.             foreach ($elements as $e) {
  954.                 if ($root->$parent_field == $e->$parent_field)
  955.                     $top_level_elements[] = $e;
  956.                 else
  957.                     $children_elements[$e->$parent_field][] = $e;
  958.             }
  959.         }
  960.  
  961.         foreach ($top_level_elements as $e)
  962.             $this->display_element($e, $children_elements, $max_depth, 0, $args, $output);
  963.  
  964.             /*
  965.          * if we are displaying all levels, and remaining children_elements is not empty,
  966.          * then we got orphans, which should be displayed regardless
  967.          */
  968.         if (($max_depth == 0) && count($children_elements) > 0) {
  969.             $empty_array = array ();
  970.             foreach ($children_elements as $orphans)
  971.                 foreach ($orphans as $op)
  972.                     $this->display_element($op, $empty_array, 1, 0, $args, $output);
  973.         }
  974.  
  975.         return $output;
  976.     }
  977.  
  978.     function start_lvl (&$output, $depth, $args)
  979.     {
  980.         $indent = str_repeat("\t", $depth);
  981.         $output .= $indent . '<ul class="children">' . "\n";
  982.     }
  983.  
  984.     function end_lvl (&$output, $depth, $args)
  985.     {
  986.         $indent = str_repeat("\t", $depth);
  987.         $output .= $indent . '</ul>' . "\n";
  988.     }
  989.  
  990.     function start_el (&$output, $category, $depth, $args)
  991.     {
  992.         extract($args);
  993.         $input_id = $this->input_id . '-' . $category->term_id;
  994.         $output .= "\n" . '<li id="' . $this->li_id . '">';
  995.         $output .= '<label for="' . $input_id . '" class="selectit">';
  996.         $output .= '<input value="' . $category->term_id . '" type="checkbox" name="' . $this->input_name . '[' . $category->term_id . ']" id="' . $input_id . '"' . (in_array($category->term_id, $selected_cats) ? ' checked="checked"' : "") . '/> ' . esc_html(apply_filters('the_category', $category->name)) . '</label>';
  997.     }
  998.  
  999.     function end_el (&$output, $category, $depth, $args)
  1000.     {
  1001.         $output .= "</li>\n";
  1002.     }
  1003. }
  1004. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement