Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#41087 closed defect (bug) (duplicate)

Customizer: Deleting a Widget does not remove instance in options

Reported by: timmydcrawford's profile timmydcrawford Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.9
Component: Customize Keywords: close
Focuses: Cc:

Description (last modified by obenland)

When deleting a widget from widgets.php, for example a new Media Image Widget, the widget instance is removed from the widget_media_image site option, along with association/placement value in sidebars_widgets.

In the customizer however, if a widget is removed without having been saved first, the widget data ( again in this case testing with an image widget ), still exists in get_option( 'widget_media_image' ), while the entry in sidebars_widgets is either never added or properly removed.

It seems removal of a widget in both places ( widgets.php and customizer ) should result in the removal from the associated option in both cases.

Change History (9)

#1 @timmydcrawford
6 years ago

Confirmed the issue on trunk too.

Steps to re-create:

  • Add a new image widget ( or any widget )
  • Delete the widget via the customizer
  • get_option('widget_media_image')

#2 @obenland
6 years ago

  • Milestone changed from Awaiting Review to 4.8.1
  • Version changed from 4.8 to 3.9

#3 follow-up: @westonruter
6 years ago

  • Keywords reporter-feedback added
  • Milestone changed from 4.8.1 to Awaiting Review

@obenland @timmydcrawford is this not a duplicate #27575? Widgets are not able to be fully deleted in the Customizer because there is not yet the ability to manage inactive widgets from there (see #27404). You'll note that the widget in the customizer has a “Remove” link as opposed to a “Delete” link.

#4 in reply to: ↑ 3 @obenland
6 years ago

  • Keywords needs-patch added; reporter-feedback removed
  • Milestone changed from Awaiting Review to 4.8.1

Replying to westonruter:

@obenland @timmydcrawford is this not a duplicate #27575? Widgets are not able to be fully deleted in the Customizer because there is not yet the ability to manage inactive widgets from there (see #27404).

The key seems to be not to save changes. If you add and remove widgets without saving, the widget option will get updated but sidebars_widgets won't. Which seems to be a quite common scenario, looking at wp.com data. Ill update the ticket description.

You'll note that the widget in the customizer has a “Remove” link as opposed to a “Delete” link.

Did that change recently? It says "Delete | Close" for me.

#5 @obenland
6 years ago

  • Description modified (diff)

This ticket was mentioned in Slack in #core-customize by obenland. View the logs.


6 years ago

#7 @westonruter
6 years ago

  • Keywords close added; needs-patch removed

@obenland see comment 2 on #27575:

It is all intentional, actually. When a widget is added to a widget area but is not yet saved, then the "Delete" link is present. When the widget gets saved for the first time, it will change to "Remove"; at this point, instead of the widget instance being lost forever, clicking Remove places it in the Inactive Widgets sidebar, which then becomes a sort of widget trash can.

I agree that this is confusing now, as it has been raised a few times. But at the moment it is expected behavior which should get addressed with #27404.

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


6 years ago

#9 @westonruter
6 years ago

  • Milestone 4.8.1 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #27575.

Please re-open if I am missing something.

Note: See TracTickets for help on using tickets.