Ticket #13258: 13258.patch
File 13258.patch, 1.8 KB (added by , 10 years ago) |
---|
-
wp-includes/category-template.php
291 291 * 'show_option_all' (string) - Text to display for showing all categories. 292 292 * 'show_option_none' (string) - Text to display for showing no categories. 293 293 * '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'. 294 296 * 'orderby' (string) default is 'ID' - What column to use for ordering the 295 297 * categories. 296 298 * 'order' (string) default is 'ASC' - What direction to order categories. … … 330 332 'name' => 'cat', 'id' => '', 331 333 'class' => 'postform', 'depth' => 0, 332 334 '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' 334 337 ); 335 338 336 339 $defaults['selected'] = ( is_category() ) ? get_query_var( 'cat' ) : 0; … … 1098 1101 /** This filter is documented in wp-includes/category-template.php */ 1099 1102 $cat_name = apply_filters( 'list_cats', $category->name, $category ); 1100 1103 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 ) 1103 1114 $output .= ' selected="selected"'; 1104 1115 $output .= '>'; 1105 1116 $output .= $pad.$cat_name;