[wp-hackers] register_setting firing callback when widget is added?!
Matt Jacob
matt at mattjacob.com
Thu Jul 29 14:43:20 UTC 2010
This is probably the most bizarre WP issue I've come across in a long
time, so I apologize if it's difficult to make sense of what I'm talking
about. I'll do my best to describe the problem clearly, though.
I have a method that gets hooked into admin_init, like so:
> add_action('admin_init', array($this, 'initialize_admin'));
> public function initialize_admin() {
> register_setting('my_group', 'my_name', array($this, 'validate_options_page'));
> }
Group and option names were changed to make the code shorter.
I also have a widget that my plugin provides. When I drag that widget
into an available widget area, I get a PHP fatal error about trying to
use an object as an array. (I store my plugin's settings in an object
and save it as a single option in the DB.)
I've tracked the error down to inside my validate_options_page method.
The question, then, is: why the heck is my validation callback firing
when activating my widget?
I'm thoroughly and legitimately stumped here. I'm hoping someone else
has some good insights into this problem.
Matt
More information about the wp-hackers
mailing list