$widget_text_do_shortcode_priority =
has_filter( 'widget_text', 'do_shortcode'
);
$should_suspend_legacy_shortcode_support =
( $is_visual_text_widget && false !==
$widget_text_do_shortcode_priority );
if ( $should_suspend_legacy_shortcode_support ) { remove_filter( 'widget_text', 'do_shortcode',
$widget_text_do_shortcode_priority );
} // Override global $post so filters (and shortcodes) apply in a consistent context.
$original_post =
$post;
if ( is_singular() ) { // Make sure post is always the queried object on singular queries (not from another sub-query that failed to clean up the global $post).
$post =
get_queried_object();
} else { // Nullify the $post global during widget rendering to prevent shortcodes from running with the unexpected context on archive queries.
$post = null;
} // Prevent dumping out all attachments from the media library.
add_filter( 'shortcode_atts_gallery', array
( $this, '_filter_gallery_shortcode_attrs'
) );
/**
* Filters the content of the Text widget.
*
* @since 2.3.0
* @since 4.4.0 Added the `$widget` parameter.
* @since 4.8.1 The `$widget` param may now be a `WP_Widget_Custom_HTML` object in addition to a `WP_Widget_Text` object.
*
* @param string $text The widget content.
* @param array $instance Array of settings for the current widget.
* @param WP_Widget_Text|WP_Widget_Custom_HTML $widget Current text or HTML widget instance.
*/