From 940c2238ecb43a1c83d1b0f9f513e7a3c5089cf7 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 18 Jul 2017 22:19:36 +0000 Subject: [PATCH] Widgets: Replace adding `balanceTags` on `widget_custom_html_content` filter in favor of just applying `widget_text` filters in Custom HTML widget. Ensures that users who copy HTML from the Text widget in legacy mode over to the Custom HTML widget will continue to get all of the same filters applied, including tag balancing and shortcodes, if a plugin added support. Plugins still have the `widget_text_content` and `widget_custom_html_content` filters they can use to target the specific widget types. Merges [41086] onto 4.8 branch. Amends [40893]. See #40951. Fixes #40907 for 4.8.1. Built from https://develop.svn.wordpress.org/branches/4.8@41087 git-svn-id: http://core.svn.wordpress.org/branches/4.8@40927 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/default-filters.php | 2 -- wp-includes/default-widgets.php | 3 ++- wp-includes/widgets/class-wp-widget-text.php | 7 ++++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index ada9c53c3f..8f0237028d 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -170,8 +170,6 @@ add_filter( 'widget_text_content', 'wptexturize' ); add_filter( 'widget_text_content', 'convert_smilies', 20 ); add_filter( 'widget_text_content', 'wpautop' ); -add_filter( 'widget_custom_html_content', 'balanceTags' ); - add_filter( 'date_i18n', 'wp_maybe_decline_date' ); // RSS filters diff --git a/wp-includes/default-widgets.php b/wp-includes/default-widgets.php index 2585978907..4afc525ecd 100644 --- a/wp-includes/default-widgets.php +++ b/wp-includes/default-widgets.php @@ -119,7 +119,8 @@ class WP_Widget_Custom_HTML extends WP_Widget { /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); - $content = $instance['content']; + /** This filter is documented in wp-includes/widgets/class-wp-widget-text.php */ + $content = apply_filters( 'widget_text', $instance['content'], $instance, $this ); /** * Filters the content of the Custom HTML widget. diff --git a/wp-includes/widgets/class-wp-widget-text.php b/wp-includes/widgets/class-wp-widget-text.php index 69b7b91aea..2297d2bee2 100644 --- a/wp-includes/widgets/class-wp-widget-text.php +++ b/wp-includes/widgets/class-wp-widget-text.php @@ -213,10 +213,11 @@ class WP_Widget_Text extends WP_Widget { * * @since 2.3.0 * @since 4.4.0 Added the `$this` parameter. + * @since 4.8.1 The `$this` 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 $this Current Text widget instance. + * @param string $text The widget content. + * @param array $instance Array of settings for the current widget. + * @param WP_Widget_Text|WP_Widget_Custom_HTML $this Current Text widget instance. */ $text = apply_filters( 'widget_text', $text, $instance, $this );