Make WordPress Core

Ticket #41392: 41392.2.diff

File 41392.2.diff, 2.1 KB (added by westonruter, 6 years ago)
  • src/wp-includes/widgets/class-wp-widget-custom-html.php

    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 { 
    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

    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 { 
    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(
    class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase { 
    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 );