Skip to content

Commit 36c2f88

Browse files
committed
Widgets: Include widget_text class name on Custom HTML widget wrapper for theme styling compatibility, in addition to previously-added textwidget class on nested content container.
Amends [40893], [41115]. See #40907. Fixes #41392 for trunk. git-svn-id: https://develop.svn.wordpress.org/trunk@41116 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 642693b commit 36c2f88

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/wp-includes/widgets/class-wp-widget-custom-html.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ public function widget( $args, $instance ) {
7575
*/
7676
$content = apply_filters( 'widget_custom_html_content', $content, $instance, $this );
7777

78+
// Inject the Text widget's container class name alongside this widget's class name for theme styling compatibility.
79+
$args['before_widget'] = preg_replace( '/(?<=\sclass=["\'])/', 'widget_text ', $args['before_widget'] );
80+
7881
echo $args['before_widget'];
7982
if ( ! empty( $title ) ) {
8083
echo $args['before_title'] . $title . $args['after_title'];

tests/phpunit/tests/widgets/custom-html-widget.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function test_widget() {
5151
$args = array(
5252
'before_title' => '<h2>',
5353
'after_title' => "</h2>\n",
54-
'before_widget' => '<section>',
54+
'before_widget' => '<section id="custom_html-5" class="widget widget_custom_html">',
5555
'after_widget' => "</section>\n",
5656
);
5757
$instance = array(
@@ -70,7 +70,8 @@ function test_widget() {
7070
$this->assertNotEmpty( $this->widget_custom_html_content_args );
7171
$this->assertNotEmpty( $this->widget_text_args );
7272
$this->assertContains( '[filter:widget_text][filter:widget_custom_html_content]', $output );
73-
$this->assertContains( '<div class="textwidget custom-html-widget">', $output );
73+
$this->assertContains( '<section id="custom_html-5" class="widget_text widget widget_custom_html">', $output );
74+
$this->assertContains( 'class="widget_text widget widget_custom_html"', $output );
7475
$this->assertNotContains( '<p>', $output );
7576
$this->assertNotContains( '<br>', $output );
7677
$this->assertNotContains( '</u>', $output );

0 commit comments

Comments
 (0)