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.

Built from https://develop.svn.wordpress.org/trunk@35106


git-svn-id: http://core.svn.wordpress.org/trunk@35071 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-10-13 01:49:48 +00:00
parent 426944c744
commit 05cd8a447e
2 changed files with 9 additions and 4 deletions

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.4-alpha-35105'; $wp_version = '4.4-alpha-35106';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -949,10 +949,15 @@ function the_widget( $widget, $instance = array(), $args = array() ) {
return; return;
} }
$before_widget = sprintf('<div class="widget %s">', $widget_obj->widget_options['classname'] ); $default_args = array(
$default_args = array( 'before_widget' => $before_widget, 'after_widget' => "</div>", 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>' ); 'before_widget' => '<div class="widget %s">',
'after_widget' => "</div>",
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
);
$args = wp_parse_args( $args, $default_args );
$args['before_widget'] = sprintf( $args['before_widget'], $widget_obj->widget_options['classname'] );
$args = wp_parse_args($args, $default_args);
$instance = wp_parse_args($instance); $instance = wp_parse_args($instance);
/** /**