Ticket #23012: 23012.2.diff
| File 23012.2.diff, 56.8 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( 'classname' => 'widget_pages', 'description' => esc_html__( 'A list of your site’s Pages.' ) ); 18 parent::__construct( 'pages', esc_html__( 'Pages' ), $widget_ops ); 19 19 } 20 20 21 21 /** … … 38 38 $sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby']; 39 39 $exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude']; 40 40 41 if ( $sortby == 'menu_order' )41 if ( 'menu_order' == $sortby ) { 42 42 $sortby = 'menu_order, post_title'; 43 } 43 44 44 45 /** 45 46 * Filter the arguments for the Pages widget. … … 54 55 'title_li' => '', 55 56 'echo' => 0, 56 57 'sort_column' => $sortby, 57 'exclude' => $exclude 58 'exclude' => $exclude, 58 59 ) ) ); 59 60 60 61 if ( ! empty( $out ) ) { … … 78 79 */ 79 80 public function update( $new_instance, $old_instance ) { 80 81 $instance = $old_instance; 81 $instance['title'] = strip_tags( $new_instance['title']);82 $instance['title'] = strip_tags( $new_instance['title'] ); 82 83 if ( in_array( $new_instance['sortby'], array( 'post_title', 'menu_order', 'ID' ) ) ) { 83 84 $instance['sortby'] = $new_instance['sortby']; 84 85 } else { … … 95 96 */ 96 97 public function form( $instance ) { 97 98 //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'] );99 $instance = wp_parse_args( (array) $instance, array( 'sortby' => 'post_title', 'title' => '', 'exclude' => '' ) ); 100 $title = isset( $instance['title'] ) ? $instance['title'] : ''; 101 $exclude = isset( $instance['exclude'] ) ? $instance['exclude'] : ''; 101 102 ?> 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>103 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_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 104 <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>105 <label for="<?php echo esc_attr( $this->get_field_id( 'sortby' ) ); ?>"><?php esc_html_e( 'Sort by:' ); ?></label> 106 <select name="<?php echo esc_attr( $this->get_field_name( 'sortby' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'sortby' ) ); ?>" class="widefat"> 107 <option value="post_title"<?php selected( $instance['sortby'], 'post_title' ); ?>><?php esc_html_e( 'Page title' ); ?></option> 108 <option value="menu_order"<?php selected( $instance['sortby'], 'menu_order' ); ?>><?php esc_html_e( 'Page order' ); ?></option> 108 109 <option value="ID"<?php selected( $instance['sortby'], 'ID' ); ?>><?php _e( 'Page ID' ); ?></option> 109 110 </select> 110 111 </p> 111 112 <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" />113 <label for="<?php echo esc_attr( $this->get_field_id( 'exclude' ) ); ?>"><?php esc_html_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 114 <br /> 114 <small><?php _e( 'Page IDs, separated by commas.' ); ?></small>115 <small><?php esc_html_e( 'Page IDs, separated by commas.' ); ?></small> 115 116 </p> 116 117 <?php 117 118 } … … 126 127 class WP_Widget_Links extends WP_Widget { 127 128 128 129 public function __construct() { 129 $widget_ops = array('description' => __( "Your blogroll" ) ); 130 parent::__construct('links', __('Links'), $widget_ops); 130 $widget_ops = array( 131 'description' => esc_html__( 'Your blogroll' ) 132 ); 133 parent::__construct( 'links', esc_html__( 'Links' ), $widget_ops ); 131 134 } 132 135 133 136 /** … … 136 139 */ 137 140 public function widget( $args, $instance ) { 138 141 $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;142 $show_name = isset($instance['name']) ? $instance['name'] : false; 143 $show_rating = isset($instance['rating']) ? $instance['rating'] : false; 144 $show_images = isset($instance['images']) ? $instance['images'] : true; 145 $category = isset($instance['category']) ? $instance['category'] : false; 146 $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name'; 147 $order = $orderby == 'rating' ? 'DESC' : 'ASC'; 148 $limit = isset( $instance['limit'] ) ? $instance['limit'] : -1; 146 149 147 150 $before_widget = preg_replace( '/id="[^"]*"/', 'id="%id"', $args['before_widget'] ); 148 151 … … 175 178 $new_instance = (array) $new_instance; 176 179 $instance = array( 'images' => 0, 'name' => 0, 'description' => 0, 'rating' => 0 ); 177 180 foreach ( $instance as $field => $val ) { 178 if ( isset($new_instance[$field]) ) 179 $instance[$field] = 1; 181 if ( isset( $new_instance[ $field ] ) ) { 182 $instance[ $field ] = 1; 183 } 180 184 } 181 185 182 186 $instance['orderby'] = 'name'; 183 if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) ) 187 if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) ) { 184 188 $instance['orderby'] = $new_instance['orderby']; 189 } 185 190 186 191 $instance['category'] = intval( $new_instance['category'] ); 187 192 $instance['limit'] = ! empty( $new_instance['limit'] ) ? intval( $new_instance['limit'] ) : -1; … … 197 202 //Defaults 198 203 $instance = wp_parse_args( (array) $instance, array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false, 'category' => false, 'orderby' => 'name', 'limit' => -1 ) ); 199 204 $link_cats = get_terms( 'link_category' ); 200 if ( ! $limit = intval( $instance['limit'] ) ) 205 if ( ! $limit = intval( $instance['limit'] ) ) { 201 206 $limit = -1; 207 } 208 202 209 ?> 203 210 <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>211 <label for="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>"><?php esc_html_e( 'Select Link Category:' ); ?></label> 212 <select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'category' ) ); ?>"> 213 <option value=""><?php _ex( 'All Links', 'links widget' ); ?></option> 207 214 <?php 208 215 foreach ( $link_cats as $link_cat ) { 209 216 echo '<option value="' . intval( $link_cat->term_id ) . '"' 210 217 . selected( $instance['category'], $link_cat->term_id, false ) 211 . '>' . $link_cat->name. "</option>\n";218 . '>' . esc_html( $link_cat->name ) . "</option>\n"; 212 219 } 213 220 ?> 214 221 </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">217 <option value="name"<?php selected( $instance['orderby'], 'name' ); ?>><?php _e( 'Link title' ); ?></option>218 <option value="rating"<?php selected( $instance['orderby'], 'rating' ); ?>><?php _e( 'Link rating' ); ?></option>219 <option value="id"<?php selected( $instance['orderby'], 'id' ); ?>><?php _e( 'Link ID' ); ?></option>222 <label for="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>"><?php esc_html_e( 'Sort by:' ); ?></label> 223 <select name="<?php echo esc_attr( $this->get_field_name( 'orderby' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>" class="widefat"> 224 <option value="name"<?php selected( $instance['orderby'], 'name' ); ?>><?php esc_html_e( 'Link title' ); ?></option> 225 <option value="rating"<?php selected( $instance['orderby'], 'rating' ); ?>><?php esc_html_e( 'Link rating' ); ?></option> 226 <option value="id"<?php selected( $instance['orderby'], 'id' ); ?>><?php esc_html_e( 'Link ID' ); ?></option> 220 227 <option value="rand"<?php selected( $instance['orderby'], 'rand' ); ?>><?php _ex( 'Random', 'Links widget' ); ?></option> 221 228 </select> 222 229 </p> 223 230 <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>231 <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' ) ); ?>" /> 232 <label for="<?php echo esc_attr( $this->get_field_id( 'images' ) ); ?>"><?php esc_html_e( 'Show Link Image' ); ?></label><br /> 233 <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' ) ); ?>" /> 234 <label for="<?php echo esc_attr( $this->get_field_id( 'name' ) ); ?>"><?php esc_html_e( 'Show Link Name' ); ?></label><br /> 235 <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' ) ); ?>" /> 236 <label for="<?php echo esc_attr( $this->get_field_id( 'description' ) ); ?>"><?php esc_html_e( 'Show Link Description' ); ?></label><br /> 237 <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' ) ); ?>" /> 238 <label for="<?php echo esc_attr( $this->get_field_id( 'rating' ) ); ?>"><?php esc_html_e( 'Show Link Rating' ); ?></label> 232 239 </p> 233 240 <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" />241 <label for="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>"><?php esc_html_e( 'Number of links to show:' ); ?></label> 242 <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 243 </p> 237 244 <?php 238 245 } … … 246 253 class WP_Widget_Search extends WP_Widget { 247 254 248 255 public function __construct() { 249 $widget_ops = array( 'classname' => 'widget_search', 'description' => __( "A search form for your site.") );256 $widget_ops = array( 'classname' => 'widget_search', 'description' => esc_html__( 'A search form for your site.' ) ); 250 257 parent::__construct( 'search', _x( 'Search', 'Search widget' ), $widget_ops ); 251 258 } 252 259 … … 273 280 * @param array $instance 274 281 */ 275 282 public function form( $instance ) { 276 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );283 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); 277 284 $title = $instance['title']; 278 285 ?> 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>286 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_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 287 <?php 281 288 } 282 289 … … 287 294 */ 288 295 public function update( $new_instance, $old_instance ) { 289 296 $instance = $old_instance; 290 $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => ''));291 $instance['title'] = strip_tags( $new_instance['title']);297 $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '' ) ); 298 $instance['title'] = strip_tags( $new_instance['title'] ); 292 299 return $instance; 293 300 } 294 301 … … 302 309 class WP_Widget_Archives extends WP_Widget { 303 310 304 311 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);312 $widget_ops = array( 'classname' => 'widget_archive', 'description' => __( 'A monthly archive of your site’s Posts.' ) ); 313 parent::__construct( 'archives', esc_html__( 'Archives' ), $widget_ops ); 307 314 } 308 315 309 316 /** … … 340 347 $dropdown_args = apply_filters( 'widget_archives_dropdown_args', array( 341 348 'type' => 'monthly', 342 349 'format' => 'option', 343 'show_post_count' => $c 350 'show_post_count' => $c, 344 351 ) ); 345 352 346 353 switch ( $dropdown_args['type'] ) { … … 382 389 */ 383 390 wp_get_archives( apply_filters( 'widget_archives_args', array( 384 391 'type' => 'monthly', 385 'show_post_count' => $c 392 'show_post_count' => $c, 386 393 ) ) ); 387 394 ?> 388 395 </ul> … … 399 406 */ 400 407 public function update( $new_instance, $old_instance ) { 401 408 $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']);409 $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'count' => 0, 'dropdown' => '' ) ); 410 $instance['title'] = strip_tags( $new_instance['title'] ); 404 411 $instance['count'] = $new_instance['count'] ? 1 : 0; 405 412 $instance['dropdown'] = $new_instance['dropdown'] ? 1 : 0; 406 413 … … 411 418 * @param array $instance 412 419 */ 413 420 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"' : '';421 $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'count' => 0, 'dropdown' => '' ) ); 422 $title = strip_tags( $instance['title'] ); 423 $count = $instance['count'] ? true : false; 424 $dropdown = $instance['dropdown'] ? true : false; 418 425 ?> 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>426 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_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 427 <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>428 <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 esc_html_e( 'Display as dropdown' ); ?></label> 422 429 <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>430 <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 esc_html_e( 'Show post counts' ); ?></label> 424 431 </p> 425 432 <?php 426 433 } … … 436 443 class WP_Widget_Meta extends WP_Widget { 437 444 438 445 public function __construct() { 439 $widget_ops = array( 'classname' => 'widget_meta', 'description' => __( "Login, RSS, & WordPress.org links.") );440 parent::__construct( 'meta', __('Meta'), $widget_ops);446 $widget_ops = array( 'classname' => 'widget_meta', 'description' => esc_html__( 'Login, RSS, & WordPress.org links.' ) ); 447 parent::__construct( 'meta', esc_html__( 'Meta' ), $widget_ops ); 441 448 } 442 449 443 450 /** … … 448 455 /** This filter is documented in wp-includes/default-widgets.php */ 449 456 $title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Meta' ) : $instance['title'], $instance, $this->id_base ); 450 457 458 /** 459 * Allowed html tags 460 */ 461 $allowed_tags = array( 462 'abbr' => array( 463 'title' => array() 464 ) 465 ); 466 451 467 echo $args['before_widget']; 452 468 if ( $title ) { 453 469 echo $args['before_title'] . $title . $args['after_title']; … … 456 472 <ul> 457 473 <?php wp_register(); ?> 458 474 <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>475 <li><a href="<?php echo esc_url( get_bloginfo( 'rss2_url' ) ); ?>"><?php echo wp_kses( __( 'Entries <abbr title="Really Simple Syndication">RSS</abbr>' ), $allowed_tags ); ?></a></li> 476 <li><a href="<?php echo esc_url( get_bloginfo( 'comments_rss2_url' ) ); ?>"><?php echo wp_kses( __( 'Comments <abbr title="Really Simple Syndication">RSS</abbr>' ), $allowed_tags ); ?></a></li> 461 477 <?php 462 478 /** 463 479 * Filter the "Powered by WordPress" text in the Meta widget. … … 486 502 */ 487 503 public function update( $new_instance, $old_instance ) { 488 504 $instance = $old_instance; 489 $instance['title'] = strip_tags( $new_instance['title']);505 $instance['title'] = strip_tags( $new_instance['title'] ); 490 506 491 507 return $instance; 492 508 } … … 496 512 */ 497 513 public function form( $instance ) { 498 514 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); 499 $title = strip_tags( $instance['title']);515 $title = strip_tags( $instance['title'] ); 500 516 ?> 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>517 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_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 518 <?php 503 519 } 504 520 } … … 511 527 class WP_Widget_Calendar extends WP_Widget { 512 528 513 529 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);530 $widget_ops = array( 'classname' => 'widget_calendar', 'description' => __( 'A calendar of your site’s Posts.' ) ); 531 parent::__construct( 'calendar', esc_html__( 'Calendar' ), $widget_ops ); 516 532 } 517 533 518 534 /** … … 540 556 */ 541 557 public function update( $new_instance, $old_instance ) { 542 558 $instance = $old_instance; 543 $instance['title'] = strip_tags( $new_instance['title']);559 $instance['title'] = strip_tags( $new_instance['title'] ); 544 560 545 561 return $instance; 546 562 } … … 550 566 */ 551 567 public function form( $instance ) { 552 568 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); 553 $title = strip_tags( $instance['title']);569 $title = strip_tags( $instance['title'] ); 554 570 ?> 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>571 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:' ); ?></label> 572 <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 573 <?php 558 574 } 559 575 } … … 566 582 class WP_Widget_Text extends WP_Widget { 567 583 568 584 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); 585 $widget_ops = array( 586 'classname' => 'widget_text', 587 'description' => esc_html__( 'Arbitrary text or HTML.' ) 588 ); 589 $control_ops = array( 590 'width' => 400, 591 'height' => 350, 592 ); 593 parent::__construct( 'text', esc_html__( 'Text' ), $widget_ops, $control_ops ); 572 594 } 573 595 574 596 /** … … 592 614 if ( ! empty( $title ) ) { 593 615 echo $args['before_title'] . $title . $args['after_title']; 594 616 } ?> 595 <div class="textwidget"><?php echo ! empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div>617 <div class="textwidget"><?php echo ! empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div> 596 618 <?php 597 619 echo $args['after_widget']; 598 620 } … … 604 626 */ 605 627 public function update( $new_instance, $old_instance ) { 606 628 $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 629 $instance['title'] = strip_tags( $new_instance['title'] ); 630 if ( current_user_can( 'unfiltered_html' ) ) { 631 $instance['text'] = $new_instance['text']; 632 } else { 633 $instance['text'] = stripslashes( wp_filter_post_kses( addslashes( $new_instance['text'] ) ) ); // wp_filter_post_kses() expects slashed 634 } 612 635 $instance['filter'] = ! empty( $new_instance['filter'] ); 613 636 return $instance; 614 637 } … … 618 641 */ 619 642 public function form( $instance ) { 620 643 $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) ); 621 $title = strip_tags( $instance['title']);622 $text = esc_textarea($instance['text']);644 $title = strip_tags( $instance['title'] ); 645 $text = isset( $instance['text'] ) ? $instance['text'] : ''; 623 646 ?> 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>647 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:' ); ?></label> 648 <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 649 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>650 <p><label for="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>"><?php esc_html_e( 'Content:' ); ?></label> 651 <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 652 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>653 <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( isset( $instance['filter'] ) ? $instance['filter'] : 0 ); ?> /> <label for="<?php echo esc_attr( $this->get_field_id( 'filter' ) ); ?>"><?php esc_html_e( 'Automatically add paragraphs' ); ?></label></p> 631 654 <?php 632 655 } 633 656 } … … 640 663 class WP_Widget_Categories extends WP_Widget { 641 664 642 665 public function __construct() { 643 $widget_ops = array( 'classname' => 'widget_categories', 'description' => __( "A list or dropdown of categories." ) ); 644 parent::__construct('categories', __('Categories'), $widget_ops); 666 $widget_ops = array( 667 'classname' => 'widget_categories', 668 'description' => esc_html__( 'A list or dropdown of categories.' ) 669 ); 670 parent::__construct( 'categories', esc_html__( 'Categories' ), $widget_ops ); 645 671 } 646 672 647 673 /** … … 668 694 $cat_args = array( 669 695 'orderby' => 'name', 670 696 'show_count' => $c, 671 'hierarchical' => $h 697 'hierarchical' => $h, 672 698 ); 673 699 674 700 if ( $d ) { … … 677 703 678 704 echo '<label class="screen-reader-text" for="' . esc_attr( $dropdown_id ) . '">' . $title . '</label>'; 679 705 680 $cat_args['show_option_none'] = __( 'Select Category' );706 $cat_args['show_option_none'] = esc_html__( 'Select Category' ); 681 707 $cat_args['id'] = $dropdown_id; 682 708 683 709 /** … … 695 721 <script type='text/javascript'> 696 722 /* <![CDATA[ */ 697 723 (function() { 698 var dropdown = document.getElementById( "<?php echo esc_js( $dropdown_id ); ?>" );724 var dropdown = document.getElementById( "<?php echo wp_json_encode( $dropdown_id ); ?>" ); 699 725 function onCatChange() { 700 726 if ( dropdown.options[ dropdown.selectedIndex ].value > 0 ) { 701 location.href = "<?php echo home_url(); ?>/?cat=" + dropdown.options[ dropdown.selectedIndex ].value;727 location.href = "<?php echo esc_url( home_url() ); ?>/?cat=" + dropdown.options[ dropdown.selectedIndex ].value; 702 728 } 703 729 } 704 730 dropdown.onchange = onCatChange; … … 736 762 */ 737 763 public function update( $new_instance, $old_instance ) { 738 764 $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;765 $instance['title'] = strip_tags( $new_instance['title'] ); 766 $instance['count'] = ! empty( $new_instance['count'] ) ? 1 : 0; 767 $instance['hierarchical'] = ! empty( $new_instance['hierarchical'] ) ? 1 : 0; 768 $instance['dropdown'] = ! empty($new_instance['dropdown'] ) ? 1 : 0; 743 769 744 770 return $instance; 745 771 } … … 749 775 */ 750 776 public function form( $instance ) { 751 777 //Defaults 752 $instance = wp_parse_args( (array) $instance, array( 'title' => '') ); 753 $title = esc_attr( $instance['title'] ); 778 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); 754 779 $count = isset($instance['count']) ? (bool) $instance['count'] :false; 755 780 $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false; 756 781 $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false; 757 782 ?> 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>783 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:' ); ?></label> 784 <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( $instance['title'] ) ?>" /></p> 760 785 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 />786 <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 ); ?> /> 787 <label for="<?php echo esc_attr( $this->get_field_id( 'dropdown' ) ); ?>"><?php esc_html_e( 'Display as dropdown' ); ?></label><br /> 763 788 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 />789 <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 ); ?> /> 790 <label for="<?php echo esc_attr( $this->get_field_id( 'count' ) ); ?>"><?php esc_html_e( 'Show post counts' ); ?></label><br /> 766 791 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>792 <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 ); ?> /> 793 <label for="<?php echo esc_attr( $this->get_field_id( 'hierarchical' ) ); ?>"><?php esc_html_e( 'Show hierarchy' ); ?></label></p> 769 794 <?php 770 795 } 771 796 … … 779 804 class WP_Widget_Recent_Posts extends WP_Widget { 780 805 781 806 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); 807 $widget_ops = array( 808 'classname' => 'widget_recent_entries', 809 'description' => esc_html__( 'Your site’s most recent Posts.' ) 810 ); 811 parent::__construct( 'recent-posts',esc_html__( 'Recent Posts' ), $widget_ops ); 784 812 $this->alt_option_name = 'widget_recent_entries'; 785 813 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') );814 add_action( 'save_post', array( $this, 'flush_widget_cache' ) ); 815 add_action( 'deleted_post', array( $this, 'flush_widget_cache' ) ); 816 add_action( 'switch_theme', array( $this, 'flush_widget_cache' ) ); 789 817 } 790 818 791 819 /** … … 819 847 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); 820 848 821 849 $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; 822 if ( ! $number ) 850 if ( ! $number ) { 823 851 $number = 5; 852 } 824 853 $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false; 825 854 826 855 /** … … 836 865 'posts_per_page' => $number, 837 866 'no_found_rows' => true, 838 867 'post_status' => 'publish', 839 'ignore_sticky_posts' => true 868 'ignore_sticky_posts' => true, 840 869 ) ) ); 841 870 842 if ( $r->have_posts()) :871 if ( $r->have_posts() ) : 843 872 ?> 844 873 <?php echo $args['before_widget']; ?> 845 <?php if ( $title ) { 874 <?php 875 if ( $title ) { 846 876 echo $args['before_title'] . $title . $args['after_title']; 847 } ?>877 }?> 848 878 <ul> 849 879 <?php while ( $r->have_posts() ) : $r->the_post(); ?> 850 880 <li> … … 877 907 */ 878 908 public function update( $new_instance, $old_instance ) { 879 909 $instance = $old_instance; 880 $instance['title'] = strip_tags( $new_instance['title']);910 $instance['title'] = strip_tags( $new_instance['title'] ); 881 911 $instance['number'] = (int) $new_instance['number']; 882 912 $instance['show_date'] = isset( $new_instance['show_date'] ) ? (bool) $new_instance['show_date'] : false; 883 913 $this->flush_widget_cache(); 884 914 885 915 $alloptions = wp_cache_get( 'alloptions', 'options' ); 886 if ( isset($alloptions['widget_recent_entries']) ) 887 delete_option('widget_recent_entries'); 916 if ( isset( $alloptions['widget_recent_entries'] ) ) { 917 delete_option( 'widget_recent_entries' ); 918 } 888 919 889 920 return $instance; 890 921 } … … 893 924 * @access public 894 925 */ 895 926 public function flush_widget_cache() { 896 wp_cache_delete( 'widget_recent_posts', 'widget');927 wp_cache_delete( 'widget_recent_posts', 'widget' ); 897 928 } 898 929 899 930 /** … … 900 931 * @param array $instance 901 932 */ 902 933 public function form( $instance ) { 903 $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ): '';904 $number = isset( $instance['number'] ) ? absint( $instance['number'] ): 5;905 $show_date = isset( $instance['show_date'] ) ? (bool)$instance['show_date'] : false;934 $title = isset( $instance['title'] ) ? $instance['title']: ''; 935 $number = isset( $instance['number'] ) ? $instance['number'] : 5; 936 $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false; 906 937 ?> 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>938 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:' ); ?></label> 939 <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 940 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>941 <p><label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"><?php esc_html_e( 'Number of posts to show:' ); ?></label> 942 <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> 912 943 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>944 <p><input class="checkbox" type="checkbox" <?php checked( (bool) $show_date ); ?> id="<?php echo esc_attr( $this->get_field_id( 'show_date' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_date' ) ); ?>" /> 945 <label for="<?php echo esc_attr( $this->get_field_id( 'show_date' ) ); ?>"><?php esc_html_e( 'Display post date?' ); ?></label></p> 915 946 <?php 916 947 } 917 948 } … … 924 955 class WP_Widget_Recent_Comments extends WP_Widget { 925 956 926 957 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); 958 $widget_ops = array( 959 'classname' => 'widget_recent_comments', 960 'description' => esc_html__( 'Your site’s most recent comments.' ) 961 ); 962 parent::__construct( 'recent-comments', esc_html__( 'Recent Comments' ), $widget_ops ); 929 963 $this->alt_option_name = 'widget_recent_comments'; 930 964 931 if ( is_active_widget(false, false, $this->id_base) ) 932 add_action( 'wp_head', array($this, 'recent_comments_style') ); 965 if ( is_active_widget( false, false, $this->id_base ) ) { 966 add_action( 'wp_head', array( $this, 'recent_comments_style' ) ); 967 } 933 968 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') );969 add_action( 'comment_post', array( $this, 'flush_widget_cache' ) ); 970 add_action( 'edit_comment', array( $this, 'flush_widget_cache' ) ); 971 add_action( 'transition_comment_status', array( $this, 'flush_widget_cache' ) ); 937 972 } 938 973 939 974 /** … … 949 984 * @param string $id_base The widget ID. 950 985 */ 951 986 if ( ! current_theme_supports( 'widgets' ) // Temp hack #14876 952 || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) 987 || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) { 953 988 return; 989 } 954 990 ?> 955 991 <style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style> 956 992 <?php … … 960 996 * @access public 961 997 */ 962 998 public function flush_widget_cache() { 963 wp_cache_delete( 'widget_recent_comments', 'widget');999 wp_cache_delete( 'widget_recent_comments', 'widget' ); 964 1000 } 965 1001 966 1002 /** … … 975 1011 976 1012 $cache = array(); 977 1013 if ( ! $this->is_preview() ) { 978 $cache = wp_cache_get( 'widget_recent_comments', 'widget');1014 $cache = wp_cache_get( 'widget_recent_comments', 'widget' ); 979 1015 } 980 1016 if ( ! is_array( $cache ) ) { 981 1017 $cache = array(); 982 1018 } 983 1019 984 if ( ! isset( $args['widget_id'] ) ) 1020 if ( ! isset( $args['widget_id'] ) ) { 985 1021 $args['widget_id'] = $this->id; 1022 } 986 1023 987 1024 if ( isset( $cache[ $args['widget_id'] ] ) ) { 988 1025 echo $cache[ $args['widget_id'] ]; … … 997 1034 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); 998 1035 999 1036 $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; 1000 if ( ! $number ) 1037 if ( ! $number ) { 1001 1038 $number = 5; 1039 } 1002 1040 1041 1003 1042 /** 1004 1043 * Filter the arguments for the Recent Comments widget. 1005 1044 * … … 1012 1051 $comments = get_comments( apply_filters( 'widget_comments_args', array( 1013 1052 'number' => $number, 1014 1053 'status' => 'approve', 1015 'post_status' => 'publish' 1054 'post_status' => 'publish', 1016 1055 ) ) ); 1017 1056 1018 1057 $output .= $args['before_widget']; … … 1026 1065 $post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) ); 1027 1066 _prime_post_caches( $post_ids, strpos( get_option( 'permalink_structure' ), '%category%' ), false ); 1028 1067 1029 foreach ( (array) $comments as $comment ) {1068 foreach ( (array) $comments as $comment ) { 1030 1069 $output .= '<li class="recentcomments">'; 1031 1070 /* translators: comments widget: 1: comment author, 2: post link */ 1032 1071 $output .= sprintf( _x( '%1$s on %2$s', 'widgets' ), … … 1136 1175 $url = esc_url(strip_tags($url)); 1137 1176 $icon = includes_url('images/rss.png'); 1138 1177 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>";1178 $title = '<a class="rsswidget" href="' . esc_url( $url ). '"><img style="border:0" width="14" height="14" src="' . esc_attr( $icon ) .'" alt="RSS" /></a> <a class="rsswidget" href="' . esc_url( $link ) .'">' . $title.'</a>'; 1140 1179 1141 1180 echo $args['before_widget']; 1142 1181 if ( $title ) { … … 1165 1204 */ 1166 1205 public function form( $instance ) { 1167 1206 if ( empty( $instance ) ) { 1168 $instance = array( 'title' => '', 'url' => '', 'items' => 10, 'error' => false, 'show_summary' => 0, 'show_author' => 0, 'show_date' => 0 ); 1207 $instance = array( 1208 'title' => '', 1209 'url' => '', 1210 'items' => 10, 1211 'error' => false, 1212 'show_summary' => 0, 1213 'show_author' => 0, 1214 'show_date' => 0 1215 ); 1169 1216 } 1170 1217 $instance['number'] = $this->number; 1171 1218 … … 1183 1230 */ 1184 1231 function wp_widget_rss_output( $rss, $args = array() ) { 1185 1232 if ( is_string( $rss ) ) { 1186 $rss = fetch_feed( $rss);1187 } elseif ( is_array( $rss) && isset($rss['url']) ) {1233 $rss = fetch_feed( $rss ); 1234 } elseif ( is_array( $rss ) && isset( $rss['url'] ) ) { 1188 1235 $args = $rss; 1189 $rss = fetch_feed( $rss['url']);1190 } elseif ( ! is_object($rss) ) {1236 $rss = fetch_feed( $rss['url'] ); 1237 } elseif ( ! is_object( $rss ) ) { 1191 1238 return; 1192 1239 } 1193 1240 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>'; 1241 if ( is_wp_error( $rss ) ) { 1242 if ( is_admin() || current_user_can( 'manage_options' ) ) { 1243 echo '<p><strong>' . sprintf( esc_html__( 'RSS Error: %s' ), $rss->get_error_message() ) . '</strong></p>'; 1244 } 1245 1197 1246 return; 1198 1247 } 1199 1248 1200 $default_args = array( 'show_author' => 0, 'show_date' => 0, 'show_summary' => 0, 'items' => 0 ); 1249 $default_args = array( 1250 'show_author' => 0, 1251 'show_date' => 0, 1252 'show_summary' => 0, 1253 'items' => 0 1254 ); 1201 1255 $args = wp_parse_args( $args, $default_args ); 1202 1256 1203 1257 $items = (int) $args['items']; 1204 if ( $items < 1 || 20 < $items ) 1258 if ( $items < 1 || 20 < $items ) { 1205 1259 $items = 10; 1260 } 1261 1206 1262 $show_summary = (int) $args['show_summary']; 1207 1263 $show_author = (int) $args['show_author']; 1208 1264 $show_date = (int) $args['show_date']; 1209 1265 1210 if ( ! $rss->get_item_quantity() ) {1211 echo '<ul><li>' . __( 'An error has occurred, which probably means the feed is down. Try again later.' ) . '</li></ul>';1266 if ( ! $rss->get_item_quantity() ) { 1267 echo '<ul><li>' . esc_html__( 'An error has occurred, which probably means the feed is down. Try again later.' ) . '</li></ul>'; 1212 1268 $rss->__destruct(); 1213 1269 unset($rss); 1214 1270 return; … … 1254 1310 $author = ''; 1255 1311 if ( $show_author ) { 1256 1312 $author = $item->get_author(); 1257 if ( is_object( $author) ) {1313 if ( is_object( $author ) ) { 1258 1314 $author = $author->get_name(); 1259 1315 $author = ' <cite>' . esc_html( strip_tags( $author ) ) . '</cite>'; 1260 1316 } … … 1261 1317 } 1262 1318 1263 1319 if ( $link == '' ) { 1264 echo "<li>$title{$date}{$summary}{$author}</li>";1320 echo '<li>' . $title . $date . $summary . $author . '</li>'; 1265 1321 } elseif ( $show_summary ) { 1266 echo "<li><a class='rsswidget' href='$link'>$title</a>{$date}{$summary}{$author}</li>";1322 echo '<li><a class="rsswidget" href="' . esc_url( $link ) .'">' . $title .'</a>' . $date . $summary . $author . '</li>'; 1267 1323 } else { 1268 echo "<li><a class='rsswidget' href='$link'>$title</a>{$date}{$author}</li>";1324 echo '<li><a class="rsswidget" href="'. esc_url( $link ) .'">' . $title . '</a>' . $date . $author . '</li>'; 1269 1325 } 1270 1326 } 1271 1327 echo '</ul>'; … … 1303 1359 $args['show_date'] = isset( $args['show_date'] ) ? (int) $args['show_date'] : (int) $inputs['show_date']; 1304 1360 1305 1361 if ( ! empty( $args['error'] ) ) { 1306 echo '<p class="widget-error"><strong>' . sprintf( __( 'RSS Error: %s' ), $args['error'] ) . '</strong></p>';1362 echo '<p class="widget-error"><strong>' . sprintf( esc_html__( 'RSS Error: %s' ), $args['error'] ) . '</strong></p>'; 1307 1363 } 1308 1364 1309 1365 if ( $inputs['url'] ) : 1310 1366 ?> 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>1367 <p><label for="rss-url-<?php echo esc_attr( $args['number'] ); ?>"><?php esc_html_e( 'Enter the RSS feed URL here:' ); ?></label> 1368 <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_attr( $args['url'] ); ?>" /></p> 1313 1369 <?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>1370 <p><label for="rss-title-<?php echo esc_attr( $args['number'] ); ?>"><?php esc_html_e( 'Give the feed a title (optional):' ); ?></label> 1371 <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 1372 <?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]">1373 <p><label for="rss-items-<?php echo esc_attr( $args['number'] ); ?>"><?php esc_html_e( 'How many items would you like to display?' ); ?></label> 1374 <select id="rss-items-<?php echo esc_attr( $args['number'] ); ?>" name="widget-rss[<?php echo esc_attr( $args['number'] ); ?>][items]"> 1319 1375 <?php 1320 1376 for ( $i = 1; $i <= 20; ++$i ) { 1321 1377 echo "<option value='$i' " . selected( $args['items'], $i, false ) . ">$i</option>"; … … 1323 1379 ?> 1324 1380 </select></p> 1325 1381 <?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>1382 <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'] ); ?> /> 1383 <label for="rss-show-summary-<?php echo esc_attr( $args['number'] ); ?>"><?php esc_html_e( 'Display item content?' ); ?></label></p> 1328 1384 <?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>1385 <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'] ); ?> /> 1386 <label for="rss-show-author-<?php echo esc_attr( $args['number'] ); ?>"><?php esc_html_e( 'Display item author if available?' ); ?></label></p> 1331 1387 <?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>1388 <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'] ); ?>/> 1389 <label for="rss-show-date-<?php echo esc_attr( $args['number'] ); ?>"><?php esc_html_e( 'Display item date?' ); ?></label></p> 1334 1390 <?php 1335 1391 endif; 1336 foreach ( array_keys( $default_inputs) as $input ) :1337 if ( 'hidden' === $inputs[ $input] ) :1392 foreach ( array_keys( $default_inputs ) as $input ) : 1393 if ( 'hidden' === $inputs[ $input ] ) : 1338 1394 $id = str_replace( '_', '-', $input ); 1339 1395 ?> 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 ]; ?>" />1396 <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 1397 <?php 1342 1398 endif; 1343 1399 endforeach; … … 1361 1417 */ 1362 1418 function wp_widget_rss_process( $widget_rss, $check_feed = true ) { 1363 1419 $items = (int) $widget_rss['items']; 1364 if ( $items < 1 || 20 < $items ) 1420 if ( $items < 1 || 20 < $items ) { 1365 1421 $items = 10; 1422 } 1423 1366 1424 $url = esc_url_raw( strip_tags( $widget_rss['url'] ) ); 1367 1425 $title = isset( $widget_rss['title'] ) ? trim( strip_tags( $widget_rss['title'] ) ) : ''; 1368 1426 $show_summary = isset( $widget_rss['show_summary'] ) ? (int) $widget_rss['show_summary'] : 0; … … 1370 1428 $show_date = isset( $widget_rss['show_date'] ) ? (int) $widget_rss['show_date'] : 0; 1371 1429 1372 1430 if ( $check_feed ) { 1373 $rss = fetch_feed( $url);1431 $rss = fetch_feed( $url ); 1374 1432 $error = false; 1375 1433 $link = ''; 1376 if ( is_wp_error( $rss) ) {1434 if ( is_wp_error( $rss ) ) { 1377 1435 $error = $rss->get_error_message(); 1378 1436 } else { 1379 $link = esc_url(strip_tags($rss->get_permalink())); 1380 while ( stristr($link, 'http') != $link ) 1381 $link = substr($link, 1); 1437 $link = esc_url( strip_tags( $rss->get_permalink() ) ); 1438 while ( stristr( $link, 'http' ) != $link ) { 1439 $link = substr( $link, 1 ); 1440 } 1382 1441 1383 1442 $rss->__destruct(); 1384 1443 unset($rss); … … 1437 1496 * @param array $current_taxonomy The taxonomy to use in the tag cloud. Default 'tags'. 1438 1497 */ 1439 1498 wp_tag_cloud( apply_filters( 'widget_tag_cloud_args', array( 1440 'taxonomy' => $current_taxonomy 1499 'taxonomy' => $current_taxonomy, 1441 1500 ) ) ); 1442 1501 1443 1502 echo "</div>\n"; … … 1493 1552 * 1494 1553 * @since 3.0.0 1495 1554 */ 1496 class WP_Nav_Menu_Widget extends WP_Widget {1555 class WP_Nav_Menu_Widget extends WP_Widget { 1497 1556 1498 1557 public function __construct() { 1499 $widget_ops = array( 'description' => __('Add a custom menu to your sidebar.') );1500 parent::__construct( 'nav_menu', __('Custom Menu'), $widget_ops );1558 $widget_ops = array( 'description' => esc_html__( 'Add a custom menu to your sidebar.' ) ); 1559 parent::__construct( 'nav_menu',esc_html__( 'Custom Menu' ), $widget_ops ); 1501 1560 } 1502 1561 1503 1562 /** … … 1508 1567 // Get menu 1509 1568 $nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false; 1510 1569 1511 if ( ! $nav_menu )1570 if ( ! $nav_menu ) { 1512 1571 return; 1572 } 1513 1573 1574 1514 1575 /** This filter is documented in wp-includes/default-widgets.php */ 1515 1576 $instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); 1516 1577 1517 1578 echo $args['before_widget']; 1518 1579 1519 if ( ! empty($instance['title']) )1580 if ( ! empty( $instance['title'] ) ) { 1520 1581 echo $args['before_title'] . $instance['title'] . $args['after_title']; 1582 } 1521 1583 1584 1522 1585 $nav_menu_args = array( 1523 1586 'fallback_cb' => '', 1524 'menu' => $nav_menu 1587 'menu' => $nav_menu, 1525 1588 ); 1526 1589 1527 1590 /** … … 1551 1614 public function update( $new_instance, $old_instance ) { 1552 1615 $instance = array(); 1553 1616 if ( ! empty( $new_instance['title'] ) ) { 1554 $instance['title'] = strip_tags( stripslashes( $new_instance['title']) );1617 $instance['title'] = strip_tags( stripslashes( $new_instance['title'] ) ); 1555 1618 } 1556 1619 if ( ! empty( $new_instance['nav_menu'] ) ) { 1557 1620 $instance['nav_menu'] = (int) $new_instance['nav_menu']; … … 1570 1633 $menus = wp_get_nav_menus(); 1571 1634 1572 1635 // If no menus exists, direct the user to go and create some. 1573 if ( ! $menus ) {1574 echo '<p>'. sprintf( __( 'No menus have been created yet. <a href="%s">Create some</a>.'), admin_url('nav-menus.php') ) .'</p>';1636 if ( ! $menus ) { 1637 echo '<p>'. sprintf( __( 'No menus have been created yet. <a href="%s">Create some</a>.' ), esc_url( admin_url( 'nav-menus.php' ) ) ) .'</p>'; 1575 1638 return; 1576 1639 } 1577 1640 ?> 1578 1641 <p> 1579 <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:') ?></label>1580 <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $title; ?>" />1642 <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:' ) ?></label> 1643 <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 ); ?>" /> 1581 1644 </p> 1582 1645 <p> 1583 <label for="<?php echo $this->get_field_id('nav_menu'); ?>"><?php _e('Select Menu:'); ?></label>1584 <select id="<?php echo $this->get_field_id('nav_menu'); ?>" name="<?php echo $this->get_field_name('nav_menu'); ?>">1646 <label for="<?php echo esc_attr( $this->get_field_id( 'nav_menu' ) ); ?>"><?php esc_html_e( 'Select Menu:' ); ?></label> 1647 <select id="<?php echo esc_attr( $this->get_field_id( 'nav_menu' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'nav_menu' ) ); ?>"> 1585 1648 <option value="0"><?php _e( '— Select —' ) ?></option> 1586 1649 <?php 1587 foreach ( $menus as $menu ) {1588 echo '<option value="' . $menu->term_id . '"'1589 . selected( $nav_menu, $menu->term_id, false )1590 . '>'. esc_html( $menu->name ) . '</option>';1591 }1650 foreach ( $menus as $menu ) { 1651 echo '<option value="' . $menu->term_id . '"' 1652 . selected( $nav_menu, $menu->term_id, false ) 1653 . '>'. esc_html( $menu->name ) . '</option>'; 1654 } 1592 1655 ?> 1593 1656 </select> 1594 1657 </p> … … 1605 1668 * @since 2.2.0 1606 1669 */ 1607 1670 function wp_widgets_init() { 1608 if ( ! is_blog_installed() )1671 if ( ! is_blog_installed() ) { 1609 1672 return; 1673 } 1610 1674 1611 register_widget( 'WP_Widget_Pages');1675 register_widget( 'WP_Widget_Pages' ); 1612 1676 1613 register_widget( 'WP_Widget_Calendar');1677 register_widget( 'WP_Widget_Calendar' ); 1614 1678 1615 register_widget( 'WP_Widget_Archives');1679 register_widget( 'WP_Widget_Archives' ); 1616 1680 1617 if ( get_option( 'link_manager_enabled' ) ) 1618 register_widget('WP_Widget_Links'); 1681 if ( get_option( 'link_manager_enabled' ) ) { 1682 register_widget( 'WP_Widget_Links' ); 1683 } 1619 1684 1620 register_widget('WP_Widget_Meta');1621 1685 1622 register_widget( 'WP_Widget_Search');1686 register_widget( 'WP_Widget_Meta' ); 1623 1687 1624 register_widget( 'WP_Widget_Text');1688 register_widget( 'WP_Widget_Search' ); 1625 1689 1626 register_widget( 'WP_Widget_Categories');1690 register_widget( 'WP_Widget_Text' ); 1627 1691 1628 register_widget( 'WP_Widget_Recent_Posts');1692 register_widget( 'WP_Widget_Categories' ); 1629 1693 1630 register_widget( 'WP_Widget_Recent_Comments');1694 register_widget( 'WP_Widget_Recent_Posts' ); 1631 1695 1632 register_widget( 'WP_Widget_RSS');1696 register_widget( 'WP_Widget_Recent_Comments' ); 1633 1697 1634 register_widget( 'WP_Widget_Tag_Cloud');1698 register_widget( 'WP_Widget_RSS' ); 1635 1699 1636 register_widget( 'WP_Nav_Menu_Widget');1700 register_widget( 'WP_Widget_Tag_Cloud' ); 1637 1701 1702 register_widget( 'WP_Nav_Menu_Widget' ); 1703 1638 1704 /** 1639 1705 * Fires after all default WordPress widgets have been registered. 1640 1706 *