Ticket #23012: 23012.diff
| File 23012.diff, 63.4 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 public function widget( $args, $instance ) { … … 34 34 $sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby']; 35 35 $exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude']; 36 36 37 if ( $sortby == 'menu_order' )37 if ( 'menu_order' == $sortby ) { 38 38 $sortby = 'menu_order, post_title'; 39 } 39 40 40 41 /** 41 42 * Filter the arguments for the Pages widget. … … 50 51 'title_li' => '', 51 52 'echo' => 0, 52 53 'sort_column' => $sortby, 53 'exclude' => $exclude 54 'exclude' => $exclude, 54 55 ) ) ); 55 56 56 57 if ( ! empty( $out ) ) { … … 69 70 70 71 public function update( $new_instance, $old_instance ) { 71 72 $instance = $old_instance; 72 $instance['title'] = strip_tags( $new_instance['title']);73 $instance['title'] = strip_tags( $new_instance['title'] ); 73 74 if ( in_array( $new_instance['sortby'], array( 'post_title', 'menu_order', 'ID' ) ) ) { 74 75 $instance['sortby'] = $new_instance['sortby']; 75 76 } else { … … 83 84 84 85 public function form( $instance ) { 85 86 //Defaults 86 $instance = wp_parse_args( (array) $instance, array( 'sortby' => 'post_title', 'title' => '', 'exclude' => '' ) );87 $title = esc_attr( $instance['title'] );88 $exclude = esc_attr( $instance['exclude'] );87 $instance = wp_parse_args( (array) $instance, array( 'sortby' => 'post_title', 'title' => '', 'exclude' => '' ) ); 88 $title = isset( $instance['title'] ) ? $instance['title'] : ''; 89 $exclude = isset( $instance['exclude'] ) ? $instance['exclude'] : ''; 89 90 ?> 90 <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>91 <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> 91 92 <p> 92 <label for="<?php echo $this->get_field_id('sortby'); ?>"><?php_e( 'Sort by:' ); ?></label>93 <select name="<?php echo $this->get_field_name('sortby'); ?>" id="<?php echo $this->get_field_id('sortby'); ?>" class="widefat">94 <option value="post_title"<?php selected( $instance['sortby'], 'post_title' ); ?>><?php _e('Page title'); ?></option>95 <option value="menu_order"<?php selected( $instance['sortby'], 'menu_order' ); ?>><?php _e('Page order'); ?></option>93 <label for="<?php echo esc_attr( $this->get_field_id( 'sortby' ) ); ?>"><?php esc_html_e( 'Sort by:' ); ?></label> 94 <select name="<?php echo esc_attr( $this->get_field_name( 'sortby' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'sortby' ) ); ?>" class="widefat"> 95 <option value="post_title"<?php selected( $instance['sortby'], 'post_title' ); ?>><?php esc_html_e( 'Page title' ); ?></option> 96 <option value="menu_order"<?php selected( $instance['sortby'], 'menu_order' ); ?>><?php esc_html_e( 'Page order' ); ?></option> 96 97 <option value="ID"<?php selected( $instance['sortby'], 'ID' ); ?>><?php _e( 'Page ID' ); ?></option> 97 98 </select> 98 99 </p> 99 100 <p> 100 <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" />101 <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" /> 101 102 <br /> 102 <small><?php _e( 'Page IDs, separated by commas.' ); ?></small>103 <small><?php esc_html_e( 'Page IDs, separated by commas.' ); ?></small> 103 104 </p> 104 105 <?php 105 106 } … … 114 115 class WP_Widget_Links extends WP_Widget { 115 116 116 117 public function __construct() { 117 $widget_ops = array( 'description' => __( "Your blogroll") );118 parent::__construct( 'links', __('Links'), $widget_ops);118 $widget_ops = array( 'description' => esc_html__( 'Your blogroll' ) ); 119 parent::__construct( 'links', esc_html__( 'Links' ), $widget_ops ); 119 120 } 120 121 121 122 public function widget( $args, $instance ) { 122 123 123 124 $show_description = isset($instance['description']) ? $instance['description'] : false; 124 $show_name = isset($instance['name']) ? $instance['name'] : false;125 $show_rating = isset($instance['rating']) ? $instance['rating'] : false;126 $show_images = isset($instance['images']) ? $instance['images'] : true;125 $show_name = isset($instance['name']) ? $instance['name'] : false; 126 $show_rating = isset($instance['rating']) ? $instance['rating'] : false; 127 $show_images = isset($instance['images']) ? $instance['images'] : true; 127 128 $category = isset($instance['category']) ? $instance['category'] : false; 128 129 $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name'; 129 130 $order = $orderby == 'rating' ? 'DESC' : 'ASC'; … … 155 156 $new_instance = (array) $new_instance; 156 157 $instance = array( 'images' => 0, 'name' => 0, 'description' => 0, 'rating' => 0 ); 157 158 foreach ( $instance as $field => $val ) { 158 if ( isset($new_instance[$field]) ) 159 $instance[$field] = 1; 159 if ( isset( $new_instance[ $field ] ) ) { 160 $instance[ $field ] = 1; 161 } 160 162 } 161 163 162 164 $instance['orderby'] = 'name'; 163 if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) ) 165 if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) ) { 164 166 $instance['orderby'] = $new_instance['orderby']; 167 } 165 168 166 169 $instance['category'] = intval( $new_instance['category'] ); 167 170 $instance['limit'] = ! empty( $new_instance['limit'] ) ? intval( $new_instance['limit'] ) : -1; … … 174 177 //Defaults 175 178 $instance = wp_parse_args( (array) $instance, array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false, 'category' => false, 'orderby' => 'name', 'limit' => -1 ) ); 176 179 $link_cats = get_terms( 'link_category' ); 177 if ( ! $limit = intval( $instance['limit'] ) ) 180 if ( ! $limit = intval( $instance['limit'] ) ) { 178 181 $limit = -1; 182 } 183 179 184 ?> 180 185 <p> 181 <label for="<?php echo $this->get_field_id('category'); ?>"><?php_e( 'Select Link Category:' ); ?></label>182 <select class="widefat" id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>">183 <option value=""><?php _ex( 'All Links', 'links widget'); ?></option>186 <label for="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>"><?php esc_html_e( 'Select Link Category:' ); ?></label> 187 <select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'category' ) ); ?>"> 188 <option value=""><?php _ex( 'All Links', 'links widget' ); ?></option> 184 189 <?php 185 190 foreach ( $link_cats as $link_cat ) { 186 191 echo '<option value="' . intval( $link_cat->term_id ) . '"' 187 192 . selected( $instance['category'], $link_cat->term_id, false ) 188 . '>' . $link_cat->name. "</option>\n";193 . '>' . esc_html( $link_cat->name ) . "</option>\n"; 189 194 } 190 195 ?> 191 196 </select> 192 <label for="<?php echo $this->get_field_id('orderby'); ?>"><?php_e( 'Sort by:' ); ?></label>193 <select name="<?php echo $this->get_field_name('orderby'); ?>" id="<?php echo $this->get_field_id('orderby'); ?>" class="widefat">194 <option value="name"<?php selected( $instance['orderby'], 'name' ); ?>><?php _e( 'Link title' ); ?></option>195 <option value="rating"<?php selected( $instance['orderby'], 'rating' ); ?>><?php _e( 'Link rating' ); ?></option>196 <option value="id"<?php selected( $instance['orderby'], 'id' ); ?>><?php _e( 'Link ID' ); ?></option>197 <label for="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>"><?php esc_html_e( 'Sort by:' ); ?></label> 198 <select name="<?php echo esc_attr( $this->get_field_name( 'orderby' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>" class="widefat"> 199 <option value="name"<?php selected( $instance['orderby'], 'name' ); ?>><?php esc_html_e( 'Link title' ); ?></option> 200 <option value="rating"<?php selected( $instance['orderby'], 'rating' ); ?>><?php esc_html_e( 'Link rating' ); ?></option> 201 <option value="id"<?php selected( $instance['orderby'], 'id' ); ?>><?php esc_html_e( 'Link ID' ); ?></option> 197 202 <option value="rand"<?php selected( $instance['orderby'], 'rand' ); ?>><?php _ex( 'Random', 'Links widget' ); ?></option> 198 203 </select> 199 204 </p> 200 205 <p> 201 <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'); ?>" />202 <label for="<?php echo $this->get_field_id('images'); ?>"><?php _e('Show Link Image'); ?></label><br />203 <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'); ?>" />204 <label for="<?php echo $this->get_field_id('name'); ?>"><?php _e('Show Link Name'); ?></label><br />205 <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'); ?>" />206 <label for="<?php echo $this->get_field_id('description'); ?>"><?php _e('Show Link Description'); ?></label><br />207 <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'); ?>" />208 <label for="<?php echo $this->get_field_id('rating'); ?>"><?php _e('Show Link Rating'); ?></label>206 <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' ) ); ?>" /> 207 <label for="<?php echo esc_attr( $this->get_field_id( 'images' ) ); ?>"><?php esc_html_e( 'Show Link Image' ); ?></label><br /> 208 <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' ) ); ?>" /> 209 <label for="<?php echo esc_attr( $this->get_field_id( 'name' ) ); ?>"><?php esc_html_e( 'Show Link Name' ); ?></label><br /> 210 <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' ) ); ?>" /> 211 <label for="<?php echo esc_attr( $this->get_field_id( 'description' ) ); ?>"><?php esc_html_e( 'Show Link Description' ); ?></label><br /> 212 <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' ) ); ?>" /> 213 <label for="<?php echo esc_attr( $this->get_field_id( 'rating' ) ); ?>"><?php esc_html_e( 'Show Link Rating' ); ?></label> 209 214 </p> 210 215 <p> 211 <label for="<?php echo $this->get_field_id('limit'); ?>"><?php_e( 'Number of links to show:' ); ?></label>212 <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" />216 <label for="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>"><?php esc_html_e( 'Number of links to show:' ); ?></label> 217 <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" /> 213 218 </p> 214 219 <?php 215 220 } … … 223 228 class WP_Widget_Search extends WP_Widget { 224 229 225 230 public function __construct() { 226 $widget_ops = array( 'classname' => 'widget_search', 'description' => __( "A search form for your site.") );231 $widget_ops = array( 'classname' => 'widget_search', 'description' => esc_html__( 'A search form for your site.' ) ); 227 232 parent::__construct( 'search', _x( 'Search', 'Search widget' ), $widget_ops ); 228 233 } 229 234 … … 244 249 } 245 250 246 251 public function form( $instance ) { 247 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );252 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); 248 253 $title = $instance['title']; 249 254 ?> 250 <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>255 <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> 251 256 <?php 252 257 } 253 258 254 259 public function update( $new_instance, $old_instance ) { 255 260 $instance = $old_instance; 256 $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => ''));257 $instance['title'] = strip_tags( $new_instance['title']);261 $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '' ) ); 262 $instance['title'] = strip_tags( $new_instance['title'] ); 258 263 return $instance; 259 264 } 260 265 … … 268 273 class WP_Widget_Archives extends WP_Widget { 269 274 270 275 public function __construct() { 271 $widget_ops = array( 'classname' => 'widget_archive', 'description' => __( 'A monthly archive of your site’s Posts.') );272 parent::__construct( 'archives', __('Archives'), $widget_ops);276 $widget_ops = array( 'classname' => 'widget_archive', 'description' => __( 'A monthly archive of your site’s Posts.' ) ); 277 parent::__construct( 'archives', esc_html__( 'Archives' ), $widget_ops ); 273 278 } 274 279 275 280 public function widget( $args, $instance ) { … … 302 307 $dropdown_args = apply_filters( 'widget_archives_dropdown_args', array( 303 308 'type' => 'monthly', 304 309 'format' => 'option', 305 'show_post_count' => $c 310 'show_post_count' => $c, 306 311 ) ); 307 312 308 313 switch ( $dropdown_args['type'] ) { … … 344 349 */ 345 350 wp_get_archives( apply_filters( 'widget_archives_args', array( 346 351 'type' => 'monthly', 347 'show_post_count' => $c 352 'show_post_count' => $c, 348 353 ) ) ); 349 354 ?> 350 355 </ul> … … 356 361 357 362 public function update( $new_instance, $old_instance ) { 358 363 $instance = $old_instance; 359 $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'count' => 0, 'dropdown' => '' ) );360 $instance['title'] = strip_tags( $new_instance['title']);364 $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'count' => 0, 'dropdown' => '' ) ); 365 $instance['title'] = strip_tags( $new_instance['title'] ); 361 366 $instance['count'] = $new_instance['count'] ? 1 : 0; 362 367 $instance['dropdown'] = $new_instance['dropdown'] ? 1 : 0; 363 368 … … 365 370 } 366 371 367 372 public function form( $instance ) { 368 $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'count' => 0, 'dropdown' => '' ) );369 $title = strip_tags($instance['title']);370 $count = $instance['count'] ? 'checked="checked"' : '';371 $dropdown = $instance['dropdown'] ? 'checked="checked"' : '';373 $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'count' => 0, 'dropdown' => '' ) ); 374 $title = strip_tags( $instance['title'] ); 375 $count = $instance['count'] ? true : false; 376 $dropdown = $instance['dropdown'] ? true : false; 372 377 ?> 373 <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>378 <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> 374 379 <p> 375 <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>380 <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> 376 381 <br/> 377 <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>382 <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> 378 383 </p> 379 384 <?php 380 385 } … … 390 395 class WP_Widget_Meta extends WP_Widget { 391 396 392 397 public function __construct() { 393 $widget_ops = array( 'classname' => 'widget_meta', 'description' => __( "Login, RSS, & WordPress.org links.") );394 parent::__construct( 'meta', __('Meta'), $widget_ops);398 $widget_ops = array( 'classname' => 'widget_meta', 'description' => esc_html__( 'Login, RSS, & WordPress.org links.' ) ); 399 parent::__construct( 'meta', esc_html__( 'Meta' ), $widget_ops ); 395 400 } 396 401 397 402 public function widget( $args, $instance ) { … … 399 404 /** This filter is documented in wp-includes/default-widgets.php */ 400 405 $title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Meta' ) : $instance['title'], $instance, $this->id_base ); 401 406 407 /** 408 * Allowed html tags 409 */ 410 $allowed_tags = array( 411 'abbr' => array( 412 'title' => array() 413 ) 414 ); 415 402 416 echo $args['before_widget']; 403 417 if ( $title ) { 404 418 echo $args['before_title'] . $title . $args['after_title']; … … 407 421 <ul> 408 422 <?php wp_register(); ?> 409 423 <li><?php wp_loginout(); ?></li> 410 <li><a href="<?php bloginfo('rss2_url'); ?>"><?php _e('Entries <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>411 <li><a href="<?php bloginfo('comments_rss2_url'); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>424 <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> 425 <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> 412 426 <?php 413 427 /** 414 428 * Filter the "Powered by WordPress" text in the Meta widget. … … 432 446 433 447 public function update( $new_instance, $old_instance ) { 434 448 $instance = $old_instance; 435 $instance['title'] = strip_tags( $new_instance['title']);449 $instance['title'] = strip_tags( $new_instance['title'] ); 436 450 437 451 return $instance; 438 452 } … … 439 453 440 454 public function form( $instance ) { 441 455 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); 442 $title = strip_tags( $instance['title']);456 $title = strip_tags( $instance['title'] ); 443 457 ?> 444 <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>458 <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> 445 459 <?php 446 460 } 447 461 } … … 454 468 class WP_Widget_Calendar extends WP_Widget { 455 469 456 470 public function __construct() { 457 $widget_ops = array( 'classname' => 'widget_calendar', 'description' => __( 'A calendar of your site’s Posts.') );458 parent::__construct( 'calendar', __('Calendar'), $widget_ops);471 $widget_ops = array( 'classname' => 'widget_calendar', 'description' => __( 'A calendar of your site’s Posts.' ) ); 472 parent::__construct( 'calendar', esc_html__( 'Calendar' ), $widget_ops ); 459 473 } 460 474 461 475 public function widget( $args, $instance ) { … … 475 489 476 490 public function update( $new_instance, $old_instance ) { 477 491 $instance = $old_instance; 478 $instance['title'] = strip_tags( $new_instance['title']);492 $instance['title'] = strip_tags( $new_instance['title'] ); 479 493 480 494 return $instance; 481 495 } … … 482 496 483 497 public function form( $instance ) { 484 498 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); 485 $title = strip_tags( $instance['title']);499 $title = strip_tags( $instance['title'] ); 486 500 ?> 487 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>488 <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>501 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:' ); ?></label> 502 <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> 489 503 <?php 490 504 } 491 505 } … … 498 512 class WP_Widget_Text extends WP_Widget { 499 513 500 514 public function __construct() { 501 $widget_ops = array('classname' => 'widget_text', 'description' => __('Arbitrary text or HTML.')); 502 $control_ops = array('width' => 400, 'height' => 350); 503 parent::__construct('text', __('Text'), $widget_ops, $control_ops); 515 $widget_ops = array( 'classname' => 'widget_text', 'description' => esc_html__( 'Arbitrary text or HTML.' ) ); 516 $control_ops = array( 517 'width' => 400, 518 'height' => 350, 519 ); 520 parent::__construct( 'text', esc_html__( 'Text' ), $widget_ops, $control_ops ); 504 521 } 505 522 506 523 public function widget( $args, $instance ) { … … 521 538 if ( ! empty( $title ) ) { 522 539 echo $args['before_title'] . $title . $args['after_title']; 523 540 } ?> 524 <div class="textwidget"><?php echo ! empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div>541 <div class="textwidget"><?php echo ! empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div> 525 542 <?php 526 543 echo $args['after_widget']; 527 544 } … … 528 545 529 546 public function update( $new_instance, $old_instance ) { 530 547 $instance = $old_instance; 531 $instance['title'] = strip_tags($new_instance['title']); 532 if ( current_user_can('unfiltered_html') ) 533 $instance['text'] = $new_instance['text']; 534 else 535 $instance['text'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text']) ) ); // wp_filter_post_kses() expects slashed 548 $instance['title'] = strip_tags( $new_instance['title'] ); 549 if ( current_user_can( 'unfiltered_html' ) ) { 550 $instance['text'] = $new_instance['text']; 551 } else { 552 $instance['text'] = stripslashes( wp_filter_post_kses( addslashes( $new_instance['text'] ) ) ); // wp_filter_post_kses() expects slashed 553 } 536 554 $instance['filter'] = ! empty( $new_instance['filter'] ); 537 555 return $instance; 538 556 } … … 539 557 540 558 public function form( $instance ) { 541 559 $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) ); 542 $title = strip_tags($instance['title']); 543 $text = esc_textarea($instance['text']); 560 $title = strip_tags( $instance['title'] ); 544 561 ?> 545 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>546 <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>562 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:' ); ?></label> 563 <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> 547 564 548 <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>565 <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> 549 566 550 <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>567 <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> 551 568 <?php 552 569 } 553 570 } … … 560 577 class WP_Widget_Categories extends WP_Widget { 561 578 562 579 public function __construct() { 563 $widget_ops = array( 'classname' => 'widget_categories', 'description' => __( "A list or dropdown of categories.") );564 parent::__construct( 'categories', __('Categories'), $widget_ops);580 $widget_ops = array( 'classname' => 'widget_categories', 'description' => esc_html__( 'A list or dropdown of categories.' ) ); 581 parent::__construct( 'categories', esc_html__( 'Categories' ), $widget_ops ); 565 582 } 566 583 567 584 public function widget( $args, $instance ) { … … 581 598 $cat_args = array( 582 599 'orderby' => 'name', 583 600 'show_count' => $c, 584 'hierarchical' => $h 601 'hierarchical' => $h, 585 602 ); 586 603 587 604 if ( $d ) { … … 592 609 593 610 echo '<label class="screen-reader-text" for="' . esc_attr( $dropdown_id ) . '">' . $title . '</label>'; 594 611 595 $cat_args['show_option_none'] = __( 'Select Category' );612 $cat_args['show_option_none'] = esc_html__( 'Select Category' ); 596 613 $cat_args['id'] = $dropdown_id; 597 614 598 615 /** … … 610 627 <script type='text/javascript'> 611 628 /* <![CDATA[ */ 612 629 (function() { 613 var dropdown = document.getElementById( "<?php echo esc_js( $dropdown_id ); ?>" );630 var dropdown = document.getElementById( "<?php echo wp_json_encode( $dropdown_id ); ?>" ); 614 631 function onCatChange() { 615 632 if ( dropdown.options[ dropdown.selectedIndex ].value > 0 ) { 616 location.href = "<?php echo home_url(); ?>/?cat=" + dropdown.options[ dropdown.selectedIndex ].value;633 location.href = "<?php echo esc_url( home_url() ); ?>/?cat=" + dropdown.options[ dropdown.selectedIndex ].value; 617 634 } 618 635 } 619 636 dropdown.onchange = onCatChange; … … 646 663 647 664 public function update( $new_instance, $old_instance ) { 648 665 $instance = $old_instance; 649 $instance['title'] = strip_tags( $new_instance['title']);650 $instance['count'] = ! empty($new_instance['count']) ? 1 : 0;651 $instance['hierarchical'] = ! empty($new_instance['hierarchical']) ? 1 : 0;652 $instance['dropdown'] = ! empty($new_instance['dropdown']) ? 1 : 0;666 $instance['title'] = strip_tags( $new_instance['title'] ); 667 $instance['count'] = ! empty( $new_instance['count'] ) ? 1 : 0; 668 $instance['hierarchical'] = ! empty( $new_instance['hierarchical'] ) ? 1 : 0; 669 $instance['dropdown'] = ! empty($new_instance['dropdown'] ) ? 1 : 0; 653 670 654 671 return $instance; 655 672 } … … 656 673 657 674 public function form( $instance ) { 658 675 //Defaults 659 $instance = wp_parse_args( (array) $instance, array( 'title' => '') ); 660 $title = esc_attr( $instance['title'] ); 676 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); 661 677 $count = isset($instance['count']) ? (bool) $instance['count'] :false; 662 678 $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false; 663 679 $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false; 664 680 ?> 665 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php_e( 'Title:' ); ?></label>666 <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>681 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:' ); ?></label> 682 <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> 667 683 668 <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 ); ?> />669 <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php_e( 'Display as dropdown' ); ?></label><br />684 <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 ); ?> /> 685 <label for="<?php echo esc_attr( $this->get_field_id( 'dropdown' ) ); ?>"><?php esc_html_e( 'Display as dropdown' ); ?></label><br /> 670 686 671 <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>"<?php checked( $count ); ?> />672 <label for="<?php echo $this->get_field_id('count'); ?>"><?php_e( 'Show post counts' ); ?></label><br />687 <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 ); ?> /> 688 <label for="<?php echo esc_attr( $this->get_field_id( 'count' ) ); ?>"><?php esc_html_e( 'Show post counts' ); ?></label><br /> 673 689 674 <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('hierarchical'); ?>" name="<?php echo $this->get_field_name('hierarchical'); ?>"<?php checked( $hierarchical ); ?> />675 <label for="<?php echo $this->get_field_id('hierarchical'); ?>"><?php_e( 'Show hierarchy' ); ?></label></p>690 <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 ); ?> /> 691 <label for="<?php echo esc_attr( $this->get_field_id( 'hierarchical' ) ); ?>"><?php esc_html_e( 'Show hierarchy' ); ?></label></p> 676 692 <?php 677 693 } 678 694 … … 686 702 class WP_Widget_Recent_Posts extends WP_Widget { 687 703 688 704 public function __construct() { 689 $widget_ops = array( 'classname' => 'widget_recent_entries', 'description' => __( "Your site’s most recent Posts.") );690 parent::__construct( 'recent-posts', __('Recent Posts'), $widget_ops);705 $widget_ops = array( 'classname' => 'widget_recent_entries', 'description' => esc_html__( 'Your site’s most recent Posts.' ) ); 706 parent::__construct( 'recent-posts',esc_html__( 'Recent Posts' ), $widget_ops ); 691 707 $this->alt_option_name = 'widget_recent_entries'; 692 708 693 add_action( 'save_post', array( $this, 'flush_widget_cache') );694 add_action( 'deleted_post', array( $this, 'flush_widget_cache') );695 add_action( 'switch_theme', array( $this, 'flush_widget_cache') );709 add_action( 'save_post', array( $this, 'flush_widget_cache' ) ); 710 add_action( 'deleted_post', array( $this, 'flush_widget_cache' ) ); 711 add_action( 'switch_theme', array( $this, 'flush_widget_cache' ) ); 696 712 } 697 713 698 714 public function widget($args, $instance) { … … 722 738 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); 723 739 724 740 $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; 725 if ( ! $number ) 741 if ( ! $number ) { 726 742 $number = 5; 743 } 727 744 $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false; 728 745 729 746 /** … … 739 756 'posts_per_page' => $number, 740 757 'no_found_rows' => true, 741 758 'post_status' => 'publish', 742 'ignore_sticky_posts' => true 759 'ignore_sticky_posts' => true, 743 760 ) ) ); 744 761 745 if ( $r->have_posts()) :762 if ( $r->have_posts() ) : 746 763 ?> 747 764 <?php echo $args['before_widget']; ?> 748 <?php if ( $title ) { 765 <?php 766 if ( $title ) { 749 767 echo $args['before_title'] . $title . $args['after_title']; 750 } ?>768 }?> 751 769 <ul> 752 770 <?php while ( $r->have_posts() ) : $r->the_post(); ?> 753 771 <li> … … 775 793 776 794 public function update( $new_instance, $old_instance ) { 777 795 $instance = $old_instance; 778 $instance['title'] = strip_tags( $new_instance['title']);796 $instance['title'] = strip_tags( $new_instance['title'] ); 779 797 $instance['number'] = (int) $new_instance['number']; 780 798 $instance['show_date'] = isset( $new_instance['show_date'] ) ? (bool) $new_instance['show_date'] : false; 781 799 $this->flush_widget_cache(); 782 800 783 801 $alloptions = wp_cache_get( 'alloptions', 'options' ); 784 if ( isset($alloptions['widget_recent_entries']) ) 785 delete_option('widget_recent_entries'); 802 if ( isset( $alloptions['widget_recent_entries'] ) ) { 803 delete_option( 'widget_recent_entries' ); 804 } 786 805 787 806 return $instance; 788 807 } 789 808 790 809 public function flush_widget_cache() { 791 wp_cache_delete( 'widget_recent_posts', 'widget');810 wp_cache_delete( 'widget_recent_posts', 'widget' ); 792 811 } 793 812 794 813 public function form( $instance ) { … … 796 815 $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; 797 816 $show_date = isset( $instance['show_date'] ) ? (bool) $instance['show_date'] : false; 798 817 ?> 799 <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php_e( 'Title:' ); ?></label>800 <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>818 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:' ); ?></label> 819 <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 $title; ?>" /></p> 801 820 802 <p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php_e( 'Number of posts to show:' ); ?></label>803 <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>821 <p><label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"><?php esc_html_e( 'Number of posts to show:' ); ?></label> 822 <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 $number; ?>" size="3" /></p> 804 823 805 <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'); ?>" />806 <label for="<?php echo $this->get_field_id( 'show_date' ); ?>"><?php_e( 'Display post date?' ); ?></label></p>824 <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' ) ); ?>" /> 825 <label for="<?php echo esc_attr( $this->get_field_id( 'show_date' ) ); ?>"><?php esc_html_e( 'Display post date?' ); ?></label></p> 807 826 <?php 808 827 } 809 828 } … … 816 835 class WP_Widget_Recent_Comments extends WP_Widget { 817 836 818 837 public function __construct() { 819 $widget_ops = array( 'classname' => 'widget_recent_comments', 'description' =>__( 'Your site’s most recent comments.' ) );820 parent::__construct( 'recent-comments', __('Recent Comments'), $widget_ops);838 $widget_ops = array( 'classname' => 'widget_recent_comments', 'description' => esc_html__( 'Your site’s most recent comments.' ) ); 839 parent::__construct( 'recent-comments', esc_html__( 'Recent Comments' ), $widget_ops ); 821 840 $this->alt_option_name = 'widget_recent_comments'; 822 841 823 if ( is_active_widget(false, false, $this->id_base) ) 824 add_action( 'wp_head', array($this, 'recent_comments_style') ); 842 if ( is_active_widget( false, false, $this->id_base ) ) { 843 add_action( 'wp_head', array( $this, 'recent_comments_style' ) ); 844 } 825 845 826 add_action( 'comment_post', array( $this, 'flush_widget_cache') );827 add_action( 'edit_comment', array( $this, 'flush_widget_cache') );828 add_action( 'transition_comment_status', array( $this, 'flush_widget_cache') );846 add_action( 'comment_post', array( $this, 'flush_widget_cache' ) ); 847 add_action( 'edit_comment', array( $this, 'flush_widget_cache' ) ); 848 add_action( 'transition_comment_status', array( $this, 'flush_widget_cache' ) ); 829 849 } 830 850 831 851 public function recent_comments_style() { … … 839 859 * @param string $id_base The widget ID. 840 860 */ 841 861 if ( ! current_theme_supports( 'widgets' ) // Temp hack #14876 842 || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) 862 || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) { 843 863 return; 864 } 844 865 ?> 845 866 <style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style> 846 867 <?php … … 847 868 } 848 869 849 870 public function flush_widget_cache() { 850 wp_cache_delete( 'widget_recent_comments', 'widget');871 wp_cache_delete( 'widget_recent_comments', 'widget' ); 851 872 } 852 873 853 874 public function widget( $args, $instance ) { … … 855 876 856 877 $cache = array(); 857 878 if ( ! $this->is_preview() ) { 858 $cache = wp_cache_get( 'widget_recent_comments', 'widget');879 $cache = wp_cache_get( 'widget_recent_comments', 'widget' ); 859 880 } 860 881 if ( ! is_array( $cache ) ) { 861 882 $cache = array(); 862 883 } 863 884 864 if ( ! isset( $args['widget_id'] ) ) 885 if ( ! isset( $args['widget_id'] ) ) { 865 886 $args['widget_id'] = $this->id; 887 } 866 888 867 889 if ( isset( $cache[ $args['widget_id'] ] ) ) { 868 890 echo $cache[ $args['widget_id'] ]; … … 877 899 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); 878 900 879 901 $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; 880 if ( ! $number ) 902 if ( ! $number ) { 881 903 $number = 5; 904 } 882 905 906 883 907 /** 884 908 * Filter the arguments for the Recent Comments widget. 885 909 * … … 892 916 $comments = get_comments( apply_filters( 'widget_comments_args', array( 893 917 'number' => $number, 894 918 'status' => 'approve', 895 'post_status' => 'publish' 919 'post_status' => 'publish', 896 920 ) ) ); 897 921 898 922 $output .= $args['before_widget']; … … 906 930 $post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) ); 907 931 _prime_post_caches( $post_ids, strpos( get_option( 'permalink_structure' ), '%category%' ), false ); 908 932 909 foreach ( (array) $comments as $comment ) {933 foreach ( (array) $comments as $comment ) { 910 934 $output .= '<li class="recentcomments">'; 911 935 /* translators: comments widget: 1: comment author, 2: post link */ 912 936 $output .= sprintf( _x( '%1$s on %2$s', 'widgets' ), … … 929 953 930 954 public function update( $new_instance, $old_instance ) { 931 955 $instance = $old_instance; 932 $instance['title'] = strip_tags( $new_instance['title']);956 $instance['title'] = strip_tags( $new_instance['title'] ); 933 957 $instance['number'] = absint( $new_instance['number'] ); 934 958 $this->flush_widget_cache(); 935 959 936 960 $alloptions = wp_cache_get( 'alloptions', 'options' ); 937 if ( isset($alloptions['widget_recent_comments']) ) 938 delete_option('widget_recent_comments'); 961 if ( isset( $alloptions['widget_recent_comments'] ) ) { 962 delete_option( 'widget_recent_comments' ); 963 } 939 964 965 940 966 return $instance; 941 967 } 942 968 943 969 public function form( $instance ) { 944 $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ): '';970 $title = isset( $instance['title'] ) ? $instance['title'] : ''; 945 971 $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; 946 972 ?> 947 <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php_e( 'Title:' ); ?></label>948 <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>973 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:' ); ?></label> 974 <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> 949 975 950 <p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php_e( 'Number of comments to show:' ); ?></label>951 <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>976 <p><label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"><?php esc_html_e( 'Number of comments to show:' ); ?></label> 977 <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> 952 978 <?php 953 979 } 954 980 } … … 961 987 class WP_Widget_RSS extends WP_Widget { 962 988 963 989 public function __construct() { 964 $widget_ops = array( 'description' => __('Entries from any RSS or Atom feed.') ); 965 $control_ops = array( 'width' => 400, 'height' => 200 ); 966 parent::__construct( 'rss', __('RSS'), $widget_ops, $control_ops ); 990 $widget_ops = array( 'description' => esc_html__( 'Entries from any RSS or Atom feed.' ) ); 991 $control_ops = array( 992 'width' => 400, 993 'height' => 200, 994 ); 995 parent::__construct( 'rss',esc_html__( 'RSS' ), $widget_ops, $control_ops ); 967 996 } 968 997 969 998 public function widget($args, $instance) { 970 999 971 if ( isset( $instance['error']) && $instance['error'] )1000 if ( isset( $instance['error'] ) && $instance['error'] ) { 972 1001 return; 1002 } 973 1003 974 1004 $url = ! empty( $instance['url'] ) ? $instance['url'] : ''; 975 while ( stristr($url, 'http') != $url ) 976 $url = substr($url, 1); 1005 while ( stristr( $url, 'http' ) != $url ) { 1006 $url = substr( $url, 1 ); 1007 } 977 1008 978 if ( empty( $url) )1009 if ( empty( $url ) ) { 979 1010 return; 1011 } 980 1012 981 1013 // self-url destruction sequence 982 if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ) ) ) 1014 if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ) ) ) { 983 1015 return; 1016 } 984 1017 985 $rss = fetch_feed( $url);1018 $rss = fetch_feed( $url ); 986 1019 $title = $instance['title']; 987 1020 $desc = ''; 988 1021 $link = ''; 989 1022 990 if ( ! is_wp_error($rss) ) { 991 $desc = esc_attr(strip_tags(@html_entity_decode($rss->get_description(), ENT_QUOTES, get_option('blog_charset')))); 992 if ( empty($title) ) 993 $title = esc_html(strip_tags($rss->get_title())); 994 $link = esc_url(strip_tags($rss->get_permalink())); 995 while ( stristr($link, 'http') != $link ) 996 $link = substr($link, 1); 1023 if ( ! is_wp_error( $rss ) ) { 1024 $desc = esc_attr( strip_tags( @html_entity_decode( $rss->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ) ) ); 1025 if ( empty( $title ) ) { 1026 $title = esc_html( strip_tags( $rss->get_title() ) ); 1027 } 1028 1029 $link = esc_url( strip_tags( $rss->get_permalink() ) ); 1030 while ( stristr( $link, 'http' ) != $link ) { 1031 $link = substr( $link, 1 ); 1032 } 997 1033 } 998 1034 999 if ( empty($title) ) 1000 $title = empty($desc) ? __('Unknown Feed') : $desc; 1035 if ( empty( $title ) ) { 1036 $title = empty( $desc ) ? esc_html__( 'Unknown Feed' ) : $desc; 1037 } 1001 1038 1039 1002 1040 /** This filter is documented in wp-includes/default-widgets.php */ 1003 1041 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); 1004 1042 1005 $url = esc_url(strip_tags($url)); 1006 $icon = includes_url('images/rss.png'); 1007 if ( $title ) 1008 $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>"; 1043 $url = esc_url( strip_tags( $url ) ); 1044 $icon = includes_url( 'images/rss.png' ); 1045 if ( $title ) { 1046 $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 ) .'">' . $title . '</a>'; 1047 } 1009 1048 1049 1010 1050 echo $args['before_widget']; 1011 1051 if ( $title ) { 1012 1052 echo $args['before_title'] . $title . $args['after_title']; … … 1014 1054 wp_widget_rss_output( $rss, $instance ); 1015 1055 echo $args['after_widget']; 1016 1056 1017 if ( ! is_wp_error( $rss) )1057 if ( ! is_wp_error( $rss ) ) { 1018 1058 $rss->__destruct(); 1059 } 1060 1019 1061 unset($rss); 1020 1062 } 1021 1063 1022 1064 public function update($new_instance, $old_instance) { 1023 $testurl = ( isset( $new_instance['url'] ) && ( ! isset( $old_instance['url'] ) || ( $new_instance['url'] != $old_instance['url'] ) ) );1065 $testurl = ( isset( $new_instance['url'] ) && ( ! isset( $old_instance['url'] ) || ( $new_instance['url'] != $old_instance['url'] ) ) ); 1024 1066 return wp_widget_rss_process( $new_instance, $testurl ); 1025 1067 } 1026 1068 1027 1069 public function form($instance) { 1028 1070 1029 if ( empty( $instance) )1071 if ( empty( $instance ) ) { 1030 1072 $instance = array( 'title' => '', 'url' => '', 'items' => 10, 'error' => false, 'show_summary' => 0, 'show_author' => 0, 'show_date' => 0 ); 1073 } 1074 1031 1075 $instance['number'] = $this->number; 1032 1076 1033 1077 wp_widget_rss_form( $instance ); … … 1044 1088 */ 1045 1089 function wp_widget_rss_output( $rss, $args = array() ) { 1046 1090 if ( is_string( $rss ) ) { 1047 $rss = fetch_feed( $rss);1048 } elseif ( is_array( $rss) && isset($rss['url']) ) {1091 $rss = fetch_feed( $rss ); 1092 } elseif ( is_array( $rss ) && isset( $rss['url'] ) ) { 1049 1093 $args = $rss; 1050 $rss = fetch_feed( $rss['url']);1051 } elseif ( ! is_object($rss) ) {1094 $rss = fetch_feed( $rss['url'] ); 1095 } elseif ( ! is_object( $rss ) ) { 1052 1096 return; 1053 1097 } 1054 1098 1055 if ( is_wp_error($rss) ) { 1056 if ( is_admin() || current_user_can('manage_options') ) 1057 echo '<p>' . sprintf( __('<strong>RSS Error</strong>: %s'), $rss->get_error_message() ) . '</p>'; 1099 if ( is_wp_error( $rss ) ) { 1100 if ( is_admin() || current_user_can( 'manage_options' ) ) { 1101 echo '<p>' . sprintf( __( '<strong>RSS Error</strong>: %s' ), $rss->get_error_message() ) . '</p>'; 1102 } 1103 1058 1104 return; 1059 1105 } 1060 1106 … … 1062 1108 $args = wp_parse_args( $args, $default_args ); 1063 1109 1064 1110 $items = (int) $args['items']; 1065 if ( $items < 1 || 20 < $items ) 1111 if ( $items < 1 || 20 < $items ) { 1066 1112 $items = 10; 1113 } 1114 1067 1115 $show_summary = (int) $args['show_summary']; 1068 1116 $show_author = (int) $args['show_author']; 1069 1117 $show_date = (int) $args['show_date']; 1070 1118 1071 if ( ! $rss->get_item_quantity() ) {1119 if ( ! $rss->get_item_quantity() ) { 1072 1120 echo '<ul><li>' . __( 'An error has occurred, which probably means the feed is down. Try again later.' ) . '</li></ul>'; 1073 1121 $rss->__destruct(); 1074 1122 unset($rss); … … 1115 1163 $author = ''; 1116 1164 if ( $show_author ) { 1117 1165 $author = $item->get_author(); 1118 if ( is_object( $author) ) {1166 if ( is_object( $author ) ) { 1119 1167 $author = $author->get_name(); 1120 1168 $author = ' <cite>' . esc_html( strip_tags( $author ) ) . '</cite>'; 1121 1169 } … … 1169 1217 1170 1218 if ( $inputs['url'] ) : 1171 1219 ?> 1172 <p><label for="rss-url-<?php echo $args['number']; ?>"><?php_e( 'Enter the RSS feed URL here:' ); ?></label>1173 <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>1220 <p><label for="rss-url-<?php echo esc_attr( $args['number'] ); ?>"><?php esc_html_e( 'Enter the RSS feed URL here:' ); ?></label> 1221 <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> 1174 1222 <?php endif; if ( $inputs['title'] ) : ?> 1175 <p><label for="rss-title-<?php echo $args['number']; ?>"><?php_e( 'Give the feed a title (optional):' ); ?></label>1176 <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>1223 <p><label for="rss-title-<?php echo esc_attr( $args['number'] ); ?>"><?php esc_html_e( 'Give the feed a title (optional):' ); ?></label> 1224 <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> 1177 1225 <?php endif; if ( $inputs['items'] ) : ?> 1178 <p><label for="rss-items-<?php echo $args['number']; ?>"><?php_e( 'How many items would you like to display?' ); ?></label>1179 <select id="rss-items-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][items]">1226 <p><label for="rss-items-<?php echo esc_attr( $args['number'] ); ?>"><?php esc_html_e( 'How many items would you like to display?' ); ?></label> 1227 <select id="rss-items-<?php echo esc_attr( $args['number'] ); ?>" name="widget-rss[<?php echo esc_attr( $args['number'] ); ?>][items]"> 1180 1228 <?php 1181 1229 for ( $i = 1; $i <= 20; ++$i ) { 1182 1230 echo "<option value='$i' " . selected( $args['items'], $i, false ) . ">$i</option>"; … … 1184 1232 ?> 1185 1233 </select></p> 1186 1234 <?php endif; if ( $inputs['show_summary'] ) : ?> 1187 <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'] ); ?> />1188 <label for="rss-show-summary-<?php echo $args['number']; ?>"><?php_e( 'Display item content?' ); ?></label></p>1235 <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'] ); ?> /> 1236 <label for="rss-show-summary-<?php echo esc_attr( $args['number'] ); ?>"><?php esc_html_e( 'Display item content?' ); ?></label></p> 1189 1237 <?php endif; if ( $inputs['show_author'] ) : ?> 1190 <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'] ); ?> />1191 <label for="rss-show-author-<?php echo $args['number']; ?>"><?php_e( 'Display item author if available?' ); ?></label></p>1238 <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'] ); ?> /> 1239 <label for="rss-show-author-<?php echo esc_attr( $args['number'] ); ?>"><?php esc_html_e( 'Display item author if available?' ); ?></label></p> 1192 1240 <?php endif; if ( $inputs['show_date'] ) : ?> 1193 <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'] ); ?>/>1194 <label for="rss-show-date-<?php echo $args['number']; ?>"><?php_e( 'Display item date?' ); ?></label></p>1241 <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'] ); ?>/> 1242 <label for="rss-show-date-<?php echo esc_attr( $args['number'] ); ?>"><?php esc_html_e( 'Display item date?' ); ?></label></p> 1195 1243 <?php 1196 1244 endif; 1197 foreach ( array_keys( $default_inputs) as $input ) :1198 if ( 'hidden' === $inputs[ $input] ) :1245 foreach ( array_keys( $default_inputs ) as $input ) : 1246 if ( 'hidden' === $inputs[ $input ] ) : 1199 1247 $id = str_replace( '_', '-', $input ); 1200 1248 ?> 1201 <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 ]; ?>" />1249 <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 ] ); ?>" /> 1202 1250 <?php 1203 1251 endif; 1204 1252 endforeach; … … 1222 1270 */ 1223 1271 function wp_widget_rss_process( $widget_rss, $check_feed = true ) { 1224 1272 $items = (int) $widget_rss['items']; 1225 if ( $items < 1 || 20 < $items ) 1273 if ( $items < 1 || 20 < $items ) { 1226 1274 $items = 10; 1275 } 1276 1227 1277 $url = esc_url_raw( strip_tags( $widget_rss['url'] ) ); 1228 1278 $title = isset( $widget_rss['title'] ) ? trim( strip_tags( $widget_rss['title'] ) ) : ''; 1229 1279 $show_summary = isset( $widget_rss['show_summary'] ) ? (int) $widget_rss['show_summary'] : 0; … … 1231 1281 $show_date = isset( $widget_rss['show_date'] ) ? (int) $widget_rss['show_date'] : 0; 1232 1282 1233 1283 if ( $check_feed ) { 1234 $rss = fetch_feed( $url);1284 $rss = fetch_feed( $url ); 1235 1285 $error = false; 1236 1286 $link = ''; 1237 if ( is_wp_error( $rss) ) {1287 if ( is_wp_error( $rss ) ) { 1238 1288 $error = $rss->get_error_message(); 1239 1289 } else { 1240 $link = esc_url(strip_tags($rss->get_permalink())); 1241 while ( stristr($link, 'http') != $link ) 1242 $link = substr($link, 1); 1290 $link = esc_url( strip_tags( $rss->get_permalink() ) ); 1291 while ( stristr( $link, 'http' ) != $link ) { 1292 $link = substr( $link, 1 ); 1293 } 1243 1294 1244 1295 $rss->__destruct(); 1245 1296 unset($rss); … … 1257 1308 class WP_Widget_Tag_Cloud extends WP_Widget { 1258 1309 1259 1310 public function __construct() { 1260 $widget_ops = array( 'description' => __( "A cloud of your most used tags.") );1261 parent::__construct( 'tag_cloud', __('Tag Cloud'), $widget_ops);1311 $widget_ops = array( 'description' => esc_html__( 'A cloud of your most used tags.' ) ); 1312 parent::__construct( 'tag_cloud', esc_html__( 'Tag Cloud' ), $widget_ops ); 1262 1313 } 1263 1314 1264 1315 public function widget( $args, $instance ) { 1265 $current_taxonomy = $this->_get_current_taxonomy( $instance);1266 if ( ! empty($instance['title']) ) {1316 $current_taxonomy = $this->_get_current_taxonomy( $instance ); 1317 if ( ! empty( $instance['title'] ) ) { 1267 1318 $title = $instance['title']; 1268 1319 } else { 1269 1320 if ( 'post_tag' == $current_taxonomy ) { 1270 $title = __('Tags');1321 $title = esc_html__( 'Tags' ); 1271 1322 } else { 1272 $tax = get_taxonomy( $current_taxonomy);1323 $tax = get_taxonomy( $current_taxonomy ); 1273 1324 $title = $tax->labels->name; 1274 1325 } 1275 1326 } … … 1294 1345 * @param array $current_taxonomy The taxonomy to use in the tag cloud. Default 'tags'. 1295 1346 */ 1296 1347 wp_tag_cloud( apply_filters( 'widget_tag_cloud_args', array( 1297 'taxonomy' => $current_taxonomy 1348 'taxonomy' => $current_taxonomy, 1298 1349 ) ) ); 1299 1350 1300 1351 echo "</div>\n"; … … 1303 1354 1304 1355 public function update( $new_instance, $old_instance ) { 1305 1356 $instance = array(); 1306 $instance['title'] = strip_tags( stripslashes($new_instance['title']));1307 $instance['taxonomy'] = stripslashes( $new_instance['taxonomy']);1357 $instance['title'] = strip_tags( stripslashes( $new_instance['title'] ) ); 1358 $instance['taxonomy'] = stripslashes( $new_instance['taxonomy'] ); 1308 1359 return $instance; 1309 1360 } 1310 1361 1311 1362 public function form( $instance ) { 1312 $current_taxonomy = $this->_get_current_taxonomy( $instance);1363 $current_taxonomy = $this->_get_current_taxonomy( $instance ); 1313 1364 ?> 1314 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:') ?></label>1315 <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>1316 <p><label for="<?php echo $this->get_field_id('taxonomy'); ?>"><?php _e('Taxonomy:') ?></label>1317 <select class="widefat" id="<?php echo $this->get_field_id('taxonomy'); ?>" name="<?php echo $this->get_field_name('taxonomy'); ?>">1365 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:' ) ?></label> 1366 <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 if ( isset ( $instance['title'] ) ) {echo esc_attr( $instance['title'] );} ?>" /></p> 1367 <p><label for="<?php echo esc_attr( $this->get_field_id( 'taxonomy' ) ); ?>"><?php esc_html_e( 'Taxonomy:' ) ?></label> 1368 <select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'taxonomy' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'taxonomy' ) ); ?>"> 1318 1369 <?php foreach ( get_taxonomies() as $taxonomy ) : 1319 $tax = get_taxonomy($taxonomy); 1320 if ( !$tax->show_tagcloud || empty($tax->labels->name) ) 1321 continue; 1370 $tax = get_taxonomy( $taxonomy ); 1371 if ( ! $tax->show_tagcloud || empty( $tax->labels->name ) ) { 1372 continue; 1373 } 1374 1322 1375 ?> 1323 <option value="<?php echo esc_attr( $taxonomy) ?>" <?php selected($taxonomy, $current_taxonomy) ?>><?php echo $tax->labels->name; ?></option>1376 <option value="<?php echo esc_attr( $taxonomy ) ?>" <?php selected( $taxonomy, $current_taxonomy ) ?>><?php echo $tax->labels->name; ?></option> 1324 1377 <?php endforeach; ?> 1325 1378 </select></p><?php 1326 1379 } 1327 1380 1328 1381 public function _get_current_taxonomy($instance) { 1329 if ( ! empty($instance['taxonomy']) && taxonomy_exists($instance['taxonomy']) )1382 if ( ! empty( $instance['taxonomy'] ) && taxonomy_exists( $instance['taxonomy'] ) ) { 1330 1383 return $instance['taxonomy']; 1384 } 1331 1385 1386 1332 1387 return 'post_tag'; 1333 1388 } 1334 1389 } … … 1338 1393 * 1339 1394 * @since 3.0.0 1340 1395 */ 1341 class WP_Nav_Menu_Widget extends WP_Widget {1396 class WP_Nav_Menu_Widget extends WP_Widget { 1342 1397 1343 1398 public function __construct() { 1344 $widget_ops = array( 'description' => __('Add a custom menu to your sidebar.') );1345 parent::__construct( 'nav_menu', __('Custom Menu'), $widget_ops );1399 $widget_ops = array( 'description' => esc_html__( 'Add a custom menu to your sidebar.' ) ); 1400 parent::__construct( 'nav_menu',esc_html__( 'Custom Menu' ), $widget_ops ); 1346 1401 } 1347 1402 1348 1403 public function widget($args, $instance) { … … 1349 1404 // Get menu 1350 1405 $nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false; 1351 1406 1352 if ( ! $nav_menu )1407 if ( ! $nav_menu ) { 1353 1408 return; 1409 } 1354 1410 1411 1355 1412 /** This filter is documented in wp-includes/default-widgets.php */ 1356 1413 $instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); 1357 1414 1358 1415 echo $args['before_widget']; 1359 1416 1360 if ( ! empty($instance['title']) )1417 if ( ! empty( $instance['title'] ) ) { 1361 1418 echo $args['before_title'] . $instance['title'] . $args['after_title']; 1419 } 1362 1420 1421 1363 1422 $nav_menu_args = array( 1364 1423 'fallback_cb' => '', 1365 'menu' => $nav_menu 1424 'menu' => $nav_menu, 1366 1425 ); 1367 1426 1368 1427 /** … … 1387 1446 public function update( $new_instance, $old_instance ) { 1388 1447 $instance = array(); 1389 1448 if ( ! empty( $new_instance['title'] ) ) { 1390 $instance['title'] = strip_tags( stripslashes( $new_instance['title']) );1449 $instance['title'] = strip_tags( stripslashes( $new_instance['title'] ) ); 1391 1450 } 1392 1451 if ( ! empty( $new_instance['nav_menu'] ) ) { 1393 1452 $instance['nav_menu'] = (int) $new_instance['nav_menu']; … … 1403 1462 $menus = wp_get_nav_menus(); 1404 1463 1405 1464 // If no menus exists, direct the user to go and create some. 1406 if ( ! $menus ) {1407 echo '<p>'. sprintf( __( 'No menus have been created yet. <a href="%s">Create some</a>.'), admin_url('nav-menus.php') ) .'</p>';1465 if ( ! $menus ) { 1466 echo '<p>'. sprintf( __( 'No menus have been created yet. <a href="%s">Create some</a>.' ), esc_url( admin_url( 'nav-menus.php' ) ) ) .'</p>'; 1408 1467 return; 1409 1468 } 1410 1469 ?> 1411 1470 <p> 1412 <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:') ?></label>1413 <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; ?>" />1471 <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:' ) ?></label> 1472 <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 ); ?>" /> 1414 1473 </p> 1415 1474 <p> 1416 <label for="<?php echo $this->get_field_id('nav_menu'); ?>"><?php _e('Select Menu:'); ?></label>1417 <select id="<?php echo $this->get_field_id('nav_menu'); ?>" name="<?php echo $this->get_field_name('nav_menu'); ?>">1475 <label for="<?php echo esc_attr( $this->get_field_id( 'nav_menu' ) ); ?>"><?php esc_html_e( 'Select Menu:' ); ?></label> 1476 <select id="<?php echo esc_attr( $this->get_field_id( 'nav_menu' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'nav_menu' ) ); ?>"> 1418 1477 <option value="0"><?php _e( '— Select —' ) ?></option> 1419 1478 <?php 1420 foreach ( $menus as $menu ) {1421 echo '<option value="' . $menu->term_id . '"'1422 . selected( $nav_menu, $menu->term_id, false )1423 . '>'. esc_html( $menu->name ) . '</option>';1424 }1479 foreach ( $menus as $menu ) { 1480 echo '<option value="' . $menu->term_id . '"' 1481 . selected( $nav_menu, $menu->term_id, false ) 1482 . '>'. esc_html( $menu->name ) . '</option>'; 1483 } 1425 1484 ?> 1426 1485 </select> 1427 1486 </p> … … 1438 1497 * @since 2.2.0 1439 1498 */ 1440 1499 function wp_widgets_init() { 1441 if ( ! is_blog_installed() )1500 if ( ! is_blog_installed() ) { 1442 1501 return; 1502 } 1443 1503 1444 register_widget( 'WP_Widget_Pages');1504 register_widget( 'WP_Widget_Pages' ); 1445 1505 1446 register_widget( 'WP_Widget_Calendar');1506 register_widget( 'WP_Widget_Calendar' ); 1447 1507 1448 register_widget( 'WP_Widget_Archives');1508 register_widget( 'WP_Widget_Archives' ); 1449 1509 1450 if ( get_option( 'link_manager_enabled' ) ) 1451 register_widget('WP_Widget_Links'); 1510 if ( get_option( 'link_manager_enabled' ) ) { 1511 register_widget( 'WP_Widget_Links' ); 1512 } 1452 1513 1453 register_widget('WP_Widget_Meta');1454 1514 1455 register_widget( 'WP_Widget_Search');1515 register_widget( 'WP_Widget_Meta' ); 1456 1516 1457 register_widget( 'WP_Widget_Text');1517 register_widget( 'WP_Widget_Search' ); 1458 1518 1459 register_widget( 'WP_Widget_Categories');1519 register_widget( 'WP_Widget_Text' ); 1460 1520 1461 register_widget( 'WP_Widget_Recent_Posts');1521 register_widget( 'WP_Widget_Categories' ); 1462 1522 1463 register_widget( 'WP_Widget_Recent_Comments');1523 register_widget( 'WP_Widget_Recent_Posts' ); 1464 1524 1465 register_widget( 'WP_Widget_RSS');1525 register_widget( 'WP_Widget_Recent_Comments' ); 1466 1526 1467 register_widget( 'WP_Widget_Tag_Cloud');1527 register_widget( 'WP_Widget_RSS' ); 1468 1528 1469 register_widget( 'WP_Nav_Menu_Widget');1529 register_widget( 'WP_Widget_Tag_Cloud' ); 1470 1530 1531 register_widget( 'WP_Nav_Menu_Widget' ); 1532 1471 1533 /** 1472 1534 * Fires after all default WordPress widgets have been registered. 1473 1535 * … … 1476 1538 do_action( 'widgets_init' ); 1477 1539 } 1478 1540 1479 add_action('init', 'wp_widgets_init', 1); 1541 add_action( 'init', 'wp_widgets_init', 1 ); 1542 No newline at end of file