Opened 13 years ago
Last modified 12 months ago
#24283 new defect (bug)
is_active_widget() incorrect logic
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | Widgets | Keywords: | dev-feedback |
| Focuses: | Cc: |
Description
is_active_widget() only returns 'true' only if widget used inside sidebar.
But there is a provision to use widget directly using the_widget() function. I believe there is a need of alter the logic of just checking inside sidebars.
Change History (2)
Note: See
TracTickets for help on using
tickets.
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 thatthe_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 callsis_active_widget()on a widget beforethe_widget()has been called to render it, WordPress can't see into the future.A couple possible solutions:
is_active_widget()and rename it tois_widget_assigned_to_sidebar()or something does the exact same thing, but better reflects what it tests.is_active_widget()return true ifthe_widget()has been called for a widget type in the current page so far. I could see this being confusing.