Ticket #21165: 21165.6.diff
File 21165.6.diff, 3.3 KB (added by , 9 years ago) |
---|
-
src/wp-includes/default-widgets.php
653 653 public function widget( $args, $instance ) { 654 654 static $first_dropdown = true; 655 655 656 $current_taxonomy = $this->_get_current_taxonomy( $instance ); 657 656 658 /** This filter is documented in wp-includes/default-widgets.php */ 657 659 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base ); 658 660 … … 665 667 echo $args['before_title'] . $title . $args['after_title']; 666 668 } 667 669 670 $tax = get_taxonomy( $current_taxonomy ); 668 671 $cat_args = array( 669 672 'orderby' => 'name', 670 673 'show_count' => $c, 671 'hierarchical' => $h 674 'hierarchical' => $h, 675 'taxonomy' => $current_taxonomy 672 676 ); 673 677 674 678 if ( $d ) { … … 677 681 678 682 echo '<label class="screen-reader-text" for="' . esc_attr( $dropdown_id ) . '">' . $title . '</label>'; 679 683 680 $cat_args['show_option_none'] = __( 'Select Category' );684 $cat_args['show_option_none'] = $tax->labels->select_name; 681 685 $cat_args['id'] = $dropdown_id; 682 686 683 687 /** … … 740 744 $instance['count'] = !empty($new_instance['count']) ? 1 : 0; 741 745 $instance['hierarchical'] = !empty($new_instance['hierarchical']) ? 1 : 0; 742 746 $instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0; 747 $instance['taxonomy'] = stripslashes( $new_instance['taxonomy'] ); 743 748 744 749 return $instance; 745 750 } … … 754 759 $count = isset($instance['count']) ? (bool) $instance['count'] :false; 755 760 $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false; 756 761 $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false; 762 $current_taxonomy = $this->_get_current_taxonomy( $instance ); 757 763 ?> 758 764 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:' ); ?></label> 759 765 <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> 760 766 767 <p><label for="<?php echo $this->get_field_id( 'taxonomy' ); ?>"><?php _e( 'Taxonomy:' ) ?></label> 768 <select class="widefat" id="<?php echo $this->get_field_id( 'taxonomy' ); ?>" name="<?php echo $this->get_field_name( 'taxonomy' ); ?>"> 769 <?php foreach ( get_taxonomies() as $taxonomy ) : 770 $tax = get_taxonomy( $taxonomy ); 771 if ( ! $tax->hierarchical || empty( $tax->labels->name ) ) { 772 continue; 773 } 774 ?> 775 <option value="<?php echo esc_attr( $taxonomy ) ?>" <?php selected( $taxonomy, $current_taxonomy ) ?>><?php echo $tax->labels->name; ?></option> 776 <?php endforeach; ?> 777 </select></p> 778 761 779 <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 ); ?> /> 762 780 <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e( 'Display as dropdown' ); ?></label><br /> 763 781 … … 769 787 <?php 770 788 } 771 789 790 function _get_current_taxonomy($instance) { 791 if ( ! empty( $instance['taxonomy'] ) && taxonomy_exists( $instance['taxonomy'] ) ) { 792 return $instance['taxonomy']; 793 } 794 795 return 'category'; 796 } 797 772 798 } 773 799 774 800 /**