Make WordPress Core

Ticket #19851: category-template.diff

File category-template.diff, 1.5 KB (added by jackreichert, 13 years ago)
  • wp-includes/category-template.php

     
    284284 *     'name' (string) - The name attribute value for select element.
    285285 *     'id' (string) - The ID attribute value for select element. Defaults to name if omitted.
    286286 *     'class' (string) - The class attribute value for select element.
     287 *         'option_class_slug' (bool|int) - Adds category slug to option with 'cat-' prefix.
    287288 *     'selected' (int) - Which category ID is selected.
    288289 *     'taxonomy' (string) - The name of the taxonomy to retrieve. Defaults to category.
    289290 *
     
    307308                'selected' => 0, 'hierarchical' => 0,
    308309                'name' => 'cat', 'id' => '',
    309310                'class' => 'postform', 'depth' => 0,
     311                'option_class_slug' => false,
    310312                'tab_index' => 0, 'taxonomy' => 'category',
    311313                'hide_if_empty' => false
    312314        );
     
    946948         */
    947949        function start_el( &$output, $category, $depth, $args, $id = 0 ) {
    948950                $pad = str_repeat(' ', $depth * 3);
    949 
     951                $option_class = ( $args['option_class_slug'] == 'true' ) ? 'cat-'.$category->slug : '';
    950952                $cat_name = apply_filters('list_cats', $category->name, $category);
    951                 $output .= "\t<option class=\"level-$depth\" value=\"".$category->term_id."\"";
     953               
     954                $output .= "\t<option class=\"level-$depth $option_class\" value=\"".$category->term_id."\"";
    952955                if ( $category->term_id == $args['selected'] )
    953956                        $output .= ' selected="selected"';
    954957                $output .= '>';