Changeset 34376
- Timestamp:
- 09/22/2015 04:24:53 AM (9 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy-functions.php
r34359 r34376 460 460 * - name - general name for the taxonomy, usually plural. The same as and overridden by $tax->label. Default is Tags/Categories 461 461 * - singular_name - name for one object of this taxonomy. Default is Tag/Category 462 * - select_name - prompt to select a taxonomy when using a dropdown list in the Categories widget. Default is 'Select Category'. 462 463 * - search_items - Default is Search Tags/Search Categories 463 464 * - popular_items - This string isn't used on hierarchical taxonomies. Default is Popular Tags … … 498 499 'name' => array( _x( 'Tags', 'taxonomy general name' ), _x( 'Categories', 'taxonomy general name' ) ), 499 500 'singular_name' => array( _x( 'Tag', 'taxonomy singular name' ), _x( 'Category', 'taxonomy singular name' ) ), 501 'select_name' => array( null, __( 'Select Category' ) ), 500 502 'search_items' => array( __( 'Search Tags' ), __( 'Search Categories' ) ), 501 503 'popular_items' => array( __( 'Popular Tags' ), null ), -
trunk/src/wp-includes/widgets/class-wp-widget-categories.php
r33954 r34376 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 ); … … 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 … … 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 … … 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; … … 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> 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> 129 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 ); ?> /> … … 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 }
Note: See TracChangeset
for help on using the changeset viewer.