Ticket #23012: 23012.4.diff
| File 23012.4.diff, 66.7 KB (added by , 11 years ago) |
|---|
-
wp-includes/default-widgets.php
14 14 class WP_Widget_Pages extends WP_Widget { 15 15 16 16 public function __construct() { 17 $widget_ops = array('classname' => 'widget_pages', 'description' => __( 'A list of your site’s Pages.') ); 18 parent::__construct('pages', __('Pages'), $widget_ops); 17 $widget_ops = array( 18 'classname' => 'widget_pages', 19 'description' => __( 'A list of your site’s Pages.' ), 20 ); 21 parent::__construct( 'pages', __( 'Pages' ), $widget_ops ); 19 22 } 20 23 21 24 /** … … 33 36 * @param array $instance An array of the widget's settings. 34 37 * @param mixed $id_base The widget ID. 35 38 */ 36 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Pages' ) : $instance['title'], $instance, $this->id_base ); 39 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Pages' ) : $instance['title'], $instance, $this->id_base ); 40 $sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby']; 41 $exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude']; 37 42 38 $sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby']; 39 $exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude']; 40 41 if ( $sortby == 'menu_order' ) 43 if ( 'menu_order' === $sortby ) { 42 44 $sortby = 'menu_order, post_title'; 45 } 43 46 44 47 /** 45 48 * Filter the arguments for the Pages widget. … … 54 57 'title_li' => '', 55 58 'echo' => 0, 56 59 'sort_column' => $sortby, 57 'exclude' => $exclude 60 'exclude' => $exclude, 58 61 ) ) ); 59 62 60 63 if ( ! empty( $out ) ) { … … 77 80 * @return array 78 81 */ 79 82 public function update( $new_instance, $old_instance ) { 80 $instance = $old_instance;81 $instance['title'] = s trip_tags($new_instance['title']);83 $instance = $old_instance; 84 $instance['title'] = sanitize_text_field( $new_instance['title'] ); 82 85 if ( in_array( $new_instance['sortby'], array( 'post_title', 'menu_order', 'ID' ) ) ) { 83 86 $instance['sortby'] = $new_instance['sortby']; 84 87 } else { … … 85 88 $instance['sortby'] = 'menu_order'; 86 89 } 87 90 88 $instance['exclude'] = s trip_tags( $new_instance['exclude'] );91 $instance['exclude'] = sanitize_text_field( $new_instance['exclude'] ); 89 92 90 93 return $instance; 91 94 } … … 95 98 */ 96 99 public function form( $instance ) { 97 100 //Defaults 98 $instance = wp_parse_args( (array) $instance, array( 'sortby' => 'post_title', 'title' => '', 'exclude' => '') );99 $title = esc_attr( $instance['title'] );100 $exclude = esc_attr( $instance['exclude'] );101 $instance = wp_parse_args( (array) $instance, array( 'sortby' => 'post_title', 'title' => '', 'exclude' => '' ) ); 102 $title = $instance['title']; 103 $exclude = $instance['exclude']; 101 104 ?> 102 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <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>105 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p> 103 106 <p> 104 <label for="<?php echo $this->get_field_id('sortby'); ?>"><?php _e( 'Sort by:' ); ?></label>105 <select name="<?php echo $this->get_field_name('sortby'); ?>" id="<?php echo $this->get_field_id('sortby'); ?>" class="widefat">106 <option value="post_title"<?php selected( $instance['sortby'], 'post_title' ); ?>><?php _e( 'Page title'); ?></option>107 <option value="menu_order"<?php selected( $instance['sortby'], 'menu_order' ); ?>><?php _e( 'Page order'); ?></option>107 <label for="<?php echo esc_attr( $this->get_field_id( 'sortby' ) ); ?>"><?php _e( 'Sort by:' ); ?></label> 108 <select name="<?php echo esc_attr( $this->get_field_name( 'sortby' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'sortby' ) ); ?>" class="widefat"> 109 <option value="post_title"<?php selected( $instance['sortby'], 'post_title' ); ?>><?php _e( 'Page title' ); ?></option> 110 <option value="menu_order"<?php selected( $instance['sortby'], 'menu_order' ); ?>><?php _e( 'Page order' ); ?></option> 108 111 <option value="ID"<?php selected( $instance['sortby'], 'ID' ); ?>><?php _e( 'Page ID' ); ?></option> 109 112 </select> 110 113 </p> 111 114 <p> 112 <label for="<?php echo $this->get_field_id('exclude'); ?>"><?php _e( 'Exclude:' ); ?></label> <input type="text" value="<?php echo $exclude; ?>" name="<?php echo $this->get_field_name('exclude'); ?>" id="<?php echo $this->get_field_id('exclude'); ?>" class="widefat" />115 <label for="<?php echo esc_attr( $this->get_field_id( 'exclude' ) ); ?>"><?php _e( 'Exclude:' ); ?></label> <input type="text" value="<?php echo esc_attr( $exclude ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'exclude' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'exclude' ) ); ?>" class="widefat" /> 113 116 <br /> 114 117 <small><?php _e( 'Page IDs, separated by commas.' ); ?></small> 115 118 </p> … … 126 129 class WP_Widget_Links extends WP_Widget { 127 130 128 131 public function __construct() { 129 $widget_ops = array('description' => __( "Your blogroll" ) ); 130 parent::__construct('links', __('Links'), $widget_ops); 132 $widget_ops = array( 133 'description' => __( 'Your blogroll' ), 134 ); 135 parent::__construct( 'links', __( 'Links' ), $widget_ops ); 131 136 } 132 137 133 138 /** … … 136 141 */ 137 142 public function widget( $args, $instance ) { 138 143 $show_description = isset($instance['description']) ? $instance['description'] : false; 139 $show_name = isset($instance['name']) ? $instance['name'] : false;140 $show_rating = isset($instance['rating']) ? $instance['rating'] : false;141 $show_images = isset($instance['images']) ? $instance['images'] : true;142 $category = isset($instance['category']) ? $instance['category'] : false;143 $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name';144 $order = $orderby == 'rating'? 'DESC' : 'ASC';145 $limit = isset( $instance['limit'] ) ? $instance['limit'] : -1;144 $show_name = isset($instance['name']) ? $instance['name'] : false; 145 $show_rating = isset($instance['rating']) ? $instance['rating'] : false; 146 $show_images = isset($instance['images']) ? $instance['images'] : true; 147 $category = isset($instance['category']) ? $instance['category'] : false; 148 $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name'; 149 $order = ( 'rating' === $orderby ) ? 'DESC' : 'ASC'; 150 $limit = isset( $instance['limit'] ) ? $instance['limit'] : -1; 146 151 147 152 $before_widget = preg_replace( '/id="[^"]*"/', 'id="%id"', $args['before_widget'] ); 148 153 … … 156 161 * @param array $args An array of arguments to retrieve the links list. 157 162 */ 158 163 wp_list_bookmarks( apply_filters( 'widget_links_args', array( 159 'title_before' => $args['before_title'], 'title_after' => $args['after_title'], 160 'category_before' => $before_widget, 'category_after' => $args['after_widget'], 161 'show_images' => $show_images, 'show_description' => $show_description, 162 'show_name' => $show_name, 'show_rating' => $show_rating, 163 'category' => $category, 'class' => 'linkcat widget', 164 'orderby' => $orderby, 'order' => $order, 165 'limit' => $limit, 164 'title_before' => $args['before_title'], 165 'title_after' => $args['after_title'], 166 'category_before' => $before_widget, 167 'category_after' => $args['after_widget'], 168 'show_images' => $show_images, 169 'show_description' => $show_description, 170 'show_name' => $show_name, 171 'show_rating' => $show_rating, 172 'category' => $category, 173 'class' => 'linkcat widget', 174 'orderby' => $orderby, 175 'order' => $order, 176 'limit' => $limit, 166 177 ) ) ); 167 178 } 168 179 … … 173 184 */ 174 185 public function update( $new_instance, $old_instance ) { 175 186 $new_instance = (array) $new_instance; 176 $instance = array( 'images' => 0, 'name' => 0, 'description' => 0, 'rating' => 0 ); 187 $instance = array( 188 'images' => 0, 189 'name' => 0, 190 'description' => 0, 191 'rating' => 0, 192 ); 177 193 foreach ( $instance as $field => $val ) { 178 if ( isset($new_instance[$field]) ) 179 $instance[$field] = 1; 194 if ( isset( $new_instance[ $field ]) ) { 195 $instance[ $field ] = 1; 196 } 180 197 } 181 198 182 199 $instance['orderby'] = 'name'; 183 if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) ) 200 if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) ) { 184 201 $instance['orderby'] = $new_instance['orderby']; 202 } 185 203 186 204 $instance['category'] = intval( $new_instance['category'] ); 187 205 $instance['limit'] = ! empty( $new_instance['limit'] ) ? intval( $new_instance['limit'] ) : -1; … … 195 213 public function form( $instance ) { 196 214 197 215 //Defaults 198 $instance = wp_parse_args( (array) $instance, array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false, 'category' => false, 'orderby' => 'name', 'limit' => -1 ) ); 216 $instance = wp_parse_args( (array) $instance, array( 217 'images' => true, 218 'name' => true, 219 'description' => false, 220 'rating' => false, 221 'category' => false, 222 'orderby' => 'name', 223 'limit' => -1, 224 ) 225 ); 199 226 $link_cats = get_terms( 'link_category' ); 200 if ( ! $limit = intval( $instance['limit'] ) ) 227 if ( ! $limit = intval( $instance['limit'] ) ) { 201 228 $limit = -1; 229 } 202 230 ?> 203 231 <p> 204 <label for="<?php echo $this->get_field_id('category'); ?>"><?php _e( 'Select Link Category:' ); ?></label>205 <select class="widefat" id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>">206 <option value=""><?php _ex( 'All Links', 'links widget'); ?></option>232 <label for="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>"><?php _e( 'Select Link Category:' ); ?></label> 233 <select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'category' ) ); ?>"> 234 <option value=""><?php _ex( 'All Links', 'links widget' ); ?></option> 207 235 <?php 208 236 foreach ( $link_cats as $link_cat ) { 209 237 echo '<option value="' . intval( $link_cat->term_id ) . '"' … … 212 240 } 213 241 ?> 214 242 </select> 215 <label for="<?php echo $this->get_field_id('orderby'); ?>"><?php _e( 'Sort by:' ); ?></label>216 <select name="<?php echo $this->get_field_name('orderby'); ?>" id="<?php echo $this->get_field_id('orderby'); ?>" class="widefat">243 <label for="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>"><?php _e( 'Sort by:' ); ?></label> 244 <select name="<?php echo esc_attr( $this->get_field_name( 'orderby' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>" class="widefat"> 217 245 <option value="name"<?php selected( $instance['orderby'], 'name' ); ?>><?php _e( 'Link title' ); ?></option> 218 246 <option value="rating"<?php selected( $instance['orderby'], 'rating' ); ?>><?php _e( 'Link rating' ); ?></option> 219 247 <option value="id"<?php selected( $instance['orderby'], 'id' ); ?>><?php _e( 'Link ID' ); ?></option> … … 221 249 </select> 222 250 </p> 223 251 <p> 224 <input class="checkbox" type="checkbox" <?php checked( $instance['images'], true) ?> id="<?php echo $this->get_field_id('images'); ?>" name="<?php echo $this->get_field_name('images'); ?>" />225 <label for="<?php echo $this->get_field_id('images'); ?>"><?php _e('Show Link Image'); ?></label><br />226 <input class="checkbox" type="checkbox" <?php checked( $instance['name'], true) ?> id="<?php echo $this->get_field_id('name'); ?>" name="<?php echo $this->get_field_name('name'); ?>" />227 <label for="<?php echo $this->get_field_id('name'); ?>"><?php _e('Show Link Name'); ?></label><br />228 <input class="checkbox" type="checkbox" <?php checked( $instance['description'], true) ?> id="<?php echo $this->get_field_id('description'); ?>" name="<?php echo $this->get_field_name('description'); ?>" />229 <label for="<?php echo $this->get_field_id('description'); ?>"><?php _e('Show Link Description'); ?></label><br />230 <input class="checkbox" type="checkbox" <?php checked( $instance['rating'], true) ?> id="<?php echo $this->get_field_id('rating'); ?>" name="<?php echo $this->get_field_name('rating'); ?>" />231 <label for="<?php echo $this->get_field_id('rating'); ?>"><?php _e('Show Link Rating'); ?></label>252 <input class="checkbox" type="checkbox" <?php checked( $instance['images'], true ) ?> id="<?php echo esc_attr( $this->get_field_id( 'images' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'images' ) ); ?>" /> 253 <label for="<?php echo esc_attr( $this->get_field_id( 'images' ) ); ?>"><?php _e( 'Show Link Image' ); ?></label><br /> 254 <input class="checkbox" type="checkbox" <?php checked( $instance['name'], true ) ?> id="<?php echo esc_attr( $this->get_field_id( 'name' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'name' ) ); ?>" /> 255 <label for="<?php echo esc_attr( $this->get_field_id( 'name' ) ); ?>"><?php _e( 'Show Link Name' ); ?></label><br /> 256 <input class="checkbox" type="checkbox" <?php checked( $instance['description'], true ) ?> id="<?php echo esc_attr( $this->get_field_id( 'description' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'description' ) ); ?>" /> 257 <label for="<?php echo esc_attr( $this->get_field_id( 'description' ) ); ?>"><?php _e( 'Show Link Description' ); ?></label><br /> 258 <input class="checkbox" type="checkbox" <?php checked( $instance['rating'], true ) ?> id="<?php echo esc_attr( $this->get_field_id( 'rating' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'rating' ) ); ?>" /> 259 <label for="<?php echo esc_attr( $this->get_field_id( 'rating' ) ); ?>"><?php _e( 'Show Link Rating' ); ?></label> 232 260 </p> 233 261 <p> 234 <label for="<?php echo $this->get_field_id('limit'); ?>"><?php _e( 'Number of links to show:' ); ?></label>235 <input id="<?php echo $this->get_field_id('limit'); ?>" name="<?php echo $this->get_field_name('limit'); ?>" type="text" value="<?php echo $limit == -1 ? '' : intval( $limit ); ?>" size="3" />262 <label for="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>"><?php _e( 'Number of links to show:' ); ?></label> 263 <input id="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'limit' ) ); ?>" type="text" value="<?php echo $limit == -1 ? '' : intval( $limit ); ?>" size="3" /> 236 264 </p> 237 265 <?php 238 266 } … … 246 274 class WP_Widget_Search extends WP_Widget { 247 275 248 276 public function __construct() { 249 $widget_ops = array('classname' => 'widget_search', 'description' => __( "A search form for your site.") ); 277 $widget_ops = array( 278 'classname' => 'widget_search', 279 'description' => __( 'A search form for your site.' ), 280 ); 250 281 parent::__construct( 'search', _x( 'Search', 'Search widget' ), $widget_ops ); 251 282 } 252 283 … … 273 304 * @param array $instance 274 305 */ 275 306 public function form( $instance ) { 276 $instance = wp_parse_args( (array) $instance, array( 'title' => '') ); 307 $instance = wp_parse_args( (array) $instance, array( 308 'title' => '', 309 ) 310 ); 277 311 $title = $instance['title']; 278 312 ?> 279 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <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); ?>" /></label></p>313 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></label></p> 280 314 <?php 281 315 } 282 316 … … 286 320 * @return array 287 321 */ 288 322 public function update( $new_instance, $old_instance ) { 289 $instance = $old_instance; 290 $new_instance = wp_parse_args((array) $new_instance, array( 'title' => '')); 291 $instance['title'] = strip_tags($new_instance['title']); 323 $instance = $old_instance; 324 $new_instance = wp_parse_args( (array) $new_instance, array( 325 'title' => '', 326 ) 327 ); 328 $instance['title'] = sanitize_text_field( $new_instance['title'] ); 292 329 return $instance; 293 330 } 294 331 … … 302 339 class WP_Widget_Archives extends WP_Widget { 303 340 304 341 public function __construct() { 305 $widget_ops = array('classname' => 'widget_archive', 'description' => __( 'A monthly archive of your site’s Posts.') ); 306 parent::__construct('archives', __('Archives'), $widget_ops); 342 $widget_ops = array( 343 'classname' => 'widget_archive', 344 'description' => __( 'A monthly archive of your site’s Posts.' ), 345 ); 346 parent::__construct( 'archives', __( 'Archives' ), $widget_ops ); 307 347 } 308 348 309 349 /** … … 340 380 $dropdown_args = apply_filters( 'widget_archives_dropdown_args', array( 341 381 'type' => 'monthly', 342 382 'format' => 'option', 343 'show_post_count' => $c 383 'show_post_count' => $c, 344 384 ) ); 345 385 346 386 switch ( $dropdown_args['type'] ) { … … 382 422 */ 383 423 wp_get_archives( apply_filters( 'widget_archives_args', array( 384 424 'type' => 'monthly', 385 'show_post_count' => $c 425 'show_post_count' => $c, 386 426 ) ) ); 387 427 ?> 388 428 </ul> … … 398 438 * @return array 399 439 */ 400 440 public function update( $new_instance, $old_instance ) { 401 $instance = $old_instance; 402 $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') ); 403 $instance['title'] = strip_tags($new_instance['title']); 404 $instance['count'] = $new_instance['count'] ? 1 : 0; 441 $instance = $old_instance; 442 $new_instance = wp_parse_args( (array) $new_instance, array( 443 'title' => '', 444 'count' => 0, 445 'dropdown' => '', 446 ) 447 ); 448 $instance['title'] = sanitize_text_field( $new_instance['title'] ); 449 $instance['count'] = $new_instance['count'] ? 1 : 0; 405 450 $instance['dropdown'] = $new_instance['dropdown'] ? 1 : 0; 406 451 407 452 return $instance; … … 411 456 * @param array $instance 412 457 */ 413 458 public function form( $instance ) { 414 $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') ); 415 $title = strip_tags($instance['title']); 416 $count = $instance['count'] ? 'checked="checked"' : ''; 417 $dropdown = $instance['dropdown'] ? 'checked="checked"' : ''; 459 $instance = wp_parse_args( (array) $instance, array( 460 'title' => '', 461 'count' => 0, 462 'dropdown' => '', 463 ) 464 ); 465 $title = $instance['title']; 466 $count = $instance['count'] ? true : false; 467 $dropdown = $instance['dropdown'] ? true : false; 418 468 ?> 419 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <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>469 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p> 420 470 <p> 421 <input class="checkbox" type="checkbox" <?php echo $dropdown; ?> id="<?php echo $this->get_field_id('dropdown'); ?>" name="<?php echo $this->get_field_name('dropdown'); ?>" /> <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e('Display as dropdown'); ?></label>471 <input class="checkbox" type="checkbox" <?php checked( true, $dropdown ); ?> id="<?php echo esc_attr( $this->get_field_id( 'dropdown' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'dropdown' ) ); ?>" /> <label for="<?php echo esc_attr( $this->get_field_id( 'dropdown' ) ); ?>"><?php _e( 'Display as dropdown' ); ?></label> 422 472 <br/> 423 <input class="checkbox" type="checkbox" <?php echo $count; ?> id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>" /> <label for="<?php echo $this->get_field_id('count'); ?>"><?php _e('Show post counts'); ?></label>473 <input class="checkbox" type="checkbox" <?php checked( true, $count ); ?> id="<?php echo esc_attr( $this->get_field_id( 'count' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'count' ) ); ?>" /> <label for="<?php echo esc_attr( $this->get_field_id( 'count' ) ); ?>"><?php _e( 'Show post counts' ); ?></label> 424 474 </p> 425 475 <?php 426 476 } … … 436 486 class WP_Widget_Meta extends WP_Widget { 437 487 438 488 public function __construct() { 439 $widget_ops = array('classname' => 'widget_meta', 'description' => __( "Login, RSS, & WordPress.org links.") ); 440 parent::__construct('meta', __('Meta'), $widget_ops); 489 $widget_ops = array( 490 'classname' => 'widget_meta', 491 'description' => __( 'Login, RSS, & WordPress.org links.' ), 492 ); 493 parent::__construct( 'meta', __( 'Meta' ), $widget_ops ); 441 494 } 442 495 443 496 /** … … 456 509 <ul> 457 510 <?php wp_register(); ?> 458 511 <li><?php wp_loginout(); ?></li> 459 <li><a href="<?php bloginfo('rss2_url'); ?>"><?php _e('Entries <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>460 <li><a href="<?php bloginfo('comments_rss2_url'); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>512 <li><a href="<?php echo esc_url( get_bloginfo( 'rss2_url' ) ); ?>"><?php _e( 'Entries <abbr title="Really Simple Syndication">RSS</abbr>' ); ?></a></li> 513 <li><a href="<?php echo esc_url( get_bloginfo( 'comments_rss2_url' ) ); ?>"><?php _e( 'Comments <abbr title="Really Simple Syndication">RSS</abbr>' ); ?></a></li> 461 514 <?php 462 515 /** 463 516 * Filter the "Powered by WordPress" text in the Meta widget. … … 485 538 * @return array 486 539 */ 487 540 public function update( $new_instance, $old_instance ) { 488 $instance = $old_instance;489 $instance['title'] = s trip_tags($new_instance['title']);541 $instance = $old_instance; 542 $instance['title'] = sanitize_text_field( $new_instance['title'] ); 490 543 491 544 return $instance; 492 545 } … … 495 548 * @param array $instance 496 549 */ 497 550 public function form( $instance ) { 498 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); 499 $title = strip_tags($instance['title']); 551 $instance = wp_parse_args( (array) $instance, array( 552 'title' => '', 553 ) 554 ); 555 $title = $instance['title']; 500 556 ?> 501 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <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>557 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p> 502 558 <?php 503 559 } 504 560 } … … 511 567 class WP_Widget_Calendar extends WP_Widget { 512 568 513 569 public function __construct() { 514 $widget_ops = array('classname' => 'widget_calendar', 'description' => __( 'A calendar of your site’s Posts.') ); 515 parent::__construct('calendar', __('Calendar'), $widget_ops); 570 $widget_ops = array( 571 'classname' => 'widget_calendar', 572 'description' => __( 'A calendar of your site’s Posts.' ), 573 ); 574 parent::__construct( 'calendar', __( 'Calendar' ), $widget_ops ); 516 575 } 517 576 518 577 /** … … 539 598 * @return array 540 599 */ 541 600 public function update( $new_instance, $old_instance ) { 542 $instance = $old_instance;543 $instance['title'] = s trip_tags($new_instance['title']);601 $instance = $old_instance; 602 $instance['title'] = sanitize_text_field( $new_instance['title'] ); 544 603 545 604 return $instance; 546 605 } … … 549 608 * @param array $instance 550 609 */ 551 610 public function form( $instance ) { 552 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); 553 $title = strip_tags($instance['title']); 611 $instance = wp_parse_args( (array) $instance, array( 612 'title' => '', 613 ) 614 ); 615 $title = $instance['title']; 554 616 ?> 555 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>556 <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>617 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label> 618 <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p> 557 619 <?php 558 620 } 559 621 } … … 566 628 class WP_Widget_Text extends WP_Widget { 567 629 568 630 public function __construct() { 569 $widget_ops = array('classname' => 'widget_text', 'description' => __('Arbitrary text or HTML.')); 570 $control_ops = array('width' => 400, 'height' => 350); 571 parent::__construct('text', __('Text'), $widget_ops, $control_ops); 631 $widget_ops = array( 632 'classname' => 'widget_text', 633 'description' => __( 'Arbitrary text or HTML.' ), 634 ); 635 $control_ops = array( 636 'width' => 400, 637 'height' => 350, 638 ); 639 parent::__construct( 'text', __( 'Text' ), $widget_ops, $control_ops ); 572 640 } 573 641 574 642 /** … … 592 660 if ( ! empty( $title ) ) { 593 661 echo $args['before_title'] . $title . $args['after_title']; 594 662 } ?> 595 <div class="textwidget"><?php echo ! empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div>663 <div class="textwidget"><?php echo ! empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div> 596 664 <?php 597 665 echo $args['after_widget']; 598 666 } … … 603 671 * @return array 604 672 */ 605 673 public function update( $new_instance, $old_instance ) { 606 $instance = $old_instance; 607 $instance['title'] = strip_tags($new_instance['title']); 608 if ( current_user_can('unfiltered_html') ) 609 $instance['text'] = $new_instance['text']; 610 else 611 $instance['text'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text']) ) ); // wp_filter_post_kses() expects slashed 674 $instance = $old_instance; 675 $instance['title'] = sanitize_text_field( $new_instance['title'] ); 676 if ( current_user_can( 'unfiltered_html' ) ) { 677 $instance['text'] = $new_instance['text']; 678 } else { 679 $instance['text'] = wp_kses_post( $new_instance['text'] ); 680 } 612 681 $instance['filter'] = ! empty( $new_instance['filter'] ); 613 682 return $instance; 614 683 } … … 617 686 * @param array $instance 618 687 */ 619 688 public function form( $instance ) { 620 $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) ); 621 $title = strip_tags($instance['title']); 622 $text = esc_textarea($instance['text']); 623 ?> 624 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> 625 <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> 689 $instance = wp_parse_args( (array) $instance, array( 690 'title' => '', 691 'text' => '', 692 ) 693 ); 694 $title = $instance['title']; 695 $text = $instance['text']; 696 $filter = isset( $instance['filter'] ) ? $instance['filter'] : 0 697 ?> 698 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label> 699 <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p> 626 700 627 <p><label for="<?php echo $this->get_field_id( 'text'); ?>"><?php _e( 'Content:' ); ?></label>628 <textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea></p>701 <p><label for="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>"><?php _e( 'Content:' ); ?></label> 702 <textarea class="widefat" rows="16" cols="20" id="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>"><?php echo esc_textarea( $text ); ?></textarea></p> 629 703 630 <p><input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox" <?php checked(isset($instance['filter']) ? $instance['filter'] : 0); ?> /> <label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs'); ?></label></p>704 <p><input id="<?php echo esc_attr( $this->get_field_id( 'filter' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'filter' ) ); ?>" type="checkbox" <?php checked( $filter ); ?> /> <label for="<?php echo esc_attr( $this->get_field_id( 'filter' ) ); ?>"><?php _e( 'Automatically add paragraphs' ); ?></label></p> 631 705 <?php 632 706 } 633 707 } … … 640 714 class WP_Widget_Categories extends WP_Widget { 641 715 642 716 public function __construct() { 643 $widget_ops = array( 'classname' => 'widget_categories', 'description' => __( "A list or dropdown of categories." ) ); 644 parent::__construct('categories', __('Categories'), $widget_ops); 717 $widget_ops = array( 718 'classname' => 'widget_categories', 719 'description' => __( 'A list or dropdown of categories.' ), 720 ); 721 parent::__construct( 'categories', __( 'Categories' ), $widget_ops ); 645 722 } 646 723 647 724 /** … … 668 745 $cat_args = array( 669 746 'orderby' => 'name', 670 747 'show_count' => $c, 671 'hierarchical' => $h 748 'hierarchical' => $h, 672 749 ); 673 750 674 751 if ( $d ) { … … 735 812 * @return array 736 813 */ 737 814 public function update( $new_instance, $old_instance ) { 738 $instance = $old_instance;739 $instance['title'] = strip_tags($new_instance['title']);740 $instance['count'] = !empty($new_instance['count']) ? 1 : 0;741 $instance['hierarchical'] = ! empty($new_instance['hierarchical']) ? 1 : 0;742 $instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0;815 $instance = $old_instance; 816 $instance['title'] = sanitize_text_field( $new_instance['title'] ); 817 $instance['count'] = ! empty( $new_instance['count'] ) ? 1 : 0; 818 $instance['hierarchical'] = ! empty( $new_instance['hierarchical'] ) ? 1 : 0; 819 $instance['dropdown'] = ! empty( $new_instance['dropdown'] ) ? 1 : 0; 743 820 744 821 return $instance; 745 822 } … … 749 826 */ 750 827 public function form( $instance ) { 751 828 //Defaults 752 $instance = wp_parse_args( (array) $instance, array( 'title' => '') ); 753 $title = esc_attr( $instance['title'] ); 754 $count = isset($instance['count']) ? (bool) $instance['count'] :false; 829 $instance = wp_parse_args( (array) $instance, array( 830 'title' => '', 831 ) 832 ); 833 $title = $instance['title']; 834 $count = isset($instance['count']) ? (bool) $instance['count'] :false; 755 835 $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false; 756 $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false;836 $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false; 757 837 ?> 758 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:' ); ?></label>759 <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>838 <p><label for="<?php echo esc_att( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label> 839 <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p> 760 840 761 <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 ); ?> />762 <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e( 'Display as dropdown' ); ?></label><br />841 <p><input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'dropdown' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'dropdown' ) ); ?>"<?php checked( $dropdown ); ?> /> 842 <label for="<?php echo esc_attr( $this->get_field_id( 'dropdown' ) ); ?>"><?php _e( 'Display as dropdown' ); ?></label><br /> 763 843 764 <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>"<?php checked( $count ); ?> />765 <label for="<?php echo $this->get_field_id('count'); ?>"><?php _e( 'Show post counts' ); ?></label><br />844 <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'count' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'count' ) ); ?>"<?php checked( $count ); ?> /> 845 <label for="<?php echo esc_attr( $this->get_field_id( 'count' ) ); ?>"><?php _e( 'Show post counts' ); ?></label><br /> 766 846 767 <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('hierarchical'); ?>" name="<?php echo $this->get_field_name('hierarchical'); ?>"<?php checked( $hierarchical ); ?> />768 <label for="<?php echo $this->get_field_id('hierarchical'); ?>"><?php _e( 'Show hierarchy' ); ?></label></p>847 <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'hierarchical' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'hierarchical' ) ); ?>"<?php checked( $hierarchical ); ?> /> 848 <label for="<?php echo esc_attr( $this->get_field_id( 'hierarchical' ) ); ?>"><?php _e( 'Show hierarchy' ); ?></label></p> 769 849 <?php 770 850 } 771 851 … … 779 859 class WP_Widget_Recent_Posts extends WP_Widget { 780 860 781 861 public function __construct() { 782 $widget_ops = array('classname' => 'widget_recent_entries', 'description' => __( "Your site’s most recent Posts.") ); 783 parent::__construct('recent-posts', __('Recent Posts'), $widget_ops); 862 $widget_ops = array( 863 'classname' => 'widget_recent_entries', 864 'description' => __( 'Your site’s most recent Posts.' ), 865 ); 866 parent::__construct( 'recent-posts', __( 'Recent Posts' ), $widget_ops ); 784 867 $this->alt_option_name = 'widget_recent_entries'; 785 868 786 add_action( 'save_post', array( $this, 'flush_widget_cache') );787 add_action( 'deleted_post', array( $this, 'flush_widget_cache') );788 add_action( 'switch_theme', array( $this, 'flush_widget_cache') );869 add_action( 'save_post', array( $this, 'flush_widget_cache' ) ); 870 add_action( 'deleted_post', array( $this, 'flush_widget_cache' ) ); 871 add_action( 'switch_theme', array( $this, 'flush_widget_cache' ) ); 789 872 } 790 873 791 874 /** … … 819 902 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); 820 903 821 904 $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; 822 if ( ! $number ) 905 if ( ! $number ) { 823 906 $number = 5; 907 } 824 908 $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false; 825 909 826 910 /** … … 836 920 'posts_per_page' => $number, 837 921 'no_found_rows' => true, 838 922 'post_status' => 'publish', 839 'ignore_sticky_posts' => true 923 'ignore_sticky_posts' => true, 840 924 ) ) ); 841 925 842 if ( $r->have_posts()) :926 if ( $r->have_posts() ) : 843 927 ?> 844 928 <?php echo $args['before_widget']; ?> 845 <?php if ( $title ) { 929 <?php 930 if ( $title ) { 846 931 echo $args['before_title'] . $title . $args['after_title']; 847 } ?> 932 } 933 ?> 848 934 <ul> 849 935 <?php while ( $r->have_posts() ) : $r->the_post(); ?> 850 936 <li> … … 876 962 * @return array 877 963 */ 878 964 public function update( $new_instance, $old_instance ) { 879 $instance = $old_instance;880 $instance['title'] = strip_tags($new_instance['title']);881 $instance['number'] = (int) $new_instance['number'];965 $instance = $old_instance; 966 $instance['title'] = santize_text_field( $new_instance['title'] ); 967 $instance['number'] = (int) $new_instance['number']; 882 968 $instance['show_date'] = isset( $new_instance['show_date'] ) ? (bool) $new_instance['show_date'] : false; 883 969 $this->flush_widget_cache(); 884 970 885 971 $alloptions = wp_cache_get( 'alloptions', 'options' ); 886 if ( isset($alloptions['widget_recent_entries']) ) 887 delete_option('widget_recent_entries'); 972 if ( isset( $alloptions['widget_recent_entries'] ) ) { 973 delete_option( 'widget_recent_entries' ); 974 } 888 975 889 976 return $instance; 890 977 } … … 893 980 * @access public 894 981 */ 895 982 public function flush_widget_cache() { 896 wp_cache_delete( 'widget_recent_posts', 'widget');983 wp_cache_delete( 'widget_recent_posts', 'widget' ); 897 984 } 898 985 899 986 /** … … 904 991 $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; 905 992 $show_date = isset( $instance['show_date'] ) ? (bool) $instance['show_date'] : false; 906 993 ?> 907 <p><label for="<?php echo $this->get_field_id( 'title'); ?>"><?php _e( 'Title:' ); ?></label>908 <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>994 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label> 995 <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p> 909 996 910 <p><label for="<?php echo $this->get_field_id( 'number'); ?>"><?php _e( 'Number of posts to show:' ); ?></label>911 <input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>997 <p><label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"><?php _e( 'Number of posts to show:' ); ?></label> 998 <input id="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'number' ) ); ?>" type="text" value="<?php echo esc_attr( $number ); ?>" size="3" /></p> 912 999 913 <p><input class="checkbox" type="checkbox" <?php checked( $show_date ); ?> id="<?php echo $this->get_field_id( 'show_date' ); ?>" name="<?php echo $this->get_field_name( 'show_date'); ?>" />914 <label for="<?php echo $this->get_field_id( 'show_date'); ?>"><?php _e( 'Display post date?' ); ?></label></p>1000 <p><input class="checkbox" type="checkbox" <?php checked( $show_date ); ?> id="<?php echo esc_attr( $this->get_field_id( 'show_date' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_date' ) ); ?>" /> 1001 <label for="<?php echo esc_attr( $this->get_field_id( 'show_date' ) ); ?>"><?php _e( 'Display post date?' ); ?></label></p> 915 1002 <?php 916 1003 } 917 1004 } … … 924 1011 class WP_Widget_Recent_Comments extends WP_Widget { 925 1012 926 1013 public function __construct() { 927 $widget_ops = array('classname' => 'widget_recent_comments', 'description' => __( 'Your site’s most recent comments.' ) ); 928 parent::__construct('recent-comments', __('Recent Comments'), $widget_ops); 1014 $widget_ops = array( 1015 'classname' => 'widget_recent_comments', 1016 'description' => __( 'Your site’s most recent comments.' ), 1017 ); 1018 parent::__construct( 'recent-comments', __( 'Recent Comments' ), $widget_ops ); 929 1019 $this->alt_option_name = 'widget_recent_comments'; 930 1020 931 if ( is_active_widget(false, false, $this->id_base) ) 932 add_action( 'wp_head', array($this, 'recent_comments_style') ); 1021 if ( is_active_widget( false, false, $this->id_base ) ) { 1022 add_action( 'wp_head', array( $this, 'recent_comments_style' ) ); 1023 } 933 1024 934 add_action( 'comment_post', array( $this, 'flush_widget_cache') );935 add_action( 'edit_comment', array( $this, 'flush_widget_cache') );936 add_action( 'transition_comment_status', array( $this, 'flush_widget_cache') );1025 add_action( 'comment_post', array( $this, 'flush_widget_cache' ) ); 1026 add_action( 'edit_comment', array( $this, 'flush_widget_cache' ) ); 1027 add_action( 'transition_comment_status', array( $this, 'flush_widget_cache' ) ); 937 1028 } 938 1029 939 1030 /** … … 949 1040 * @param string $id_base The widget ID. 950 1041 */ 951 1042 if ( ! current_theme_supports( 'widgets' ) // Temp hack #14876 952 || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) 1043 || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) { 953 1044 return; 1045 } 954 1046 ?> 955 1047 <style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style> 956 1048 <?php … … 960 1052 * @access public 961 1053 */ 962 1054 public function flush_widget_cache() { 963 wp_cache_delete( 'widget_recent_comments', 'widget');1055 wp_cache_delete( 'widget_recent_comments', 'widget' ); 964 1056 } 965 1057 966 1058 /** … … 975 1067 976 1068 $cache = array(); 977 1069 if ( ! $this->is_preview() ) { 978 $cache = wp_cache_get( 'widget_recent_comments', 'widget');1070 $cache = wp_cache_get( 'widget_recent_comments', 'widget' ); 979 1071 } 980 1072 if ( ! is_array( $cache ) ) { 981 1073 $cache = array(); 982 1074 } 983 1075 984 if ( ! isset( $args['widget_id'] ) ) 1076 if ( ! isset( $args['widget_id'] ) ) { 985 1077 $args['widget_id'] = $this->id; 1078 } 986 1079 987 1080 if ( isset( $cache[ $args['widget_id'] ] ) ) { 988 1081 echo $cache[ $args['widget_id'] ]; … … 997 1090 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); 998 1091 999 1092 $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; 1000 if ( ! $number ) 1093 if ( ! $number ) { 1001 1094 $number = 5; 1095 } 1002 1096 1003 1097 /** 1004 1098 * Filter the arguments for the Recent Comments widget. … … 1012 1106 $comments = get_comments( apply_filters( 'widget_comments_args', array( 1013 1107 'number' => $number, 1014 1108 'status' => 'approve', 1015 'post_status' => 'publish' 1109 'post_status' => 'publish', 1016 1110 ) ) ); 1017 1111 1018 1112 $output .= $args['before_widget']; … … 1026 1120 $post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) ); 1027 1121 _prime_post_caches( $post_ids, strpos( get_option( 'permalink_structure' ), '%category%' ), false ); 1028 1122 1029 foreach ( (array) $comments as $comment ) {1123 foreach ( (array) $comments as $comment ) { 1030 1124 $output .= '<li class="recentcomments">'; 1031 1125 /* translators: comments widget: 1: comment author, 2: post link */ 1032 1126 $output .= sprintf( _x( '%1$s on %2$s', 'widgets' ), … … 1053 1147 * @return array 1054 1148 */ 1055 1149 public function update( $new_instance, $old_instance ) { 1056 $instance = $old_instance;1057 $instance['title'] = strip_tags($new_instance['title']);1150 $instance = $old_instance; 1151 $instance['title'] = sanitize_text_field( $new_instance['title'] ); 1058 1152 $instance['number'] = absint( $new_instance['number'] ); 1059 1153 $this->flush_widget_cache(); 1060 1154 1061 1155 $alloptions = wp_cache_get( 'alloptions', 'options' ); 1062 if ( isset($alloptions['widget_recent_comments']) ) 1063 delete_option('widget_recent_comments'); 1156 if ( isset( $alloptions['widget_recent_comments'] ) ) { 1157 delete_option( 'widget_recent_comments' ); 1158 } 1064 1159 1065 1160 return $instance; 1066 1161 } … … 1069 1164 * @param array $instance 1070 1165 */ 1071 1166 public function form( $instance ) { 1072 $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ): '';1073 $number = isset( $instance['number'] ) ? absint( $instance['number'] ): 5;1167 $title = isset( $instance['title'] ) ? $instance['title'] : ''; 1168 $number = isset( $instance['number'] ) ? $instance['number'] : 5; 1074 1169 ?> 1075 <p><label for="<?php echo $this->get_field_id( 'title'); ?>"><?php _e( 'Title:' ); ?></label>1076 <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>1170 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label> 1171 <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p> 1077 1172 1078 <p><label for="<?php echo $this->get_field_id( 'number'); ?>"><?php _e( 'Number of comments to show:' ); ?></label>1079 <input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>1173 <p><label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"><?php _e( 'Number of comments to show:' ); ?></label> 1174 <input id="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'number' ) ); ?>" type="text" value="<?php echo absint( $number ); ?>" size="3" /></p> 1080 1175 <?php 1081 1176 } 1082 1177 } … … 1089 1184 class WP_Widget_RSS extends WP_Widget { 1090 1185 1091 1186 public function __construct() { 1092 $widget_ops = array( 'description' => __('Entries from any RSS or Atom feed.') ); 1093 $control_ops = array( 'width' => 400, 'height' => 200 ); 1094 parent::__construct( 'rss', __('RSS'), $widget_ops, $control_ops ); 1187 $widget_ops = array( 1188 'description' => __( 'Entries from any RSS or Atom feed.' ), 1189 ); 1190 $control_ops = array( 1191 'width' => 400, 1192 'height' => 200, 1193 ); 1194 parent::__construct( 'rss', __( 'RSS' ), $widget_ops, $control_ops ); 1095 1195 } 1096 1196 1097 1197 /** … … 1099 1199 * @param array $instance 1100 1200 */ 1101 1201 public function widget( $args, $instance ) { 1102 if ( isset( $instance['error']) && $instance['error'] )1202 if ( isset( $instance['error'] ) && $instance['error'] ){ 1103 1203 return; 1204 } 1104 1205 1105 1206 $url = ! empty( $instance['url'] ) ? $instance['url'] : ''; 1106 while ( stristr($url, 'http') != $url ) 1107 $url = substr($url, 1); 1207 while ( stristr( $url, 'http' ) != $url ){ 1208 $url = substr( $url, 1 ); 1209 } 1108 1210 1109 if ( empty( $url) )1211 if ( empty( $url ) ) { 1110 1212 return; 1213 } 1111 1214 1112 1215 // self-url destruction sequence 1113 if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ) ) ) 1216 if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ) ) ) { 1114 1217 return; 1218 } 1115 1219 1116 $rss = fetch_feed($url);1220 $rss = fetch_feed( $url ); 1117 1221 $title = $instance['title']; 1118 $desc = '';1119 $link = '';1222 $desc = ''; 1223 $link = ''; 1120 1224 1121 if ( ! is_wp_error($rss) ) { 1122 $desc = esc_attr(strip_tags(@html_entity_decode($rss->get_description(), ENT_QUOTES, get_option('blog_charset')))); 1123 if ( empty($title) ) 1124 $title = esc_html(strip_tags($rss->get_title())); 1125 $link = esc_url(strip_tags($rss->get_permalink())); 1126 while ( stristr($link, 'http') != $link ) 1127 $link = substr($link, 1); 1225 if ( ! is_wp_error( $rss ) ) { 1226 $desc = esc_attr( strip_tags( @html_entity_decode( $rss->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ) ) ); 1227 if ( empty( $title ) ) { 1228 $title = strip_tags( $rss->get_title() ); 1229 } 1230 $link = strip_tags( $rss->get_permalink() ); 1231 while ( stristr( $link, 'http' ) != $link ) { 1232 $link = substr( $link, 1 ); 1233 } 1128 1234 } 1129 1235 1130 if ( empty($title) ) 1131 $title = empty($desc) ? __('Unknown Feed') : $desc; 1236 if ( empty( $title ) ) { 1237 $title = empty( $desc ) ? __( 'Unknown Feed' ) : $desc; 1238 } 1132 1239 1133 1240 /** This filter is documented in wp-includes/default-widgets.php */ 1134 1241 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); 1135 1242 1136 $url = esc_url(strip_tags($url)); 1137 $icon = includes_url('images/rss.png'); 1138 if ( $title ) 1139 $title = "<a class='rsswidget' href='$url'><img style='border:0' width='14' height='14' src='$icon' alt='RSS' /></a> <a class='rsswidget' href='$link'>$title</a>"; 1243 $url = strip_tags( $url ); 1244 $icon = includes_url( 'images/rss.png' ); 1245 if ( $title ) { 1246 $title = '<a class="rsswidget" href="' . esc_url( $url ) . '"><img style="border:0" width="14" height="14" src="' . esc_url( $icon ) . '" alt="RSS" /></a> <a class="rsswidget" href="' . esc_url( $link ) . '">"'. esc_html( $title ) .'"</a>'; 1247 } 1140 1248 1141 1249 echo $args['before_widget']; 1142 1250 if ( $title ) { … … 1145 1253 wp_widget_rss_output( $rss, $instance ); 1146 1254 echo $args['after_widget']; 1147 1255 1148 if ( ! is_wp_error( $rss) )1256 if ( ! is_wp_error( $rss ) ) { 1149 1257 $rss->__destruct(); 1258 } 1150 1259 unset($rss); 1151 1260 } 1152 1261 … … 1156 1265 * @return array 1157 1266 */ 1158 1267 public function update( $new_instance, $old_instance ) { 1159 $testurl = ( isset( $new_instance['url'] ) && ( ! isset( $old_instance['url'] ) || ( $new_instance['url'] != $old_instance['url'] ) ) );1268 $testurl = ( isset( $new_instance['url'] ) && ( ! isset( $old_instance['url'] ) || ( $new_instance['url'] != $old_instance['url'] ) ) ); 1160 1269 return wp_widget_rss_process( $new_instance, $testurl ); 1161 1270 } 1162 1271 … … 1165 1274 */ 1166 1275 public function form( $instance ) { 1167 1276 if ( empty( $instance ) ) { 1168 $instance = array( 'title' => '', 'url' => '', 'items' => 10, 'error' => false, 'show_summary' => 0, 'show_author' => 0, 'show_date' => 0 ); 1277 $instance = array( 1278 'title' => '', 1279 'url' => '', 1280 'items' => 10, 1281 'error' => false, 1282 'show_summary' => 0, 1283 'show_author' => 0, 1284 'show_date' => 0, 1285 ); 1169 1286 } 1170 1287 $instance['number'] = $this->number; 1171 1288 … … 1183 1300 */ 1184 1301 function wp_widget_rss_output( $rss, $args = array() ) { 1185 1302 if ( is_string( $rss ) ) { 1186 $rss = fetch_feed( $rss);1187 } elseif ( is_array( $rss) && isset($rss['url']) ) {1303 $rss = fetch_feed( $rss ); 1304 } elseif ( is_array( $rss ) && isset( $rss['url'] ) ) { 1188 1305 $args = $rss; 1189 $rss = fetch_feed( $rss['url']);1190 } elseif ( ! is_object($rss) ) {1306 $rss = fetch_feed( $rss['url'] ); 1307 } elseif ( ! is_object( $rss ) ) { 1191 1308 return; 1192 1309 } 1193 1310 1194 if ( is_wp_error($rss) ) { 1195 if ( is_admin() || current_user_can('manage_options') ) 1196 echo '<p>' . sprintf( __('<strong>RSS Error</strong>: %s'), $rss->get_error_message() ) . '</p>'; 1311 if ( is_wp_error( $rss ) ) { 1312 if ( is_admin() || current_user_can( 'manage_options' ) ) { 1313 echo '<p>' . sprintf( __( '<strong>RSS Error</strong>: %s' ), $rss->get_error_message() ) . '</p>'; 1314 } 1197 1315 return; 1198 1316 } 1199 1317 1200 $default_args = array( 'show_author' => 0, 'show_date' => 0, 'show_summary' => 0, 'items' => 0 ); 1318 $default_args = array( 1319 'show_author' => 0, 1320 'show_date' => 0, 1321 'show_summary' => 0, 1322 'items' => 0, 1323 ); 1201 1324 $args = wp_parse_args( $args, $default_args ); 1202 1325 1203 1326 $items = (int) $args['items']; 1204 if ( $items < 1 || 20 < $items ) 1327 if ( $items < 1 || 20 < $items ) { 1205 1328 $items = 10; 1329 } 1206 1330 $show_summary = (int) $args['show_summary']; 1207 1331 $show_author = (int) $args['show_author']; 1208 1332 $show_date = (int) $args['show_date']; 1209 1333 1210 if ( ! $rss->get_item_quantity() ) {1334 if ( ! $rss->get_item_quantity() ) { 1211 1335 echo '<ul><li>' . __( 'An error has occurred, which probably means the feed is down. Try again later.' ) . '</li></ul>'; 1212 1336 $rss->__destruct(); 1213 unset( $rss);1337 unset( $rss ); 1214 1338 return; 1215 1339 } 1216 1340 … … 1254 1378 $author = ''; 1255 1379 if ( $show_author ) { 1256 1380 $author = $item->get_author(); 1257 if ( is_object( $author) ) {1381 if ( is_object( $author ) ) { 1258 1382 $author = $author->get_name(); 1259 1383 $author = ' <cite>' . esc_html( strip_tags( $author ) ) . '</cite>'; 1260 1384 } … … 1286 1410 * @param array $inputs Override default display options. 1287 1411 */ 1288 1412 function wp_widget_rss_form( $args, $inputs = null ) { 1289 $default_inputs = array( 'url' => true, 'title' => true, 'items' => true, 'show_summary' => true, 'show_author' => true, 'show_date' => true ); 1413 $default_inputs = array( 1414 'url' => true, 1415 'title' => true, 1416 'items' => true, 1417 'show_summary' => true, 1418 'show_author' => true, 1419 'show_date' => true, 1420 ); 1290 1421 $inputs = wp_parse_args( $inputs, $default_inputs ); 1291 1422 1292 $args['number'] = esc_attr( $args['number'] );1293 $args['title'] = isset( $args['title'] ) ? esc_attr( $args['title'] ): '';1294 $args['url'] = isset( $args['url'] ) ? esc_url( $args['url'] ): '';1295 $args['items'] = isset( $args['items'] ) ? (int) $args['items'] : 0;1423 $args['number'] = $args['number']; 1424 $args['title'] = isset( $args['title'] ) ? $args['title'] : ''; 1425 $args['url'] = isset( $args['url'] ) ? $args['url'] : ''; 1426 $args['items'] = isset( $args['items'] ) ? (int) $args['items'] : 0; 1296 1427 1297 1428 if ( $args['items'] < 1 || 20 < $args['items'] ) { 1298 1429 $args['items'] = 10; … … 1308 1439 1309 1440 if ( $inputs['url'] ) : 1310 1441 ?> 1311 <p><label for="rss-url-<?php echo $args['number']; ?>"><?php _e( 'Enter the RSS feed URL here:' ); ?></label>1312 <input class="widefat" id="rss-url-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][url]" type="text" value="<?php echo $args['url']; ?>" /></p>1442 <p><label for="rss-url-<?php echo esc_attr( $args['number'] ); ?>"><?php _e( 'Enter the RSS feed URL here:' ); ?></label> 1443 <input class="widefat" id="rss-url-<?php echo esc_attr( $args['number'] ); ?>" name="widget-rss[<?php echo esc_attr( $args['number'] ); ?>][url]" type="text" value="<?php echo esc_url( $args['url'] ); ?>" /></p> 1313 1444 <?php endif; if ( $inputs['title'] ) : ?> 1314 <p><label for="rss-title-<?php echo $args['number']; ?>"><?php _e( 'Give the feed a title (optional):' ); ?></label>1315 <input class="widefat" id="rss-title-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][title]" type="text" value="<?php echo $args['title']; ?>" /></p>1445 <p><label for="rss-title-<?php echo esc_attr( $args['number'] ); ?>"><?php _e( 'Give the feed a title (optional):' ); ?></label> 1446 <input class="widefat" id="rss-title-<?php echo esc_attr( $args['number'] ); ?>" name="widget-rss[<?php echo esc_attr( $args['number'] ); ?>][title]" type="text" value="<?php echo esc_attr( $args['title'] ); ?>" /></p> 1316 1447 <?php endif; if ( $inputs['items'] ) : ?> 1317 <p><label for="rss-items-<?php echo $args['number']; ?>"><?php _e( 'How many items would you like to display?' ); ?></label>1318 <select id="rss-items-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][items]">1319 <?php1320 for ( $i = 1; $i <= 20; ++$i ) {1321 echo "<option value='$i' " . selected( $args['items'], $i, false ) . ">$i</option>";1322 }1323 ?>1448 <p><label for="rss-items-<?php echo esc_attr( $args['number'] ); ?>"><?php _e( 'How many items would you like to display?' ); ?></label> 1449 <select id="rss-items-<?php echo esc_attr( $args['number'] ); ?>" name="widget-rss[<?php echo esc_attr( $args['number'] ); ?>][items]"> 1450 <?php 1451 for ( $i = 1; $i <= 20; ++$i ) { 1452 echo "<option value='$i' " . selected( $args['items'], $i, false ) . ">$i</option>"; 1453 } 1454 ?> 1324 1455 </select></p> 1325 1456 <?php endif; if ( $inputs['show_summary'] ) : ?> 1326 <p><input id="rss-show-summary-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][show_summary]" type="checkbox" value="1" <?php checked( $args['show_summary'] ); ?> />1327 <label for="rss-show-summary-<?php echo $args['number']; ?>"><?php _e( 'Display item content?' ); ?></label></p>1457 <p><input id="rss-show-summary-<?php echo esc_attr( $args['number'] ); ?>" name="widget-rss[<?php echo esc_attr( $args['number'] ); ?>][show_summary]" type="checkbox" value="1" <?php checked( $args['show_summary'] ); ?> /> 1458 <label for="rss-show-summary-<?php echo esc_attr( $args['number'] ); ?>"><?php _e( 'Display item content?' ); ?></label></p> 1328 1459 <?php endif; if ( $inputs['show_author'] ) : ?> 1329 <p><input id="rss-show-author-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][show_author]" type="checkbox" value="1" <?php checked( $args['show_author'] ); ?> />1330 <label for="rss-show-author-<?php echo $args['number']; ?>"><?php _e( 'Display item author if available?' ); ?></label></p>1460 <p><input id="rss-show-author-<?php echo esc_attr( $args['number'] ); ?>" name="widget-rss[<?php echo esc_attr( $args['number'] ); ?>][show_author]" type="checkbox" value="1" <?php checked( $args['show_author'] ); ?> /> 1461 <label for="rss-show-author-<?php echo esc_attr( $args['number'] ); ?>"><?php _e( 'Display item author if available?' ); ?></label></p> 1331 1462 <?php endif; if ( $inputs['show_date'] ) : ?> 1332 <p><input id="rss-show-date-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][show_date]" type="checkbox" value="1" <?php checked( $args['show_date'] ); ?>/>1333 <label for="rss-show-date-<?php echo $args['number']; ?>"><?php _e( 'Display item date?' ); ?></label></p>1463 <p><input id="rss-show-date-<?php echo esc_attr( $args['number'] ); ?>" name="widget-rss[<?php echo esc_attr( $args['number'] ); ?>][show_date]" type="checkbox" value="1" <?php checked( $args['show_date'] ); ?>/> 1464 <label for="rss-show-date-<?php echo esc_attr( $args['number'] ); ?>"><?php _e( 'Display item date?' ); ?></label></p> 1334 1465 <?php 1335 1466 endif; 1336 1467 foreach ( array_keys($default_inputs) as $input ) : … … 1337 1468 if ( 'hidden' === $inputs[$input] ) : 1338 1469 $id = str_replace( '_', '-', $input ); 1339 1470 ?> 1340 <input type="hidden" id="rss-<?php echo $id; ?>-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][<?php echo $input; ?>]" value="<?php echo $args[ $input ]; ?>" />1471 <input type="hidden" id="rss-<?php echo esc_attr( $id ); ?>-<?php echo esc_attr( $args['number'] ); ?>" name="widget-rss[<?php echo esc_attr( $args['number'] ); ?>][<?php echo esc_attr( $input ); ?>]" value="<?php echo esc_attr( $args[ $input ] ); ?>" /> 1341 1472 <?php 1342 1473 endif; 1343 1474 endforeach; … … 1361 1492 */ 1362 1493 function wp_widget_rss_process( $widget_rss, $check_feed = true ) { 1363 1494 $items = (int) $widget_rss['items']; 1364 if ( $items < 1 || 20 < $items ) 1495 if ( $items < 1 || 20 < $items ) { 1365 1496 $items = 10; 1497 } 1366 1498 $url = esc_url_raw( strip_tags( $widget_rss['url'] ) ); 1367 1499 $title = isset( $widget_rss['title'] ) ? trim( strip_tags( $widget_rss['title'] ) ) : ''; 1368 1500 $show_summary = isset( $widget_rss['show_summary'] ) ? (int) $widget_rss['show_summary'] : 0; … … 1370 1502 $show_date = isset( $widget_rss['show_date'] ) ? (int) $widget_rss['show_date'] : 0; 1371 1503 1372 1504 if ( $check_feed ) { 1373 $rss = fetch_feed( $url);1505 $rss = fetch_feed( $url ); 1374 1506 $error = false; 1375 1507 $link = ''; 1376 if ( is_wp_error( $rss) ) {1508 if ( is_wp_error( $rss ) ) { 1377 1509 $error = $rss->get_error_message(); 1378 1510 } else { 1379 $link = esc_url(strip_tags($rss->get_permalink())); 1380 while ( stristr($link, 'http') != $link ) 1381 $link = substr($link, 1); 1511 $link = esc_url( strip_tags( $rss->get_permalink() ) ); 1512 while ( stristr( $link, 'http' ) != $link ) { 1513 $link = substr( $link, 1 ); 1514 } 1382 1515 1383 1516 $rss->__destruct(); 1384 unset( $rss);1517 unset( $rss ); 1385 1518 } 1386 1519 } 1387 1520 … … 1396 1529 class WP_Widget_Tag_Cloud extends WP_Widget { 1397 1530 1398 1531 public function __construct() { 1399 $widget_ops = array( 'description' => __( "A cloud of your most used tags.") ); 1400 parent::__construct('tag_cloud', __('Tag Cloud'), $widget_ops); 1532 $widget_ops = array( 1533 'description' => __( 'A cloud of your most used tags.' ), 1534 ); 1535 parent::__construct( 'tag_cloud', __( 'Tag Cloud' ), $widget_ops ); 1401 1536 } 1402 1537 1403 1538 /** … … 1405 1540 * @param array $instance 1406 1541 */ 1407 1542 public function widget( $args, $instance ) { 1408 $current_taxonomy = $this->_get_current_taxonomy( $instance);1409 if ( ! empty($instance['title']) ) {1543 $current_taxonomy = $this->_get_current_taxonomy( $instance ); 1544 if ( ! empty( $instance['title'] ) ) { 1410 1545 $title = $instance['title']; 1411 1546 } else { 1412 if ( 'post_tag' == $current_taxonomy ) {1413 $title = __( 'Tags');1547 if ( 'post_tag' === $current_taxonomy ) { 1548 $title = __( 'Tags' ); 1414 1549 } else { 1415 $tax = get_taxonomy( $current_taxonomy);1550 $tax = get_taxonomy( $current_taxonomy ); 1416 1551 $title = $tax->labels->name; 1417 1552 } 1418 1553 } … … 1437 1572 * @param array $current_taxonomy The taxonomy to use in the tag cloud. Default 'tags'. 1438 1573 */ 1439 1574 wp_tag_cloud( apply_filters( 'widget_tag_cloud_args', array( 1440 'taxonomy' => $current_taxonomy 1575 'taxonomy' => $current_taxonomy, 1441 1576 ) ) ); 1442 1577 1443 1578 echo "</div>\n"; … … 1451 1586 */ 1452 1587 public function update( $new_instance, $old_instance ) { 1453 1588 $instance = array(); 1454 $instance['title'] = s trip_tags(stripslashes($new_instance['title']));1455 $instance['taxonomy'] = stripslashes( $new_instance['taxonomy']);1589 $instance['title'] = sanitize_text_field( $new_instance['title'] ); 1590 $instance['taxonomy'] = stripslashes( $new_instance['taxonomy'] ); 1456 1591 return $instance; 1457 1592 } 1458 1593 … … 1460 1595 * @param array $instance 1461 1596 */ 1462 1597 public function form( $instance ) { 1463 $current_taxonomy = $this->_get_current_taxonomy($instance); 1598 $current_taxonomy = $this->_get_current_taxonomy( $instance ); 1599 $title = isset( $instance['title'] ) ? $instance['title'] : ''; 1464 1600 ?> 1465 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:') ?></label>1466 <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php if (isset ( $instance['title'])) {echo esc_attr( $instance['title'] );}?>" /></p>1467 <p><label for="<?php echo $this->get_field_id('taxonomy'); ?>"><?php _e('Taxonomy:') ?></label>1468 <select class="widefat" id="<?php echo $this->get_field_id('taxonomy'); ?>" name="<?php echo $this->get_field_name('taxonomy'); ?>">1469 <?php foreach ( get_taxonomies() as $taxonomy ) :1470 $tax = get_taxonomy( $taxonomy);1471 if ( ! $tax->show_tagcloud || empty($tax->labels->name) )1601 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ) ?></label> 1602 <input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_attr( $title ); ?>" /></p> 1603 <p><label for="<?php echo esc_attr( $this->get_field_id( 'taxonomy' ) ); ?>"><?php _e( 'Taxonomy:' ) ?></label> 1604 <select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'taxonomy' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'taxonomy' ) ); ?>"> 1605 <?php foreach ( get_taxonomies() as $taxonomy ) : 1606 $tax = get_taxonomy( $taxonomy ); 1607 if ( ! $tax->show_tagcloud || empty( $tax->labels->name ) ){ 1472 1608 continue; 1473 ?> 1474 <option value="<?php echo esc_attr($taxonomy) ?>" <?php selected($taxonomy, $current_taxonomy) ?>><?php echo $tax->labels->name; ?></option> 1609 } 1610 ?> 1611 <option value="<?php echo esc_attr( $taxonomy ) ?>" <?php selected( $taxonomy, $current_taxonomy ) ?>><?php echo esc_attr( $tax->labels->name ); ?></option> 1475 1612 <?php endforeach; ?> 1476 1613 </select></p><?php 1477 1614 } … … 1481 1618 * @return string 1482 1619 */ 1483 1620 public function _get_current_taxonomy($instance) { 1484 if ( ! empty($instance['taxonomy']) && taxonomy_exists($instance['taxonomy']) )1621 if ( ! empty( $instance['taxonomy'] ) && taxonomy_exists( $instance['taxonomy'] ) ) { 1485 1622 return $instance['taxonomy']; 1623 } 1486 1624 1487 1625 return 'post_tag'; 1488 1626 } … … 1496 1634 class WP_Nav_Menu_Widget extends WP_Widget { 1497 1635 1498 1636 public function __construct() { 1499 $widget_ops = array( 'description' => __('Add a custom menu to your sidebar.') ); 1500 parent::__construct( 'nav_menu', __('Custom Menu'), $widget_ops ); 1637 $widget_ops = array( 1638 'description' => __( 'Add a custom menu to your sidebar.' ), 1639 ); 1640 parent::__construct( 'nav_menu', __( 'Custom Menu' ), $widget_ops ); 1501 1641 } 1502 1642 1503 1643 /** … … 1508 1648 // Get menu 1509 1649 $nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false; 1510 1650 1511 if ( ! $nav_menu )1651 if ( ! $nav_menu ) { 1512 1652 return; 1653 } 1513 1654 1514 1655 /** This filter is documented in wp-includes/default-widgets.php */ 1515 1656 $instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); … … 1516 1657 1517 1658 echo $args['before_widget']; 1518 1659 1519 if ( ! empty($instance['title']) )1660 if ( ! empty( $instance['title'] ) ) { 1520 1661 echo $args['before_title'] . $instance['title'] . $args['after_title']; 1662 } 1521 1663 1522 1664 $nav_menu_args = array( 1523 1665 'fallback_cb' => '', 1524 'menu' => $nav_menu 1666 'menu' => $nav_menu, 1525 1667 ); 1526 1668 1527 1669 /** … … 1551 1693 public function update( $new_instance, $old_instance ) { 1552 1694 $instance = array(); 1553 1695 if ( ! empty( $new_instance['title'] ) ) { 1554 $instance['title'] = s trip_tags( stripslashes($new_instance['title']));1696 $instance['title'] = sanitize_text_field( $new_instance['title'] ); 1555 1697 } 1556 1698 if ( ! empty( $new_instance['nav_menu'] ) ) { 1557 1699 $instance['nav_menu'] = (int) $new_instance['nav_menu']; … … 1563 1705 * @param array $instance 1564 1706 */ 1565 1707 public function form( $instance ) { 1566 $title = isset( $instance['title'] ) ? $instance['title'] : '';1708 $title = isset( $instance['title'] ) ? $instance['title'] : ''; 1567 1709 $nav_menu = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : ''; 1568 1710 1569 1711 // Get menus … … 1584 1726 </p> 1585 1727 <div class="nav-menu-widget-form-controls" <?php if ( empty( $menus ) ) { echo ' style="display:none" '; } ?>> 1586 1728 <p> 1587 <label for="<?php echo $this->get_field_id( 'title'); ?>"><?php _e( 'Title:' ) ?></label>1588 <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title'); ?>" value="<?php echo esc_attr( $title ); ?>"/>1729 <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ) ?></label> 1730 <input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_attr( $title ); ?>"/> 1589 1731 </p> 1590 1732 <p> 1591 <label for="<?php echo $this->get_field_id( 'nav_menu'); ?>"><?php _e( 'Select Menu:' ); ?></label>1592 <select id="<?php echo $this->get_field_id( 'nav_menu' ); ?>" name="<?php echo $this->get_field_name( 'nav_menu'); ?>">1733 <label for="<?php echo esc_attr( $this->get_field_id( 'nav_menu' ) ); ?>"><?php _e( 'Select Menu:' ); ?></label> 1734 <select id="<?php echo esc_attr( $this->get_field_id( 'nav_menu' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'nav_menu' ) ); ?>"> 1593 1735 <option value="0"><?php _e( '— Select —' ); ?></option> 1594 1736 <?php foreach ( $menus as $menu ) : ?> 1595 1737 <option value="<?php echo esc_attr( $menu->term_id ); ?>" <?php selected( $nav_menu, $menu->term_id ); ?>> … … 1612 1754 * @since 2.2.0 1613 1755 */ 1614 1756 function wp_widgets_init() { 1615 if ( !is_blog_installed() ) 1757 1758 if ( ! is_blog_installed() ) { 1616 1759 return; 1760 } 1617 1761 1618 register_widget( 'WP_Widget_Pages');1762 register_widget( 'WP_Widget_Pages' ); 1619 1763 1620 register_widget( 'WP_Widget_Calendar');1764 register_widget( 'WP_Widget_Calendar' ); 1621 1765 1622 register_widget( 'WP_Widget_Archives');1766 register_widget( 'WP_Widget_Archives' ); 1623 1767 1624 if ( get_option( 'link_manager_enabled' ) ) 1625 register_widget('WP_Widget_Links'); 1768 if ( get_option( 'link_manager_enabled' ) ) { 1769 register_widget( 'WP_Widget_Links' ); 1770 } 1626 1771 1627 register_widget( 'WP_Widget_Meta');1772 register_widget( 'WP_Widget_Meta' ); 1628 1773 1629 register_widget( 'WP_Widget_Search');1774 register_widget( 'WP_Widget_Search' ); 1630 1775 1631 register_widget( 'WP_Widget_Text');1776 register_widget( 'WP_Widget_Text' ); 1632 1777 1633 register_widget( 'WP_Widget_Categories');1778 register_widget( 'WP_Widget_Categories' ); 1634 1779 1635 register_widget( 'WP_Widget_Recent_Posts');1780 register_widget( 'WP_Widget_Recent_Posts' ); 1636 1781 1637 register_widget( 'WP_Widget_Recent_Comments');1782 register_widget( 'WP_Widget_Recent_Comments' ); 1638 1783 1639 register_widget( 'WP_Widget_RSS');1784 register_widget( 'WP_Widget_RSS' ); 1640 1785 1641 register_widget( 'WP_Widget_Tag_Cloud');1786 register_widget( 'WP_Widget_Tag_Cloud' ); 1642 1787 1643 register_widget( 'WP_Nav_Menu_Widget');1788 register_widget( 'WP_Nav_Menu_Widget' ); 1644 1789 1645 1790 /** 1646 1791 * Fires after all default WordPress widgets have been registered.