WordPress-Plugin-Template icon indicating copy to clipboard operation
WordPress-Plugin-Template copied to clipboard

Settings array empty

Open nine-2-five opened this issue 9 years ago • 3 comments

On init, the instance of this plugin contains the object WordPress_Plugin_Template_Settings, but its field 'settings' is an empty array. Is it my responsibility to create/load this array with plugin settings or should this happen automagically?

nine-2-five avatar Oct 04 '15 08:10 nine-2-five

WordPress_Plugin_Template_Settings has settings which are automatically added to the settings array by the settings_fields() function, These settings are only examples. You will need to edit that function to create the setting fields that will work for your plugin.

geotonics avatar Oct 05 '15 09:10 geotonics

Yeah I created the new settings fields, and they save to db ok. But I don't know whether there's a simpler way than get_option('prefix_fieldnam') for each field. Is it possible to get an array of all the settings at once?

nine-2-five avatar Oct 05 '15 09:10 nine-2-five

You can get all options with https://codex.wordpress.org/Function_Reference/wp_load_alloptions but I don't know of any built in way to get all options for one plugin. You could create your own function to limit the results to certain options by copying that function, renaming the copy, and modifying the query. .

geotonics avatar Oct 05 '15 11:10 geotonics