Opened 10 years ago
Closed 8 years ago
#36772 closed defect (bug) (invalid)
Widget from deactivated plugin still has its position in a sidebar
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | Widgets | Keywords: | has-screenshots |
| Focuses: | Cc: |
Description
Really not an expert about widgets, and not sure if this is the expected behavior. Noticed while working on #23328.
This gets evident when setting the Widgets screen in "accessibility mode" from the Screen Options tab.
To reproduce:
- enable a plugin that provides a widget
- add the widget from the plugin to a sidebar
- disable the plugin
At this point, my Sidebar has 3 widgets (without the one from the disabled plugin). But when editing one of the widgets in the sidebar, the select that shows the widgets "positions" shows 4 "positions". See screenshot below:
Attachments (2)
Change History (11)
#2
@
9 years ago
- Keywords needs-patch added; has-patch removed
Looks like unit tests are failing on my patch. Will address and update.
#3
@
9 years ago
@welcher see also how this was implemented for widgets in the Customizer: https://github.com/WordPress/wordpress-develop/blob/4.8.0/src/wp-includes/class-wp-customize-widgets.php#L1369-L1387
#4
@
8 years ago
@afercia I reviewed this again with some fresh eyes and am starting to think that this actually desired behavior.
When I add a new widget in no-js mode to an empty Sidebar - there is a position available for selection. It looks to be adding what the new position of the widget being added would be. See attached screenshot.
#5
@
8 years ago
@welcher I guess when adding a new widget, that's ok. The point is when editing existing widgets. If you follow the steps described above, there are 3 widgets and when editing one of them, I see 4 positions.
#6
@
8 years ago
- Keywords dev-feedback needs-patch removed
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
@afercia can you try it again. I just ran the steps above and can't reproduce - it might be me though :)

sidebars_widgetsstores an array of sidebar ID's which is another array with the widget instance id for each widget assigned to that sidebar id.To my knowledge, there is no simple way to retrieve a list of registered
id_base's so I've added a new array to the widget factory that tracks theid_basefor each registered widget class. Using that and thesidebars_widgetsfilter, we are able to remove any instances of unregistered widgets.