JoeSz / Exopite-Simple-Options-Framework

Fast, easy and lightweight admin options/metabox form generator for WordPress Plugins and metaboxes.
GNU General Public License v3.0
78 stars 24 forks source link

Do not call default settings #32

Open mohammadr3z opened 3 years ago

mohammadr3z commented 3 years ago

When activating the plugin in WordPress, the default values are not called and the save settings button must be clicked. Is there a way to call the default values?

JoeSz commented 3 years ago

You could save the default options on plugin activation.

(https://developer.wordpress.org/reference/functions/get_option/) You can also use get_option( string $option, mixed $default = false ), but -I think- only if you save the options as "simple".

I would go with the plugin activation.

omgwtfwow commented 3 years ago

Hey @JoeSz any chance we can get a little documentation or advice on how to save these defaults on plugin activation?

For example, in the wp plugin boilerplate, we have a function that runs on plugin activation, but I don't understand what/which hooks I can use, or how to store the defaults so that they're available before the plugin throws the warnings/errors.