Ticket #23012: 23012.3.diff
| File 23012.3.diff, 62.7 KB (added by , 11 years ago) |
|---|
-
wp-includes/default-widgets.php
14 14 class WP_Widget_Pages extends WP_Widget { 15 15 16 16 public function __construct() { 17 $widget_ops = array( 'classname' => 'widget_pages', 'description' => __( 'A list of your site’s Pages.') );18 parent::__construct( 'pages', __('Pages'), $widget_ops);17 $widget_ops = array( 'classname' => 'widget_pages', 'description' => __( 'A list of your site’s Pages.' ) ); 18 parent::__construct( 'pages', __( 'Pages' ), $widget_ops ); 19 19 } 20 20 21 21 /** … … 33 33 * @param array $instance An array of the widget's settings. 34 34 * @param mixed $id_base The widget ID. 35 35 */ 36 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Pages' ) : $instance['title'], $instance, $this->id_base ); 37 38 $sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby']; 36 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Pages' ) : $instance['title'], $instance, $this->id_base ); 37 $sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby']; 39 38 $exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude']; 40 39 41 if ( $sortby == 'menu_order' )40 if ( 'menu_order' == $sortby ) { 42 41 $sortby = 'menu_order, post_title'; 42 } 43 43 44 44 /** 45 45 * Filter the arguments for the Pages widget. … … 54 54 'title_li' => '', 55 55 'echo' => 0, 56 56 'sort_column' => $sortby, 57 'exclude' => $exclude 57 'exclude' => $exclude, 58 58 ) ) ); 59 59 60 60 if ( ! empty( $out ) ) { … … 78 78 */ 79 79 public function update( $new_instance, $old_instance ) { 80 80 $instance = $old_instance; 81 $instance['title'] = strip_tags( $new_instance['title']);81 $instance['title'] = strip_tags( $new_instance['title'] ); 82 82 if ( in_array( $new_instance['sortby'], array( 'post_title', 'menu_order', 'ID' ) ) ) { 83 83 $instance['sortby'] = $new_instance['sortby']; 84 84 } else { … … 95 95 */ 96 96 public function form( $instance ) { 97 97 //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'] );98 $instance = wp_parse_args( (array) $instance, array( 'sortby' => 'post_title', 'title' => '', 'exclude' => '' ) ); 99 $title = isset( $instance['title'] ) ? $instance['title'] : ''; 100 $exclude = isset( $instance['exclude'] ) ? $instance['exclude'] : ''; 101 101 ?> 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>102 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p> 103 103 <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>104 <label for="<?php echo esc_attr( $this->get_field_id( 'sortby' ) ); ?>"><?php esc_html_e( 'Sort by:' ); ?></label> 105 <select name="<?php echo esc_attr( $this->get_field_name( 'sortby' ) ); ?>" id="<?php echo esc_attr( $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> 108 108 <option value="ID"<?php selected( $instance['sortby'], 'ID' ); ?>><?php _e( 'Page ID' ); ?></option> 109 109 </select> 110 110 </p> 111 111 <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" />112 <label for="<?php echo esc_attr( $this->get_field_id( 'exclude' ) ); ?>"><?php _e( 'Exclude:' ); ?></label> <input type="text" value="<?php echo esc_attr( $exclude ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'exclude' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'exclude' ) ); ?>" class="widefat" /> 113 113 <br /> 114 114 <small><?php _e( 'Page IDs, separated by commas.' ); ?></small> 115 115 </p> … … 126 126 class WP_Widget_Links extends WP_Widget { 127 127 128 128 public function __construct() { 129 $widget_ops = array('description' => __( "Your blogroll" ) ); 130 parent::__construct('links', __('Links'), $widget_ops); 129 $widget_ops = array( 130 'description' => __( 'Your blogroll' ) 131 ); 132 parent::__construct( 'links',__( 'Links' ), $widget_ops ); 131 133 } 132 134 133 135 /** … … 136 138 */ 137 139 public function widget( $args, $instance ) { 138 140 $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;141 $show_name = isset($instance['name']) ? $instance['name'] : false; 142 $show_rating = isset($instance['rating']) ? $instance['rating'] : false; 143 $show_images = isset($instance['images']) ? $instance['images'] : true; 144 $category = isset($instance['category']) ? $instance['category'] : false; 145 $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name'; 146 $order = $orderby == 'rating' ? 'DESC' : 'ASC'; 147 $limit = isset( $instance['limit'] ) ? $instance['limit'] : -1; 146 148 147 149 $before_widget = preg_replace( '/id="[^"]*"/', 'id="%id"', $args['before_widget'] ); 148 150 … … 175 177 $new_instance = (array) $new_instance; 176 178 $instance = array( 'images' => 0, 'name' => 0, 'description' => 0, 'rating' => 0 ); 177 179 foreach ( $instance as $field => $val ) { 178 if ( isset($new_instance[$field]) ) 179 $instance[$field] = 1; 180 if ( isset( $new_instance[ $field ] ) ) { 181 $instance[ $field ] = 1; 182 } 180 183 } 181 184 182 185 $instance['orderby'] = 'name'; 183 if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) ) 186 if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) ) { 184 187 $instance['orderby'] = $new_instance['orderby']; 188 } 185 189 186 190 $instance['category'] = intval( $new_instance['category'] ); 187 191 $instance['limit'] = ! empty( $new_instance['limit'] ) ? intval( $new_instance['limit'] ) : -1; … … 197 201 //Defaults 198 202 $instance = wp_parse_args( (array) $instance, array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false, 'category' => false, 'orderby' => 'name', 'limit' => -1 ) ); 199 203 $link_cats = get_terms( 'link_category' ); 200 if ( ! $limit = intval( $instance['limit'] ) ) 204 if ( ! $limit = intval( $instance['limit'] ) ) { 201 205 $limit = -1; 206 } 207 202 208 ?> 203 209 <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>210 <label for="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>"><?php _e( 'Select Link Category:' ); ?></label> 211 <select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'category' ) ); ?>"> 212 <option value=""><?php _ex( 'All Links', 'links widget' ); ?></option> 207 213 <?php 208 214 foreach ( $link_cats as $link_cat ) { 209 215 echo '<option value="' . intval( $link_cat->term_id ) . '"' … … 212 218 } 213 219 ?> 214 220 </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">221 <label for="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>"><?php _e( 'Sort by:' ); ?></label> 222 <select name="<?php echo esc_attr( $this->get_field_name( 'orderby' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>" class="widefat"> 217 223 <option value="name"<?php selected( $instance['orderby'], 'name' ); ?>><?php _e( 'Link title' ); ?></option> 218 224 <option value="rating"<?php selected( $instance['orderby'], 'rating' ); ?>><?php _e( 'Link rating' ); ?></option> 219 225 <option value="id"<?php selected( $instance['orderby'], 'id' ); ?>><?php _e( 'Link ID' ); ?></option> … … 221 227 </select> 222 228 </p> 223 229 <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>230 <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' ) ); ?>" /> 231 <label for="<?php echo esc_attr( $this->get_field_id( 'images' ) ); ?>"><?php _e( 'Show Link Image' ); ?></label><br /> 232 <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' ) ); ?>" /> 233 <label for="<?php echo esc_attr( $this->get_field_id( 'name' ) ); ?>"><?php _e( 'Show Link Name' ); ?></label><br /> 234 <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' ) ); ?>" /> 235 <label for="<?php echo esc_attr( $this->get_field_id( 'description' ) ); ?>"><?php _e( 'Show Link Description' ); ?></label><br /> 236 <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' ) ); ?>" /> 237 <label for="<?php echo esc_attr( $this->get_field_id( 'rating' ) ); ?>"><?php _e( 'Show Link Rating' ); ?></label> 232 238 </p> 233 239 <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" />240 <label for="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>"><?php _e( 'Number of links to show:' ); ?></label> 241 <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 242 </p> 237 243 <?php 238 244 } … … 246 252 class WP_Widget_Search extends WP_Widget { 247 253 248 254 public function __construct() { 249 $widget_ops = array( 'classname' => 'widget_search', 'description' => __( "A search form for your site.") );255 $widget_ops = array( 'classname' => 'widget_search', 'description' => _( 'A search form for your site.' ) ); 250 256 parent::__construct( 'search', _x( 'Search', 'Search widget' ), $widget_ops ); 251 257 } 252 258 … … 273 279 * @param array $instance 274 280 */ 275 281 public function form( $instance ) { 276 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );282 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); 277 283 $title = $instance['title']; 278 284 ?> 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>285 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></label></p> 280 286 <?php 281 287 } 282 288 … … 287 293 */ 288 294 public function update( $new_instance, $old_instance ) { 289 295 $instance = $old_instance; 290 $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => ''));291 $instance['title'] = strip_tags( $new_instance['title']);296 $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '' ) ); 297 $instance['title'] = strip_tags( $new_instance['title'] ); 292 298 return $instance; 293 299 } 294 300 … … 302 308 class WP_Widget_Archives extends WP_Widget { 303 309 304 310 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);311 $widget_ops = array( 'classname' => 'widget_archive', 'description' => __( 'A monthly archive of your site’s Posts.' ) ); 312 parent::__construct( 'archives', __( 'Archives' ), $widget_ops ); 307 313 } 308 314 309 315 /** … … 340 346 $dropdown_args = apply_filters( 'widget_archives_dropdown_args', array( 341 347 'type' => 'monthly', 342 348 'format' => 'option', 343 'show_post_count' => $c 349 'show_post_count' => $c, 344 350 ) ); 345 351 346 352 switch ( $dropdown_args['type'] ) { … … 382 388 */ 383 389 wp_get_archives( apply_filters( 'widget_archives_args', array( 384 390 'type' => 'monthly', 385 'show_post_count' => $c 391 'show_post_count' => $c, 386 392 ) ) ); 387 393 ?> 388 394 </ul> … … 399 405 */ 400 406 public function update( $new_instance, $old_instance ) { 401 407 $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']);408 $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'count' => 0, 'dropdown' => '' ) ); 409 $instance['title'] = strip_tags( $new_instance['title'] ); 404 410 $instance['count'] = $new_instance['count'] ? 1 : 0; 405 411 $instance['dropdown'] = $new_instance['dropdown'] ? 1 : 0; 406 412 … … 411 417 * @param array $instance 412 418 */ 413 419 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"' : '';420 $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'count' => 0, 'dropdown' => '' ) ); 421 $title = strip_tags( $instance['title'] ); 422 $count = $instance['count'] ? true : false; 423 $dropdown = $instance['dropdown'] ? true : false; 418 424 ?> 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>425 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p> 420 426 <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>427 <input class="checkbox" type="checkbox" <?php checked( true , $dropdown ); ?> id="<?php echo esc_attr( $this->get_field_id( 'dropdown' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'dropdown' ) ); ?>" /> <label for="<?php echo esc_attr( $this->get_field_id( 'dropdown' ) ); ?>"><?php _e( 'Display as dropdown' ); ?></label> 422 428 <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>429 <input class="checkbox" type="checkbox" <?php checked( true , $count ); ?> id="<?php echo esc_attr( $this->get_field_id( 'count' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'count' ) ); ?>" /> <label for="<?php echo esc_attr( $this->get_field_id( 'count' ) ); ?>"><?php _e( 'Show post counts' ); ?></label> 424 430 </p> 425 431 <?php 426 432 } … … 436 442 class WP_Widget_Meta extends WP_Widget { 437 443 438 444 public function __construct() { 439 $widget_ops = array( 'classname' => 'widget_meta', 'description' => __( "Login, RSS, & WordPress.org links.") );440 parent::__construct( 'meta', __('Meta'), $widget_ops);445 $widget_ops = array( 'classname' => 'widget_meta', 'description' => __( 'Login, RSS, & WordPress.org links.' ) ); 446 parent::__construct( 'meta', __( 'Meta' ), $widget_ops ); 441 447 } 442 448 443 449 /** … … 456 462 <ul> 457 463 <?php wp_register(); ?> 458 464 <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>465 <li><a href="<?php echo esc_url( get_bloginfo( 'rss2_url' ) ); ?>"><?php echo _e( 'Entries <abbr title="Really Simple Syndication">RSS</abbr>' ); ?></a></li> 466 <li><a href="<?php echo esc_url( get_bloginfo( 'comments_rss2_url' ) ); ?>"><?php _e( 'Comments <abbr title="Really Simple Syndication">RSS</abbr>' ); ?></a></li> 461 467 <?php 462 468 /** 463 469 * Filter the "Powered by WordPress" text in the Meta widget. … … 486 492 */ 487 493 public function update( $new_instance, $old_instance ) { 488 494 $instance = $old_instance; 489 $instance['title'] = strip_tags( $new_instance['title']);495 $instance['title'] = strip_tags( $new_instance['title'] ); 490 496 491 497 return $instance; 492 498 } … … 496 502 */ 497 503 public function form( $instance ) { 498 504 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); 499 $title = strip_tags( $instance['title']);505 $title = strip_tags( $instance['title'] ); 500 506 ?> 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>507 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p> 502 508 <?php 503 509 } 504 510 } … … 511 517 class WP_Widget_Calendar extends WP_Widget { 512 518 513 519 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);520 $widget_ops = array( 'classname' => 'widget_calendar', 'description' => __( 'A calendar of your site’s Posts.' ) ); 521 parent::__construct( 'calendar', __( 'Calendar' ), $widget_ops ); 516 522 } 517 523 518 524 /** … … 540 546 */ 541 547 public function update( $new_instance, $old_instance ) { 542 548 $instance = $old_instance; 543 $instance['title'] = strip_tags( $new_instance['title']);549 $instance['title'] = strip_tags( $new_instance['title'] ); 544 550 545 551 return $instance; 546 552 } … … 550 556 */ 551 557 public function form( $instance ) { 552 558 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); 553 $title = strip_tags( $instance['title']);559 $title = strip_tags( $instance['title'] ); 554 560 ?> 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>561 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label> 562 <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 563 <?php 558 564 } 559 565 } … … 566 572 class WP_Widget_Text extends WP_Widget { 567 573 568 574 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); 575 $widget_ops = array( 576 'classname' => 'widget_text', 577 'description' => __( 'Arbitrary text or HTML.' ) 578 ); 579 $control_ops = array( 580 'width' => 400, 581 'height' => 350, 582 ); 583 parent::__construct( 'text', __( 'Text' ), $widget_ops, $control_ops ); 572 584 } 573 585 574 586 /** … … 592 604 if ( ! empty( $title ) ) { 593 605 echo $args['before_title'] . $title . $args['after_title']; 594 606 } ?> 595 <div class="textwidget"><?php echo ! empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div>607 <div class="textwidget"><?php echo ! empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div> 596 608 <?php 597 609 echo $args['after_widget']; 598 610 } … … 604 616 */ 605 617 public function update( $new_instance, $old_instance ) { 606 618 $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 619 $instance['title'] = strip_tags( $new_instance['title'] ); 620 if ( current_user_can( 'unfiltered_html' ) ) { 621 $instance['text'] = $new_instance['text']; 622 } else { 623 $instance['text'] = stripslashes( wp_filter_post_kses( addslashes( $new_instance['text'] ) ) ); // wp_filter_post_kses() expects slashed 624 } 612 625 $instance['filter'] = ! empty( $new_instance['filter'] ); 613 626 return $instance; 614 627 } … … 618 631 */ 619 632 public function form( $instance ) { 620 633 $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) ); 621 $title = strip_tags( $instance['title']);622 $text = esc_textarea($instance['text']);634 $title = strip_tags( $instance['title'] ); 635 $text = isset( $instance['text'] ) ? $instance['text'] : ''; 623 636 ?> 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>637 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label> 638 <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 639 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>640 <p><label for="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>"><?php _e( 'Content:' ); ?></label> 641 <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 642 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>643 <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 _e( 'Automatically add paragraphs' ); ?></label></p> 631 644 <?php 632 645 } 633 646 } … … 640 653 class WP_Widget_Categories extends WP_Widget { 641 654 642 655 public function __construct() { 643 $widget_ops = array( 'classname' => 'widget_categories', 'description' => __( "A list or dropdown of categories." ) ); 644 parent::__construct('categories', __('Categories'), $widget_ops); 656 $widget_ops = array( 657 'classname' => 'widget_categories', 658 'description' => __( 'A list or dropdown of categories.' ) 659 ); 660 parent::__construct( 'categories', __( 'Categories' ), $widget_ops ); 645 661 } 646 662 647 663 /** … … 668 684 $cat_args = array( 669 685 'orderby' => 'name', 670 686 'show_count' => $c, 671 'hierarchical' => $h 687 'hierarchical' => $h, 672 688 ); 673 689 674 690 if ( $d ) { … … 695 711 <script type='text/javascript'> 696 712 /* <![CDATA[ */ 697 713 (function() { 698 var dropdown = document.getElementById( "<?php echo esc_js( $dropdown_id ); ?>" );714 var dropdown = document.getElementById( "<?php echo wp_json_encode( $dropdown_id ); ?>" ); 699 715 function onCatChange() { 700 716 if ( dropdown.options[ dropdown.selectedIndex ].value > 0 ) { 701 location.href = "<?php echo home_url(); ?>/?cat=" + dropdown.options[ dropdown.selectedIndex ].value;717 location.href = "<?php echo esc_url( home_url() ); ?>/?cat=" + dropdown.options[ dropdown.selectedIndex ].value; 702 718 } 703 719 } 704 720 dropdown.onchange = onCatChange; … … 736 752 */ 737 753 public function update( $new_instance, $old_instance ) { 738 754 $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;755 $instance['title'] = strip_tags( $new_instance['title'] ); 756 $instance['count'] = ! empty( $new_instance['count'] ) ? 1 : 0; 757 $instance['hierarchical'] = ! empty( $new_instance['hierarchical'] ) ? 1 : 0; 758 $instance['dropdown'] = ! empty($new_instance['dropdown'] ) ? 1 : 0; 743 759 744 760 return $instance; 745 761 } … … 749 765 */ 750 766 public function form( $instance ) { 751 767 //Defaults 752 $instance = wp_parse_args( (array) $instance, array( 'title' => '') ); 753 $title = esc_attr( $instance['title'] ); 768 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); 754 769 $count = isset($instance['count']) ? (bool) $instance['count'] :false; 755 770 $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false; 756 771 $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false; 757 772 ?> 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>773 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label> 774 <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 775 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 />776 <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 ); ?> /> 777 <label for="<?php echo esc_attr( $this->get_field_id( 'dropdown' ) ); ?>"><?php _e( 'Display as dropdown' ); ?></label><br /> 763 778 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 />779 <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 ); ?> /> 780 <label for="<?php echo esc_attr( $this->get_field_id( 'count' ) ); ?>"><?php _e( 'Show post counts' ); ?></label><br /> 766 781 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>782 <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 ); ?> /> 783 <label for="<?php echo esc_attr( $this->get_field_id( 'hierarchical' ) ); ?>"><?php _e( 'Show hierarchy' ); ?></label></p> 769 784 <?php 770 785 } 771 786 … … 779 794 class WP_Widget_Recent_Posts extends WP_Widget { 780 795 781 796 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); 797 $widget_ops = array( 798 'classname' => 'widget_recent_entries', 799 'description' => __( 'Your site’s most recent Posts.' ) 800 ); 801 parent::__construct( 'recent-posts', __( 'Recent Posts' ), $widget_ops ); 784 802 $this->alt_option_name = 'widget_recent_entries'; 785 803 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') );804 add_action( 'save_post', array( $this, 'flush_widget_cache' ) ); 805 add_action( 'deleted_post', array( $this, 'flush_widget_cache' ) ); 806 add_action( 'switch_theme', array( $this, 'flush_widget_cache' ) ); 789 807 } 790 808 791 809 /** … … 819 837 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); 820 838 821 839 $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; 822 if ( ! $number ) 840 if ( ! $number ) { 823 841 $number = 5; 842 } 824 843 $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false; 825 844 826 845 /** … … 836 855 'posts_per_page' => $number, 837 856 'no_found_rows' => true, 838 857 'post_status' => 'publish', 839 'ignore_sticky_posts' => true 858 'ignore_sticky_posts' => true, 840 859 ) ) ); 841 860 842 if ( $r->have_posts()) :861 if ( $r->have_posts() ) : 843 862 ?> 844 863 <?php echo $args['before_widget']; ?> 845 <?php if ( $title ) { 864 <?php 865 if ( $title ) { 846 866 echo $args['before_title'] . $title . $args['after_title']; 847 } ?>867 }?> 848 868 <ul> 849 869 <?php while ( $r->have_posts() ) : $r->the_post(); ?> 850 870 <li> … … 877 897 */ 878 898 public function update( $new_instance, $old_instance ) { 879 899 $instance = $old_instance; 880 $instance['title'] = strip_tags( $new_instance['title']);900 $instance['title'] = strip_tags( $new_instance['title'] ); 881 901 $instance['number'] = (int) $new_instance['number']; 882 902 $instance['show_date'] = isset( $new_instance['show_date'] ) ? (bool) $new_instance['show_date'] : false; 883 903 $this->flush_widget_cache(); 884 904 885 905 $alloptions = wp_cache_get( 'alloptions', 'options' ); 886 if ( isset($alloptions['widget_recent_entries']) ) 887 delete_option('widget_recent_entries'); 906 if ( isset( $alloptions['widget_recent_entries'] ) ) { 907 delete_option( 'widget_recent_entries' ); 908 } 888 909 889 910 return $instance; 890 911 } … … 893 914 * @access public 894 915 */ 895 916 public function flush_widget_cache() { 896 wp_cache_delete( 'widget_recent_posts', 'widget');917 wp_cache_delete( 'widget_recent_posts', 'widget' ); 897 918 } 898 919 899 920 /** … … 900 921 * @param array $instance 901 922 */ 902 923 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;924 $title = isset( $instance['title'] ) ? $instance['title']: ''; 925 $number = isset( $instance['number'] ) ? $instance['number'] : 5; 926 $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false; 906 927 ?> 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>928 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label> 929 <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 930 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>931 <p><label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"><?php _e( 'Number of posts to show:' ); ?></label> 932 <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 933 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>934 <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' ) ); ?>" /> 935 <label for="<?php echo esc_attr( $this->get_field_id( 'show_date' ) ); ?>"><?php _e( 'Display post date?' ); ?></label></p> 915 936 <?php 916 937 } 917 938 } … … 924 945 class WP_Widget_Recent_Comments extends WP_Widget { 925 946 926 947 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); 948 $widget_ops = array( 949 'classname' => 'widget_recent_comments', 950 'description' => _( 'Your site’s most recent comments.' ) 951 ); 952 parent::__construct( 'recent-comments', __( 'Recent Comments' ), $widget_ops ); 929 953 $this->alt_option_name = 'widget_recent_comments'; 930 954 931 if ( is_active_widget(false, false, $this->id_base) ) 932 add_action( 'wp_head', array($this, 'recent_comments_style') ); 955 if ( is_active_widget( false, false, $this->id_base ) ) { 956 add_action( 'wp_head', array( $this, 'recent_comments_style' ) ); 957 } 933 958 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') );959 add_action( 'comment_post', array( $this, 'flush_widget_cache' ) ); 960 add_action( 'edit_comment', array( $this, 'flush_widget_cache' ) ); 961 add_action( 'transition_comment_status', array( $this, 'flush_widget_cache' ) ); 937 962 } 938 963 939 964 /** … … 949 974 * @param string $id_base The widget ID. 950 975 */ 951 976 if ( ! current_theme_supports( 'widgets' ) // Temp hack #14876 952 || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) 977 || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) { 953 978 return; 979 } 954 980 ?> 955 981 <style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style> 956 982 <?php … … 960 986 * @access public 961 987 */ 962 988 public function flush_widget_cache() { 963 wp_cache_delete( 'widget_recent_comments', 'widget');989 wp_cache_delete( 'widget_recent_comments', 'widget' ); 964 990 } 965 991 966 992 /** … … 975 1001 976 1002 $cache = array(); 977 1003 if ( ! $this->is_preview() ) { 978 $cache = wp_cache_get( 'widget_recent_comments', 'widget');1004 $cache = wp_cache_get( 'widget_recent_comments', 'widget' ); 979 1005 } 980 1006 if ( ! is_array( $cache ) ) { 981 1007 $cache = array(); 982 1008 } 983 1009 984 if ( ! isset( $args['widget_id'] ) ) 1010 if ( ! isset( $args['widget_id'] ) ) { 985 1011 $args['widget_id'] = $this->id; 1012 } 986 1013 987 1014 if ( isset( $cache[ $args['widget_id'] ] ) ) { 988 1015 echo $cache[ $args['widget_id'] ]; … … 997 1024 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); 998 1025 999 1026 $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; 1000 if ( ! $number ) 1027 if ( ! $number ) { 1001 1028 $number = 5; 1029 } 1002 1030 1031 1003 1032 /** 1004 1033 * Filter the arguments for the Recent Comments widget. 1005 1034 * … … 1012 1041 $comments = get_comments( apply_filters( 'widget_comments_args', array( 1013 1042 'number' => $number, 1014 1043 'status' => 'approve', 1015 'post_status' => 'publish' 1044 'post_status' => 'publish', 1016 1045 ) ) ); 1017 1046 1018 1047 $output .= $args['before_widget']; … … 1026 1055 $post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) ); 1027 1056 _prime_post_caches( $post_ids, strpos( get_option( 'permalink_structure' ), '%category%' ), false ); 1028 1057 1029 foreach ( (array) $comments as $comment ) {1058 foreach ( (array) $comments as $comment ) { 1030 1059 $output .= '<li class="recentcomments">'; 1031 1060 /* translators: comments widget: 1: comment author, 2: post link */ 1032 1061 $output .= sprintf( _x( '%1$s on %2$s', 'widgets' ), … … 1054 1083 */ 1055 1084 public function update( $new_instance, $old_instance ) { 1056 1085 $instance = $old_instance; 1057 $instance['title'] = strip_tags( $new_instance['title']);1086 $instance['title'] = strip_tags( $new_instance['title'] ); 1058 1087 $instance['number'] = absint( $new_instance['number'] ); 1059 1088 $this->flush_widget_cache(); 1060 1089 1061 1090 $alloptions = wp_cache_get( 'alloptions', 'options' ); 1062 if ( isset($alloptions['widget_recent_comments']) ) 1063 delete_option('widget_recent_comments'); 1091 if ( isset( $alloptions['widget_recent_comments'] ) ) { 1092 delete_option( 'widget_recent_comments' ); 1093 } 1064 1094 1065 1095 return $instance; 1066 1096 } … … 1089 1119 class WP_Widget_RSS extends WP_Widget { 1090 1120 1091 1121 public function __construct() { 1092 $widget_ops = array( 'description' => __( 'Entries from any RSS or Atom feed.') );1122 $widget_ops = array( 'description' => __( 'Entries from any RSS or Atom feed.' ) ); 1093 1123 $control_ops = array( 'width' => 400, 'height' => 200 ); 1094 parent::__construct( 'rss', __( 'RSS'), $widget_ops, $control_ops );1124 parent::__construct( 'rss', __( 'RSS' ), $widget_ops, $control_ops ); 1095 1125 } 1096 1126 1097 1127 /** … … 1099 1129 * @param array $instance 1100 1130 */ 1101 1131 public function widget( $args, $instance ) { 1102 if ( isset($instance['error']) && $instance['error'] ) 1132 if ( isset($instance['error']) && $instance['error'] ) { 1103 1133 return; 1134 } 1104 1135 1105 1136 $url = ! empty( $instance['url'] ) ? $instance['url'] : ''; 1106 while ( stristr($url, 'http') != $url ) 1107 $url = substr($url, 1); 1137 while ( stristr( $url, 'http' ) != $url ) { 1138 $url = substr( $url, 1 ); 1139 } 1108 1140 1109 if ( empty($url) ) 1141 if ( empty($url) ) { 1110 1142 return; 1143 } 1111 1144 1112 1145 // self-url destruction sequence 1113 if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ) ) ) 1146 if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ) ) ) { 1114 1147 return; 1148 } 1115 1149 1116 $rss = fetch_feed( $url);1150 $rss = fetch_feed( $url ); 1117 1151 $title = $instance['title']; 1118 1152 $desc = ''; 1119 1153 $link = ''; 1120 1154 1121 if ( ! is_wp_error($rss) ) { 1122 $desc = esc_attr(strip_tags(@html_entity_decode($rss->get_description(), ENT_QUOTES, get_option('blog_charset')))); 1123 if ( empty($title) ) 1124 $title = esc_html(strip_tags($rss->get_title())); 1125 $link = esc_url(strip_tags($rss->get_permalink())); 1126 while ( stristr($link, 'http') != $link ) 1127 $link = substr($link, 1); 1155 if ( ! is_wp_error( $rss ) ) { 1156 $desc = esc_attr( strip_tags( @html_entity_decode( $rss->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ) ) ); 1157 if ( empty( $title ) ) { 1158 $title = esc_html( strip_tags( $rss->get_title() ) ); 1159 } 1160 $link = esc_url( strip_tags( $rss->get_permalink() ) ); 1161 while ( stristr( $link, 'http' ) != $link ) { 1162 $link = substr( $link, 1 ); 1163 } 1128 1164 } 1129 1165 1130 if ( empty($title) ) 1131 $title = empty($desc) ? __('Unknown Feed') : $desc; 1166 if ( empty( $title ) ) { 1167 $title = empty( $desc ) ? __( 'Unknown Feed' ) : $desc; 1168 } 1132 1169 1133 1170 /** This filter is documented in wp-includes/default-widgets.php */ 1134 1171 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); 1135 1172 1136 $url = esc_url(strip_tags($url)); 1137 $icon = includes_url('images/rss.png'); 1138 if ( $title ) 1139 $title = "<a class='rsswidget' href='$url'><img style='border:0' width='14' height='14' src='$icon' alt='RSS' /></a> <a class='rsswidget' href='$link'>$title</a>"; 1173 $url = esc_url( strip_tags( $url ) ); 1174 $icon = includes_url( 'images/rss.png' ); 1175 if ( $title ) { 1176 $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>'; 1177 } 1140 1178 1141 1179 echo $args['before_widget']; 1142 1180 if ( $title ) { … … 1145 1183 wp_widget_rss_output( $rss, $instance ); 1146 1184 echo $args['after_widget']; 1147 1185 1148 if ( ! is_wp_error( $rss) )1186 if ( ! is_wp_error( $rss ) ) { 1149 1187 $rss->__destruct(); 1188 } 1150 1189 unset($rss); 1151 1190 } 1152 1191 … … 1156 1195 * @return array 1157 1196 */ 1158 1197 public function update( $new_instance, $old_instance ) { 1159 $testurl = ( isset( $new_instance['url'] ) && ( ! isset( $old_instance['url'] ) || ( $new_instance['url'] != $old_instance['url'] ) ) );1198 $testurl = ( isset( $new_instance['url'] ) && ( ! isset( $old_instance['url'] ) || ( $new_instance['url'] != $old_instance['url'] ) ) ); 1160 1199 return wp_widget_rss_process( $new_instance, $testurl ); 1161 1200 } 1162 1201 … … 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( __( '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() ) {1266 if ( ! $rss->get_item_quantity() ) { 1211 1267 echo '<ul><li>' . __( 'An error has occurred, which probably means the feed is down. Try again later.' ) . '</li></ul>'; 1212 1268 $rss->__destruct(); 1213 1269 unset($rss); … … 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>'; … … 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 _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 _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 _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 _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 _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 _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); … … 1396 1455 class WP_Widget_Tag_Cloud extends WP_Widget { 1397 1456 1398 1457 public function __construct() { 1399 $widget_ops = array( 'description' => __( "A cloud of your most used tags.") );1400 parent::__construct( 'tag_cloud', __('Tag Cloud'), $widget_ops);1458 $widget_ops = array( 'description' => __( 'A cloud of your most used tags.' ) ); 1459 parent::__construct( 'tag_cloud', __( 'Tag Cloud' ), $widget_ops ); 1401 1460 } 1402 1461 1403 1462 /** … … 1405 1464 * @param array $instance 1406 1465 */ 1407 1466 public function widget( $args, $instance ) { 1408 $current_taxonomy = $this->_get_current_taxonomy( $instance);1409 if ( ! empty($instance['title']) ) {1467 $current_taxonomy = $this->_get_current_taxonomy( $instance ); 1468 if ( ! empty( $instance['title'] ) ) { 1410 1469 $title = $instance['title']; 1411 1470 } else { 1412 1471 if ( 'post_tag' == $current_taxonomy ) { 1413 $title = __( 'Tags');1472 $title = __( 'Tags' ); 1414 1473 } else { 1415 $tax = get_taxonomy( $current_taxonomy);1474 $tax = get_taxonomy( $current_taxonomy ); 1416 1475 $title = $tax->labels->name; 1417 1476 } 1418 1477 } … … 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"; … … 1451 1510 */ 1452 1511 public function update( $new_instance, $old_instance ) { 1453 1512 $instance = array(); 1454 $instance['title'] = strip_tags( stripslashes($new_instance['title']));1455 $instance['taxonomy'] = stripslashes( $new_instance['taxonomy']);1513 $instance['title'] = strip_tags( stripslashes( $new_instance['title'] ) ); 1514 $instance['taxonomy'] = stripslashes( $new_instance['taxonomy'] ); 1456 1515 return $instance; 1457 1516 } 1458 1517 … … 1460 1519 * @param array $instance 1461 1520 */ 1462 1521 public function form( $instance ) { 1463 $current_taxonomy = $this->_get_current_taxonomy($instance); 1522 $current_taxonomy = $this->_get_current_taxonomy( $instance ); 1523 $title = ( isset ( $instance['title'] ) ) ? $instance['title'] : ''; 1464 1524 ?> 1465 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:') ?></label>1466 <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php if (isset ( $instance['title'])) {echo esc_attr( $instance['title'] );}?>" /></p>1467 <p><label for="<?php echo $this->get_field_id('taxonomy'); ?>"><?php _e('Taxonomy:') ?></label>1468 <select class="widefat" id="<?php echo $this->get_field_id('taxonomy'); ?>" name="<?php echo $this->get_field_name('taxonomy'); ?>">1525 <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ) ?></label> 1526 <input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_attr( $title );?>" /></p> 1527 <p><label for="<?php echo esc_attr( $this->get_field_id( 'taxonomy' ) ); ?>"><?php _e( 'Taxonomy:' ) ?></label> 1528 <select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'taxonomy' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'taxonomy' ) ); ?>"> 1469 1529 <?php foreach ( get_taxonomies() as $taxonomy ) : 1470 $tax = get_taxonomy( $taxonomy);1471 if ( ! $tax->show_tagcloud || empty($tax->labels->name) )1530 $tax = get_taxonomy( $taxonomy ); 1531 if ( ! $tax->show_tagcloud || empty( $tax->labels->name ) ) { 1472 1532 continue; 1533 } 1473 1534 ?> 1474 <option value="<?php echo esc_attr( $taxonomy) ?>" <?php selected($taxonomy, $current_taxonomy) ?>><?php echo $tax->labels->name; ?></option>1535 <option value="<?php echo esc_attr( $taxonomy ) ?>" <?php selected( $taxonomy, $current_taxonomy ) ?>><?php echo esc_html( $tax->labels->name ); ?></option> 1475 1536 <?php endforeach; ?> 1476 1537 </select></p><?php 1477 1538 } … … 1481 1542 * @return string 1482 1543 */ 1483 1544 public function _get_current_taxonomy($instance) { 1484 if ( ! empty($instance['taxonomy']) && taxonomy_exists($instance['taxonomy']) )1545 if ( ! empty( $instance['taxonomy'] ) && taxonomy_exists( $instance['taxonomy'] ) ) { 1485 1546 return $instance['taxonomy']; 1547 } 1486 1548 1487 1549 return 'post_tag'; 1488 1550 } … … 1493 1555 * 1494 1556 * @since 3.0.0 1495 1557 */ 1496 class WP_Nav_Menu_Widget extends WP_Widget {1558 class WP_Nav_Menu_Widget extends WP_Widget { 1497 1559 1498 1560 public function __construct() { 1499 $widget_ops = array( 'description' => __( 'Add a custom menu to your sidebar.') );1500 parent::__construct( 'nav_menu', __( 'Custom Menu'), $widget_ops );1561 $widget_ops = array( 'description' => __( 'Add a custom menu to your sidebar.' ) ); 1562 parent::__construct( 'nav_menu', __( 'Custom Menu' ), $widget_ops ); 1501 1563 } 1502 1564 1503 1565 /** … … 1508 1570 // Get menu 1509 1571 $nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false; 1510 1572 1511 if ( ! $nav_menu )1573 if ( ! $nav_menu ) { 1512 1574 return; 1575 } 1513 1576 1577 1514 1578 /** This filter is documented in wp-includes/default-widgets.php */ 1515 1579 $instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); 1516 1580 1517 1581 echo $args['before_widget']; 1518 1582 1519 if ( ! empty($instance['title']) )1583 if ( ! empty( $instance['title'] ) ) { 1520 1584 echo $args['before_title'] . $instance['title'] . $args['after_title']; 1585 } 1521 1586 1587 1522 1588 $nav_menu_args = array( 1523 1589 'fallback_cb' => '', 1524 'menu' => $nav_menu 1590 'menu' => $nav_menu, 1525 1591 ); 1526 1592 1527 1593 /** … … 1551 1617 public function update( $new_instance, $old_instance ) { 1552 1618 $instance = array(); 1553 1619 if ( ! empty( $new_instance['title'] ) ) { 1554 $instance['title'] = strip_tags( stripslashes( $new_instance['title']) );1620 $instance['title'] = strip_tags( stripslashes( $new_instance['title'] ) ); 1555 1621 } 1556 1622 if ( ! empty( $new_instance['nav_menu'] ) ) { 1557 1623 $instance['nav_menu'] = (int) $new_instance['nav_menu']; … … 1563 1629 * @param array $instance 1564 1630 */ 1565 1631 public function form( $instance ) { 1566 $title = isset( $instance['title'] ) ? $instance['title'] : '';1632 $title = isset( $instance['title'] ) ? $instance['title'] : ''; 1567 1633 $nav_menu = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : ''; 1568 1634 1569 1635 // Get menus … … 1570 1636 $menus = wp_get_nav_menus(); 1571 1637 1572 1638 // 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>';1639 if ( ! $menus ) { 1640 echo '<p>'. sprintf( __( 'No menus have been created yet. <a href="%s">Create some</a>.' ), esc_url( admin_url( 'nav-menus.php' ) ) ) .'</p>'; 1575 1641 return; 1576 1642 } 1577 1643 ?> 1578 1644 <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; ?>" />1645 <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ) ?></label> 1646 <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 1647 </p> 1582 1648 <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'); ?>">1649 <label for="<?php echo esc_attr( $this->get_field_id( 'nav_menu' ) ); ?>"><?php _e( 'Select Menu:' ); ?></label> 1650 <select id="<?php echo esc_attr( $this->get_field_id( 'nav_menu' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'nav_menu' ) ); ?>"> 1585 1651 <option value="0"><?php _e( '— Select —' ) ?></option> 1586 1652 <?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 }1653 foreach ( $menus as $menu ) { 1654 echo '<option value="' . $menu->term_id . '"' 1655 . selected( $nav_menu, $menu->term_id, false ) 1656 . '>'. esc_html( $menu->name ) . '</option>'; 1657 } 1592 1658 ?> 1593 1659 </select> 1594 1660 </p> … … 1605 1671 * @since 2.2.0 1606 1672 */ 1607 1673 function wp_widgets_init() { 1608 if ( ! is_blog_installed() )1674 if ( ! is_blog_installed() ) { 1609 1675 return; 1676 } 1610 1677 1611 register_widget( 'WP_Widget_Pages');1678 register_widget( 'WP_Widget_Pages' ); 1612 1679 1613 register_widget( 'WP_Widget_Calendar');1680 register_widget( 'WP_Widget_Calendar' ); 1614 1681 1615 register_widget( 'WP_Widget_Archives');1682 register_widget( 'WP_Widget_Archives' ); 1616 1683 1617 if ( get_option( 'link_manager_enabled' ) ) 1618 register_widget('WP_Widget_Links'); 1684 if ( get_option( 'link_manager_enabled' ) ) { 1685 register_widget( 'WP_Widget_Links' ); 1686 } 1619 1687 1620 register_widget('WP_Widget_Meta');1621 1688 1622 register_widget( 'WP_Widget_Search');1689 register_widget( 'WP_Widget_Meta' ); 1623 1690 1624 register_widget( 'WP_Widget_Text');1691 register_widget( 'WP_Widget_Search' ); 1625 1692 1626 register_widget( 'WP_Widget_Categories');1693 register_widget( 'WP_Widget_Text' ); 1627 1694 1628 register_widget( 'WP_Widget_Recent_Posts');1695 register_widget( 'WP_Widget_Categories' ); 1629 1696 1630 register_widget( 'WP_Widget_Recent_Comments');1697 register_widget( 'WP_Widget_Recent_Posts' ); 1631 1698 1632 register_widget( 'WP_Widget_RSS');1699 register_widget( 'WP_Widget_Recent_Comments' ); 1633 1700 1634 register_widget( 'WP_Widget_Tag_Cloud');1701 register_widget( 'WP_Widget_RSS' ); 1635 1702 1636 register_widget( 'WP_Nav_Menu_Widget');1703 register_widget( 'WP_Widget_Tag_Cloud' ); 1637 1704 1705 register_widget( 'WP_Nav_Menu_Widget' ); 1706 1638 1707 /** 1639 1708 * Fires after all default WordPress widgets have been registered. 1640 1709 *