[wp-trac] [WordPress Trac] #19450: the_widget won't replace the widget class if not using the default sidebar arguments

WordPress Trac wp-trac at lists.automattic.com
Fri Apr 27 19:31:05 UTC 2012


#19450: the_widget won't replace the widget class if not using the default sidebar
arguments
--------------------------+-----------------------------
 Reporter:  Felipelavinz  |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Future Release
Component:  Widgets       |     Version:  3.2.1
 Severity:  minor         |  Resolution:
 Keywords:  has-patch     |
--------------------------+-----------------------------
Changes (by coffee2code):

 * keywords:  needs-patch => has-patch
 * version:   => 3.2.1
 * milestone:  Awaiting Review => Future Release


Comment:

 Added [attachment:19450.diff].

 As originally reported, it is true that when using `the_widget()`, if you
 override the `before_widget` arg for the widget, there is no way to gain
 the benefit of auto-assignment of the default classname. The default
 `before_widget` value is defined as `<div class="widget %s">`. However,
 the %s gets replaced prior to use in the defaults arg array (and thus
 prior to being passed through `wp_parse_args()` to determine the final arg
 array).

 The patch, as originally proposed by @Felipelavinz, simply delays the
 `sprintf()` substitution until after the `wp_parse_args()` completes,
 allowing the following example to work properly:

 {{{
 the_widget('WP_Widget_Pages', 'title=Contents&sortby=post_modified',
 'before_widget=<div class="special
 %s">&before_title=<span>&after_title=</span>');
 }}}

 There should be no compatibility issues or any other drawbacks to its
 implementation.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/19450#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list