equal
deleted
inserted
replaced
32 public function __construct() { |
32 public function __construct() { |
33 $widget_ops = array( |
33 $widget_ops = array( |
34 'classname' => 'widget_text', |
34 'classname' => 'widget_text', |
35 'description' => __( 'Arbitrary text.' ), |
35 'description' => __( 'Arbitrary text.' ), |
36 'customize_selective_refresh' => true, |
36 'customize_selective_refresh' => true, |
|
37 'show_instance_in_rest' => true, |
37 ); |
38 ); |
38 $control_ops = array( |
39 $control_ops = array( |
39 'width' => 400, |
40 'width' => 400, |
40 'height' => 350, |
41 'height' => 350, |
41 ); |
42 ); |
43 } |
44 } |
44 |
45 |
45 /** |
46 /** |
46 * Add hooks for enqueueing assets when registering all widget instances of this widget class. |
47 * Add hooks for enqueueing assets when registering all widget instances of this widget class. |
47 * |
48 * |
48 * @param integer $number Optional. The unique order number of this widget instance |
49 * @param int $number Optional. The unique order number of this widget instance |
49 * compared to other instances of the same class. Default -1. |
50 * compared to other instances of the same class. Default -1. |
50 */ |
51 */ |
51 public function _register_one( $number = -1 ) { |
52 public function _register_one( $number = -1 ) { |
52 parent::_register_one( $number ); |
53 parent::_register_one( $number ); |
53 if ( $this->registered ) { |
54 if ( $this->registered ) { |
54 return; |
55 return; |
191 // Otherwise, the text contains no elements/attributes that TinyMCE could drop, and therefore the widget does not need legacy mode. |
192 // Otherwise, the text contains no elements/attributes that TinyMCE could drop, and therefore the widget does not need legacy mode. |
192 return false; |
193 return false; |
193 } |
194 } |
194 |
195 |
195 /** |
196 /** |
196 * Filter gallery shortcode attributes. |
197 * Filters gallery shortcode attributes. |
197 * |
198 * |
198 * Prevents all of a site's attachments from being shown in a gallery displayed on a |
199 * Prevents all of a site's attachments from being shown in a gallery displayed on a |
199 * non-singular template where a $post context is not available. |
200 * non-singular template where a $post context is not available. |
200 * |
201 * |
201 * @since 4.9.0 |
202 * @since 4.9.0 |
268 |
269 |
269 /** |
270 /** |
270 * Filters the content of the Text widget. |
271 * Filters the content of the Text widget. |
271 * |
272 * |
272 * @since 2.3.0 |
273 * @since 2.3.0 |
273 * @since 4.4.0 Added the `$this` parameter. |
274 * @since 4.4.0 Added the `$widget` parameter. |
274 * @since 4.8.1 The `$this` param may now be a `WP_Widget_Custom_HTML` object in addition to a `WP_Widget_Text` object. |
275 * @since 4.8.1 The `$widget` param may now be a `WP_Widget_Custom_HTML` object in addition to a `WP_Widget_Text` object. |
275 * |
276 * |
276 * @param string $text The widget content. |
277 * @param string $text The widget content. |
277 * @param array $instance Array of settings for the current widget. |
278 * @param array $instance Array of settings for the current widget. |
278 * @param WP_Widget_Text|WP_Widget_Custom_HTML $this Current Text widget instance. |
279 * @param WP_Widget_Text|WP_Widget_Custom_HTML $widget Current text or HTML widget instance. |
279 */ |
280 */ |
280 $text = apply_filters( 'widget_text', $text, $instance, $this ); |
281 $text = apply_filters( 'widget_text', $text, $instance, $this ); |
281 |
282 |
282 if ( $is_visual_text_widget ) { |
283 if ( $is_visual_text_widget ) { |
283 |
284 |
288 * |
289 * |
289 * @since 4.8.0 |
290 * @since 4.8.0 |
290 * |
291 * |
291 * @param string $text The widget content. |
292 * @param string $text The widget content. |
292 * @param array $instance Array of settings for the current widget. |
293 * @param array $instance Array of settings for the current widget. |
293 * @param WP_Widget_Text $this Current Text widget instance. |
294 * @param WP_Widget_Text $widget Current Text widget instance. |
294 */ |
295 */ |
295 $text = apply_filters( 'widget_text_content', $text, $instance, $this ); |
296 $text = apply_filters( 'widget_text_content', $text, $instance, $this ); |
296 } else { |
297 } else { |
297 // Now in legacy mode, add paragraphs and line breaks when checkbox is checked. |
298 // Now in legacy mode, add paragraphs and line breaks when checkbox is checked. |
298 if ( ! empty( $instance['filter'] ) ) { |
299 if ( ! empty( $instance['filter'] ) ) { |
329 echo $args['before_title'] . $title . $args['after_title']; |
330 echo $args['before_title'] . $title . $args['after_title']; |
330 } |
331 } |
331 |
332 |
332 $text = preg_replace_callback( '#<(video|iframe|object|embed)\s[^>]*>#i', array( $this, 'inject_video_max_width_style' ), $text ); |
333 $text = preg_replace_callback( '#<(video|iframe|object|embed)\s[^>]*>#i', array( $this, 'inject_video_max_width_style' ), $text ); |
333 |
334 |
334 // Adds noreferrer and noopener relationships, without duplicating values, to all HTML A elements that have a target. |
335 // Adds 'noopener' relationship, without duplicating values, to all HTML A elements that have a target. |
335 $text = wp_targeted_link_rel( $text ); |
336 $text = wp_targeted_link_rel( $text ); |
336 |
337 |
337 ?> |
338 ?> |
338 <div class="textwidget"><?php echo $text; ?></div> |
339 <div class="textwidget"><?php echo $text; ?></div> |
339 <?php |
340 <?php |
487 <input id="<?php echo $this->get_field_id( 'visual' ); ?>" name="<?php echo $this->get_field_name( 'visual' ); ?>" class="visual sync-input" type="hidden" value="on"> |
488 <input id="<?php echo $this->get_field_id( 'visual' ); ?>" name="<?php echo $this->get_field_name( 'visual' ); ?>" class="visual sync-input" type="hidden" value="on"> |
488 <?php else : ?> |
489 <?php else : ?> |
489 <input id="<?php echo $this->get_field_id( 'visual' ); ?>" name="<?php echo $this->get_field_name( 'visual' ); ?>" class="visual" type="hidden" value=""> |
490 <input id="<?php echo $this->get_field_id( 'visual' ); ?>" name="<?php echo $this->get_field_name( 'visual' ); ?>" class="visual" type="hidden" value=""> |
490 <p> |
491 <p> |
491 <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> |
492 <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> |
492 <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>"/> |
493 <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" /> |
493 </p> |
494 </p> |
494 <div class="notice inline notice-info notice-alt"> |
495 <div class="notice inline notice-info notice-alt"> |
495 <?php if ( ! isset( $instance['visual'] ) ) : ?> |
496 <?php if ( ! isset( $instance['visual'] ) ) : ?> |
496 <p><?php _e( 'This widget may contain code that may work better in the “Custom HTML” widget. How about trying that widget instead?' ); ?></p> |
497 <p><?php _e( 'This widget may contain code that may work better in the “Custom HTML” widget. How about trying that widget instead?' ); ?></p> |
497 <?php else : ?> |
498 <?php else : ?> |