Ticket #19851: category-template.slug_as_value.patch
File category-template.slug_as_value.patch, 1.6 KB (added by , 13 years ago) |
---|
-
wp-includes/category-template.php
284 284 * 'name' (string) - The name attribute value for select element. 285 285 * 'id' (string) - The ID attribute value for select element. Defaults to name if omitted. 286 286 * 'class' (string) - The class attribute value for select element. 287 * 'slug_as_value' (bool|int) - Uses category slug as option value instead of category ID. 287 288 * 'selected' (int) - Which category ID is selected. 288 289 * 'taxonomy' (string) - The name of the taxonomy to retrieve. Defaults to category. 289 290 * … … 308 309 'name' => 'cat', 'id' => '', 309 310 'class' => 'postform', 'depth' => 0, 310 311 'tab_index' => 0, 'taxonomy' => 'category', 311 'hide_if_empty' => false 312 'hide_if_empty' => false, 313 'slug_as_value' => false 312 314 ); 313 315 314 316 $defaults['selected'] = ( is_category() ) ? get_query_var( 'cat' ) : 0; … … 946 948 */ 947 949 function start_el( &$output, $category, $depth, $args, $id = 0 ) { 948 950 $pad = str_repeat(' ', $depth * 3); 949 951 $option_value = ( $args['slug_as_value'] == 'true' ) ? $category->slug : $category->term_id; 950 952 $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\" value=\"".option_value."\""; 952 955 if ( $category->term_id == $args['selected'] ) 953 956 $output .= ' selected="selected"'; 954 957 $output .= '>';