[wp-trac] [WordPress Trac] #27444: delete widget action hook

WordPress Trac noreply at wordpress.org
Tue Mar 18 16:49:58 UTC 2014


#27444: delete widget action hook
-------------------------+-----------------------------
 Reporter:  afercia      |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Widgets      |    Version:  trunk
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 Just a proposal to have a new action to hook in when deleting a widget.

 For example, many themes or plugins provide widgets that fetch data from
 external sources and then store the response in a transient.
 When users delete the widget, the transient won't be deleted and will live
 forever in the database because it won't be requested again.

 Currently, the only way I've found to delete that transient, would be
 checking if POST 'delete_widget' isset and true and then checking POST
 'widget-id'. Same checks are already used in the core but having a
 specific action to use would be much more clean.

 Then, it would be a matter of a few lines of code to add an action to your
 widget constructor and write a new small method in your widget class to
 delete the transient. Basically it's something similar to what you're
 already doing to flush the wp_cache of the default Recent Posts widget.

 Besides this specific scenario, there might be lots of things developers
 would like to do after deleting a widget and this would be very handy.

 Attached proposal is just an example, for sure can be improved (maybe pass
 the widget-id as argument?) and extended. Hope you get the idea. Please
 consider I'm an absolute beginner with the WP core. Be nice :)

--
Ticket URL: <https://core.trac.wordpress.org/ticket/27444>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list