Ticket #19780: 19780.3.diff
File 19780.3.diff, 8.7 KB (added by , 12 years ago) |
---|
-
wp-admin/admin-header.php
93 93 ?> 94 94 </head> 95 95 <body class="wp-admin wp-core-ui no-js <?php echo apply_filters( 'admin_body_class', '' ) . " $admin_body_class"; ?>"> 96 <?php wp_dropdown_terms( array() ); ?> 96 97 <script type="text/javascript"> 97 98 document.body.className = document.body.className.replace('no-js','js'); 98 99 </script> -
wp-includes/category-template.php
263 263 } 264 264 265 265 /** 266 * Display or retrieve the HTML dropdown list of categories.266 * Display or retrieve the HTML dropdown list of terms. 267 267 * 268 268 * The list of arguments is below: 269 * 'show_option_all' (string) - Text to display for showing all categories. 270 * 'show_option_none' (string) - Text to display for showing no categories. 271 * 'orderby' (string) default is 'ID' - What column to use for ordering the 272 * categories. 273 * 'order' (string) default is 'ASC' - What direction to order categories. 274 * 'show_count' (bool|int) default is 0 - Whether to show how many posts are 275 * in the category. 276 * 'hide_empty' (bool|int) default is 1 - Whether to hide categories that 269 * 'show_option_all' (string) - Text to display for showing all terms. 270 * 'show_option_none' (string) - Text to display for showing no terms. 271 * 'orderby' (string) default is 'ID' - What column to use for ordering the terms. 272 * 'order' (string) default is 'ASC' - What direction to order terms. 273 * 'show_count' (bool|int) default is 0 - Whether to show how many posts are in the terms. 274 * 'hide_empty' (bool|int) default is 1 - Whether to hide terms that 277 275 * don't have any posts attached to them. 278 276 * 'child_of' (int) default is 0 - See {@link get_categories()}. 279 277 * 'exclude' (string) - See {@link get_categories()}. … … 284 282 * 'id' (string) - The ID attribute value for select element. Defaults to name if omitted. 285 283 * 'class' (string) - The class attribute value for select element. 286 284 * 'selected' (int) - Which category ID is selected. 287 * 'taxonomy' (string) - The name of the taxonomy to retrieve. Defaults to category.288 285 * 289 286 * The 'hierarchical' argument, which is disabled by default, will override the 290 287 * depth argument, unless it is true. When the argument is false, it will 291 * display all of the categories. When it is enabled it will use the value in288 * display all of the terms. When it is enabled it will use the value in 292 289 * the 'depth' argument. 293 290 * 294 * @since 2.1.0 295 * 291 * @since 3.7.0 292 * 293 * @param string $tax The taxonomy to create the dropdown for. 296 294 * @param string|array $args Optional. Override default arguments. 297 295 * @return string HTML content only if 'echo' argument is 0. 298 296 */ 299 function wp_dropdown_ categories($args = '' ) {297 function wp_dropdown_terms( $taxonomy, $args = '' ) { 300 298 $defaults = array( 301 299 'show_option_all' => '', 'show_option_none' => '', 302 300 'orderby' => 'id', 'order' => 'ASC', 303 'show_count' => 0, 304 'hide_empty' => 1, 'child_of' => 0, 301 'show_count' => 0, 'hide_empty' => 1, 'child_of' => 0, 305 302 'exclude' => '', 'echo' => 1, 306 303 'selected' => 0, 'hierarchical' => 0, 307 304 'name' => 'cat', 'id' => '', 308 305 'class' => 'postform', 'depth' => 0, 309 'tab_index' => 0, 'taxonomy' => 'category', 310 'hide_if_empty' => false 306 'tab_index' => 0, 'hide_if_empty' => false 311 307 ); 312 308 313 309 $defaults['selected'] = ( is_category() ) ? get_query_var( 'cat' ) : 0; 314 310 315 // Back compat.316 if ( isset( $args['type'] ) && 'link' == $args['type'] ) {317 _deprecated_argument( __FUNCTION__, '3.0', '' );318 $args['taxonomy'] = 'link_category';319 }320 321 311 $r = wp_parse_args( $args, $defaults ); 322 312 323 if ( ! isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) {313 if ( ! isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) { 324 314 $r['pad_counts'] = true; 325 315 } 326 316 327 extract( $r ); 317 // Back compat. 318 if ( ! empty( $r['show_option_all'] ) ) 319 $r['show_option_all'] = apply_filters( 'list_cats', $r['show_option_all'] ); 320 if ( ! empty( $r['show_option_none'] ) ) 321 $r['show_option_none'] = apply_filters( 'list_cats', $r['show_option_none'] ); 328 322 329 $tab_index_attribute = ''; 330 if ( (int) $tab_index > 0 ) 331 $tab_index_attribute = " tabindex=\"$tab_index\""; 323 $terms = get_terms( $taxonomy, $r ); 324 $name = esc_attr( $r['name'] ); 325 $class = esc_attr( $r['class'] ); 326 $id = $r['id'] ? esc_attr( $r['id'] ) : $name; 327 $tab_index_attribute = ( (int) $r['tab_index'] > 0 ) ? " tabindex='{$r['tab_index']}'" : ''; 328 $show_option_all = esc_html( apply_filters( 'list_terms_show_all', $r['show_option_all'] ) ); 329 $show_option_none = esc_html( apply_filters( 'list_terms_show_none', $r['show_option_none'] ) ); 330 $depth = ( $r['hierarchical'] ) ? $r['depth'] : -1; // Walk the depth only if heirarchical. 332 331 333 $categories = get_terms( $taxonomy, $r ); 334 $name = esc_attr( $name ); 335 $class = esc_attr( $class ); 336 $id = $id ? esc_attr( $id ) : $name; 332 $output = "<select name='$name' id='$id' class='$class' $tab_index_attribute>\n"; 337 333 338 if ( ! $r['hide_if_empty'] || ! empty($categories) ) 339 $output = "<select name='$name' id='$id' class='$class' $tab_index_attribute>\n"; 340 else 341 $output = ''; 334 if ( empty( $terms ) ) { 335 if ( $r['hide_if_empty'] ) 336 return ''; 337 elseif ( $show_option_none ) 338 $output .= "\t<option value='-1' selected='selected'>$show_option_none</option>\n"; 339 } else { 342 340 343 if ( empty($categories) && ! $r['hide_if_empty'] && !empty($show_option_none) ) {344 $show_option_none = apply_filters( 'list_cats', $show_option_none );345 $output .= "\t<option value='-1' selected='selected'>$show_option_none</option>\n";346 }347 348 if ( ! empty( $categories ) ) {349 350 341 if ( $show_option_all ) { 351 $show_option_all = apply_filters( 'list_cats', $show_option_all ); 352 $selected = ( '0' === strval($r['selected']) ) ? " selected='selected'" : ''; 342 $selected = ( '0' === strval( $r['selected'] ) ) ? " selected='selected'" : ''; 353 343 $output .= "\t<option value='0'$selected>$show_option_all</option>\n"; 354 344 } 355 345 356 346 if ( $show_option_none ) { 357 $show_option_none = apply_filters( 'list_cats', $show_option_none );358 347 $selected = ( '-1' === strval($r['selected']) ) ? " selected='selected'" : ''; 359 348 $output .= "\t<option value='-1'$selected>$show_option_none</option>\n"; 360 349 } 361 350 362 if ( $hierarchical ) 363 $depth = $r['depth']; // Walk the full depth. 364 else 365 $depth = -1; // Flat. 366 367 $output .= walk_category_dropdown_tree( $categories, $depth, $r ); 351 $output .= walk_category_dropdown_tree( $terms, $depth, $r ); 368 352 } 353 354 $output .= "</select>\n"; 369 355 370 if ( ! $r['hide_if_empty'] || ! empty($categories) ) 371 $output .= "</select>\n"; 372 356 // Back compat. 373 357 $output = apply_filters( 'wp_dropdown_cats', $output ); 358 $output = apply_filters( 'wp_dropdown_terms', $output ); 374 359 375 if ( $ echo)360 if ( $r['echo'] ) 376 361 echo $output; 377 362 378 363 return $output; 379 364 } 380 365 381 366 /** 382 * Display or retrieve the HTML list of categories.367 * Display or retrieve the HTML dropdown list of categories. 383 368 * 369 * The list of arguments matches {@link wp_dropdown_terms()}. 370 * 371 * @since 2.1.0 372 * 373 * @param string|array $args Optional. Override default arguments. 374 * @return string HTML content only if 'echo' argument is 0. 375 */ 376 function wp_dropdown_categories( $args = '' ) { 377 $taxonomy = 'category'; 378 379 // Back compat. 380 if ( isset( $args['type'] ) && 'link' === $args['type'] ) { 381 _deprecated_argument( __FUNCTION__, '3.0', '' ); 382 $taxonomy = 'link_category'; 383 } elseif ( isset( $args['taxonomy'] ) && ! empty( $args['taxonomy'] ) ) { 384 _deprecated_argument( __FUNCTION__, '3.7', '' ); 385 $taxonomy = $args['taxonomy']; 386 unset( $args['taxonomy'] ); 387 } 388 389 return wp_dropdown_terms( $args, $taxonomy ); 390 } 391 392 /** 393 * Display or retrieve the HTML list of a taxonomy's terms. 394 * 384 395 * The list of arguments is below: 385 396 * 'show_option_all' (string) - Text to display for showing all categories. 386 397 * 'orderby' (string) default is 'ID' - What column to use for ordering the … … 491 502 } 492 503 493 504 /** 505 * Display or retrieve the HTML list of a taxonomy's terms. 506 * 507 * The list of arguments matches wp_list_categories() with the exception of 508 * 'taxonomy', which is its own function argument here. 509 * 510 * @since 3.5 511 * 512 * @param string $taxonomy Taxonomy name 513 * @param string|array $args Optional. Override default arguments. 514 * @return string HTML content only if 'echo' argument is 0. 515 */ 516 function wp_list_terms( $taxonomy, $args = '' ) { 517 $args = wp_parse_args( $args ); 518 $args['taxonomy'] = $taxonomy; 519 520 return wp_list_categories( $args ); 521 } 522 523 /** 494 524 * Display tag cloud. 495 525 * 496 526 * The text size is set by the 'smallest' and 'largest' arguments, which will