equal
deleted
inserted
replaced
57 $widget_opts = wp_parse_args( |
57 $widget_opts = wp_parse_args( |
58 $widget_options, |
58 $widget_options, |
59 array( |
59 array( |
60 'description' => __( 'A media item.' ), |
60 'description' => __( 'A media item.' ), |
61 'customize_selective_refresh' => true, |
61 'customize_selective_refresh' => true, |
|
62 'show_instance_in_rest' => true, |
62 'mime_type' => '', |
63 'mime_type' => '', |
63 ) |
64 ) |
64 ); |
65 ); |
65 |
66 |
66 $control_opts = wp_parse_args( $control_options, array() ); |
67 $control_opts = wp_parse_args( $control_options, array() ); |
94 /** |
95 /** |
95 * Add hooks while registering all widget instances of this widget class. |
96 * Add hooks while registering all widget instances of this widget class. |
96 * |
97 * |
97 * @since 4.8.0 |
98 * @since 4.8.0 |
98 * |
99 * |
99 * @param integer $number Optional. The unique order number of this widget instance |
100 * @param int $number Optional. The unique order number of this widget instance |
100 * compared to other instances of the same class. Default -1. |
101 * compared to other instances of the same class. Default -1. |
101 */ |
102 */ |
102 public function _register_one( $number = -1 ) { |
103 public function _register_one( $number = -1 ) { |
103 parent::_register_one( $number ); |
104 parent::_register_one( $number ); |
104 if ( $this->registered ) { |
105 if ( $this->registered ) { |
105 return; |
106 return; |
160 * Filters the media widget instance schema to add additional properties. |
161 * Filters the media widget instance schema to add additional properties. |
161 * |
162 * |
162 * @since 4.9.0 |
163 * @since 4.9.0 |
163 * |
164 * |
164 * @param array $schema Instance schema. |
165 * @param array $schema Instance schema. |
165 * @param WP_Widget_Media $this Widget object. |
166 * @param WP_Widget_Media $widget Widget object. |
166 */ |
167 */ |
167 $schema = apply_filters( "widget_{$this->id_base}_instance_schema", $schema, $this ); |
168 $schema = apply_filters( "widget_{$this->id_base}_instance_schema", $schema, $this ); |
168 |
169 |
169 return $schema; |
170 return $schema; |
170 } |
171 } |
206 if ( is_string( $tokens ) ) { |
207 if ( is_string( $tokens ) ) { |
207 $tokens = preg_split( '/\s+/', trim( $tokens ) ); |
208 $tokens = preg_split( '/\s+/', trim( $tokens ) ); |
208 } |
209 } |
209 $tokens = array_map( 'sanitize_html_class', $tokens ); |
210 $tokens = array_map( 'sanitize_html_class', $tokens ); |
210 $tokens = array_filter( $tokens ); |
211 $tokens = array_filter( $tokens ); |
211 return join( ' ', $tokens ); |
212 return implode( ' ', $tokens ); |
212 } |
213 } |
213 |
214 |
214 /** |
215 /** |
215 * Displays the widget on the front-end. |
216 * Displays the widget on the front-end. |
216 * |
217 * |
243 * |
244 * |
244 * @since 4.8.0 |
245 * @since 4.8.0 |
245 * |
246 * |
246 * @param array $instance Instance data. |
247 * @param array $instance Instance data. |
247 * @param array $args Widget args. |
248 * @param array $args Widget args. |
248 * @param WP_Widget_Media $this Widget object. |
249 * @param WP_Widget_Media $widget Widget object. |
249 */ |
250 */ |
250 $instance = apply_filters( "widget_{$this->id_base}_instance", $instance, $args, $this ); |
251 $instance = apply_filters( "widget_{$this->id_base}_instance", $instance, $args, $this ); |
251 |
252 |
252 $this->render_media( $instance ); |
253 $this->render_media( $instance ); |
253 |
254 |
341 type="hidden" |
342 type="hidden" |
342 data-property="<?php echo esc_attr( $name ); ?>" |
343 data-property="<?php echo esc_attr( $name ); ?>" |
343 class="media-widget-instance-property" |
344 class="media-widget-instance-property" |
344 name="<?php echo esc_attr( $this->get_field_name( $name ) ); ?>" |
345 name="<?php echo esc_attr( $this->get_field_name( $name ) ); ?>" |
345 id="<?php echo esc_attr( $this->get_field_id( $name ) ); // Needed specifically by wpWidgets.appendTitle(). ?>" |
346 id="<?php echo esc_attr( $this->get_field_id( $name ) ); // Needed specifically by wpWidgets.appendTitle(). ?>" |
346 value="<?php echo esc_attr( is_array( $value ) ? join( ',', $value ) : strval( $value ) ); ?>" |
347 value="<?php echo esc_attr( is_array( $value ) ? implode( ',', $value ) : (string) $value ); ?>" |
347 /> |
348 /> |
348 <?php |
349 <?php |
349 endforeach; |
350 endforeach; |
350 } |
351 } |
351 |
352 |