[wp-hackers] register_setting firing callback when widget is added?!

Matt Jacob matt at mattjacob.com
Thu Jul 29 14:59:57 UTC 2010


On 7/29/10 7:49 AM, Andrew Nacin wrote:
> you might be missing.. But it may help to understand how
> register_setting()'s sanitization callbacks work. It simply hooks the
> callback to the sanitize_option_$option filter, thus if you are calling
> update_option( 'my_name', ... ) on your own, you're also triggering your
> callback.

Actually, that is helpful to know. My callback for 
wp_register_widget_control does an update_option when the widget is 
submitted, so that explains it. I can check whether the argument to the 
validation callback is an array or an object and work around the problem 
that way.

But now I'm wondering why the widget is submitted immediately after 
adding it. That seems... unnecessary?

Matt


More information about the wp-hackers mailing list