[wp-trac] [WordPress Trac] #29155: Widgets: is_active_widget returns true even when the widget is not displayed on specific page

WordPress Trac noreply at wordpress.org
Fri Aug 8 18:13:34 UTC 2014


#29155: Widgets: is_active_widget returns true even when the widget is not
displayed on specific page
--------------------------+------------------------------
 Reporter:  jeherve       |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Widgets       |     Version:  2.3
 Severity:  normal        |  Resolution:
 Keywords:  close         |     Focuses:
--------------------------+------------------------------
Changes (by westonruter):

 * keywords:   => close
 * version:  3.9.1 => 2.3


Comment:

 Yeah, that's probably not intuitive. The `is_active_widget` actually
 returns true if the widget is assigned to a sidebar, not whether it was
 actually rendered on the page. To do that, you' would currently need to
 add an action for `dynamic_sidebar` and keep a log of the widgets that are
 actually rendered on the page, and then in `wp_footer` you could do
 something with them. This is what Widget Customizer is doing, see
 [https://core.trac.wordpress.org/browser/tags/3.9.2/src/wp-includes/class-
 wp-customize-widgets.php#L1108
 WP_Customize_Widgets::tally_sidebars_via_dynamic_sidebar_calls()].

 A new function would be needed with different semantics than
 `is_active_widget()`, like `is_widget_displayed()`.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29155#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list