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.

git-svn-id: https://develop.svn.wordpress.org/trunk@45100 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2019-04-02 22:12:11 +00:00
parent b3a625fdf1
commit f4e57f92e4
4 changed files with 48 additions and 53 deletions

View File

@ -62,9 +62,7 @@ class WP_Widget_Media_Audio extends WP_Widget_Media {
* @return array Schema for properties.
*/
public function get_instance_schema() {
$schema = array_merge(
parent::get_instance_schema(),
array(
$schema = array(
'preload' => array(
'type' => 'string',
'enum' => array( 'none', 'auto', 'metadata' ),
@ -76,7 +74,6 @@ class WP_Widget_Media_Audio extends WP_Widget_Media {
'default' => false,
'description' => __( 'Loop' ),
),
)
);
foreach ( wp_get_audio_extensions() as $audio_extension ) {
@ -89,7 +86,7 @@ class WP_Widget_Media_Audio extends WP_Widget_Media {
);
}
return $schema;
return array_merge( $schema, parent::get_instance_schema() );
}
/**

View File

@ -62,7 +62,6 @@ class WP_Widget_Media_Image extends WP_Widget_Media {
*/
public function get_instance_schema() {
return array_merge(
parent::get_instance_schema(),
array(
'size' => array(
'type' => 'string',
@ -161,7 +160,8 @@ class WP_Widget_Media_Image extends WP_Widget_Media {
* - height (redundant when size is not custom)
* - width (redundant when size is not custom)
*/
)
),
parent::get_instance_schema()
);
}

View File

@ -63,9 +63,8 @@ class WP_Widget_Media_Video extends WP_Widget_Media {
* @return array Schema for properties.
*/
public function get_instance_schema() {
$schema = array_merge(
parent::get_instance_schema(),
array(
$schema = array(
'preload' => array(
'type' => 'string',
'enum' => array( 'none', 'auto', 'metadata' ),
@ -86,7 +85,6 @@ class WP_Widget_Media_Video extends WP_Widget_Media {
'description' => __( 'Tracks (subtitles, captions, descriptions, chapters, or metadata)' ),
'should_preview_update' => false,
),
)
);
foreach ( wp_get_video_extensions() as $video_extension ) {
@ -99,7 +97,7 @@ class WP_Widget_Media_Video extends WP_Widget_Media {
);
}
return $schema;
return array_merge( $schema, parent::get_instance_schema() );
}
/**