Make WordPress Core

Ticket #13258: 13258.patch

File 13258.patch, 1.8 KB (added by jfarthing84, 10 years ago)
  • wp-includes/category-template.php

     
    291291 *     'show_option_all' (string) - Text to display for showing all categories.
    292292 *     'show_option_none' (string) - Text to display for showing no categories.
    293293 *     'option_none_value' (mixed) - Value to use when no category is selected.
     294 *     'option_value_field' (string) - What column to use for the option value
     295 * attribute. Can either be 'slug' or 'id'. Defaults to 'id'.
    294296 *     'orderby' (string) default is 'ID' - What column to use for ordering the
    295297 * categories.
    296298 *     'order' (string) default is 'ASC' - What direction to order categories.
     
    330332                'name' => 'cat', 'id' => '',
    331333                'class' => 'postform', 'depth' => 0,
    332334                'tab_index' => 0, 'taxonomy' => 'category',
    333                 'hide_if_empty' => false, 'option_none_value' => -1
     335                'hide_if_empty' => false, 'option_none_value' => -1,
     336                'option_value_field' => 'id'
    334337        );
    335338
    336339        $defaults['selected'] = ( is_category() ) ? get_query_var( 'cat' ) : 0;
     
    10981101                /** This filter is documented in wp-includes/category-template.php */
    10991102                $cat_name = apply_filters( 'list_cats', $category->name, $category );
    11001103
    1101                 $output .= "\t<option class=\"level-$depth\" value=\"".$category->term_id."\"";
    1102                 if ( $category->term_id == $args['selected'] )
     1104                if ( 'slug' == $args['option_value_field'] ) {
     1105                        $value = $category->slug;
     1106                        $selected = $category->slug == $args['selected'];
     1107                } else {
     1108                        $value = $category->term_id;
     1109                        $selected = $category->term_id == $args['selected'];
     1110                }
     1111
     1112                $output .= "\t<option class=\"level-$depth\" value=\"$value\"";
     1113                if ( $selected )
    11031114                        $output .= ' selected="selected"';
    11041115                $output .= '>';
    11051116                $output .= $pad.$cat_name;