Ticket #21165: 21165.5.diff
File 21165.5.diff, 4.5 KB (added by , 12 years ago) |
---|
-
wp-includes/taxonomy.php
385 385 * Accepted keys of the label array in the taxonomy object: 386 386 * - name - general name for the taxonomy, usually plural. The same as and overridden by $tax->label. Default is Tags/Categories 387 387 * - singular_name - name for one object of this taxonomy. Default is Tag/Category 388 * - select_name - prompt to select a taxonomy when using a dropdown list in the Categories widget. Default is 'Select Category'. 388 389 * - search_items - Default is Search Tags/Search Categories 389 390 * - popular_items - This string isn't used on hierarchical taxonomies. Default is Popular Tags 390 391 * - all_items - Default is All Tags/All Categories … … 413 414 $nohier_vs_hier_defaults = array( 414 415 'name' => array( _x( 'Tags', 'taxonomy general name' ), _x( 'Categories', 'taxonomy general name' ) ), 415 416 'singular_name' => array( _x( 'Tag', 'taxonomy singular name' ), _x( 'Category', 'taxonomy singular name' ) ), 417 'select_name' => array( null, __( 'Select Category' ) ), 416 418 'search_items' => array( __( 'Search Tags' ), __( 'Search Categories' ) ), 417 419 'popular_items' => array( __( 'Popular Tags' ), null ), 418 420 'all_items' => array( __( 'All Tags' ), __( 'All Categories' ) ), -
wp-includes/default-widgets.php
446 446 447 447 function widget( $args, $instance ) { 448 448 extract( $args ); 449 449 $current_taxonomy = $this->_get_current_taxonomy( $instance ); 450 450 $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base); 451 451 $c = ! empty( $instance['count'] ) ? '1' : '0'; 452 452 $h = ! empty( $instance['hierarchical'] ) ? '1' : '0'; … … 456 456 if ( $title ) 457 457 echo $before_title . $title . $after_title; 458 458 459 $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h );459 $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h, 'taxonomy' => $current_taxonomy); 460 460 461 461 if ( $d ) { 462 $cat_args['show_option_none'] = __('Select Category');462 $cat_args['show_option_none'] = get_taxonomy( $current_taxonomy )->labels->select_name; 463 463 wp_dropdown_categories(apply_filters('widget_categories_dropdown_args', $cat_args)); 464 464 ?> 465 465 … … 496 496 $instance['count'] = !empty($new_instance['count']) ? 1 : 0; 497 497 $instance['hierarchical'] = !empty($new_instance['hierarchical']) ? 1 : 0; 498 498 $instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0; 499 $instance['taxonomy'] = stripslashes( $new_instance['taxonomy'] ); 499 500 500 501 return $instance; 501 502 } … … 507 508 $count = isset($instance['count']) ? (bool) $instance['count'] :false; 508 509 $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false; 509 510 $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false; 511 $current_taxonomy = $this->_get_current_taxonomy( $instance ); 510 512 ?> 511 513 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:' ); ?></label> 512 514 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p> 513 515 516 <p><label for="<?php echo $this->get_field_id( 'taxonomy' ); ?>"><?php _e( 'Taxonomy:' ) ?></label> 517 <select class="widefat" id="<?php echo $this->get_field_id( 'taxonomy' ); ?>" name="<?php echo $this->get_field_name( 'taxonomy' ); ?>"> 518 <?php foreach ( get_taxonomies() as $taxonomy ) : 519 $tax = get_taxonomy( $taxonomy ); 520 if ( ! $tax->hierarchical || empty( $tax->labels->name ) ) 521 continue; 522 ?> 523 <option value="<?php echo esc_attr( $taxonomy ) ?>" <?php selected( $taxonomy, $current_taxonomy ) ?>><?php echo $tax->labels->name; ?></option> 524 <?php endforeach; ?> 525 </select></p> 526 514 527 <p><input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('dropdown'); ?>" name="<?php echo $this->get_field_name('dropdown'); ?>"<?php checked( $dropdown ); ?> /> 515 528 <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e( 'Display as dropdown' ); ?></label><br /> 516 529 … … 522 535 <?php 523 536 } 524 537 538 function _get_current_taxonomy($instance) { 539 if ( ! empty( $instance['taxonomy'] ) && taxonomy_exists( $instance['taxonomy'] ) ) 540 return $instance['taxonomy']; 541 542 return 'category'; 543 } 544 545 525 546 } 526 547 527 548 /**