Make WordPress Core


Ignore:
Timestamp:
10/19/2017 11:43:22 PM (9 years ago)
Author:
westonruter
Message:

Widgets: Improve extensibility of the Gallery widget and of media widgets generally.

  • Introduce a widget_{$id_base}_instance_schema filter for plugins to add new properties to a media widget's instance schema.
  • Pass all of a gallery widget's instance props to the gallery media frame, not just the ones that core supports.

See #32417, #41914.
Fixes #42285.

File:
1 edited

Legend:

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

    r41840 r41951  
    4747         */
    4848        public function get_instance_schema() {
    49                 return array(
     49                $schema = array(
    5050                        'title' => array(
    5151                                'type' => 'string',
    … …  
    8888                        ),
    8989                );
     90
     91                /** This filter is documented in wp-includes/widgets/class-wp-widget-media.php */
     92                $schema = apply_filters( "widget_{$this->id_base}_instance_schema", $schema, $this );
     93
     94                return $schema;
    9095        }
    9196
    … …  
    101106                $instance = array_merge( wp_list_pluck( $this->get_instance_schema(), 'default' ), $instance );
    102107
    103                 $shortcode_atts = array(
    104                         'ids'     => $instance['ids'],
    105                         'columns' => $instance['columns'],
    106                         'link'    => $instance['link_type'],
    107                         'size'    => $instance['size'],
     108                $shortcode_atts = array_merge(
     109                        $instance,
     110                        array(
     111                                'link' => $instance['link_type'],
     112                        )
    108113                );
    109114
Note: See TracChangeset for help on using the changeset viewer.