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 7447415185..7fcce78f19 100644 --- a/src/wp-includes/widgets/class-wp-widget-custom-html.php +++ b/src/wp-includes/widgets/class-wp-widget-custom-html.php @@ -75,6 +75,9 @@ class WP_Widget_Custom_HTML extends WP_Widget { */ $content = apply_filters( 'widget_custom_html_content', $content, $instance, $this ); + // Inject the Text widget's container class name alongside this widget's class name for theme styling compatibility. + $args['before_widget'] = preg_replace( '/(?<=\sclass=["\'])/', 'widget_text ', $args['before_widget'] ); + echo $args['before_widget']; if ( ! empty( $title ) ) { echo $args['before_title'] . $title . $args['after_title']; diff --git a/tests/phpunit/tests/widgets/custom-html-widget.php b/tests/phpunit/tests/widgets/custom-html-widget.php index a9fe7c33cb..916cc1fc46 100644 --- a/tests/phpunit/tests/widgets/custom-html-widget.php +++ b/tests/phpunit/tests/widgets/custom-html-widget.php @@ -51,7 +51,7 @@ class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase { $args = array( 'before_title' => '