[wp-hackers] Does a widget save hook exist or do I need to create a ticket in Trac?
eric at eam.me
Thu Nov 3 15:46:26 UTC 2011
If this widget is your own widget, you can add your own hook to the
`update()` method of the widget class.
Your other option is to hook into the 'update_option' action directly.
When you save a widget's options it does the following:
1. Processing for the actual widget
2. Calling apply_filters<http://phpxref.ftwr.co.uk/wordpress/_functions/apply_filters.html>('widget_update_callback',
3. Calling $this<http://phpxref.ftwr.co.uk/wordpress/_variables/this.html>
To save the settings of all instances of that widget.
4. save_settings() calls update_option() ... code below:
= 1; update_option
So you *should* be able to hook into the regular update hooks just fine ...
On Thu, Nov 3, 2011 at 7:45 AM, Bjorn Wijers <burobjorn at gmail.com> wrote:
> I'm looking for a hook to use just after a widget has saved it's options.
> For example:
> I have a widget W whose options I have changed in the Appearance->Widgets
> screen. I press save and after the save a hook H is being called. My code
> hooks into the hook and does its thing.
> Clearing a site transient which is set in site X and also being used in
> all the other sites of my WordPress Multisite installation. Basically it
> saves me from (ab)using switch_to_blog()
> I've used the 'widget_update_callback' which in fact is called before the
> update (is this a bug or feature?) as well as the 'widget_form_callback',
> which gets called repeatedly something I would like to prevent. Any ideas
> for a better hook to use?
> Afaik there is not (yet?) a hook directly after saving a widget's options.
> Or is there? If not shall I create a ticket for this?
> Thanks in advance,
> wp-hackers mailing list
> wp-hackers at lists.automattic.**com <wp-hackers at lists.automattic.com>
More information about the wp-hackers