Hi David,
I think the better way to approach the options save would be using WordPress settings API instead of a custom form submission method for POST. That way you can also safely ensure that your plugin settings are updated only when the ‘submit’ button from your plugin options page is pressed but not when other options are saved or updated.
Here is a guide to WP settings API and there are useful functions to automatically render the options in your relevant form fields (settings_fields, do_settings_fields() and automatically update the options when the form is submitted (register_setting).
So, in your options form, you can add these two lines immediately after the form tag:
<form ...
settings_fields('footnotes-made-easy-settings-group');
do_settings_sections('footnotes-made-easy-settings-group');
....
and before closing the form you can add the submit button using the function:
...
submit_button();
</form>
To register your custom settings group so WP knows that they are valid options to be automatically processed, you can use the register_setting
function in an admin hook.
add_action('admin_init', 'register_footnotes_settings');
function register_footnotes_settings()
{
register_setting('footnotes-made-easy-settings-group', 'your_option_name');
register_setting('footnotes-made-easy-settings-group', 'your_option_name');
}
I would advise to use your option_name
as an array for all your fields so as to store the options in a serialised array rather than each single option. Otherwise, you will have to register each option field separately using the register_setting
method as shown above.
I hope it helps.
Best,
Fathima
I’ve now released version 1.0.2 of the plugin which, I believe, resolves the un-going issue.
Apologies for how long this has taken to resolve.
Unfortunately the Version 1.0.2 isn’t working as well 🙁
Thanks for letting me know. Can you confirm what happened? I’ve had no other reports that this hasn’t worked and it’s been working perfectly on my own site as well.
I use it for talmud.de – as soon as I activate the new version I get hundreds of lines with this error: [snip] is the path on the server. I deleted some elements:
Warning: strpos(): Empty needle in [snip] tlmd/wp-content/plugins/footnotes-made-easy/footnotes-made-easy.php on line 260
What happened: I updated the plugin, I activated the plugin, I reloaded a page without any footnotes: Fail with the error message above.
So, I deactivated it, activated it again, opened the settings page, saved the new settings, reloaded a page without footnotes: Fail with the error message above.
Can you provide me with a screenshot of your Footnotes settings screen? That would really help.
Ah, I see – most of your options are still blank and that will be causing the issue. Make sure you fill in all the settings, save and the error should go.