From 642693bb916f233e36a5a4ad9b2a9707a2fb728a Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Fri, 21 Jul 2017 18:12:43 +0000 Subject: [PATCH] Widgets: Improve theme styling compatibility for Custom HTML widget by adding container with `textwidget` class. The same styling from the Text widget should apply to the Custom HTML widget since users are expected to copy HTML from the (legacy) Text widget into the latter. Amends [40893]. See #40907. Fixes #41392. git-svn-id: https://develop.svn.wordpress.org/trunk@41115 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/widgets/class-wp-widget-custom-html.php | 2 ++ tests/phpunit/tests/widgets/custom-html-widget.php | 1 + 2 files changed, 3 insertions(+) diff --git a/src/wp-includes/widgets/class-wp-widget-custom-html.php b/src/wp-includes/widgets/class-wp-widget-custom-html.php index 5de618285f..7447415185 100644 --- a/src/wp-includes/widgets/class-wp-widget-custom-html.php +++ b/src/wp-includes/widgets/class-wp-widget-custom-html.php @@ -79,7 +79,9 @@ class WP_Widget_Custom_HTML extends WP_Widget { if ( ! empty( $title ) ) { echo $args['before_title'] . $title . $args['after_title']; } + echo '
'; // The textwidget class is for theme styling compatibility. echo $content; + echo '
'; echo $args['after_widget']; } diff --git a/tests/phpunit/tests/widgets/custom-html-widget.php b/tests/phpunit/tests/widgets/custom-html-widget.php index c7c2e91bf8..a9fe7c33cb 100644 --- a/tests/phpunit/tests/widgets/custom-html-widget.php +++ b/tests/phpunit/tests/widgets/custom-html-widget.php @@ -70,6 +70,7 @@ class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase { $this->assertNotEmpty( $this->widget_custom_html_content_args ); $this->assertNotEmpty( $this->widget_text_args ); $this->assertContains( '[filter:widget_text][filter:widget_custom_html_content]', $output ); + $this->assertContains( '
', $output ); $this->assertNotContains( '

', $output ); $this->assertNotContains( '
', $output ); $this->assertNotContains( '', $output );