Make WordPress Core

Ticket #23012: 23012.4.diff

File 23012.4.diff, 66.7 KB (added by welcher, 11 years ago)

Post 4.3 patch refresh

  • 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(
     18                        'classname'   => 'widget_pages',
     19                        'description' => __( 'A list of your site’s Pages.' ),
     20                );
     21                parent::__construct( 'pages', __( 'Pages' ), $widget_ops );
    1922        }
    2023
    2124        /**
     
    3336                 * @param array  $instance An array of the widget's settings.
    3437                 * @param mixed  $id_base  The widget ID.
    3538                 */
    36                 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Pages' ) : $instance['title'], $instance, $this->id_base );
     39                $title      = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Pages' ) : $instance['title'], $instance, $this->id_base );
     40                $sortby     = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby'];
     41                $exclude    = empty( $instance['exclude'] ) ? '' : $instance['exclude'];
    3742
    38                 $sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby'];
    39                 $exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude'];
    40 
    41                 if ( $sortby == 'menu_order' )
     43                if ( 'menu_order' === $sortby ) {
    4244                        $sortby = 'menu_order, post_title';
     45                }
    4346
    4447                /**
    4548                 * Filter the arguments for the Pages widget.
     
    5457                        'title_li'    => '',
    5558                        'echo'        => 0,
    5659                        'sort_column' => $sortby,
    57                         'exclude'     => $exclude
     60                        'exclude'     => $exclude,
    5861                ) ) );
    5962
    6063                if ( ! empty( $out ) ) {
     
    7780         * @return array
    7881         */
    7982        public function update( $new_instance, $old_instance ) {
    80                 $instance = $old_instance;
    81                 $instance['title'] = strip_tags($new_instance['title']);
     83                $instance          = $old_instance;
     84                $instance['title'] = sanitize_text_field( $new_instance['title'] );
    8285                if ( in_array( $new_instance['sortby'], array( 'post_title', 'menu_order', 'ID' ) ) ) {
    8386                        $instance['sortby'] = $new_instance['sortby'];
    8487                } else {
     
    8588                        $instance['sortby'] = 'menu_order';
    8689                }
    8790
    88                 $instance['exclude'] = strip_tags( $new_instance['exclude'] );
     91                $instance['exclude'] = sanitize_text_field( $new_instance['exclude'] );
    8992
    9093                return $instance;
    9194        }
     
    9598         */
    9699        public function form( $instance ) {
    97100                //Defaults
    98                 $instance = wp_parse_args( (array) $instance, array( 'sortby' => 'post_title', 'title' => '', 'exclude' => '') );
    99                 $title = esc_attr( $instance['title'] );
    100                 $exclude = esc_attr( $instance['exclude'] );
     101                $instance   = wp_parse_args( (array) $instance, array( 'sortby' => 'post_title', 'title' => '', 'exclude' => '' ) );
     102                $title      = $instance['title'];
     103                $exclude    = $instance['exclude'];
    101104        ?>
    102                 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
     105                <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p>
    103106                <p>
    104                         <label for="<?php echo $this->get_field_id('sortby'); ?>"><?php _e( 'Sort by:' ); ?></label>
    105                         <select name="<?php echo $this->get_field_name('sortby'); ?>" id="<?php echo $this->get_field_id('sortby'); ?>" class="widefat">
    106                                 <option value="post_title"<?php selected( $instance['sortby'], 'post_title' ); ?>><?php _e('Page title'); ?></option>
    107                                 <option value="menu_order"<?php selected( $instance['sortby'], 'menu_order' ); ?>><?php _e('Page order'); ?></option>
     107                        <label for="<?php echo esc_attr( $this->get_field_id( 'sortby' ) ); ?>"><?php _e( 'Sort by:' ); ?></label>
     108                        <select name="<?php echo esc_attr( $this->get_field_name( 'sortby' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'sortby' ) ); ?>" class="widefat">
     109                                <option value="post_title"<?php selected( $instance['sortby'], 'post_title' ); ?>><?php _e( 'Page title' ); ?></option>
     110                                <option value="menu_order"<?php selected( $instance['sortby'], 'menu_order' ); ?>><?php _e( 'Page order' ); ?></option>
    108111                                <option value="ID"<?php selected( $instance['sortby'], 'ID' ); ?>><?php _e( 'Page ID' ); ?></option>
    109112                        </select>
    110113                </p>
    111114                <p>
    112                         <label for="<?php echo $this->get_field_id('exclude'); ?>"><?php _e( 'Exclude:' ); ?></label> <input type="text" value="<?php echo $exclude; ?>" name="<?php echo $this->get_field_name('exclude'); ?>" id="<?php echo $this->get_field_id('exclude'); ?>" class="widefat" />
     115                        <label for="<?php echo esc_attr( $this->get_field_id( 'exclude' ) ); ?>"><?php _e( 'Exclude:' ); ?></label> <input type="text" value="<?php echo esc_attr( $exclude ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'exclude' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'exclude' ) ); ?>" class="widefat" />
    113116                        <br />
    114117                        <small><?php _e( 'Page IDs, separated by commas.' ); ?></small>
    115118                </p>
     
    126129class WP_Widget_Links extends WP_Widget {
    127130
    128131        public function __construct() {
    129                 $widget_ops = array('description' => __( "Your blogroll" ) );
    130                 parent::__construct('links', __('Links'), $widget_ops);
     132                $widget_ops = array(
     133                        'description' => __( 'Your blogroll' ),
     134                );
     135                parent::__construct( 'links', __( 'Links' ), $widget_ops );
    131136        }
    132137
    133138        /**
     
    136141         */
    137142        public function widget( $args, $instance ) {
    138143                $show_description = isset($instance['description']) ? $instance['description'] : false;
    139                 $show_name = isset($instance['name']) ? $instance['name'] : false;
    140                 $show_rating = isset($instance['rating']) ? $instance['rating'] : false;
    141                 $show_images = isset($instance['images']) ? $instance['images'] : true;
    142                 $category = isset($instance['category']) ? $instance['category'] : false;
    143                 $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name';
    144                 $order = $orderby == 'rating' ? 'DESC' : 'ASC';
    145                 $limit = isset( $instance['limit'] ) ? $instance['limit'] : -1;
     144                $show_name        = isset($instance['name']) ? $instance['name'] : false;
     145                $show_rating      = isset($instance['rating']) ? $instance['rating'] : false;
     146                $show_images      = isset($instance['images']) ? $instance['images'] : true;
     147                $category         = isset($instance['category']) ? $instance['category'] : false;
     148                $orderby          = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name';
     149                $order            = ( 'rating' === $orderby ) ? 'DESC' : 'ASC';
     150                $limit            = isset( $instance['limit'] ) ? $instance['limit'] : -1;
    146151
    147152                $before_widget = preg_replace( '/id="[^"]*"/', 'id="%id"', $args['before_widget'] );
    148153
     
    156161                 * @param array $args An array of arguments to retrieve the links list.
    157162                 */
    158163                wp_list_bookmarks( apply_filters( 'widget_links_args', array(
    159                         'title_before' => $args['before_title'], 'title_after' => $args['after_title'],
    160                         'category_before' => $before_widget, 'category_after' => $args['after_widget'],
    161                         'show_images' => $show_images, 'show_description' => $show_description,
    162                         'show_name' => $show_name, 'show_rating' => $show_rating,
    163                         'category' => $category, 'class' => 'linkcat widget',
    164                         'orderby' => $orderby, 'order' => $order,
    165                         'limit' => $limit,
     164                        'title_before'     => $args['before_title'],
     165                        'title_after'      => $args['after_title'],
     166                        'category_before'  => $before_widget,
     167                        'category_after'   => $args['after_widget'],
     168                        'show_images'      => $show_images,
     169                        'show_description' => $show_description,
     170                        'show_name'        => $show_name,
     171                        'show_rating'      => $show_rating,
     172                        'category'         => $category,
     173                        'class'            => 'linkcat widget',
     174                        'orderby'          => $orderby,
     175                        'order'            => $order,
     176                        'limit'            => $limit,
    166177                ) ) );
    167178        }
    168179
     
    173184         */
    174185        public function update( $new_instance, $old_instance ) {
    175186                $new_instance = (array) $new_instance;
    176                 $instance = array( 'images' => 0, 'name' => 0, 'description' => 0, 'rating' => 0 );
     187                $instance = array(
     188                        'images'      => 0,
     189                        'name'        => 0,
     190                        'description' => 0,
     191                        'rating'      => 0,
     192                );
    177193                foreach ( $instance as $field => $val ) {
    178                         if ( isset($new_instance[$field]) )
    179                                 $instance[$field] = 1;
     194                        if ( isset( $new_instance[ $field ]) ) {
     195                                $instance[ $field ] = 1;
     196                        }
    180197                }
    181198
    182199                $instance['orderby'] = 'name';
    183                 if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) )
     200                if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) ) {
    184201                        $instance['orderby'] = $new_instance['orderby'];
     202                }
    185203
    186204                $instance['category'] = intval( $new_instance['category'] );
    187205                $instance['limit'] = ! empty( $new_instance['limit'] ) ? intval( $new_instance['limit'] ) : -1;
     
    195213        public function form( $instance ) {
    196214
    197215                //Defaults
    198                 $instance = wp_parse_args( (array) $instance, array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false, 'category' => false, 'orderby' => 'name', 'limit' => -1 ) );
     216                $instance = wp_parse_args( (array) $instance, array(
     217                        'images'      => true,
     218                        'name'        => true,
     219                        'description' => false,
     220                        'rating'      => false,
     221                        'category'    => false,
     222                        'orderby'     => 'name',
     223                        'limit'       => -1,
     224                        )
     225                );
    199226                $link_cats = get_terms( 'link_category' );
    200                 if ( ! $limit = intval( $instance['limit'] ) )
     227                if ( ! $limit = intval( $instance['limit'] ) ) {
    201228                        $limit = -1;
     229                }
    202230?>
    203231                <p>
    204                 <label for="<?php echo $this->get_field_id('category'); ?>"><?php _e( 'Select Link Category:' ); ?></label>
    205                 <select class="widefat" id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>">
    206                 <option value=""><?php _ex('All Links', 'links widget'); ?></option>
     232                <label for="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>"><?php _e( 'Select Link Category:' ); ?></label>
     233                <select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'category' ) ); ?>">
     234                <option value=""><?php _ex( 'All Links', 'links widget' ); ?></option>
    207235                <?php
    208236                foreach ( $link_cats as $link_cat ) {
    209237                        echo '<option value="' . intval( $link_cat->term_id ) . '"'
     
    212240                }
    213241                ?>
    214242                </select>
    215                 <label for="<?php echo $this->get_field_id('orderby'); ?>"><?php _e( 'Sort by:' ); ?></label>
    216                 <select name="<?php echo $this->get_field_name('orderby'); ?>" id="<?php echo $this->get_field_id('orderby'); ?>" class="widefat">
     243                <label for="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>"><?php _e( 'Sort by:' ); ?></label>
     244                <select name="<?php echo esc_attr( $this->get_field_name( 'orderby' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>" class="widefat">
    217245                        <option value="name"<?php selected( $instance['orderby'], 'name' ); ?>><?php _e( 'Link title' ); ?></option>
    218246                        <option value="rating"<?php selected( $instance['orderby'], 'rating' ); ?>><?php _e( 'Link rating' ); ?></option>
    219247                        <option value="id"<?php selected( $instance['orderby'], 'id' ); ?>><?php _e( 'Link ID' ); ?></option>
     
    221249                </select>
    222250                </p>
    223251                <p>
    224                 <input class="checkbox" type="checkbox" <?php checked($instance['images'], true) ?> id="<?php echo $this->get_field_id('images'); ?>" name="<?php echo $this->get_field_name('images'); ?>" />
    225                 <label for="<?php echo $this->get_field_id('images'); ?>"><?php _e('Show Link Image'); ?></label><br />
    226                 <input class="checkbox" type="checkbox" <?php checked($instance['name'], true) ?> id="<?php echo $this->get_field_id('name'); ?>" name="<?php echo $this->get_field_name('name'); ?>" />
    227                 <label for="<?php echo $this->get_field_id('name'); ?>"><?php _e('Show Link Name'); ?></label><br />
    228                 <input class="checkbox" type="checkbox" <?php checked($instance['description'], true) ?> id="<?php echo $this->get_field_id('description'); ?>" name="<?php echo $this->get_field_name('description'); ?>" />
    229                 <label for="<?php echo $this->get_field_id('description'); ?>"><?php _e('Show Link Description'); ?></label><br />
    230                 <input class="checkbox" type="checkbox" <?php checked($instance['rating'], true) ?> id="<?php echo $this->get_field_id('rating'); ?>" name="<?php echo $this->get_field_name('rating'); ?>" />
    231                 <label for="<?php echo $this->get_field_id('rating'); ?>"><?php _e('Show Link Rating'); ?></label>
     252                <input class="checkbox" type="checkbox" <?php checked( $instance['images'], true ) ?> id="<?php echo esc_attr( $this->get_field_id( 'images' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'images' ) ); ?>" />
     253                <label for="<?php echo esc_attr( $this->get_field_id( 'images' ) ); ?>"><?php _e( 'Show Link Image' ); ?></label><br />
     254                <input class="checkbox" type="checkbox" <?php checked( $instance['name'], true ) ?> id="<?php echo esc_attr( $this->get_field_id( 'name' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'name' ) ); ?>" />
     255                <label for="<?php echo esc_attr( $this->get_field_id( 'name' ) ); ?>"><?php _e( 'Show Link Name' ); ?></label><br />
     256                <input class="checkbox" type="checkbox" <?php checked( $instance['description'], true ) ?> id="<?php echo esc_attr( $this->get_field_id( 'description' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'description' ) ); ?>" />
     257                <label for="<?php echo esc_attr( $this->get_field_id( 'description' ) ); ?>"><?php _e( 'Show Link Description' ); ?></label><br />
     258                <input class="checkbox" type="checkbox" <?php checked( $instance['rating'], true ) ?> id="<?php echo esc_attr( $this->get_field_id( 'rating' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'rating' ) ); ?>" />
     259                <label for="<?php echo esc_attr( $this->get_field_id( 'rating' ) ); ?>"><?php _e( 'Show Link Rating' ); ?></label>
    232260                </p>
    233261                <p>
    234                 <label for="<?php echo $this->get_field_id('limit'); ?>"><?php _e( 'Number of links to show:' ); ?></label>
    235                 <input id="<?php echo $this->get_field_id('limit'); ?>" name="<?php echo $this->get_field_name('limit'); ?>" type="text" value="<?php echo $limit == -1 ? '' : intval( $limit ); ?>" size="3" />
     262                <label for="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>"><?php _e( 'Number of links to show:' ); ?></label>
     263                <input id="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'limit' ) ); ?>" type="text" value="<?php echo $limit == -1 ? '' : intval( $limit ); ?>" size="3" />
    236264                </p>
    237265<?php
    238266        }
     
    246274class WP_Widget_Search extends WP_Widget {
    247275
    248276        public function __construct() {
    249                 $widget_ops = array('classname' => 'widget_search', 'description' => __( "A search form for your site.") );
     277                $widget_ops = array(
     278                        'classname'   => 'widget_search',
     279                        'description' => __( 'A search form for your site.' ),
     280                );
    250281                parent::__construct( 'search', _x( 'Search', 'Search widget' ), $widget_ops );
    251282        }
    252283
     
    273304         * @param array $instance
    274305         */
    275306        public function form( $instance ) {
    276                 $instance = wp_parse_args( (array) $instance, array( 'title' => '') );
     307                $instance = wp_parse_args( (array) $instance, array(
     308                        'title' => '',
     309                        )
     310                );
    277311                $title = $instance['title'];
    278312?>
    279                 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p>
     313                <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></label></p>
    280314<?php
    281315        }
    282316
     
    286320         * @return array
    287321         */
    288322        public function update( $new_instance, $old_instance ) {
    289                 $instance = $old_instance;
    290                 $new_instance = wp_parse_args((array) $new_instance, array( 'title' => ''));
    291                 $instance['title'] = strip_tags($new_instance['title']);
     323                $instance     = $old_instance;
     324                $new_instance = wp_parse_args( (array) $new_instance, array(
     325                        'title' => '',
     326                        )
     327                );
     328                $instance['title'] = sanitize_text_field( $new_instance['title'] );
    292329                return $instance;
    293330        }
    294331
     
    302339class WP_Widget_Archives extends WP_Widget {
    303340
    304341        public function __construct() {
    305                 $widget_ops = array('classname' => 'widget_archive', 'description' => __( 'A monthly archive of your site&#8217;s Posts.') );
    306                 parent::__construct('archives', __('Archives'), $widget_ops);
     342                $widget_ops = array(
     343                        'classname'   => 'widget_archive',
     344                        'description' => __( 'A monthly archive of your site&#8217;s Posts.' ),
     345                );
     346                parent::__construct( 'archives', __( 'Archives' ), $widget_ops );
    307347        }
    308348
    309349        /**
     
    340380                        $dropdown_args = apply_filters( 'widget_archives_dropdown_args', array(
    341381                                'type'            => 'monthly',
    342382                                'format'          => 'option',
    343                                 'show_post_count' => $c
     383                                'show_post_count' => $c,
    344384                        ) );
    345385
    346386                        switch ( $dropdown_args['type'] ) {
     
    382422                 */
    383423                wp_get_archives( apply_filters( 'widget_archives_args', array(
    384424                        'type'            => 'monthly',
    385                         'show_post_count' => $c
     425                        'show_post_count' => $c,
    386426                ) ) );
    387427?>
    388428                </ul>
     
    398438         * @return array
    399439         */
    400440        public function update( $new_instance, $old_instance ) {
    401                 $instance = $old_instance;
    402                 $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') );
    403                 $instance['title'] = strip_tags($new_instance['title']);
    404                 $instance['count'] = $new_instance['count'] ? 1 : 0;
     441                $instance     = $old_instance;
     442                $new_instance = wp_parse_args( (array) $new_instance, array(
     443                        'title'    => '',
     444                        'count'    => 0,
     445                        'dropdown' => '',
     446                        )
     447                );
     448                $instance['title']    = sanitize_text_field( $new_instance['title'] );
     449                $instance['count']    = $new_instance['count'] ? 1 : 0;
    405450                $instance['dropdown'] = $new_instance['dropdown'] ? 1 : 0;
    406451
    407452                return $instance;
     
    411456         * @param array $instance
    412457         */
    413458        public function form( $instance ) {
    414                 $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') );
    415                 $title = strip_tags($instance['title']);
    416                 $count = $instance['count'] ? 'checked="checked"' : '';
    417                 $dropdown = $instance['dropdown'] ? 'checked="checked"' : '';
     459                $instance = wp_parse_args( (array) $instance, array(
     460                        'title'    => '',
     461                        'count'    => 0,
     462                        'dropdown' => '',
     463                        )
     464                );
     465                $title    = $instance['title'];
     466                $count    = $instance['count'] ? true : false;
     467                $dropdown = $instance['dropdown'] ? true : false;
    418468?>
    419                 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
     469                <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p>
    420470                <p>
    421                         <input class="checkbox" type="checkbox" <?php echo $dropdown; ?> id="<?php echo $this->get_field_id('dropdown'); ?>" name="<?php echo $this->get_field_name('dropdown'); ?>" /> <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e('Display as dropdown'); ?></label>
     471                        <input class="checkbox" type="checkbox" <?php checked( true, $dropdown ); ?> id="<?php echo esc_attr( $this->get_field_id( 'dropdown' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'dropdown' ) ); ?>" /> <label for="<?php echo esc_attr( $this->get_field_id( 'dropdown' ) ); ?>"><?php _e( 'Display as dropdown' ); ?></label>
    422472                        <br/>
    423                         <input class="checkbox" type="checkbox" <?php echo $count; ?> id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>" /> <label for="<?php echo $this->get_field_id('count'); ?>"><?php _e('Show post counts'); ?></label>
     473                        <input class="checkbox" type="checkbox" <?php checked( true, $count ); ?> id="<?php echo esc_attr( $this->get_field_id( 'count' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'count' ) ); ?>" /> <label for="<?php echo esc_attr( $this->get_field_id( 'count' ) ); ?>"><?php _e( 'Show post counts' ); ?></label>
    424474                </p>
    425475<?php
    426476        }
     
    436486class WP_Widget_Meta extends WP_Widget {
    437487
    438488        public function __construct() {
    439                 $widget_ops = array('classname' => 'widget_meta', 'description' => __( "Login, RSS, &amp; WordPress.org links.") );
    440                 parent::__construct('meta', __('Meta'), $widget_ops);
     489                $widget_ops = array(
     490                        'classname'   => 'widget_meta',
     491                        'description' => __( 'Login, RSS, &amp; WordPress.org links.' ),
     492                );
     493                parent::__construct( 'meta', __( 'Meta' ), $widget_ops );
    441494        }
    442495
    443496        /**
     
    456509                        <ul>
    457510                        <?php wp_register(); ?>
    458511                        <li><?php wp_loginout(); ?></li>
    459                         <li><a href="<?php bloginfo('rss2_url'); ?>"><?php _e('Entries <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
    460                         <li><a href="<?php bloginfo('comments_rss2_url'); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
     512                        <li><a href="<?php echo esc_url( get_bloginfo( 'rss2_url' ) ); ?>"><?php _e( 'Entries <abbr title="Really Simple Syndication">RSS</abbr>' ); ?></a></li>
     513                        <li><a href="<?php echo esc_url( get_bloginfo( 'comments_rss2_url' ) ); ?>"><?php _e( 'Comments <abbr title="Really Simple Syndication">RSS</abbr>' ); ?></a></li>
    461514<?php
    462515                        /**
    463516                         * Filter the "Powered by WordPress" text in the Meta widget.
     
    485538         * @return array
    486539         */
    487540        public function update( $new_instance, $old_instance ) {
    488                 $instance = $old_instance;
    489                 $instance['title'] = strip_tags($new_instance['title']);
     541                $instance          = $old_instance;
     542                $instance['title'] = sanitize_text_field( $new_instance['title'] );
    490543
    491544                return $instance;
    492545        }
     
    495548         * @param array $instance
    496549         */
    497550        public function form( $instance ) {
    498                 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
    499                 $title = strip_tags($instance['title']);
     551                $instance = wp_parse_args( (array) $instance, array(
     552                        'title' => '',
     553                        )
     554                );
     555                $title = $instance['title'];
    500556?>
    501                         <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
     557                        <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p>
    502558<?php
    503559        }
    504560}
     
    511567class WP_Widget_Calendar extends WP_Widget {
    512568
    513569        public function __construct() {
    514                 $widget_ops = array('classname' => 'widget_calendar', 'description' => __( 'A calendar of your site&#8217;s Posts.') );
    515                 parent::__construct('calendar', __('Calendar'), $widget_ops);
     570                $widget_ops = array(
     571                        'classname'   => 'widget_calendar',
     572                        'description' => __( 'A calendar of your site&#8217;s Posts.' ),
     573                );
     574                parent::__construct( 'calendar', __( 'Calendar' ), $widget_ops );
    516575        }
    517576
    518577        /**
     
    539598         * @return array
    540599         */
    541600        public function update( $new_instance, $old_instance ) {
    542                 $instance = $old_instance;
    543                 $instance['title'] = strip_tags($new_instance['title']);
     601                $instance          = $old_instance;
     602                $instance['title'] = sanitize_text_field( $new_instance['title'] );
    544603
    545604                return $instance;
    546605        }
     
    549608         * @param array $instance
    550609         */
    551610        public function form( $instance ) {
    552                 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
    553                 $title = strip_tags($instance['title']);
     611                $instance = wp_parse_args( (array) $instance, array(
     612                        'title' => '',
     613                        )
     614                );
     615                $title = $instance['title'];
    554616?>
    555                 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
    556                 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
     617                <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label>
     618                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p>
    557619<?php
    558620        }
    559621}
     
    566628class WP_Widget_Text extends WP_Widget {
    567629
    568630        public function __construct() {
    569                 $widget_ops = array('classname' => 'widget_text', 'description' => __('Arbitrary text or HTML.'));
    570                 $control_ops = array('width' => 400, 'height' => 350);
    571                 parent::__construct('text', __('Text'), $widget_ops, $control_ops);
     631                $widget_ops = array(
     632                        'classname'   => 'widget_text',
     633                        'description' => __( 'Arbitrary text or HTML.' ),
     634                );
     635                $control_ops = array(
     636                        'width'  => 400,
     637                        'height' => 350,
     638                );
     639                parent::__construct( 'text', __( 'Text' ), $widget_ops, $control_ops );
    572640        }
    573641
    574642        /**
     
    592660                if ( ! empty( $title ) ) {
    593661                        echo $args['before_title'] . $title . $args['after_title'];
    594662                } ?>
    595                         <div class="textwidget"><?php echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div>
     663                        <div class="textwidget"><?php echo ! empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div>
    596664                <?php
    597665                echo $args['after_widget'];
    598666        }
     
    603671         * @return array
    604672         */
    605673        public function update( $new_instance, $old_instance ) {
    606                 $instance = $old_instance;
    607                 $instance['title'] = strip_tags($new_instance['title']);
    608                 if ( current_user_can('unfiltered_html') )
    609                         $instance['text'] =  $new_instance['text'];
    610                 else
    611                         $instance['text'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text']) ) ); // wp_filter_post_kses() expects slashed
     674                $instance          = $old_instance;
     675                $instance['title'] = sanitize_text_field( $new_instance['title'] );
     676                if ( current_user_can( 'unfiltered_html' ) ) {
     677                        $instance['text'] = $new_instance['text'];
     678                } else {
     679                        $instance['text'] = wp_kses_post( $new_instance['text'] );
     680                }
    612681                $instance['filter'] = ! empty( $new_instance['filter'] );
    613682                return $instance;
    614683        }
     
    617686         * @param array $instance
    618687         */
    619688        public function form( $instance ) {
    620                 $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) );
    621                 $title = strip_tags($instance['title']);
    622                 $text = esc_textarea($instance['text']);
    623 ?>
    624                 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
    625                 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
     689                $instance = wp_parse_args( (array) $instance, array(
     690                        'title' => '',
     691                        'text' => '',
     692                        )
     693                );
     694                $title  = $instance['title'];
     695                $text   = $instance['text'];
     696                $filter = isset( $instance['filter'] ) ? $instance['filter'] : 0
     697                ?>
     698                <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label>
     699                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p>
    626700
    627                 <p><label for="<?php echo $this->get_field_id( 'text' ); ?>"><?php _e( 'Content:' ); ?></label>
    628                 <textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea></p>
     701                <p><label for="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>"><?php _e( 'Content:' ); ?></label>
     702                <textarea class="widefat" rows="16" cols="20" id="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>"><?php echo esc_textarea( $text ); ?></textarea></p>
    629703
    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); ?> />&nbsp;<label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs'); ?></label></p>
     704                <p><input id="<?php echo esc_attr( $this->get_field_id( 'filter' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'filter' ) ); ?>" type="checkbox" <?php checked( $filter ); ?> />&nbsp;<label for="<?php echo esc_attr( $this->get_field_id( 'filter' ) ); ?>"><?php _e( 'Automatically add paragraphs' ); ?></label></p>
    631705<?php
    632706        }
    633707}
     
    640714class WP_Widget_Categories extends WP_Widget {
    641715
    642716        public function __construct() {
    643                 $widget_ops = array( 'classname' => 'widget_categories', 'description' => __( "A list or dropdown of categories." ) );
    644                 parent::__construct('categories', __('Categories'), $widget_ops);
     717                $widget_ops = array(
     718                        'classname'   => 'widget_categories',
     719                        'description' => __( 'A list or dropdown of categories.' ),
     720                );
     721                parent::__construct( 'categories', __( 'Categories' ), $widget_ops );
    645722        }
    646723
    647724        /**
     
    668745                $cat_args = array(
    669746                        'orderby'      => 'name',
    670747                        'show_count'   => $c,
    671                         'hierarchical' => $h
     748                        'hierarchical' => $h,
    672749                );
    673750
    674751                if ( $d ) {
     
    735812         * @return array
    736813         */
    737814        public function update( $new_instance, $old_instance ) {
    738                 $instance = $old_instance;
    739                 $instance['title'] = strip_tags($new_instance['title']);
    740                 $instance['count'] = !empty($new_instance['count']) ? 1 : 0;
    741                 $instance['hierarchical'] = !empty($new_instance['hierarchical']) ? 1 : 0;
    742                 $instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0;
     815                $instance                 = $old_instance;
     816                $instance['title']        = sanitize_text_field( $new_instance['title'] );
     817                $instance['count']        = ! empty( $new_instance['count'] ) ? 1 : 0;
     818                $instance['hierarchical'] = ! empty( $new_instance['hierarchical'] ) ? 1 : 0;
     819                $instance['dropdown']     = ! empty( $new_instance['dropdown'] ) ? 1 : 0;
    743820
    744821                return $instance;
    745822        }
     
    749826         */
    750827        public function form( $instance ) {
    751828                //Defaults
    752                 $instance = wp_parse_args( (array) $instance, array( 'title' => '') );
    753                 $title = esc_attr( $instance['title'] );
    754                 $count = isset($instance['count']) ? (bool) $instance['count'] :false;
     829                $instance = wp_parse_args( (array) $instance, array(
     830                        'title' => '',
     831                        )
     832                );
     833                $title        = $instance['title'];
     834                $count        = isset($instance['count']) ? (bool) $instance['count'] :false;
    755835                $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false;
    756                 $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false;
     836                $dropdown     = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false;
    757837?>
    758                 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:' ); ?></label>
    759                 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
     838                <p><label for="<?php echo esc_att( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label>
     839                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p>
    760840
    761                 <p><input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('dropdown'); ?>" name="<?php echo $this->get_field_name('dropdown'); ?>"<?php checked( $dropdown ); ?> />
    762                 <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e( 'Display as dropdown' ); ?></label><br />
     841                <p><input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'dropdown' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'dropdown' ) ); ?>"<?php checked( $dropdown ); ?> />
     842                <label for="<?php echo esc_attr( $this->get_field_id( 'dropdown' ) ); ?>"><?php _e( 'Display as dropdown' ); ?></label><br />
    763843
    764                 <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>"<?php checked( $count ); ?> />
    765                 <label for="<?php echo $this->get_field_id('count'); ?>"><?php _e( 'Show post counts' ); ?></label><br />
     844                <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'count' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'count' ) ); ?>"<?php checked( $count ); ?> />
     845                <label for="<?php echo esc_attr( $this->get_field_id( 'count' ) ); ?>"><?php _e( 'Show post counts' ); ?></label><br />
    766846
    767                 <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('hierarchical'); ?>" name="<?php echo $this->get_field_name('hierarchical'); ?>"<?php checked( $hierarchical ); ?> />
    768                 <label for="<?php echo $this->get_field_id('hierarchical'); ?>"><?php _e( 'Show hierarchy' ); ?></label></p>
     847                <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'hierarchical' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'hierarchical' ) ); ?>"<?php checked( $hierarchical ); ?> />
     848                <label for="<?php echo esc_attr( $this->get_field_id( 'hierarchical' ) ); ?>"><?php _e( 'Show hierarchy' ); ?></label></p>
    769849<?php
    770850        }
    771851
     
    779859class WP_Widget_Recent_Posts extends WP_Widget {
    780860
    781861        public function __construct() {
    782                 $widget_ops = array('classname' => 'widget_recent_entries', 'description' => __( "Your site&#8217;s most recent Posts.") );
    783                 parent::__construct('recent-posts', __('Recent Posts'), $widget_ops);
     862                $widget_ops = array(
     863                        'classname'   => 'widget_recent_entries',
     864                        'description' => __( 'Your site&#8217;s most recent Posts.' ),
     865                );
     866                parent::__construct( 'recent-posts', __( 'Recent Posts' ), $widget_ops );
    784867                $this->alt_option_name = 'widget_recent_entries';
    785868
    786                 add_action( 'save_post', array($this, 'flush_widget_cache') );
    787                 add_action( 'deleted_post', array($this, 'flush_widget_cache') );
    788                 add_action( 'switch_theme', array($this, 'flush_widget_cache') );
     869                add_action( 'save_post', array( $this, 'flush_widget_cache' ) );
     870                add_action( 'deleted_post', array( $this, 'flush_widget_cache' ) );
     871                add_action( 'switch_theme', array( $this, 'flush_widget_cache' ) );
    789872        }
    790873
    791874        /**
     
    819902                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    820903
    821904                $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5;
    822                 if ( ! $number )
     905                if ( ! $number ) {
    823906                        $number = 5;
     907                }
    824908                $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false;
    825909
    826910                /**
     
    836920                        'posts_per_page'      => $number,
    837921                        'no_found_rows'       => true,
    838922                        'post_status'         => 'publish',
    839                         'ignore_sticky_posts' => true
     923                        'ignore_sticky_posts' => true,
    840924                ) ) );
    841925
    842                 if ($r->have_posts()) :
     926                if ( $r->have_posts() ) :
    843927?>
    844928                <?php echo $args['before_widget']; ?>
    845                 <?php if ( $title ) {
     929                <?php
     930                if ( $title ) {
    846931                        echo $args['before_title'] . $title . $args['after_title'];
    847                 } ?>
     932                }
     933                ?>
    848934                <ul>
    849935                <?php while ( $r->have_posts() ) : $r->the_post(); ?>
    850936                        <li>
     
    876962         * @return array
    877963         */
    878964        public function update( $new_instance, $old_instance ) {
    879                 $instance = $old_instance;
    880                 $instance['title'] = strip_tags($new_instance['title']);
    881                 $instance['number'] = (int) $new_instance['number'];
     965                $instance              = $old_instance;
     966                $instance['title']     = santize_text_field( $new_instance['title'] );
     967                $instance['number']    = (int) $new_instance['number'];
    882968                $instance['show_date'] = isset( $new_instance['show_date'] ) ? (bool) $new_instance['show_date'] : false;
    883969                $this->flush_widget_cache();
    884970
    885971                $alloptions = wp_cache_get( 'alloptions', 'options' );
    886                 if ( isset($alloptions['widget_recent_entries']) )
    887                         delete_option('widget_recent_entries');
     972                if ( isset( $alloptions['widget_recent_entries'] ) ) {
     973                        delete_option( 'widget_recent_entries' );
     974                }
    888975
    889976                return $instance;
    890977        }
     
    893980         * @access public
    894981         */
    895982        public function flush_widget_cache() {
    896                 wp_cache_delete('widget_recent_posts', 'widget');
     983                wp_cache_delete( 'widget_recent_posts', 'widget' );
    897984        }
    898985
    899986        /**
     
    904991                $number    = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
    905992                $show_date = isset( $instance['show_date'] ) ? (bool) $instance['show_date'] : false;
    906993?>
    907                 <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
    908                 <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /></p>
     994                <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label>
     995                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p>
    909996
    910                 <p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of posts to show:' ); ?></label>
    911                 <input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
     997                <p><label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"><?php _e( 'Number of posts to show:' ); ?></label>
     998                <input id="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'number' ) ); ?>" type="text" value="<?php echo esc_attr( $number ); ?>" size="3" /></p>
    912999
    913                 <p><input class="checkbox" type="checkbox" <?php checked( $show_date ); ?> id="<?php echo $this->get_field_id( 'show_date' ); ?>" name="<?php echo $this->get_field_name( 'show_date' ); ?>" />
    914                 <label for="<?php echo $this->get_field_id( 'show_date' ); ?>"><?php _e( 'Display post date?' ); ?></label></p>
     1000                <p><input class="checkbox" type="checkbox" <?php checked( $show_date ); ?> id="<?php echo esc_attr( $this->get_field_id( 'show_date' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_date' ) ); ?>" />
     1001                <label for="<?php echo esc_attr( $this->get_field_id( 'show_date' ) ); ?>"><?php _e( 'Display post date?' ); ?></label></p>
    9151002<?php
    9161003        }
    9171004}
     
    9241011class WP_Widget_Recent_Comments extends WP_Widget {
    9251012
    9261013        public function __construct() {
    927                 $widget_ops = array('classname' => 'widget_recent_comments', 'description' => __( 'Your site&#8217;s most recent comments.' ) );
    928                 parent::__construct('recent-comments', __('Recent Comments'), $widget_ops);
     1014                $widget_ops = array(
     1015                        'classname' => 'widget_recent_comments',
     1016                        'description' => __( 'Your site&#8217;s most recent comments.' ),
     1017                );
     1018                parent::__construct( 'recent-comments', __( 'Recent Comments' ), $widget_ops );
    9291019                $this->alt_option_name = 'widget_recent_comments';
    9301020
    931                 if ( is_active_widget(false, false, $this->id_base) )
    932                         add_action( 'wp_head', array($this, 'recent_comments_style') );
     1021                if ( is_active_widget( false, false, $this->id_base ) ) {
     1022                        add_action( 'wp_head', array( $this, 'recent_comments_style' ) );
     1023                }
    9331024
    934                 add_action( 'comment_post', array($this, 'flush_widget_cache') );
    935                 add_action( 'edit_comment', array($this, 'flush_widget_cache') );
    936                 add_action( 'transition_comment_status', array($this, 'flush_widget_cache') );
     1025                add_action( 'comment_post', array( $this, 'flush_widget_cache' ) );
     1026                add_action( 'edit_comment', array( $this, 'flush_widget_cache' ) );
     1027                add_action( 'transition_comment_status', array( $this, 'flush_widget_cache' ) );
    9371028        }
    9381029
    9391030        /**
     
    9491040                 * @param string $id_base The widget ID.
    9501041                 */
    9511042                if ( ! current_theme_supports( 'widgets' ) // Temp hack #14876
    952                         || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) )
     1043                        || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) {
    9531044                        return;
     1045                }
    9541046                ?>
    9551047        <style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>
    9561048<?php
     
    9601052         * @access public
    9611053         */
    9621054        public function flush_widget_cache() {
    963                 wp_cache_delete('widget_recent_comments', 'widget');
     1055                wp_cache_delete( 'widget_recent_comments', 'widget' );
    9641056        }
    9651057
    9661058        /**
     
    9751067
    9761068                $cache = array();
    9771069                if ( ! $this->is_preview() ) {
    978                         $cache = wp_cache_get('widget_recent_comments', 'widget');
     1070                        $cache = wp_cache_get( 'widget_recent_comments', 'widget' );
    9791071                }
    9801072                if ( ! is_array( $cache ) ) {
    9811073                        $cache = array();
    9821074                }
    9831075
    984                 if ( ! isset( $args['widget_id'] ) )
     1076                if ( ! isset( $args['widget_id'] ) ) {
    9851077                        $args['widget_id'] = $this->id;
     1078                }
    9861079
    9871080                if ( isset( $cache[ $args['widget_id'] ] ) ) {
    9881081                        echo $cache[ $args['widget_id'] ];
     
    9971090                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    9981091
    9991092                $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5;
    1000                 if ( ! $number )
     1093                if ( ! $number ) {
    10011094                        $number = 5;
     1095                }
    10021096
    10031097                /**
    10041098                 * Filter the arguments for the Recent Comments widget.
     
    10121106                $comments = get_comments( apply_filters( 'widget_comments_args', array(
    10131107                        'number'      => $number,
    10141108                        'status'      => 'approve',
    1015                         'post_status' => 'publish'
     1109                        'post_status' => 'publish',
    10161110                ) ) );
    10171111
    10181112                $output .= $args['before_widget'];
     
    10261120                        $post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) );
    10271121                        _prime_post_caches( $post_ids, strpos( get_option( 'permalink_structure' ), '%category%' ), false );
    10281122
    1029                         foreach ( (array) $comments as $comment) {
     1123                        foreach ( (array) $comments as $comment ) {
    10301124                                $output .= '<li class="recentcomments">';
    10311125                                /* translators: comments widget: 1: comment author, 2: post link */
    10321126                                $output .= sprintf( _x( '%1$s on %2$s', 'widgets' ),
     
    10531147         * @return array
    10541148         */
    10551149        public function update( $new_instance, $old_instance ) {
    1056                 $instance = $old_instance;
    1057                 $instance['title'] = strip_tags($new_instance['title']);
     1150                $instance           = $old_instance;
     1151                $instance['title']  = sanitize_text_field( $new_instance['title'] );
    10581152                $instance['number'] = absint( $new_instance['number'] );
    10591153                $this->flush_widget_cache();
    10601154
    10611155                $alloptions = wp_cache_get( 'alloptions', 'options' );
    1062                 if ( isset($alloptions['widget_recent_comments']) )
    1063                         delete_option('widget_recent_comments');
     1156                if ( isset( $alloptions['widget_recent_comments'] ) ) {
     1157                        delete_option( 'widget_recent_comments' );
     1158                }
    10641159
    10651160                return $instance;
    10661161        }
     
    10691164         * @param array $instance
    10701165         */
    10711166        public function form( $instance ) {
    1072                 $title  = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
    1073                 $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
     1167                $title  = isset( $instance['title'] ) ? $instance['title'] : '';
     1168                $number = isset( $instance['number'] ) ? $instance['number'] : 5;
    10741169?>
    1075                 <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
    1076                 <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /></p>
     1170                <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label>
     1171                <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p>
    10771172
    1078                 <p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of comments to show:' ); ?></label>
    1079                 <input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
     1173                <p><label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"><?php _e( 'Number of comments to show:' ); ?></label>
     1174                <input id="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'number' ) ); ?>" type="text" value="<?php echo absint( $number ); ?>" size="3" /></p>
    10801175<?php
    10811176        }
    10821177}
     
    10891184class WP_Widget_RSS extends WP_Widget {
    10901185
    10911186        public function __construct() {
    1092                 $widget_ops = array( 'description' => __('Entries from any RSS or Atom feed.') );
    1093                 $control_ops = array( 'width' => 400, 'height' => 200 );
    1094                 parent::__construct( 'rss', __('RSS'), $widget_ops, $control_ops );
     1187                $widget_ops = array(
     1188                        'description' => __( 'Entries from any RSS or Atom feed.' ),
     1189                );
     1190                $control_ops = array(
     1191                        'width'  => 400,
     1192                        'height' => 200,
     1193                );
     1194                parent::__construct( 'rss', __( 'RSS' ), $widget_ops, $control_ops );
    10951195        }
    10961196
    10971197        /**
     
    10991199         * @param array $instance
    11001200         */
    11011201        public function widget( $args, $instance ) {
    1102                 if ( isset($instance['error']) && $instance['error'] )
     1202                if ( isset( $instance['error'] ) && $instance['error'] ){
    11031203                        return;
     1204                }
    11041205
    11051206                $url = ! empty( $instance['url'] ) ? $instance['url'] : '';
    1106                 while ( stristr($url, 'http') != $url )
    1107                         $url = substr($url, 1);
     1207                while ( stristr( $url, 'http' ) != $url ){
     1208                        $url = substr( $url, 1 );
     1209                }
    11081210
    1109                 if ( empty($url) )
     1211                if ( empty( $url ) ) {
    11101212                        return;
     1213                }
    11111214
    11121215                // self-url destruction sequence
    1113                 if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ) ) )
     1216                if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ) ) ) {
    11141217                        return;
     1218                }
    11151219
    1116                 $rss = fetch_feed($url);
     1220                $rss   = fetch_feed( $url );
    11171221                $title = $instance['title'];
    1118                 $desc = '';
    1119                 $link = '';
     1222                $desc  = '';
     1223                $link  = '';
    11201224
    1121                 if ( ! is_wp_error($rss) ) {
    1122                         $desc = esc_attr(strip_tags(@html_entity_decode($rss->get_description(), ENT_QUOTES, get_option('blog_charset'))));
    1123                         if ( empty($title) )
    1124                                 $title = esc_html(strip_tags($rss->get_title()));
    1125                         $link = esc_url(strip_tags($rss->get_permalink()));
    1126                         while ( stristr($link, 'http') != $link )
    1127                                 $link = substr($link, 1);
     1225                if ( ! is_wp_error( $rss ) ) {
     1226                        $desc = esc_attr( strip_tags( @html_entity_decode( $rss->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ) ) );
     1227                        if ( empty( $title ) ) {
     1228                                $title = strip_tags( $rss->get_title() );
     1229                        }
     1230                        $link = strip_tags( $rss->get_permalink() );
     1231                        while ( stristr( $link, 'http' ) != $link ) {
     1232                                $link = substr( $link, 1 );
     1233                        }
    11281234                }
    11291235
    1130                 if ( empty($title) )
    1131                         $title = empty($desc) ? __('Unknown Feed') : $desc;
     1236                if ( empty( $title ) ) {
     1237                        $title = empty( $desc ) ? __( 'Unknown Feed' ) : $desc;
     1238                }
    11321239
    11331240                /** This filter is documented in wp-includes/default-widgets.php */
    11341241                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    11351242
    1136                 $url = esc_url(strip_tags($url));
    1137                 $icon = includes_url('images/rss.png');
    1138                 if ( $title )
    1139                         $title = "<a class='rsswidget' href='$url'><img style='border:0' width='14' height='14' src='$icon' alt='RSS' /></a> <a class='rsswidget' href='$link'>$title</a>";
     1243                $url = strip_tags( $url );
     1244                $icon = includes_url( 'images/rss.png' );
     1245                if ( $title ) {
     1246                        $title = '<a class="rsswidget" href="' . esc_url( $url ) . '"><img style="border:0" width="14" height="14" src="' . esc_url( $icon ) . '" alt="RSS" /></a> <a class="rsswidget" href="' . esc_url( $link ) . '">"'. esc_html( $title ) .'"</a>';
     1247                }
    11401248
    11411249                echo $args['before_widget'];
    11421250                if ( $title ) {
     
    11451253                wp_widget_rss_output( $rss, $instance );
    11461254                echo $args['after_widget'];
    11471255
    1148                 if ( ! is_wp_error($rss) )
     1256                if ( ! is_wp_error( $rss ) ) {
    11491257                        $rss->__destruct();
     1258                }
    11501259                unset($rss);
    11511260        }
    11521261
     
    11561265         * @return array
    11571266         */
    11581267        public function update( $new_instance, $old_instance ) {
    1159                 $testurl = ( isset( $new_instance['url'] ) && ( !isset( $old_instance['url'] ) || ( $new_instance['url'] != $old_instance['url'] ) ) );
     1268                $testurl = ( isset( $new_instance['url'] ) && ( ! isset( $old_instance['url'] ) || ( $new_instance['url'] != $old_instance['url'] ) ) );
    11601269                return wp_widget_rss_process( $new_instance, $testurl );
    11611270        }
    11621271
     
    11651274         */
    11661275        public function form( $instance ) {
    11671276                if ( empty( $instance ) ) {
    1168                         $instance = array( 'title' => '', 'url' => '', 'items' => 10, 'error' => false, 'show_summary' => 0, 'show_author' => 0, 'show_date' => 0 );
     1277                        $instance = array(
     1278                                'title'        => '',
     1279                                'url'          => '',
     1280                                'items'        => 10,
     1281                                'error'        => false,
     1282                                'show_summary' => 0,
     1283                                'show_author'  => 0,
     1284                                'show_date'    => 0,
     1285                                );
    11691286                }
    11701287                $instance['number'] = $this->number;
    11711288
     
    11831300 */
    11841301function wp_widget_rss_output( $rss, $args = array() ) {
    11851302        if ( is_string( $rss ) ) {
    1186                 $rss = fetch_feed($rss);
    1187         } elseif ( is_array($rss) && isset($rss['url']) ) {
     1303                $rss = fetch_feed( $rss );
     1304        } elseif ( is_array( $rss ) && isset( $rss['url'] ) ) {
    11881305                $args = $rss;
    1189                 $rss = fetch_feed($rss['url']);
    1190         } elseif ( !is_object($rss) ) {
     1306                $rss = fetch_feed( $rss['url'] );
     1307        } elseif ( ! is_object( $rss ) ) {
    11911308                return;
    11921309        }
    11931310
    1194         if ( is_wp_error($rss) ) {
    1195                 if ( is_admin() || current_user_can('manage_options') )
    1196                         echo '<p>' . sprintf( __('<strong>RSS Error</strong>: %s'), $rss->get_error_message() ) . '</p>';
     1311        if ( is_wp_error( $rss ) ) {
     1312                if ( is_admin() || current_user_can( 'manage_options' ) ) {
     1313                        echo '<p>' . sprintf( __( '<strong>RSS Error</strong>: %s' ), $rss->get_error_message() ) . '</p>';
     1314                }
    11971315                return;
    11981316        }
    11991317
    1200         $default_args = array( 'show_author' => 0, 'show_date' => 0, 'show_summary' => 0, 'items' => 0 );
     1318        $default_args = array(
     1319                'show_author'  => 0,
     1320                'show_date'    => 0,
     1321                'show_summary' => 0,
     1322                'items'        => 0,
     1323                );
    12011324        $args = wp_parse_args( $args, $default_args );
    12021325
    12031326        $items = (int) $args['items'];
    1204         if ( $items < 1 || 20 < $items )
     1327        if ( $items < 1 || 20 < $items ) {
    12051328                $items = 10;
     1329        }
    12061330        $show_summary  = (int) $args['show_summary'];
    12071331        $show_author   = (int) $args['show_author'];
    12081332        $show_date     = (int) $args['show_date'];
    12091333
    1210         if ( !$rss->get_item_quantity() ) {
     1334        if ( ! $rss->get_item_quantity() ) {
    12111335                echo '<ul><li>' . __( 'An error has occurred, which probably means the feed is down. Try again later.' ) . '</li></ul>';
    12121336                $rss->__destruct();
    1213                 unset($rss);
     1337                unset( $rss );
    12141338                return;
    12151339        }
    12161340
     
    12541378                $author = '';
    12551379                if ( $show_author ) {
    12561380                        $author = $item->get_author();
    1257                         if ( is_object($author) ) {
     1381                        if ( is_object( $author ) ) {
    12581382                                $author = $author->get_name();
    12591383                                $author = ' <cite>' . esc_html( strip_tags( $author ) ) . '</cite>';
    12601384                        }
     
    12861410 * @param array $inputs Override default display options.
    12871411 */
    12881412function wp_widget_rss_form( $args, $inputs = null ) {
    1289         $default_inputs = array( 'url' => true, 'title' => true, 'items' => true, 'show_summary' => true, 'show_author' => true, 'show_date' => true );
     1413        $default_inputs = array(
     1414                'url'           => true,
     1415                'title'         => true,
     1416                'items'         => true,
     1417                'show_summary'  => true,
     1418                'show_author'   => true,
     1419                'show_date'      => true,
     1420        );
    12901421        $inputs = wp_parse_args( $inputs, $default_inputs );
    12911422
    1292         $args['number'] = esc_attr( $args['number'] );
    1293         $args['title'] = isset( $args['title'] ) ? esc_attr( $args['title'] ) : '';
    1294         $args['url'] = isset( $args['url'] ) ? esc_url( $args['url'] ) : '';
    1295         $args['items'] = isset( $args['items'] ) ? (int) $args['items'] : 0;
     1423        $args['number'] = $args['number'];
     1424        $args['title']  = isset( $args['title'] ) ? $args['title'] : '';
     1425        $args['url']    = isset( $args['url'] ) ? $args['url'] : '';
     1426        $args['items']  = isset( $args['items'] ) ? (int) $args['items'] : 0;
    12961427
    12971428        if ( $args['items'] < 1 || 20 < $args['items'] ) {
    12981429                $args['items'] = 10;
     
    13081439
    13091440        if ( $inputs['url'] ) :
    13101441?>
    1311         <p><label for="rss-url-<?php echo $args['number']; ?>"><?php _e( 'Enter the RSS feed URL here:' ); ?></label>
    1312         <input class="widefat" id="rss-url-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][url]" type="text" value="<?php echo $args['url']; ?>" /></p>
     1442        <p><label for="rss-url-<?php echo esc_attr( $args['number'] ); ?>"><?php _e( 'Enter the RSS feed URL here:' ); ?></label>
     1443        <input class="widefat" id="rss-url-<?php echo esc_attr( $args['number'] ); ?>" name="widget-rss[<?php echo esc_attr( $args['number'] ); ?>][url]" type="text" value="<?php echo esc_url( $args['url'] ); ?>" /></p>
    13131444<?php endif; if ( $inputs['title'] ) : ?>
    1314         <p><label for="rss-title-<?php echo $args['number']; ?>"><?php _e( 'Give the feed a title (optional):' ); ?></label>
    1315         <input class="widefat" id="rss-title-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][title]" type="text" value="<?php echo $args['title']; ?>" /></p>
     1445        <p><label for="rss-title-<?php echo esc_attr( $args['number'] ); ?>"><?php _e( 'Give the feed a title (optional):' ); ?></label>
     1446        <input class="widefat" id="rss-title-<?php echo esc_attr( $args['number'] ); ?>" name="widget-rss[<?php echo esc_attr( $args['number'] ); ?>][title]" type="text" value="<?php echo esc_attr( $args['title'] ); ?>" /></p>
    13161447<?php endif; if ( $inputs['items'] ) : ?>
    1317         <p><label for="rss-items-<?php echo $args['number']; ?>"><?php _e( 'How many items would you like to display?' ); ?></label>
    1318         <select id="rss-items-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][items]">
    1319 <?php
    1320                 for ( $i = 1; $i <= 20; ++$i ) {
    1321                         echo "<option value='$i' " . selected( $args['items'], $i, false ) . ">$i</option>";
    1322                 }
    1323 ?>
     1448        <p><label for="rss-items-<?php echo esc_attr( $args['number'] ); ?>"><?php _e( 'How many items would you like to display?' ); ?></label>
     1449        <select id="rss-items-<?php echo esc_attr( $args['number'] ); ?>" name="widget-rss[<?php echo esc_attr( $args['number'] ); ?>][items]">
     1450        <?php
     1451        for ( $i = 1; $i <= 20; ++$i ) {
     1452                echo "<option value='$i' " . selected( $args['items'], $i, false ) . ">$i</option>";
     1453        }
     1454        ?>
    13241455        </select></p>
    13251456<?php endif; if ( $inputs['show_summary'] ) : ?>
    1326         <p><input id="rss-show-summary-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][show_summary]" type="checkbox" value="1" <?php checked( $args['show_summary'] ); ?> />
    1327         <label for="rss-show-summary-<?php echo $args['number']; ?>"><?php _e( 'Display item content?' ); ?></label></p>
     1457        <p><input id="rss-show-summary-<?php echo esc_attr( $args['number'] ); ?>" name="widget-rss[<?php echo esc_attr( $args['number'] ); ?>][show_summary]" type="checkbox" value="1" <?php checked( $args['show_summary'] ); ?> />
     1458        <label for="rss-show-summary-<?php echo esc_attr( $args['number'] ); ?>"><?php _e( 'Display item content?' ); ?></label></p>
    13281459<?php endif; if ( $inputs['show_author'] ) : ?>
    1329         <p><input id="rss-show-author-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][show_author]" type="checkbox" value="1" <?php checked( $args['show_author'] ); ?> />
    1330         <label for="rss-show-author-<?php echo $args['number']; ?>"><?php _e( 'Display item author if available?' ); ?></label></p>
     1460        <p><input id="rss-show-author-<?php echo esc_attr( $args['number'] ); ?>" name="widget-rss[<?php echo esc_attr( $args['number'] ); ?>][show_author]" type="checkbox" value="1" <?php checked( $args['show_author'] ); ?> />
     1461        <label for="rss-show-author-<?php echo esc_attr( $args['number'] ); ?>"><?php _e( 'Display item author if available?' ); ?></label></p>
    13311462<?php endif; if ( $inputs['show_date'] ) : ?>
    1332         <p><input id="rss-show-date-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][show_date]" type="checkbox" value="1" <?php checked( $args['show_date'] ); ?>/>
    1333         <label for="rss-show-date-<?php echo $args['number']; ?>"><?php _e( 'Display item date?' ); ?></label></p>
     1463        <p><input id="rss-show-date-<?php echo esc_attr( $args['number'] ); ?>" name="widget-rss[<?php echo esc_attr( $args['number'] ); ?>][show_date]" type="checkbox" value="1" <?php checked( $args['show_date'] ); ?>/>
     1464        <label for="rss-show-date-<?php echo esc_attr( $args['number'] ); ?>"><?php _e( 'Display item date?' ); ?></label></p>
    13341465<?php
    13351466        endif;
    13361467        foreach ( array_keys($default_inputs) as $input ) :
     
    13371468                if ( 'hidden' === $inputs[$input] ) :
    13381469                        $id = str_replace( '_', '-', $input );
    13391470?>
    1340         <input type="hidden" id="rss-<?php echo $id; ?>-<?php echo $args['number']; ?>" name="widget-rss[<?php echo $args['number']; ?>][<?php echo $input; ?>]" value="<?php echo $args[ $input ]; ?>" />
     1471        <input type="hidden" id="rss-<?php echo esc_attr( $id ); ?>-<?php echo esc_attr( $args['number'] ); ?>" name="widget-rss[<?php echo esc_attr( $args['number'] ); ?>][<?php echo esc_attr( $input ); ?>]" value="<?php echo esc_attr( $args[ $input ] ); ?>" />
    13411472<?php
    13421473                endif;
    13431474        endforeach;
     
    13611492 */
    13621493function wp_widget_rss_process( $widget_rss, $check_feed = true ) {
    13631494        $items = (int) $widget_rss['items'];
    1364         if ( $items < 1 || 20 < $items )
     1495        if ( $items < 1 || 20 < $items ) {
    13651496                $items = 10;
     1497        }
    13661498        $url           = esc_url_raw( strip_tags( $widget_rss['url'] ) );
    13671499        $title         = isset( $widget_rss['title'] ) ? trim( strip_tags( $widget_rss['title'] ) ) : '';
    13681500        $show_summary  = isset( $widget_rss['show_summary'] ) ? (int) $widget_rss['show_summary'] : 0;
     
    13701502        $show_date     = isset( $widget_rss['show_date'] ) ? (int) $widget_rss['show_date'] : 0;
    13711503
    13721504        if ( $check_feed ) {
    1373                 $rss = fetch_feed($url);
     1505                $rss = fetch_feed( $url );
    13741506                $error = false;
    13751507                $link = '';
    1376                 if ( is_wp_error($rss) ) {
     1508                if ( is_wp_error( $rss ) ) {
    13771509                        $error = $rss->get_error_message();
    13781510                } else {
    1379                         $link = esc_url(strip_tags($rss->get_permalink()));
    1380                         while ( stristr($link, 'http') != $link )
    1381                                 $link = substr($link, 1);
     1511                        $link = esc_url( strip_tags( $rss->get_permalink() ) );
     1512                        while ( stristr( $link, 'http' ) != $link ) {
     1513                                $link = substr( $link, 1 );
     1514                        }
    13821515
    13831516                        $rss->__destruct();
    1384                         unset($rss);
     1517                        unset( $rss );
    13851518                }
    13861519        }
    13871520
     
    13961529class WP_Widget_Tag_Cloud extends WP_Widget {
    13971530
    13981531        public function __construct() {
    1399                 $widget_ops = array( 'description' => __( "A cloud of your most used tags.") );
    1400                 parent::__construct('tag_cloud', __('Tag Cloud'), $widget_ops);
     1532                $widget_ops = array(
     1533                        'description' => __( 'A cloud of your most used tags.' ),
     1534                );
     1535                parent::__construct( 'tag_cloud', __( 'Tag Cloud' ), $widget_ops );
    14011536        }
    14021537
    14031538        /**
     
    14051540         * @param array $instance
    14061541         */
    14071542        public function widget( $args, $instance ) {
    1408                 $current_taxonomy = $this->_get_current_taxonomy($instance);
    1409                 if ( !empty($instance['title']) ) {
     1543                $current_taxonomy = $this->_get_current_taxonomy( $instance );
     1544                if ( ! empty( $instance['title'] ) ) {
    14101545                        $title = $instance['title'];
    14111546                } else {
    1412                         if ( 'post_tag' == $current_taxonomy ) {
    1413                                 $title = __('Tags');
     1547                        if ( 'post_tag' === $current_taxonomy ) {
     1548                                $title = __( 'Tags' );
    14141549                        } else {
    1415                                 $tax = get_taxonomy($current_taxonomy);
     1550                                $tax = get_taxonomy( $current_taxonomy );
    14161551                                $title = $tax->labels->name;
    14171552                        }
    14181553                }
     
    14371572                 * @param array $current_taxonomy The taxonomy to use in the tag cloud. Default 'tags'.
    14381573                 */
    14391574                wp_tag_cloud( apply_filters( 'widget_tag_cloud_args', array(
    1440                         'taxonomy' => $current_taxonomy
     1575                        'taxonomy' => $current_taxonomy,
    14411576                ) ) );
    14421577
    14431578                echo "</div>\n";
     
    14511586         */
    14521587        public function update( $new_instance, $old_instance ) {
    14531588                $instance = array();
    1454                 $instance['title'] = strip_tags(stripslashes($new_instance['title']));
    1455                 $instance['taxonomy'] = stripslashes($new_instance['taxonomy']);
     1589                $instance['title'] = sanitize_text_field( $new_instance['title'] );
     1590                $instance['taxonomy'] = stripslashes( $new_instance['taxonomy'] );
    14561591                return $instance;
    14571592        }
    14581593
     
    14601595         * @param array $instance
    14611596         */
    14621597        public function form( $instance ) {
    1463                 $current_taxonomy = $this->_get_current_taxonomy($instance);
     1598                $current_taxonomy = $this->_get_current_taxonomy( $instance );
     1599                $title            = isset( $instance['title'] ) ? $instance['title'] : '';
    14641600?>
    1465         <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:') ?></label>
    1466         <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php if (isset ( $instance['title'])) {echo esc_attr( $instance['title'] );} ?>" /></p>
    1467         <p><label for="<?php echo $this->get_field_id('taxonomy'); ?>"><?php _e('Taxonomy:') ?></label>
    1468         <select class="widefat" id="<?php echo $this->get_field_id('taxonomy'); ?>" name="<?php echo $this->get_field_name('taxonomy'); ?>">
    1469         <?php foreach ( get_taxonomies() as $taxonomy ) :
    1470                                 $tax = get_taxonomy($taxonomy);
    1471                                 if ( !$tax->show_tagcloud || empty($tax->labels->name) )
     1601        <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ) ?></label>
     1602        <input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_attr( $title ); ?>" /></p>
     1603        <p><label for="<?php echo esc_attr( $this->get_field_id( 'taxonomy' ) ); ?>"><?php _e( 'Taxonomy:' ) ?></label>
     1604        <select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'taxonomy' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'taxonomy' ) ); ?>">
     1605                        <?php foreach ( get_taxonomies() as $taxonomy ) :
     1606                                $tax = get_taxonomy( $taxonomy );
     1607                                if ( ! $tax->show_tagcloud || empty( $tax->labels->name ) ){
    14721608                                        continue;
    1473         ?>
    1474                 <option value="<?php echo esc_attr($taxonomy) ?>" <?php selected($taxonomy, $current_taxonomy) ?>><?php echo $tax->labels->name; ?></option>
     1609                                }
     1610                        ?>
     1611                <option value="<?php echo esc_attr( $taxonomy ) ?>" <?php selected( $taxonomy, $current_taxonomy ) ?>><?php echo esc_attr( $tax->labels->name ); ?></option>
    14751612        <?php endforeach; ?>
    14761613        </select></p><?php
    14771614        }
     
    14811618         * @return string
    14821619         */
    14831620        public function _get_current_taxonomy($instance) {
    1484                 if ( !empty($instance['taxonomy']) && taxonomy_exists($instance['taxonomy']) )
     1621                if ( ! empty( $instance['taxonomy'] ) && taxonomy_exists( $instance['taxonomy'] ) ) {
    14851622                        return $instance['taxonomy'];
     1623                }
    14861624
    14871625                return 'post_tag';
    14881626        }
     
    14961634 class WP_Nav_Menu_Widget extends WP_Widget {
    14971635
    14981636        public function __construct() {
    1499                 $widget_ops = array( 'description' => __('Add a custom menu to your sidebar.') );
    1500                 parent::__construct( 'nav_menu', __('Custom Menu'), $widget_ops );
     1637                $widget_ops = array(
     1638                        'description' => __( 'Add a custom menu to your sidebar.' ),
     1639                );
     1640                parent::__construct( 'nav_menu', __( 'Custom Menu' ), $widget_ops );
    15011641        }
    15021642
    15031643        /**
     
    15081648                // Get menu
    15091649                $nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false;
    15101650
    1511                 if ( !$nav_menu )
     1651                if ( ! $nav_menu ) {
    15121652                        return;
     1653                }
    15131654
    15141655                /** This filter is documented in wp-includes/default-widgets.php */
    15151656                $instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
     
    15161657
    15171658                echo $args['before_widget'];
    15181659
    1519                 if ( !empty($instance['title']) )
     1660                if ( ! empty( $instance['title'] ) ) {
    15201661                        echo $args['before_title'] . $instance['title'] . $args['after_title'];
     1662                }
    15211663
    15221664                $nav_menu_args = array(
    15231665                        'fallback_cb' => '',
    1524                         'menu'        => $nav_menu
     1666                        'menu'        => $nav_menu,
    15251667                );
    15261668
    15271669                /**
     
    15511693        public function update( $new_instance, $old_instance ) {
    15521694                $instance = array();
    15531695                if ( ! empty( $new_instance['title'] ) ) {
    1554                         $instance['title'] = strip_tags( stripslashes($new_instance['title']) );
     1696                        $instance['title'] = sanitize_text_field( $new_instance['title'] );
    15551697                }
    15561698                if ( ! empty( $new_instance['nav_menu'] ) ) {
    15571699                        $instance['nav_menu'] = (int) $new_instance['nav_menu'];
     
    15631705         * @param array $instance
    15641706         */
    15651707        public function form( $instance ) {
    1566                 $title = isset( $instance['title'] ) ? $instance['title'] : '';
     1708                $title    = isset( $instance['title'] ) ? $instance['title'] : '';
    15671709                $nav_menu = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : '';
    15681710
    15691711                // Get menus
     
    15841726                </p>
    15851727                <div class="nav-menu-widget-form-controls" <?php if ( empty( $menus ) ) { echo ' style="display:none" '; } ?>>
    15861728                        <p>
    1587                                 <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ) ?></label>
    1588                                 <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $title ); ?>"/>
     1729                                <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ) ?></label>
     1730                                <input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_attr( $title ); ?>"/>
    15891731                        </p>
    15901732                        <p>
    1591                                 <label for="<?php echo $this->get_field_id( 'nav_menu' ); ?>"><?php _e( 'Select Menu:' ); ?></label>
    1592                                 <select id="<?php echo $this->get_field_id( 'nav_menu' ); ?>" name="<?php echo $this->get_field_name( 'nav_menu' ); ?>">
     1733                                <label for="<?php echo esc_attr( $this->get_field_id( 'nav_menu' ) ); ?>"><?php _e( 'Select Menu:' ); ?></label>
     1734                                <select id="<?php echo esc_attr( $this->get_field_id( 'nav_menu' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'nav_menu' ) ); ?>">
    15931735                                        <option value="0"><?php _e( '&mdash; Select &mdash;' ); ?></option>
    15941736                                        <?php foreach ( $menus as $menu ) : ?>
    15951737                                                <option value="<?php echo esc_attr( $menu->term_id ); ?>" <?php selected( $nav_menu, $menu->term_id ); ?>>
     
    16121754 * @since 2.2.0
    16131755 */
    16141756function wp_widgets_init() {
    1615         if ( !is_blog_installed() )
     1757
     1758        if ( ! is_blog_installed() ) {
    16161759                return;
     1760        }
    16171761
    1618         register_widget('WP_Widget_Pages');
     1762        register_widget( 'WP_Widget_Pages' );
    16191763
    1620         register_widget('WP_Widget_Calendar');
     1764        register_widget( 'WP_Widget_Calendar' );
    16211765
    1622         register_widget('WP_Widget_Archives');
     1766        register_widget( 'WP_Widget_Archives' );
    16231767
    1624         if ( get_option( 'link_manager_enabled' ) )
    1625                 register_widget('WP_Widget_Links');
     1768        if ( get_option( 'link_manager_enabled' ) ) {
     1769                register_widget( 'WP_Widget_Links' );
     1770        }
    16261771
    1627         register_widget('WP_Widget_Meta');
     1772        register_widget( 'WP_Widget_Meta' );
    16281773
    1629         register_widget('WP_Widget_Search');
     1774        register_widget( 'WP_Widget_Search' );
    16301775
    1631         register_widget('WP_Widget_Text');
     1776        register_widget( 'WP_Widget_Text' );
    16321777
    1633         register_widget('WP_Widget_Categories');
     1778        register_widget( 'WP_Widget_Categories' );
    16341779
    1635         register_widget('WP_Widget_Recent_Posts');
     1780        register_widget( 'WP_Widget_Recent_Posts' );
    16361781
    1637         register_widget('WP_Widget_Recent_Comments');
     1782        register_widget( 'WP_Widget_Recent_Comments' );
    16381783
    1639         register_widget('WP_Widget_RSS');
     1784        register_widget( 'WP_Widget_RSS' );
    16401785
    1641         register_widget('WP_Widget_Tag_Cloud');
     1786        register_widget( 'WP_Widget_Tag_Cloud' );
    16421787
    1643         register_widget('WP_Nav_Menu_Widget');
     1788        register_widget( 'WP_Nav_Menu_Widget' );
    16441789
    16451790        /**
    16461791         * Fires after all default WordPress widgets have been registered.