Changeset 35278
- Timestamp:
- 10/20/2015 04:56:57 AM (9 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy-functions.php
r35268 r35278 480 480 * - name - general name for the taxonomy, usually plural. The same as and overridden by $tax->label. Default is Tags/Categories 481 481 * - singular_name - name for one object of this taxonomy. Default is Tag/Category 482 * - select_name - prompt to select a taxonomy when using a dropdown list in the Categories widget. Default is 'Select Category'.483 482 * - search_items - Default is Search Tags/Search Categories 484 483 * - popular_items - This string isn't used on hierarchical taxonomies. Default is Popular Tags … … 521 520 'name' => array( _x( 'Tags', 'taxonomy general name' ), _x( 'Categories', 'taxonomy general name' ) ), 522 521 'singular_name' => array( _x( 'Tag', 'taxonomy singular name' ), _x( 'Category', 'taxonomy singular name' ) ), 523 'select_name' => array( null, __( 'Select Category' ) ),524 522 'search_items' => array( __( 'Search Tags' ), __( 'Search Categories' ) ), 525 523 'popular_items' => array( __( 'Popular Tags' ), null ), -
trunk/src/wp-includes/widgets/class-wp-widget-categories.php
r34618 r35278 12 12 * 13 13 * @since 2.8.0 14 * @since 4.4.0 Added support for other taxonomies.15 14 * 16 15 * @see WP_Widget … … 42 41 static $first_dropdown = true; 43 42 44 $current_taxonomy = $this->_get_current_taxonomy( $instance );45 46 43 /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ 47 44 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base ); … … 56 53 } 57 54 58 $tax = get_taxonomy( $current_taxonomy );59 60 55 $cat_args = array( 61 56 'orderby' => 'name', 62 57 'show_count' => $c, 63 'hierarchical' => $h, 64 'taxonomy' => $current_taxonomy, 58 'hierarchical' => $h 65 59 ); 66 60 … … 71 65 echo '<label class="screen-reader-text" for="' . esc_attr( $dropdown_id ) . '">' . $title . '</label>'; 72 66 73 $cat_args['show_option_none'] = $tax->labels->select_name;67 $cat_args['show_option_none'] = __( 'Select Category' ); 74 68 $cat_args['id'] = $dropdown_id; 75 69 … … 140 134 $instance['hierarchical'] = !empty($new_instance['hierarchical']) ? 1 : 0; 141 135 $instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0; 142 $instance['taxonomy'] = stripslashes( $new_instance['taxonomy'] );143 136 144 137 return $instance; … … 160 153 $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false; 161 154 $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false; 162 $current_taxonomy = $this->_get_current_taxonomy( $instance );163 155 ?> 164 156 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:' ); ?></label> 165 157 <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> 166 167 <p>168 <label for="<?php echo esc_attr( $this->get_field_id( 'taxonomy' ) ); ?>"><?php _e( 'Taxonomy:' ) ?></label>169 <select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'taxonomy' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'taxonomy' ) ); ?>">170 <?php foreach ( get_taxonomies( array(), 'objects' ) as $taxonomy ) : ?>171 <?php172 if ( ! $taxonomy->hierarchical || empty( $taxonomy->labels->name ) ) :173 continue;174 endif;175 ?>176 <option value="<?php echo esc_attr( $taxonomy->name ); ?>" <?php selected( $taxonomy->name, $current_taxonomy ) ?>><?php echo esc_html( $taxonomy->labels->name ); ?></option>177 <?php endforeach; ?>178 </select>179 </p>180 158 181 159 <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 ); ?> /> … … 190 168 } 191 169 192 /**193 * Retrieves the taxonomy for the current Categories widget instance.194 *195 * @since 4.4.0196 * @access public197 *198 * @param array $instance Current settings.199 * @return string Name of the current taxonomy if set, otherwise 'category'.200 */201 public function _get_current_taxonomy( $instance ) {202 if ( ! empty( $instance['taxonomy'] ) && taxonomy_exists( $instance['taxonomy'] ) ) {203 return $instance['taxonomy'];204 }205 return 'category';206 }207 170 }
Note: See TracChangeset
for help on using the changeset viewer.