Example #1
0
 /**
  * Display or retrieve the HTML dropdown list of product categories.
  *
  * The list of arguments is below:
  *     "show_option_all" (string) - Text to display for showing all categories.
  *     "show_option_none" (string) - Text to display for showing no categories.
  *     "orderby" (string) default is "ID" - What column to use for ordering the
  * categories.
  *     "order" (string) default is "ASC" - What direction to order categories.
  *     "show_last_update" (bool|int) default is 0 - See {@link get_categories()}
  *     "show_count" (bool|int) default is 0 - Whether to show how many posts are
  * in the category.
  *     "hide_empty" (bool|int) default is 1 - Whether to hide categories that
  * don"t have any posts attached to them.
  *     "child_of" (int) default is 0 - See {@link get_categories()}.
  *     "exclude" (string) - See {@link get_categories()}.
  *     "depth" (int) - The max depth.
  *     "tab_index" (int) - Tab index for select element.
  *     "name" (string) - The name attribute value for select element.
  *     "id" (string) - The ID attribute value for select element. Defaults to name if omitted.
  *     "class" (string) - The class attribute value for select element.
  *     "selected" (int) - Which category ID is selected.
  *     "taxonomy" (string) - The name of the taxonomy to retrieve. Defaults to category.
  *
  * The "hierarchical" argument, which is disabled by default, will override the
  * depth argument, unless it is true. When the argument is false, it will
  * display all of the categories. When it is enabled it will use the value in
  * the "depth" argument.
  *
  */
 function mp_dropdown_categories_sc($atts)
 {
     return mp_dropdown_categories(false, $atts);
 }
Example #2
0
    function widget($args, $instance)
    {
        if ($instance['only_store_pages'] && !mp_is_shop_page()) {
            return;
        }
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Product Categories', 'mp') : $instance['title'], $instance, $this->id_base);
        $c = $instance['count'] ? '1' : '0';
        $h = $instance['hierarchical'] ? '1' : '0';
        $d = $instance['dropdown'] ? '1' : '0';
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h);
        if ($d) {
            $cat_args['show_option_none'] = __('Select Category');
            $cat_args['taxonomy'] = 'product_category';
            $cat_args['id'] = 'mp_category_dropdown';
            mp_dropdown_categories(true, $cat_args);
        } else {
            ?>
<ul id="mp_category_list">
<?php 
            $cat_args['title_li'] = '';
            $cat_args['taxonomy'] = 'product_category';
            wp_list_categories($cat_args);
            ?>
</ul>
<?php 
        }
        echo $after_widget;
    }