Changeset 41951
- Timestamp:
- 10/19/2017 11:43:22 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/widgets/media-gallery-widget.js
r41872 r41951 202 202 203 203 mediaFrameProps = control.mapModelToMediaFrameProps( control.model.toJSON() ); 204 selection.gallery = new Backbone.Model( _.pick( mediaFrameProps, 'columns', 'link', 'size', '_orderbyRandom' ));204 selection.gallery = new Backbone.Model( mediaFrameProps ); 205 205 if ( mediaFrameProps.size ) { 206 206 control.displaySettings.set( 'size', mediaFrameProps.size ); -
trunk/src/wp-includes/widgets/class-wp-widget-media-gallery.php
r41840 r41951 47 47 */ 48 48 public function get_instance_schema() { 49 returnarray(49 $schema = array( 50 50 'title' => array( 51 51 'type' => 'string', … … 88 88 ), 89 89 ); 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; 90 95 } 91 96 … … 101 106 $instance = array_merge( wp_list_pluck( $this->get_instance_schema(), 'default' ), $instance ); 102 107 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 ) 108 113 ); 109 114 -
trunk/src/wp-includes/widgets/class-wp-widget-media.php
r41866 r41951 128 128 */ 129 129 public function get_instance_schema() { 130 returnarray(130 $schema = array( 131 131 'attachment_id' => array( 132 132 'type' => 'integer', … … 150 150 ), 151 151 ); 152 153 /** 154 * Filters the media widget instance schema to add additional properties. 155 * 156 * @since 4.9.0 157 * 158 * @param array $schema Instance schema. 159 * @param WP_Widget_Media $this Widget object. 160 */ 161 $schema = apply_filters( "widget_{$this->id_base}_instance_schema", $schema, $this ); 162 163 return $schema; 152 164 } 153 165 -
trunk/tests/phpunit/tests/widgets/media-widget.php
r40674 r41951 166 166 167 167 /** 168 * Instance schema args. 169 * 170 * @var array 171 */ 172 protected $filter_instance_schema_args; 173 174 /** 175 * Filter instance schema. 176 * 177 * @param array $schema Schema. 178 * @param WP_Widget_Media $widget Widget. 179 * 180 * @return array 181 */ 182 public function filter_instance_schema( $schema, $widget ) { 183 $this->filter_instance_schema_args = compact( 'schema', 'widget' ); 184 $schema['injected'] = array( 185 'type' => 'boolean', 186 ); 187 return $schema; 188 } 189 190 /** 168 191 * Test get_instance_schema method. 169 192 * … … 179 202 'url', 180 203 ), array_keys( $schema ) ); 204 205 // Check filter usage. 206 $this->filter_instance_schema_args = null; 207 add_filter( 'widget_mocked_instance_schema', array( $this, 'filter_instance_schema' ), 10, 2 ); 208 $schema = $widget->get_instance_schema(); 209 $this->assertInternalType( 'array', $this->filter_instance_schema_args ); 210 $this->assertSame( $widget, $this->filter_instance_schema_args['widget'] ); 211 $this->assertEqualSets( array( 'attachment_id', 'title', 'url' ), array_keys( $this->filter_instance_schema_args['schema'] ) ); 212 $this->assertArrayHasKey( 'injected', $schema ); 181 213 } 182 214
Note: See TracChangeset
for help on using the changeset viewer.