| 1 | Index: wp-includes/taxonomy.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/taxonomy.php (revision 21229) |
|---|
| 4 | +++ wp-includes/taxonomy.php (working copy) |
|---|
| 5 | @@ -385,6 +385,7 @@ |
|---|
| 6 | * Accepted keys of the label array in the taxonomy object: |
|---|
| 7 | * - name - general name for the taxonomy, usually plural. The same as and overridden by $tax->label. Default is Tags/Categories |
|---|
| 8 | * - singular_name - name for one object of this taxonomy. Default is Tag/Category |
|---|
| 9 | + * - select_name - prompt to select a taxonomy when using a dropdown list in the Categories widget. Default is 'Select Category'. |
|---|
| 10 | * - search_items - Default is Search Tags/Search Categories |
|---|
| 11 | * - popular_items - This string isn't used on hierarchical taxonomies. Default is Popular Tags |
|---|
| 12 | * - all_items - Default is All Tags/All Categories |
|---|
| 13 | @@ -413,6 +414,7 @@ |
|---|
| 14 | $nohier_vs_hier_defaults = array( |
|---|
| 15 | 'name' => array( _x( 'Tags', 'taxonomy general name' ), _x( 'Categories', 'taxonomy general name' ) ), |
|---|
| 16 | 'singular_name' => array( _x( 'Tag', 'taxonomy singular name' ), _x( 'Category', 'taxonomy singular name' ) ), |
|---|
| 17 | + 'select_name' => array( null, __( 'Select Category' ) ), |
|---|
| 18 | 'search_items' => array( __( 'Search Tags' ), __( 'Search Categories' ) ), |
|---|
| 19 | 'popular_items' => array( __( 'Popular Tags' ), null ), |
|---|
| 20 | 'all_items' => array( __( 'All Tags' ), __( 'All Categories' ) ), |
|---|
| 21 | Index: wp-includes/default-widgets.php |
|---|
| 22 | =================================================================== |
|---|
| 23 | --- wp-includes/default-widgets.php (revision 21229) |
|---|
| 24 | +++ wp-includes/default-widgets.php (working copy) |
|---|
| 25 | @@ -446,7 +446,7 @@ |
|---|
| 26 | |
|---|
| 27 | function widget( $args, $instance ) { |
|---|
| 28 | extract( $args ); |
|---|
| 29 | - |
|---|
| 30 | + $current_taxonomy = $this->_get_current_taxonomy( $instance ); |
|---|
| 31 | $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base); |
|---|
| 32 | $c = ! empty( $instance['count'] ) ? '1' : '0'; |
|---|
| 33 | $h = ! empty( $instance['hierarchical'] ) ? '1' : '0'; |
|---|
| 34 | @@ -456,10 +456,10 @@ |
|---|
| 35 | if ( $title ) |
|---|
| 36 | echo $before_title . $title . $after_title; |
|---|
| 37 | |
|---|
| 38 | - $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h); |
|---|
| 39 | + $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h, 'taxonomy' => $current_taxonomy); |
|---|
| 40 | |
|---|
| 41 | if ( $d ) { |
|---|
| 42 | - $cat_args['show_option_none'] = __('Select Category'); |
|---|
| 43 | + $cat_args['show_option_none'] = get_taxonomy( $current_taxonomy )->labels->select_name; |
|---|
| 44 | wp_dropdown_categories(apply_filters('widget_categories_dropdown_args', $cat_args)); |
|---|
| 45 | ?> |
|---|
| 46 | |
|---|
| 47 | @@ -496,6 +496,7 @@ |
|---|
| 48 | $instance['count'] = !empty($new_instance['count']) ? 1 : 0; |
|---|
| 49 | $instance['hierarchical'] = !empty($new_instance['hierarchical']) ? 1 : 0; |
|---|
| 50 | $instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0; |
|---|
| 51 | + $instance['taxonomy'] = stripslashes( $new_instance['taxonomy'] ); |
|---|
| 52 | |
|---|
| 53 | return $instance; |
|---|
| 54 | } |
|---|
| 55 | @@ -507,10 +508,22 @@ |
|---|
| 56 | $count = isset($instance['count']) ? (bool) $instance['count'] :false; |
|---|
| 57 | $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false; |
|---|
| 58 | $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false; |
|---|
| 59 | + $current_taxonomy = $this->_get_current_taxonomy( $instance ); |
|---|
| 60 | ?> |
|---|
| 61 | <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:' ); ?></label> |
|---|
| 62 | <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> |
|---|
| 63 | |
|---|
| 64 | + <p><label for="<?php echo $this->get_field_id( 'taxonomy' ); ?>"><?php _e( 'Taxonomy:' ) ?></label> |
|---|
| 65 | + <select class="widefat" id="<?php echo $this->get_field_id( 'taxonomy' ); ?>" name="<?php echo $this->get_field_name( 'taxonomy' ); ?>"> |
|---|
| 66 | + <?php foreach ( get_taxonomies() as $taxonomy ) : |
|---|
| 67 | + $tax = get_taxonomy( $taxonomy ); |
|---|
| 68 | + if ( ! $tax->hierarchical || empty( $tax->labels->name ) ) |
|---|
| 69 | + continue; |
|---|
| 70 | + ?> |
|---|
| 71 | + <option value="<?php echo esc_attr( $taxonomy ) ?>" <?php selected( $taxonomy, $current_taxonomy ) ?>><?php echo $tax->labels->name; ?></option> |
|---|
| 72 | + <?php endforeach; ?> |
|---|
| 73 | + </select></p> |
|---|
| 74 | + |
|---|
| 75 | <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 ); ?> /> |
|---|
| 76 | <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e( 'Display as dropdown' ); ?></label><br /> |
|---|
| 77 | |
|---|
| 78 | @@ -522,6 +535,14 @@ |
|---|
| 79 | <?php |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | + function _get_current_taxonomy($instance) { |
|---|
| 83 | + if ( ! empty( $instance['taxonomy'] ) && taxonomy_exists( $instance['taxonomy'] ) ) |
|---|
| 84 | + return $instance['taxonomy']; |
|---|
| 85 | + |
|---|
| 86 | + return 'category'; |
|---|
| 87 | + } |
|---|
| 88 | + |
|---|
| 89 | + |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | /** |
|---|