Widgets: When using the_widget(), the $before_widget argument only receives the widget class if using the default sidebar arguments. Run sprintf after parsing the args to fix this.

Adds unit test.

Props coffee2code.
Fixes #19450.


git-svn-id: https://develop.svn.wordpress.org/trunk@35106 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2015-10-13 01:48:41 +00:00
parent c0c0305749
commit 65c8adc252
2 changed files with 23 additions and 3 deletions

View File

@@ -607,4 +607,19 @@ class Tests_Widgets extends WP_UnitTestCase {
$this->assertContains( $contained, $control );
}
}
function test_the_widget_custom_before_title_arg() {
ob_start();
the_widget(
'WP_Widget_Text',
array( 'title' => 'Notes', 'text' => 'Sample text' ),
array( 'before_widget' => '<span class="special %s">', 'after_widget' => '</span>' )
);
$actual = ob_get_clean();
$this->assertRegExp( '/<span class="special widget_text">/', $actual );
}
}