WordPress.org

Make WordPress Core

Ticket #49588: 49588.patch

File 49588.patch, 2.3 KB (added by sabernhardt, 3 months ago)
  • src/wp-includes/widgets/class-wp-widget-custom-html.php

     
    164164                $post = $original_post;
    165165                remove_filter( 'shortcode_atts_gallery', array( $this, '_filter_gallery_shortcode_attrs' ) );
    166166
    167                 // Inject the Text widget's container class name alongside this widget's class name for theme styling compatibility.
    168                 $args['before_widget'] = preg_replace( '/(?<=\sclass=["\'])/', 'widget_text ', $args['before_widget'] );
     167                $args = apply_filters( 'widget_custom_html_args', $args );
    169168
     169                // Inject the Text widget's container class names alongside this widget's class name for theme styling compatibility.
     170                $args['before_widget'] = preg_replace( '/(?<=\sclass=["\'])/', 'widget_text textwidget custom-html-widget ', $args['before_widget'], 1 );
     171
    170172                echo $args['before_widget'];
    171173                if ( ! empty( $title ) ) {
    172174                        echo $args['before_title'] . $title . $args['after_title'];
    173175                }
    174                 echo '<div class="textwidget custom-html-widget">'; // The textwidget class is for theme styling compatibility.
    175176                echo $content;
    176                 echo '</div>';
    177177                echo $args['after_widget'];
    178178        }
    179179
  • tests/phpunit/tests/widgets/custom-html-widget.php

     
    112112                $this->assertNotEmpty( $this->widget_custom_html_content_args );
    113113                $this->assertNotEmpty( $this->widget_text_args );
    114114                $this->assertContains( '[filter:widget_text][filter:widget_custom_html_content]', $output );
    115                 $this->assertContains( '<section id="custom_html-5" class="widget_text widget widget_custom_html">', $output );
    116                 $this->assertContains( '<div class="textwidget custom-html-widget">', $output );
     115                $this->assertContains( '<section id="custom_html-5" class="widget_text textwidget custom-html-widget widget widget_custom_html">', $output );
    117116                $this->assertNotContains( '<p>', $output );
    118117                $this->assertNotContains( '<br>', $output );
    119118                $this->assertNotContains( '</u>', $output );