[wp-trac] [WordPress Trac] #24283: is_active_widget() incorrect logic

WordPress Trac noreply at wordpress.org
Sun Oct 27 18:40:53 UTC 2013


#24283: is_active_widget() incorrect logic
--------------------------+------------------------------
 Reporter:  valllabh      |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Widgets       |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  dev-feedback  |
--------------------------+------------------------------
Changes (by csixty4):

 * keywords:   => dev-feedback


Comment:

 I'm not sure this can be addressed practically. `is_active_widget()` just
 checks to see if a widget is assigned to a sidebar, and the reporter is
 right that `the_widget()` can render an arbitrary widget anywhere in a
 theme or plugin.

 If a widget is assigned to a sidebar, then `is_active_widget()` knows its
 state at start of rendering the page. But if something calls
 `is_active_widget()` on a widget before `the_widget()` has been called to
 render it, WordPress can't see into the future.

 A couple possible solutions:

 1. Keep the existing code as-is
 1. Deprecate `is_active_widget()` and rename it to
 `is_widget_assigned_to_sidebar()` or something does the exact same thing,
 but better reflects what it tests.
 1. Make `is_active_widget()` return true if `the_widget()` has been called
 for a widget type in the current page so far. I could see this being
 confusing.
 1. Provide a way for themes & plugins to declare what widgets they invoke
 directly. But that sets a precedent I'm not comfortable with, and the
 widgets can be rendered on a per-page basis which makes this kind of moot.

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


More information about the wp-trac mailing list