Make WordPress Core

Changeset 45100


Ignore:
Timestamp:
04/02/2019 10:12:11 PM (8 years ago)
Author:
SergeyBiryukov
Message:

Widgets: Make sure changes to media widgets' instance schema via widget_{$this->id_base}_instance_schema filter are not overridden by subclasses.

Previously, WP_Widget_Media_Audio, WP_Widget_Media_Image, and WP_Widget_Media_Video used to override the changes due to reversed arguments in array_merge() call.

Props Toro_Unit, birgire.
Fixes #45029.

Location:
trunk/src/wp-includes/widgets
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/widgets/class-wp-widget-media-audio.php

    r43571 r45100  
    2020         * Constructor.
    2121         *
    22          * @since  4.8.0
     22         * @since 4.8.0
    2323         */
    2424        public function __construct() {
    … …  
    5555         * Get schema for properties of a widget instance (item).
    5656         *
    57          * @since  4.8.0
     57         * @since 4.8.0
    5858         *
    5959         * @see WP_REST_Controller::get_item_schema()
    … …  
    6363         */
    6464        public function get_instance_schema() {
    65                 $schema = array_merge(
    66                         parent::get_instance_schema(),
    67                         array(
    68                                 'preload' => array(
    69                                         'type'        => 'string',
    70                                         'enum'        => array( 'none', 'auto', 'metadata' ),
    71                                         'default'     => 'none',
    72                                         'description' => __( 'Preload' ),
    73                                 ),
    74                                 'loop'    => array(
    75                                         'type'        => 'boolean',
    76                                         'default'     => false,
    77                                         'description' => __( 'Loop' ),
    78                                 ),
    79                         )
     65                $schema = array(
     66                        'preload' => array(
     67                                'type'        => 'string',
     68                                'enum'        => array( 'none', 'auto', 'metadata' ),
     69                                'default'     => 'none',
     70                                'description' => __( 'Preload' ),
     71                        ),
     72                        'loop'    => array(
     73                                'type'        => 'boolean',
     74                                'default'     => false,
     75                                'description' => __( 'Loop' ),
     76                        ),
    8077                );
    8178
    … …  
    9087                }
    9188
    92                 return $schema;
     89                return array_merge( $schema, parent::get_instance_schema() );
    9390        }
    9491
    … …  
    9693         * Render the media on the frontend.
    9794         *
    98          * @since  4.8.0
     95         * @since 4.8.0
    9996         *
    10097         * @param array $instance Widget instance props.
  • trunk/src/wp-includes/widgets/class-wp-widget-media-image.php

    r44767 r45100  
    2020         * Constructor.
    2121         *
    22          * @since  4.8.0
     22         * @since 4.8.0
    2323         */
    2424        public function __construct() {
    … …  
    5454         * Get schema for properties of a widget instance (item).
    5555         *
    56          * @since  4.8.0
     56         * @since 4.8.0
    5757         *
    5858         * @see WP_REST_Controller::get_item_schema()
    … …  
    6363        public function get_instance_schema() {
    6464                return array_merge(
    65                         parent::get_instance_schema(),
    6665                        array(
    6766                                'size'              => array(
    … …  
    162161                                 * - width (redundant when size is not custom)
    163162                                 */
    164                         )
     163                        ),
     164                        parent::get_instance_schema()
    165165                );
    166166        }
    … …  
    169169         * Render the media on the frontend.
    170170         *
    171          * @since  4.8.0
     171         * @since 4.8.0
    172172         *
    173173         * @param array $instance Widget instance props.
  • trunk/src/wp-includes/widgets/class-wp-widget-media-video.php

    r43571 r45100  
    2020         * Constructor.
    2121         *
    22          * @since  4.8.0
     22         * @since 4.8.0
    2323         */
    2424        public function __construct() {
    … …  
    5656         * Get schema for properties of a widget instance (item).
    5757         *
    58          * @since  4.8.0
     58         * @since 4.8.0
    5959         *
    6060         * @see WP_REST_Controller::get_item_schema()
    … …  
    6464         */
    6565        public function get_instance_schema() {
    66                 $schema = array_merge(
    67                         parent::get_instance_schema(),
    68                         array(
    69                                 'preload' => array(
    70                                         'type'                  => 'string',
    71                                         'enum'                  => array( 'none', 'auto', 'metadata' ),
    72                                         'default'               => 'metadata',
    73                                         'description'           => __( 'Preload' ),
    74                                         'should_preview_update' => false,
    75                                 ),
    76                                 'loop'    => array(
    77                                         'type'                  => 'boolean',
    78                                         'default'               => false,
    79                                         'description'           => __( 'Loop' ),
    80                                         'should_preview_update' => false,
    81                                 ),
    82                                 'content' => array(
    83                                         'type'                  => 'string',
    84                                         'default'               => '',
    85                                         'sanitize_callback'     => 'wp_kses_post',
    86                                         'description'           => __( 'Tracks (subtitles, captions, descriptions, chapters, or metadata)' ),
    87                                         'should_preview_update' => false,
    88                                 ),
    89                         )
     66
     67                $schema = array(
     68                        'preload' => array(
     69                                'type'                  => 'string',
     70                                'enum'                  => array( 'none', 'auto', 'metadata' ),
     71                                'default'               => 'metadata',
     72                                'description'           => __( 'Preload' ),
     73                                'should_preview_update' => false,
     74                        ),
     75                        'loop'    => array(
     76                                'type'                  => 'boolean',
     77                                'default'               => false,
     78                                'description'           => __( 'Loop' ),
     79                                'should_preview_update' => false,
     80                        ),
     81                        'content' => array(
     82                                'type'                  => 'string',
     83                                'default'               => '',
     84                                'sanitize_callback'     => 'wp_kses_post',
     85                                'description'           => __( 'Tracks (subtitles, captions, descriptions, chapters, or metadata)' ),
     86                                'should_preview_update' => false,
     87                        ),
    9088                );
    9189
    … …  
    10098                }
    10199
    102                 return $schema;
     100                return array_merge( $schema, parent::get_instance_schema() );
    103101        }
    104102
    … …  
    106104         * Render the media on the frontend.
    107105         *
    108          * @since  4.8.0
     106         * @since 4.8.0
    109107         *
    110108         * @param array $instance Widget instance props.
  • trunk/src/wp-includes/widgets/class-wp-widget-media.php

    r44796 r45100  
    123123         * Get schema for properties of a widget instance (item).
    124124         *
    125          * @since  4.8.0
     125         * @since 4.8.0
    126126         *
    127127         * @see WP_REST_Controller::get_item_schema()
Note: See TracChangeset for help on using the changeset viewer.