diff --git src/wp-includes/widgets/class-wp-widget-custom-html.php src/wp-includes/widgets/class-wp-widget-custom-html.php
index 7447415185..7fcce78f19 100644
|
|
|
class WP_Widget_Custom_HTML extends WP_Widget { |
| 75 | 75 | */ |
| 76 | 76 | $content = apply_filters( 'widget_custom_html_content', $content, $instance, $this ); |
| 77 | 77 | |
| | 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 | |
| 78 | 81 | echo $args['before_widget']; |
| 79 | 82 | if ( ! empty( $title ) ) { |
| 80 | 83 | echo $args['before_title'] . $title . $args['after_title']; |
diff --git tests/phpunit/tests/widgets/custom-html-widget.php tests/phpunit/tests/widgets/custom-html-widget.php
index a9fe7c33cb..916cc1fc46 100644
|
|
|
class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase { |
| 51 | 51 | $args = array( |
| 52 | 52 | 'before_title' => '<h2>', |
| 53 | 53 | 'after_title' => "</h2>\n", |
| 54 | | 'before_widget' => '<section>', |
| | 54 | 'before_widget' => '<section id="custom_html-5" class="widget widget_custom_html">', |
| 55 | 55 | 'after_widget' => "</section>\n", |
| 56 | 56 | ); |
| 57 | 57 | $instance = array( |
| … |
… |
class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase { |
| 70 | 70 | $this->assertNotEmpty( $this->widget_custom_html_content_args ); |
| 71 | 71 | $this->assertNotEmpty( $this->widget_text_args ); |
| 72 | 72 | $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 ); |
| 74 | 75 | $this->assertNotContains( '<p>', $output ); |
| 75 | 76 | $this->assertNotContains( '<br>', $output ); |
| 76 | 77 | $this->assertNotContains( '</u>', $output ); |