Make WordPress Core

Ticket #23012: 23012.diff

File 23012.diff, 63.4 KB (added by welcher, 11 years ago)

First pass of default-widgets.php

  • wp-includes/default-widgets.php

     
    1414class WP_Widget_Pages extends WP_Widget {
    1515
    1616        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 );
    1919        }
    2020
    2121        public function widget( $args, $instance ) {
     
    3434                $sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby'];
    3535                $exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude'];
    3636
    37                 if ( $sortby == 'menu_order' )
     37                if ( 'menu_order' == $sortby ) {
    3838                        $sortby = 'menu_order, post_title';
     39                }
    3940
    4041                /**
    4142                 * Filter the arguments for the Pages widget.
     
    5051                        'title_li'    => '',
    5152                        'echo'        => 0,
    5253                        'sort_column' => $sortby,
    53                         'exclude'     => $exclude
     54                        'exclude'     => $exclude,
    5455                ) ) );
    5556
    5657                if ( ! empty( $out ) ) {
     
    6970
    7071        public function update( $new_instance, $old_instance ) {
    7172                $instance = $old_instance;
    72                 $instance['title'] = strip_tags($new_instance['title']);
     73                $instance['title'] = strip_tags( $new_instance['title'] );
    7374                if ( in_array( $new_instance['sortby'], array( 'post_title', 'menu_order', 'ID' ) ) ) {
    7475                        $instance['sortby'] = $new_instance['sortby'];
    7576                } else {
     
    8384
    8485        public function form( $instance ) {
    8586                //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'] : '';
    8990        ?>
    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>
    9192                <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>
    9697                                <option value="ID"<?php selected( $instance['sortby'], 'ID' ); ?>><?php _e( 'Page ID' ); ?></option>
    9798                        </select>
    9899                </p>
    99100                <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" />
    101102                        <br />
    102                         <small><?php _e( 'Page IDs, separated by commas.' ); ?></small>
     103                        <small><?php esc_html_e( 'Page IDs, separated by commas.' ); ?></small>
    103104                </p>
    104105<?php
    105106        }
     
    114115class WP_Widget_Links extends WP_Widget {
    115116
    116117        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 );
    119120        }
    120121
    121122        public function widget( $args, $instance ) {
    122123
    123124                $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;
    127128                $category = isset($instance['category']) ? $instance['category'] : false;
    128129                $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name';
    129130                $order = $orderby == 'rating' ? 'DESC' : 'ASC';
     
    155156                $new_instance = (array) $new_instance;
    156157                $instance = array( 'images' => 0, 'name' => 0, 'description' => 0, 'rating' => 0 );
    157158                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                        }
    160162                }
    161163
    162164                $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' ) ) ) {
    164166                        $instance['orderby'] = $new_instance['orderby'];
     167                }
    165168
    166169                $instance['category'] = intval( $new_instance['category'] );
    167170                $instance['limit'] = ! empty( $new_instance['limit'] ) ? intval( $new_instance['limit'] ) : -1;
     
    174177                //Defaults
    175178                $instance = wp_parse_args( (array) $instance, array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false, 'category' => false, 'orderby' => 'name', 'limit' => -1 ) );
    176179                $link_cats = get_terms( 'link_category' );
    177                 if ( ! $limit = intval( $instance['limit'] ) )
     180                if ( ! $limit = intval( $instance['limit'] ) ) {
    178181                        $limit = -1;
     182                }
     183
    179184?>
    180185                <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>
    184189                <?php
    185190                foreach ( $link_cats as $link_cat ) {
    186191                        echo '<option value="' . intval( $link_cat->term_id ) . '"'
    187192                                . selected( $instance['category'], $link_cat->term_id, false )
    188                                 . '>' . $link_cat->name . "</option>\n";
     193                                . '>' . esc_html( $link_cat->name ) . "</option>\n";
    189194                }
    190195                ?>
    191196                </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>
    197202                        <option value="rand"<?php selected( $instance['orderby'], 'rand' ); ?>><?php _ex( 'Random', 'Links widget' ); ?></option>
    198203                </select>
    199204                </p>
    200205                <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>
    209214                </p>
    210215                <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" />
    213218                </p>
    214219<?php
    215220        }
     
    223228class WP_Widget_Search extends WP_Widget {
    224229
    225230        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.' ) );
    227232                parent::__construct( 'search', _x( 'Search', 'Search widget' ), $widget_ops );
    228233        }
    229234
     
    244249        }
    245250
    246251        public function form( $instance ) {
    247                 $instance = wp_parse_args( (array) $instance, array( 'title' => '') );
     252                $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
    248253                $title = $instance['title'];
    249254?>
    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>
    251256<?php
    252257        }
    253258
    254259        public function update( $new_instance, $old_instance ) {
    255260                $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'] );
    258263                return $instance;
    259264        }
    260265
     
    268273class WP_Widget_Archives extends WP_Widget {
    269274
    270275        public function __construct() {
    271                 $widget_ops = array('classname' => 'widget_archive', 'description' => __( 'A monthly archive of your site&#8217;s Posts.') );
    272                 parent::__construct('archives', __('Archives'), $widget_ops);
     276                $widget_ops = array( 'classname' => 'widget_archive', 'description' => __( 'A monthly archive of your site&#8217;s Posts.' ) );
     277                parent::__construct( 'archives', esc_html__( 'Archives' ), $widget_ops );
    273278        }
    274279
    275280        public function widget( $args, $instance ) {
     
    302307                        $dropdown_args = apply_filters( 'widget_archives_dropdown_args', array(
    303308                                'type'            => 'monthly',
    304309                                'format'          => 'option',
    305                                 'show_post_count' => $c
     310                                'show_post_count' => $c,
    306311                        ) );
    307312
    308313                        switch ( $dropdown_args['type'] ) {
     
    344349                 */
    345350                wp_get_archives( apply_filters( 'widget_archives_args', array(
    346351                        'type'            => 'monthly',
    347                         'show_post_count' => $c
     352                        'show_post_count' => $c,
    348353                ) ) );
    349354?>
    350355                </ul>
     
    356361
    357362        public function update( $new_instance, $old_instance ) {
    358363                $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'] );
    361366                $instance['count'] = $new_instance['count'] ? 1 : 0;
    362367                $instance['dropdown'] = $new_instance['dropdown'] ? 1 : 0;
    363368
     
    365370        }
    366371
    367372        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;
    372377?>
    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>
    374379                <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>
    376381                        <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>
    378383                </p>
    379384<?php
    380385        }
     
    390395class WP_Widget_Meta extends WP_Widget {
    391396
    392397        public function __construct() {
    393                 $widget_ops = array('classname' => 'widget_meta', 'description' => __( "Login, RSS, &amp; WordPress.org links.") );
    394                 parent::__construct('meta', __('Meta'), $widget_ops);
     398                $widget_ops = array( 'classname' => 'widget_meta', 'description' => esc_html__( 'Login, RSS, &amp; WordPress.org links.' ) );
     399                parent::__construct( 'meta', esc_html__( 'Meta' ), $widget_ops );
    395400        }
    396401
    397402        public function widget( $args, $instance ) {
     
    399404                /** This filter is documented in wp-includes/default-widgets.php */
    400405                $title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Meta' ) : $instance['title'], $instance, $this->id_base );
    401406
     407                /**
     408                 * Allowed html tags
     409                 */
     410                $allowed_tags = array(
     411                        'abbr' => array(
     412                                'title' => array()
     413                        )
     414                );
     415
    402416                echo $args['before_widget'];
    403417                if ( $title ) {
    404418                        echo $args['before_title'] . $title . $args['after_title'];
     
    407421                        <ul>
    408422                        <?php wp_register(); ?>
    409423                        <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>
    412426<?php
    413427                        /**
    414428                         * Filter the "Powered by WordPress" text in the Meta widget.
     
    432446
    433447        public function update( $new_instance, $old_instance ) {
    434448                $instance = $old_instance;
    435                 $instance['title'] = strip_tags($new_instance['title']);
     449                $instance['title'] = strip_tags( $new_instance['title'] );
    436450
    437451                return $instance;
    438452        }
     
    439453
    440454        public function form( $instance ) {
    441455                $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
    442                 $title = strip_tags($instance['title']);
     456                $title = strip_tags( $instance['title'] );
    443457?>
    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>
    445459<?php
    446460        }
    447461}
     
    454468class WP_Widget_Calendar extends WP_Widget {
    455469
    456470        public function __construct() {
    457                 $widget_ops = array('classname' => 'widget_calendar', 'description' => __( 'A calendar of your site&#8217;s Posts.') );
    458                 parent::__construct('calendar', __('Calendar'), $widget_ops);
     471                $widget_ops = array( 'classname' => 'widget_calendar', 'description' => __( 'A calendar of your site&#8217;s Posts.' ) );
     472                parent::__construct( 'calendar', esc_html__( 'Calendar' ), $widget_ops );
    459473        }
    460474
    461475        public function widget( $args, $instance ) {
     
    475489
    476490        public function update( $new_instance, $old_instance ) {
    477491                $instance = $old_instance;
    478                 $instance['title'] = strip_tags($new_instance['title']);
     492                $instance['title'] = strip_tags( $new_instance['title'] );
    479493
    480494                return $instance;
    481495        }
     
    482496
    483497        public function form( $instance ) {
    484498                $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
    485                 $title = strip_tags($instance['title']);
     499                $title = strip_tags( $instance['title'] );
    486500?>
    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>
    489503<?php
    490504        }
    491505}
     
    498512class WP_Widget_Text extends WP_Widget {
    499513
    500514        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 );
    504521        }
    505522
    506523        public function widget( $args, $instance ) {
     
    521538                if ( ! empty( $title ) ) {
    522539                        echo $args['before_title'] . $title . $args['after_title'];
    523540                } ?>
    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>
    525542                <?php
    526543                echo $args['after_widget'];
    527544        }
     
    528545
    529546        public function update( $new_instance, $old_instance ) {
    530547                $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                }
    536554                $instance['filter'] = ! empty( $new_instance['filter'] );
    537555                return $instance;
    538556        }
     
    539557
    540558        public function form( $instance ) {
    541559                $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'] );
    544561?>
    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>
    547564
    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>
    549566
    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); ?> />&nbsp;<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 ); ?> />&nbsp;<label for="<?php echo esc_attr( $this->get_field_id( 'filter' ) ); ?>"><?php esc_html_e( 'Automatically add paragraphs' ); ?></label></p>
    551568<?php
    552569        }
    553570}
     
    560577class WP_Widget_Categories extends WP_Widget {
    561578
    562579        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 );
    565582        }
    566583
    567584        public function widget( $args, $instance ) {
     
    581598                $cat_args = array(
    582599                        'orderby'      => 'name',
    583600                        'show_count'   => $c,
    584                         'hierarchical' => $h
     601                        'hierarchical' => $h,
    585602                );
    586603
    587604                if ( $d ) {
     
    592609
    593610                        echo '<label class="screen-reader-text" for="' . esc_attr( $dropdown_id ) . '">' . $title . '</label>';
    594611
    595                         $cat_args['show_option_none'] = __( 'Select Category' );
     612                        $cat_args['show_option_none'] = esc_html__( 'Select Category' );
    596613                        $cat_args['id'] = $dropdown_id;
    597614
    598615                        /**
     
    610627<script type='text/javascript'>
    611628/* <![CDATA[ */
    612629(function() {
    613         var dropdown = document.getElementById( "<?php echo esc_js( $dropdown_id ); ?>" );
     630        var dropdown = document.getElementById( "<?php echo wp_json_encode( $dropdown_id ); ?>" );
    614631        function onCatChange() {
    615632                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;
    617634                }
    618635        }
    619636        dropdown.onchange = onCatChange;
     
    646663
    647664        public function update( $new_instance, $old_instance ) {
    648665                $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;
    653670
    654671                return $instance;
    655672        }
     
    656673
    657674        public function form( $instance ) {
    658675                //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' => '' ) );
    661677                $count = isset($instance['count']) ? (bool) $instance['count'] :false;
    662678                $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false;
    663679                $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false;
    664680?>
    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>
    667683
    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 />
    670686
    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 />
    673689
    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>
    676692<?php
    677693        }
    678694
     
    686702class WP_Widget_Recent_Posts extends WP_Widget {
    687703
    688704        public function __construct() {
    689                 $widget_ops = array('classname' => 'widget_recent_entries', 'description' => __( "Your site&#8217;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&#8217;s most recent Posts.' ) );
     706                parent::__construct( 'recent-posts',esc_html__( 'Recent Posts' ), $widget_ops );
    691707                $this->alt_option_name = 'widget_recent_entries';
    692708
    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' ) );
    696712        }
    697713
    698714        public function widget($args, $instance) {
     
    722738                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    723739
    724740                $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5;
    725                 if ( ! $number )
     741                if ( ! $number ) {
    726742                        $number = 5;
     743                }
    727744                $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false;
    728745
    729746                /**
     
    739756                        'posts_per_page'      => $number,
    740757                        'no_found_rows'       => true,
    741758                        'post_status'         => 'publish',
    742                         'ignore_sticky_posts' => true
     759                        'ignore_sticky_posts' => true,
    743760                ) ) );
    744761
    745                 if ($r->have_posts()) :
     762                if ( $r->have_posts() ) :
    746763?>
    747764                <?php echo $args['before_widget']; ?>
    748                 <?php if ( $title ) {
     765                <?php
     766                if ( $title ) {
    749767                        echo $args['before_title'] . $title . $args['after_title'];
    750                 } ?>
     768                }?>
    751769                <ul>
    752770                <?php while ( $r->have_posts() ) : $r->the_post(); ?>
    753771                        <li>
     
    775793
    776794        public function update( $new_instance, $old_instance ) {
    777795                $instance = $old_instance;
    778                 $instance['title'] = strip_tags($new_instance['title']);
     796                $instance['title'] = strip_tags( $new_instance['title'] );
    779797                $instance['number'] = (int) $new_instance['number'];
    780798                $instance['show_date'] = isset( $new_instance['show_date'] ) ? (bool) $new_instance['show_date'] : false;
    781799                $this->flush_widget_cache();
    782800
    783801                $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                }
    786805
    787806                return $instance;
    788807        }
    789808
    790809        public function flush_widget_cache() {
    791                 wp_cache_delete('widget_recent_posts', 'widget');
     810                wp_cache_delete( 'widget_recent_posts', 'widget' );
    792811        }
    793812
    794813        public function form( $instance ) {
     
    796815                $number    = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
    797816                $show_date = isset( $instance['show_date'] ) ? (bool) $instance['show_date'] : false;
    798817?>
    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>
    801820
    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>
    804823
    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>
    807826<?php
    808827        }
    809828}
     
    816835class WP_Widget_Recent_Comments extends WP_Widget {
    817836
    818837        public function __construct() {
    819                 $widget_ops = array('classname' => 'widget_recent_comments', 'description' => __( 'Your site&#8217;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&#8217;s most recent comments.' ) );
     839                parent::__construct( 'recent-comments', esc_html__( 'Recent Comments' ), $widget_ops );
    821840                $this->alt_option_name = 'widget_recent_comments';
    822841
    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                }
    825845
    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' ) );
    829849        }
    830850
    831851        public function recent_comments_style() {
     
    839859                 * @param string $id_base The widget ID.
    840860                 */
    841861                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 ) ) {
    843863                        return;
     864                }
    844865                ?>
    845866        <style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>
    846867<?php
     
    847868        }
    848869
    849870        public function flush_widget_cache() {
    850                 wp_cache_delete('widget_recent_comments', 'widget');
     871                wp_cache_delete( 'widget_recent_comments', 'widget' );
    851872        }
    852873
    853874        public function widget( $args, $instance ) {
     
    855876
    856877                $cache = array();
    857878                if ( ! $this->is_preview() ) {
    858                         $cache = wp_cache_get('widget_recent_comments', 'widget');
     879                        $cache = wp_cache_get( 'widget_recent_comments', 'widget' );
    859880                }
    860881                if ( ! is_array( $cache ) ) {
    861882                        $cache = array();
    862883                }
    863884
    864                 if ( ! isset( $args['widget_id'] ) )
     885                if ( ! isset( $args['widget_id'] ) ) {
    865886                        $args['widget_id'] = $this->id;
     887                }
    866888
    867889                if ( isset( $cache[ $args['widget_id'] ] ) ) {
    868890                        echo $cache[ $args['widget_id'] ];
     
    877899                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    878900
    879901                $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5;
    880                 if ( ! $number )
     902                if ( ! $number ) {
    881903                        $number = 5;
     904                }
    882905
     906
    883907                /**
    884908                 * Filter the arguments for the Recent Comments widget.
    885909                 *
     
    892916                $comments = get_comments( apply_filters( 'widget_comments_args', array(
    893917                        'number'      => $number,
    894918                        'status'      => 'approve',
    895                         'post_status' => 'publish'
     919                        'post_status' => 'publish',
    896920                ) ) );
    897921
    898922                $output .= $args['before_widget'];
     
    906930                        $post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) );
    907931                        _prime_post_caches( $post_ids, strpos( get_option( 'permalink_structure' ), '%category%' ), false );
    908932
    909                         foreach ( (array) $comments as $comment) {
     933                        foreach ( (array) $comments as $comment ) {
    910934                                $output .= '<li class="recentcomments">';
    911935                                /* translators: comments widget: 1: comment author, 2: post link */
    912936                                $output .= sprintf( _x( '%1$s on %2$s', 'widgets' ),
     
    929953
    930954        public function update( $new_instance, $old_instance ) {
    931955                $instance = $old_instance;
    932                 $instance['title'] = strip_tags($new_instance['title']);
     956                $instance['title'] = strip_tags( $new_instance['title'] );
    933957                $instance['number'] = absint( $new_instance['number'] );
    934958                $this->flush_widget_cache();
    935959
    936960                $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                }
    939964
     965
    940966                return $instance;
    941967        }
    942968
    943969        public function form( $instance ) {
    944                 $title  = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
     970                $title  = isset( $instance['title'] ) ? $instance['title'] : '';
    945971                $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
    946972?>
    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>
    949975
    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>
    952978<?php
    953979        }
    954980}
     
    961987class WP_Widget_RSS extends WP_Widget {
    962988
    963989        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 );
    967996        }
    968997
    969998        public function widget($args, $instance) {
    970999
    971                 if ( isset($instance['error']) && $instance['error'] )
     1000                if ( isset( $instance['error'] ) && $instance['error'] ) {
    9721001                        return;
     1002                }
    9731003
    9741004                $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                }
    9771008
    978                 if ( empty($url) )
     1009                if ( empty( $url ) ) {
    9791010                        return;
     1011                }
    9801012
    9811013                // 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() ) ) ) {
    9831015                        return;
     1016                }
    9841017
    985                 $rss = fetch_feed($url);
     1018                $rss = fetch_feed( $url );
    9861019                $title = $instance['title'];
    9871020                $desc = '';
    9881021                $link = '';
    9891022
    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                        }
    9971033                }
    9981034
    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                }
    10011038
     1039
    10021040                /** This filter is documented in wp-includes/default-widgets.php */
    10031041                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    10041042
    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                }
    10091048
     1049
    10101050                echo $args['before_widget'];
    10111051                if ( $title ) {
    10121052                        echo $args['before_title'] . $title . $args['after_title'];
     
    10141054                wp_widget_rss_output( $rss, $instance );
    10151055                echo $args['after_widget'];
    10161056
    1017                 if ( ! is_wp_error($rss) )
     1057                if ( ! is_wp_error( $rss ) ) {
    10181058                        $rss->__destruct();
     1059                }
     1060
    10191061                unset($rss);
    10201062        }
    10211063
    10221064        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'] ) ) );
    10241066                return wp_widget_rss_process( $new_instance, $testurl );
    10251067        }
    10261068
    10271069        public function form($instance) {
    10281070
    1029                 if ( empty($instance) )
     1071                if ( empty( $instance ) ) {
    10301072                        $instance = array( 'title' => '', 'url' => '', 'items' => 10, 'error' => false, 'show_summary' => 0, 'show_author' => 0, 'show_date' => 0 );
     1073                }
     1074
    10311075                $instance['number'] = $this->number;
    10321076
    10331077                wp_widget_rss_form( $instance );
     
    10441088 */
    10451089function wp_widget_rss_output( $rss, $args = array() ) {
    10461090        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'] ) ) {
    10491093                $args = $rss;
    1050                 $rss = fetch_feed($rss['url']);
    1051         } elseif ( !is_object($rss) ) {
     1094                $rss = fetch_feed( $rss['url'] );
     1095        } elseif ( ! is_object( $rss ) ) {
    10521096                return;
    10531097        }
    10541098
    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
    10581104                return;
    10591105        }
    10601106
     
    10621108        $args = wp_parse_args( $args, $default_args );
    10631109
    10641110        $items = (int) $args['items'];
    1065         if ( $items < 1 || 20 < $items )
     1111        if ( $items < 1 || 20 < $items ) {
    10661112                $items = 10;
     1113        }
     1114
    10671115        $show_summary  = (int) $args['show_summary'];
    10681116        $show_author   = (int) $args['show_author'];
    10691117        $show_date     = (int) $args['show_date'];
    10701118
    1071         if ( !$rss->get_item_quantity() ) {
     1119        if ( ! $rss->get_item_quantity() ) {
    10721120                echo '<ul><li>' . __( 'An error has occurred, which probably means the feed is down. Try again later.' ) . '</li></ul>';
    10731121                $rss->__destruct();
    10741122                unset($rss);
     
    11151163                $author = '';
    11161164                if ( $show_author ) {
    11171165                        $author = $item->get_author();
    1118                         if ( is_object($author) ) {
     1166                        if ( is_object( $author ) ) {
    11191167                                $author = $author->get_name();
    11201168                                $author = ' <cite>' . esc_html( strip_tags( $author ) ) . '</cite>';
    11211169                        }
     
    11691217
    11701218        if ( $inputs['url'] ) :
    11711219?>
    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>
    11741222<?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>
    11771225<?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]">
    11801228<?php
    11811229                for ( $i = 1; $i <= 20; ++$i ) {
    11821230                        echo "<option value='$i' " . selected( $args['items'], $i, false ) . ">$i</option>";
     
    11841232?>
    11851233        </select></p>
    11861234<?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>
    11891237<?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>
    11921240<?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>
    11951243<?php
    11961244        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 ] ) :
    11991247                        $id = str_replace( '_', '-', $input );
    12001248?>
    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 ] ); ?>" />
    12021250<?php
    12031251                endif;
    12041252        endforeach;
     
    12221270 */
    12231271function wp_widget_rss_process( $widget_rss, $check_feed = true ) {
    12241272        $items = (int) $widget_rss['items'];
    1225         if ( $items < 1 || 20 < $items )
     1273        if ( $items < 1 || 20 < $items ) {
    12261274                $items = 10;
     1275        }
     1276
    12271277        $url           = esc_url_raw( strip_tags( $widget_rss['url'] ) );
    12281278        $title         = isset( $widget_rss['title'] ) ? trim( strip_tags( $widget_rss['title'] ) ) : '';
    12291279        $show_summary  = isset( $widget_rss['show_summary'] ) ? (int) $widget_rss['show_summary'] : 0;
     
    12311281        $show_date     = isset( $widget_rss['show_date'] ) ? (int) $widget_rss['show_date'] : 0;
    12321282
    12331283        if ( $check_feed ) {
    1234                 $rss = fetch_feed($url);
     1284                $rss = fetch_feed( $url );
    12351285                $error = false;
    12361286                $link = '';
    1237                 if ( is_wp_error($rss) ) {
     1287                if ( is_wp_error( $rss ) ) {
    12381288                        $error = $rss->get_error_message();
    12391289                } 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                        }
    12431294
    12441295                        $rss->__destruct();
    12451296                        unset($rss);
     
    12571308class WP_Widget_Tag_Cloud extends WP_Widget {
    12581309
    12591310        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 );
    12621313        }
    12631314
    12641315        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'] ) ) {
    12671318                        $title = $instance['title'];
    12681319                } else {
    12691320                        if ( 'post_tag' == $current_taxonomy ) {
    1270                                 $title = __('Tags');
     1321                                $title = esc_html__( 'Tags' );
    12711322                        } else {
    1272                                 $tax = get_taxonomy($current_taxonomy);
     1323                                $tax = get_taxonomy( $current_taxonomy );
    12731324                                $title = $tax->labels->name;
    12741325                        }
    12751326                }
     
    12941345                 * @param array $current_taxonomy The taxonomy to use in the tag cloud. Default 'tags'.
    12951346                 */
    12961347                wp_tag_cloud( apply_filters( 'widget_tag_cloud_args', array(
    1297                         'taxonomy' => $current_taxonomy
     1348                        'taxonomy' => $current_taxonomy,
    12981349                ) ) );
    12991350
    13001351                echo "</div>\n";
     
    13031354
    13041355        public function update( $new_instance, $old_instance ) {
    13051356                $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'] );
    13081359                return $instance;
    13091360        }
    13101361
    13111362        public function form( $instance ) {
    1312                 $current_taxonomy = $this->_get_current_taxonomy($instance);
     1363                $current_taxonomy = $this->_get_current_taxonomy( $instance );
    13131364?>
    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' ) ); ?>">
    13181369        <?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
    13221375        ?>
    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>
    13241377        <?php endforeach; ?>
    13251378        </select></p><?php
    13261379        }
    13271380
    13281381        public function _get_current_taxonomy($instance) {
    1329                 if ( !empty($instance['taxonomy']) && taxonomy_exists($instance['taxonomy']) )
     1382                if ( ! empty( $instance['taxonomy'] ) && taxonomy_exists( $instance['taxonomy'] ) ) {
    13301383                        return $instance['taxonomy'];
     1384                }
    13311385
     1386
    13321387                return 'post_tag';
    13331388        }
    13341389}
     
    13381393 *
    13391394 * @since 3.0.0
    13401395 */
    1341  class WP_Nav_Menu_Widget extends WP_Widget {
     1396class WP_Nav_Menu_Widget extends WP_Widget {
    13421397
    13431398        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 );
    13461401        }
    13471402
    13481403        public function widget($args, $instance) {
     
    13491404                // Get menu
    13501405                $nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false;
    13511406
    1352                 if ( !$nav_menu )
     1407                if ( ! $nav_menu ) {
    13531408                        return;
     1409                }
    13541410
     1411
    13551412                /** This filter is documented in wp-includes/default-widgets.php */
    13561413                $instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
    13571414
    13581415                echo $args['before_widget'];
    13591416
    1360                 if ( !empty($instance['title']) )
     1417                if ( ! empty( $instance['title'] ) ) {
    13611418                        echo $args['before_title'] . $instance['title'] . $args['after_title'];
     1419                }
    13621420
     1421
    13631422                $nav_menu_args = array(
    13641423                        'fallback_cb' => '',
    1365                         'menu'        => $nav_menu
     1424                        'menu'        => $nav_menu,
    13661425                );
    13671426
    13681427                /**
     
    13871446        public function update( $new_instance, $old_instance ) {
    13881447                $instance = array();
    13891448                if ( ! empty( $new_instance['title'] ) ) {
    1390                         $instance['title'] = strip_tags( stripslashes($new_instance['title']) );
     1449                        $instance['title'] = strip_tags( stripslashes( $new_instance['title'] ) );
    13911450                }
    13921451                if ( ! empty( $new_instance['nav_menu'] ) ) {
    13931452                        $instance['nav_menu'] = (int) $new_instance['nav_menu'];
     
    14031462                $menus = wp_get_nav_menus();
    14041463
    14051464                // 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>';
    14081467                        return;
    14091468                }
    14101469                ?>
    14111470                <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 ); ?>" />
    14141473                </p>
    14151474                <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' ) ); ?>">
    14181477                                <option value="0"><?php _e( '&mdash; Select &mdash;' ) ?></option>
    14191478                <?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                }
    14251484                ?>
    14261485                        </select>
    14271486                </p>
     
    14381497 * @since 2.2.0
    14391498 */
    14401499function wp_widgets_init() {
    1441         if ( !is_blog_installed() )
     1500        if ( ! is_blog_installed() ) {
    14421501                return;
     1502        }
    14431503
    1444         register_widget('WP_Widget_Pages');
     1504        register_widget( 'WP_Widget_Pages' );
    14451505
    1446         register_widget('WP_Widget_Calendar');
     1506        register_widget( 'WP_Widget_Calendar' );
    14471507
    1448         register_widget('WP_Widget_Archives');
     1508        register_widget( 'WP_Widget_Archives' );
    14491509
    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        }
    14521513
    1453         register_widget('WP_Widget_Meta');
    14541514
    1455         register_widget('WP_Widget_Search');
     1515        register_widget( 'WP_Widget_Meta' );
    14561516
    1457         register_widget('WP_Widget_Text');
     1517        register_widget( 'WP_Widget_Search' );
    14581518
    1459         register_widget('WP_Widget_Categories');
     1519        register_widget( 'WP_Widget_Text' );
    14601520
    1461         register_widget('WP_Widget_Recent_Posts');
     1521        register_widget( 'WP_Widget_Categories' );
    14621522
    1463         register_widget('WP_Widget_Recent_Comments');
     1523        register_widget( 'WP_Widget_Recent_Posts' );
    14641524
    1465         register_widget('WP_Widget_RSS');
     1525        register_widget( 'WP_Widget_Recent_Comments' );
    14661526
    1467         register_widget('WP_Widget_Tag_Cloud');
     1527        register_widget( 'WP_Widget_RSS' );
    14681528
    1469         register_widget('WP_Nav_Menu_Widget');
     1529        register_widget( 'WP_Widget_Tag_Cloud' );
    14701530
     1531        register_widget( 'WP_Nav_Menu_Widget' );
     1532
    14711533        /**
    14721534         * Fires after all default WordPress widgets have been registered.
    14731535         *
     
    14761538        do_action( 'widgets_init' );
    14771539}
    14781540
    1479 add_action('init', 'wp_widgets_init', 1);
     1541add_action( 'init', 'wp_widgets_init', 1 );
     1542 No newline at end of file