Make WordPress Core

Ticket #35574: 35574.wip.diff

File 35574.wip.diff, 8.4 KB (added by westonruter, 9 years ago)

WIP

  • src/wp-includes/class-wp-widget.php

    diff --git src/wp-includes/class-wp-widget.php src/wp-includes/class-wp-widget.php
    index a99568d..5dc808b 100644
    class WP_Widget { 
    7373        public $id = false;
    7474
    7575        /**
     76         * Default instance.
     77         *
     78         * @since 4.5.0
     79         * @access public
     80         * @var array
     81         */
     82        public $default_instance = array();
     83
     84        /**
    7685         * Whether the widget data has been updated.
    7786         *
    7887         * Set to true when the data is updated after a POST submit - ensures it does
    class WP_Widget { 
    335344
    336345                if ( array_key_exists( $this->number, $instances ) ) {
    337346                        $instance = $instances[ $this->number ];
     347                        $instance = wp_parse_args( $instance, $this->default_instance );
    338348
    339349                        /**
    340350                         * Filter the settings for a particular widget instance.
    class WP_Widget { 
    419429                                        wp_suspend_cache_addition( true );
    420430                                }
    421431
     432                                $new_instance = wp_parse_args( $new_instance, $this->default_instance );
    422433                                $instance = $this->update( $new_instance, $old_instance );
    423434
    424435                                if ( $this->is_preview() ) {
  • src/wp-includes/widgets/class-wp-widget-links.php

    diff --git src/wp-includes/widgets/class-wp-widget-links.php src/wp-includes/widgets/class-wp-widget-links.php
    index 96ecc77..152652f 100644
     
    1717class WP_Widget_Links extends WP_Widget {
    1818
    1919        /**
     20         * Default instance.
     21         *
     22         * @since 4.5.0
     23         * @var array
     24         */
     25        public $default_instance = array(
     26                'description' => false,
     27                'name' => false,
     28                'images' => false,
     29                'rating' => false,
     30                'category' => false,
     31                'orderby' => 'name',
     32                'order' => 'DESC',
     33                'limit' => -1,
     34        );
     35
     36        /**
    2037         * Sets up a new Links widget instance.
    2138         *
    2239         * @since 2.8.0
  • src/wp-includes/widgets/class-wp-widget-meta.php

    diff --git src/wp-includes/widgets/class-wp-widget-meta.php src/wp-includes/widgets/class-wp-widget-meta.php
    index c12238f..3b1e07e 100644
     
    1919class WP_Widget_Meta extends WP_Widget {
    2020
    2121        /**
     22         * Default instance.
     23         *
     24         * @since 4.5.0
     25         * @var array
     26         */
     27        public $default_instance = array(
     28                'title' => '',
     29        );
     30
     31        /**
    2232         * Sets up a new Meta widget instance.
    2333         *
    2434         * @since 2.8.0
  • src/wp-includes/widgets/class-wp-widget-pages.php

    diff --git src/wp-includes/widgets/class-wp-widget-pages.php src/wp-includes/widgets/class-wp-widget-pages.php
    index e8737ac..e62c044 100644
     
    1717class WP_Widget_Pages extends WP_Widget {
    1818
    1919        /**
     20         * Default instance.
     21         *
     22         * @since 4.5.0
     23         * @var array
     24         */
     25        public $default_instance = array(
     26                'title' => '',
     27                'orderby' => 'menu_order',
     28                'exclude' => '',
     29        );
     30
     31        /**
    2032         * Sets up a new Pages widget instance.
    2133         *
    2234         * @since 2.8.0
    class WP_Widget_Pages extends WP_Widget { 
    5062                 */
    5163                $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Pages' ) : $instance['title'], $instance, $this->id_base );
    5264
    53                 $sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby'];
    54                 $exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude'];
     65                $sortby = $instance['sortby'];
     66                $exclude = $instance['exclude'];
    5567
    56                 if ( $sortby == 'menu_order' )
     68                if ( $sortby === 'menu_order' )
    5769                        $sortby = 'menu_order, post_title';
    5870
    5971                /**
  • src/wp-includes/widgets/class-wp-widget-recent-comments.php

    diff --git src/wp-includes/widgets/class-wp-widget-recent-comments.php src/wp-includes/widgets/class-wp-widget-recent-comments.php
    index 0f1a3b5..b77a74a 100644
     
    1717class WP_Widget_Recent_Comments extends WP_Widget {
    1818
    1919        /**
     20         * Default instance.
     21         *
     22         * @since 4.5.0
     23         * @var array
     24         */
     25        public $default_instance = array(
     26                'title' => '',
     27                'number' => 5,
     28        );
     29
     30        /**
    2031         * Sets up a new Recent Comments widget instance.
    2132         *
    2233         * @since 2.8.0
    class WP_Widget_Recent_Comments extends WP_Widget { 
    7586                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    7687                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    7788
    78                 $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5;
    79                 if ( ! $number )
    80                         $number = 5;
     89                $number = $instance['number'];
    8190
    8291                /**
    8392                 * Filter the arguments for the Recent Comments widget.
    class WP_Widget_Recent_Comments extends WP_Widget { 
    91100                $comments = get_comments( apply_filters( 'widget_comments_args', array(
    92101                        'number'      => $number,
    93102                        'status'      => 'approve',
    94                         'post_status' => 'publish'
     103                        'post_status' => 'publish',
    95104                ) ) );
    96105
    97106                $output .= $args['before_widget'];
  • src/wp-includes/widgets/class-wp-widget-recent-posts.php

    diff --git src/wp-includes/widgets/class-wp-widget-recent-posts.php src/wp-includes/widgets/class-wp-widget-recent-posts.php
    index 8f92bf3..30257f9 100644
     
    1717class WP_Widget_Recent_Posts extends WP_Widget {
    1818
    1919        /**
     20         * Default instance.
     21         *
     22         * @since 4.5.0
     23         * @var array
     24         */
     25        public $default_instance = array(
     26                'title' => '',
     27                'number' => 5,
     28                'show_date' => false,
     29        );
     30
     31        /**
    2032         * Sets up a new Recent Posts widget instance.
    2133         *
    2234         * @since 2.8.0
    class WP_Widget_Recent_Posts extends WP_Widget { 
    4860                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    4961                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    5062
    51                 $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5;
    52                 if ( ! $number )
    53                         $number = 5;
    54                 $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false;
     63                $number = absint( $instance['number'] );
    5564
    5665                /**
    5766                 * Filter the arguments for the Recent Posts widget.
    class WP_Widget_Recent_Posts extends WP_Widget { 
    6675                        'posts_per_page'      => $number,
    6776                        'no_found_rows'       => true,
    6877                        'post_status'         => 'publish',
    69                         'ignore_sticky_posts' => true
     78                        'ignore_sticky_posts' => true,
    7079                ) ) );
    7180
    7281                if ($r->have_posts()) :
    class WP_Widget_Recent_Posts extends WP_Widget { 
    121130         * @param array $instance Current settings.
    122131         */
    123132        public function form( $instance ) {
    124                 $title     = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
    125                 $number    = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
    126                 $show_date = isset( $instance['show_date'] ) ? (bool) $instance['show_date'] : false;
     133                $title     = $instance['title'];
     134                $number    = absint( $instance['number'] );
     135                $show_date = (bool) $instance['show_date'];
    127136?>
    128137                <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
    129                 <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>
     138                <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>
    130139
    131140                <p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of posts to show:' ); ?></label>
    132                 <input class="tiny-text" id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="number" step="1" min="1" value="<?php echo $number; ?>" size="3" /></p>
     141                <input class="tiny-text" id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="number" step="1" min="1" value="<?php echo esc_attr( $number ); ?>" size="3" /></p>
    133142
    134143                <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' ); ?>" />
    135144                <label for="<?php echo $this->get_field_id( 'show_date' ); ?>"><?php _e( 'Display post date?' ); ?></label></p>
  • src/wp-includes/widgets/class-wp-widget-rss.php

    diff --git src/wp-includes/widgets/class-wp-widget-rss.php src/wp-includes/widgets/class-wp-widget-rss.php
    index b477a6e..361f313 100644
     
    1717class WP_Widget_RSS extends WP_Widget {
    1818
    1919        /**
     20         * Default instance.
     21         *
     22         * @since 4.5.0
     23         * @var array
     24         */
     25        public $default_instance = array(
     26                'title' => '',
     27                // @todo
     28        );
     29
     30        /**
    2031         * Sets up a new RSS widget instance.
    2132         *
    2233         * @since 2.8.0