Default settings ignored in register_settings
-
I’m built a plugin, and set up its default settings with register_settings:
register_setting(Add_Img_Maps::get_plugin_name() , Add_Img_Maps::get_plugin_name(), array( 'default'=> array( 'header' => 1, 'content' => 1, 'thumbnail' => 1, 'imagemapresizer' => 1, 'srcset' => 'off', ) ));
(And yes, I’ve confirmed that the function is called.)
The options page is displayed by a partial .php file which calls get_options. But when I installed the plugin on a fresh site, no options were set,
srcset
which is an either/or radio button setting.The options page works apart from this, which makes this a trivial-impact bug. Which is just as well, because I don’t have the kind of virtual machine setup which would let me instantiate new WordPress installations to test this out on. (Settings persist even when I uninstall the plugin, despite a proper uninstall script, which is another trivial-impact issue.)
I’ve checked that the activate() function is called, the register_settings documentation, and that the key matches the get_options call. What else should I be checking?
The zipfiles on the release page can be imported directly into WordPress.
The page I need help with: [log in to see the link]
- The topic ‘Default settings ignored in register_settings’ is closed to new replies.