Ticket #12494: 12494.patch
File 12494.patch, 2.9 KB (added by , 10 years ago) |
---|
-
wp-includes/post-template.php
950 950 'selected' => 0, 'echo' => 1, 951 951 'name' => 'page_id', 'id' => '', 952 952 'show_option_none' => '', 'show_option_no_change' => '', 953 'option_none_value' => '' 953 'option_none_value' => '', 954 'optio_value_field' => 'id' 954 955 ); 955 956 956 957 $r = wp_parse_args( $args, $defaults ); … … 1412 1413 public function start_el( &$output, $page, $depth = 0, $args = array(), $id = 0 ) { 1413 1414 $pad = str_repeat(' ', $depth * 3); 1414 1415 1415 $output .= "\t<option class=\"level-$depth\" value=\"$page->ID\""; 1416 if ( $page->ID == $args['selected'] ) 1416 if ( 'slug' == $args['option_value_field'] ) { 1417 $value = $page->post_name; 1418 $selected = $page->post_name == $args['selected']; 1419 } else { 1420 $value = $page->ID; 1421 $selected = $page->ID == $args['selected']; 1422 } 1423 1424 $output .= "\t<option class=\"level-$depth\" value=\"$value\""; 1425 if ( $selected ) 1417 1426 $output .= ' selected="selected"'; 1418 1427 $output .= '>'; 1419 1428 -
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;