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
This commit is contained in:
parent
642693bb91
commit
36c2f88a60
@ -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'];
|
||||
|
@ -51,7 +51,7 @@ class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase {
|
||||
$args = array(
|
||||
'before_title' => '<h2>',
|
||||
'after_title' => "</h2>\n",
|
||||
'before_widget' => '<section>',
|
||||
'before_widget' => '<section id="custom_html-5" class="widget widget_custom_html">',
|
||||
'after_widget' => "</section>\n",
|
||||
);
|
||||
$instance = array(
|
||||
@ -70,7 +70,8 @@ class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase {
|
||||
$this->assertNotEmpty( $this->widget_custom_html_content_args );
|
||||
$this->assertNotEmpty( $this->widget_text_args );
|
||||
$this->assertContains( '[filter:widget_text][filter:widget_custom_html_content]', $output );
|
||||
$this->assertContains( '<div class="textwidget custom-html-widget">', $output );
|
||||
$this->assertContains( '<section id="custom_html-5" class="widget_text widget widget_custom_html">', $output );
|
||||
$this->assertContains( 'class="widget_text widget widget_custom_html"', $output );
|
||||
$this->assertNotContains( '<p>', $output );
|
||||
$this->assertNotContains( '<br>', $output );
|
||||
$this->assertNotContains( '</u>', $output );
|
||||
|
Loading…
Reference in New Issue
Block a user