0

Looking at the Settings API and you can register new setting using register_setting() but I can't find a way of getting all the settings for a certain plugin.

Let's say I want to get a list with all settings for pluginA, how would you do it?

1
  • If I'm not wrong, the 2nd parameter of register_setting() is actually the option_name of options table. If you are putting multiple fields under a same setting, the option_value would be an array, otherwise would be a string. And you can get each of those register_setting very simply by putting get_option('option_name') – Mayeenul Islam Nov 18 '15 at 15:42
1

Setting aren't registered in the database by plugin, though a plugin should be using an identifying prefix. That is, there is no specific queryable cross-linking in the database between plugin and setting. The only way to way to pull all settings for a plugin is to know what keys the plugin has used to save those settings.

4
  • any suggestion how do I get to know what keys the plugin has used to save those settings? I mean, I could open the plugin and read it, but I want to be able to do it automatically so how could I write code that reads which keys have been used to save the settings? – user83847 Nov 18 '15 at 15:42
  • find all the files of that plugin for string like register_setting if the plugin uses Settings API. – Mayeenul Islam Nov 18 '15 at 15:44
  • Look at the plugin source. Read through the code. That's it. I guess you could grep for register_setting or update_option... things like that. – s_ha_dum Nov 18 '15 at 15:45
  • "... how could I write code that reads which keys..." -- your code will have to open the plugin source and read it, which is a complex project. There is no other way besides reading the plugin code. – s_ha_dum Nov 18 '15 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.