- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/widgets/class-wp-widget-categories.php
r41867 r42343 24 24 public function __construct() { 25 25 $widget_ops = array( 26 'classname' => 'widget_categories',27 'description' => __( 'A list or dropdown of categories.' ),26 'classname' => 'widget_categories', 27 'description' => __( 'A list or dropdown of categories.' ), 28 28 'customize_selective_refresh' => true, 29 29 ); … … 68 68 if ( $d ) { 69 69 echo sprintf( '<form action="%s" method="get">', esc_url( home_url() ) ); 70 $dropdown_id = ( $first_dropdown ) ? 'cat' : "{$this->id_base}-dropdown-{$this->number}";70 $dropdown_id = ( $first_dropdown ) ? 'cat' : "{$this->id_base}-dropdown-{$this->number}"; 71 71 $first_dropdown = false; 72 72 … … 74 74 75 75 $cat_args['show_option_none'] = __( 'Select Category' ); 76 $cat_args['id'] = $dropdown_id;76 $cat_args['id'] = $dropdown_id; 77 77 78 78 /** … … 142 142 */ 143 143 public function update( $new_instance, $old_instance ) { 144 $instance = $old_instance;145 $instance['title'] = sanitize_text_field( $new_instance['title'] );146 $instance['count'] = !empty($new_instance['count']) ? 1 : 0;147 $instance['hierarchical'] = ! empty($new_instance['hierarchical']) ? 1 : 0;148 $instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0;144 $instance = $old_instance; 145 $instance['title'] = sanitize_text_field( $new_instance['title'] ); 146 $instance['count'] = ! empty( $new_instance['count'] ) ? 1 : 0; 147 $instance['hierarchical'] = ! empty( $new_instance['hierarchical'] ) ? 1 : 0; 148 $instance['dropdown'] = ! empty( $new_instance['dropdown'] ) ? 1 : 0; 149 149 150 150 return $instance; … … 160 160 public function form( $instance ) { 161 161 //Defaults 162 $instance = wp_parse_args( (array) $instance, array( 'title' => '') );163 $title = sanitize_text_field( $instance['title'] );164 $count = isset($instance['count']) ? (bool) $instance['count'] :false;162 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); 163 $title = sanitize_text_field( $instance['title'] ); 164 $count = isset( $instance['count'] ) ? (bool) $instance['count'] : false; 165 165 $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false; 166 $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false;166 $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false; 167 167 ?> 168 <p><label for="<?php echo $this->get_field_id( 'title'); ?>"><?php _e( 'Title:' ); ?></label>169 <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>168 <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> 169 <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> 170 170 171 <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 ); ?> />172 <label for="<?php echo $this->get_field_id( 'dropdown'); ?>"><?php _e( 'Display as dropdown' ); ?></label><br />171 <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 ); ?> /> 172 <label for="<?php echo $this->get_field_id( 'dropdown' ); ?>"><?php _e( 'Display as dropdown' ); ?></label><br /> 173 173 174 <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id( 'count'); ?>" name="<?php echo $this->get_field_name('count'); ?>"<?php checked( $count ); ?> />175 <label for="<?php echo $this->get_field_id( 'count'); ?>"><?php _e( 'Show post counts' ); ?></label><br />174 <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id( 'count' ); ?>" name="<?php echo $this->get_field_name( 'count' ); ?>"<?php checked( $count ); ?> /> 175 <label for="<?php echo $this->get_field_id( 'count' ); ?>"><?php _e( 'Show post counts' ); ?></label><br /> 176 176 177 <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id( 'hierarchical'); ?>" name="<?php echo $this->get_field_name('hierarchical'); ?>"<?php checked( $hierarchical ); ?> />178 <label for="<?php echo $this->get_field_id( 'hierarchical'); ?>"><?php _e( 'Show hierarchy' ); ?></label></p>177 <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id( 'hierarchical' ); ?>" name="<?php echo $this->get_field_name( 'hierarchical' ); ?>"<?php checked( $hierarchical ); ?> /> 178 <label for="<?php echo $this->get_field_id( 'hierarchical' ); ?>"><?php _e( 'Show hierarchy' ); ?></label></p> 179 179 <?php 180 180 }
Note: See TracChangeset
for help on using the changeset viewer.