diff --git src/wp-includes/taxonomy-functions.php src/wp-includes/taxonomy-functions.php
index 280f440..6631bae 100644
|
|
|
function register_taxonomy( $taxonomy, $object_type, $args = array() ) { |
| 458 | 458 | * |
| 459 | 459 | * - name - general name for the taxonomy, usually plural. The same as and overridden by $tax->label. Default is Tags/Categories |
| 460 | 460 | * - singular_name - name for one object of this taxonomy. Default is Tag/Category |
| | 461 | * - select_name - prompt to select a taxonomy when using a dropdown list in the Categories widget. Default is 'Select Category'. |
| 461 | 462 | * - search_items - Default is Search Tags/Search Categories |
| 462 | 463 | * - popular_items - This string isn't used on hierarchical taxonomies. Default is Popular Tags |
| 463 | 464 | * - all_items - Default is All Tags/All Categories |
| … |
… |
function get_taxonomy_labels( $tax ) { |
| 496 | 497 | $nohier_vs_hier_defaults = array( |
| 497 | 498 | 'name' => array( _x( 'Tags', 'taxonomy general name' ), _x( 'Categories', 'taxonomy general name' ) ), |
| 498 | 499 | 'singular_name' => array( _x( 'Tag', 'taxonomy singular name' ), _x( 'Category', 'taxonomy singular name' ) ), |
| | 500 | 'select_name' => array( null, __( 'Select Category' ) ), |
| 499 | 501 | 'search_items' => array( __( 'Search Tags' ), __( 'Search Categories' ) ), |
| 500 | 502 | 'popular_items' => array( __( 'Popular Tags' ), null ), |
| 501 | 503 | 'all_items' => array( __( 'All Tags' ), __( 'All Categories' ) ), |
diff --git src/wp-includes/widgets/class-wp-widget-categories.php src/wp-includes/widgets/class-wp-widget-categories.php
index 313041a..dabfc0e 100644
|
|
|
class WP_Widget_Categories extends WP_Widget { |
| 22 | 22 | public function widget( $args, $instance ) { |
| 23 | 23 | static $first_dropdown = true; |
| 24 | 24 | |
| | 25 | $current_taxonomy = $this->_get_current_taxonomy( $instance ); |
| | 26 | |
| 25 | 27 | /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
| 26 | 28 | $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base ); |
| 27 | 29 | |
| … |
… |
class WP_Widget_Categories extends WP_Widget { |
| 34 | 36 | echo $args['before_title'] . $title . $args['after_title']; |
| 35 | 37 | } |
| 36 | 38 | |
| | 39 | $tax = get_taxonomy( $current_taxonomy ); |
| | 40 | |
| 37 | 41 | $cat_args = array( |
| 38 | 42 | 'orderby' => 'name', |
| 39 | 43 | 'show_count' => $c, |
| 40 | | 'hierarchical' => $h |
| | 44 | 'hierarchical' => $h, |
| | 45 | 'taxonomy' => $current_taxonomy, |
| 41 | 46 | ); |
| 42 | 47 | |
| 43 | 48 | if ( $d ) { |
| … |
… |
class WP_Widget_Categories extends WP_Widget { |
| 46 | 51 | |
| 47 | 52 | echo '<label class="screen-reader-text" for="' . esc_attr( $dropdown_id ) . '">' . $title . '</label>'; |
| 48 | 53 | |
| 49 | | $cat_args['show_option_none'] = __( 'Select Category' ); |
| | 54 | $cat_args['show_option_none'] = $tax->labels->select_name; |
| 50 | 55 | $cat_args['id'] = $dropdown_id; |
| 51 | 56 | |
| 52 | 57 | /** |
| … |
… |
class WP_Widget_Categories extends WP_Widget { |
| 109 | 114 | $instance['count'] = !empty($new_instance['count']) ? 1 : 0; |
| 110 | 115 | $instance['hierarchical'] = !empty($new_instance['hierarchical']) ? 1 : 0; |
| 111 | 116 | $instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0; |
| | 117 | $instance['taxonomy'] = stripslashes( $new_instance['taxonomy'] ); |
| 112 | 118 | |
| 113 | 119 | return $instance; |
| 114 | 120 | } |
| … |
… |
class WP_Widget_Categories extends WP_Widget { |
| 123 | 129 | $count = isset($instance['count']) ? (bool) $instance['count'] :false; |
| 124 | 130 | $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false; |
| 125 | 131 | $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false; |
| | 132 | $current_taxonomy = $this->_get_current_taxonomy( $instance ); |
| 126 | 133 | ?> |
| 127 | 134 | <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:' ); ?></label> |
| 128 | 135 | <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p> |
| 129 | 136 | |
| | 137 | <p> |
| | 138 | <label for="<?php echo esc_attr( $this->get_field_id( 'taxonomy' ) ); ?>"><?php _e( 'Taxonomy:' ) ?></label> |
| | 139 | <select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'taxonomy' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'taxonomy' ) ); ?>"> |
| | 140 | <?php foreach ( get_taxonomies( array(), 'objects' ) as $taxonomy ) : ?> |
| | 141 | <?php |
| | 142 | if ( ! $taxonomy->hierarchical || empty( $taxonomy->labels->name ) ) : |
| | 143 | continue; |
| | 144 | endif; |
| | 145 | ?> |
| | 146 | <option value="<?php echo esc_attr( $taxonomy->name ); ?>" <?php selected( $taxonomy->name, $current_taxonomy ) ?>><?php echo esc_html( $taxonomy->labels->name ); ?></option> |
| | 147 | <?php endforeach; ?> |
| | 148 | </select> |
| | 149 | </p> |
| | 150 | |
| 130 | 151 | <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 ); ?> /> |
| 131 | 152 | <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e( 'Display as dropdown' ); ?></label><br /> |
| 132 | 153 | |
| … |
… |
class WP_Widget_Categories extends WP_Widget { |
| 138 | 159 | <?php |
| 139 | 160 | } |
| 140 | 161 | |
| | 162 | /** |
| | 163 | * Retrieves the taxonomy for the current widget instance. |
| | 164 | * |
| | 165 | * @since 4.4.0 |
| | 166 | * @access public |
| | 167 | * |
| | 168 | * @param array $instance Current settings. |
| | 169 | * @return string Name of the current taxonomy if set, otherwise 'category'. |
| | 170 | */ |
| | 171 | public function _get_current_taxonomy( $instance ) { |
| | 172 | if ( ! empty( $instance['taxonomy'] ) && taxonomy_exists( $instance['taxonomy'] ) ) { |
| | 173 | return $instance['taxonomy']; |
| | 174 | } |
| | 175 | return 'category'; |
| | 176 | } |
| 141 | 177 | } |