Make WordPress Core

Opened 9 years ago

Last modified 5 years ago

#33602 assigned defect (bug)

is_active_sidebar returns true when widget has been deactivated

Reported by: karlikdesign's profile karlikdesign Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.3
Component: Widgets Keywords: reporter-feedback
Focuses: administration Cc:

Description

When I activate a plugin (in this case Ultimate Social Media and Share icons)
Add the widget to my sidebar area
Deactivate the plugin
The widget is no longer visible in the sidebar
BUT
is_active_sidebar still returns true

Attachments (1)

33602.diff (1.4 KB) - added by welcher 9 years ago.

Download all attachments as: .zip

Change History (7)

#1 @welcher
9 years ago

  • Focuses administration added
  • Keywords close 2nd-opinion added

I believe this is due to how the widgets are stored. Adding a widget to a sidebar and then deactivating the plugin that generates the widget doesn't purge the widget instance from the sidebars_widgets option - to my knowledge anyway - and that is essentially what is driving whether or not a sidebar is considered active.

#2 follow-up: @knutsp
9 years ago

Can is_active_sidebar() scan through all the widgets and check is every registered widget is actually not deactivated?

If not realistic, this a wontfix, even if it may seem unexpected behaviour. A note could be added to the docs.

#3 in reply to: ↑ 2 @welcher
9 years ago

  • Keywords close 2nd-opinion removed
  • Owner set to welcher
  • Status changed from new to assigned

Replying to knutsp:

Can is_active_sidebar() scan through all the widgets and check is every registered widget is actually not deactivated?

If not realistic, this a wontfix, even if it may seem unexpected behaviour. A note could be added to the docs.

It's possible to look at the contents of $wp_registered_widgets to see if the instances stored in sidebars_widgets are in there. I was able to address the issue by using the is_active_sidebar filter with this -[ https://gist.github.com/ryanwelcher/64042dc1946f36840b61]

I'll work it into a patch shortly.

@welcher
9 years ago

#4 @welcher
9 years ago

  • Keywords has-patch dev-feedback added
  • Milestone changed from Awaiting Review to 4.4

#5 @welcher
9 years ago

  • Keywords needs-testing added; dev-feedback removed

#6 @welcher
9 years ago

  • Keywords reporter-feedback added; has-patch needs-testing removed
  • Milestone changed from 4.4 to Future Release
  • Owner welcher deleted

After some review, I think we need some more insight on how to reproduce this. Would you be able to provide concise steps to reproduce this?

Note: See TracTickets for help on using tickets.