Make WordPress Core


Ignore:
Timestamp:
04/02/2019 10:12:11 PM (6 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.

File:
1 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.
Note: See TracChangeset for help on using the changeset viewer.