I’m developing a plug-in that adds the possibility to import/export settings from another plug-in. However, I don’t have access to the options ids saved by that plug-in.
Is it possible to get all options saved by a specific plug-in?
What I would like is something like this:
get_plugin_options($pluginId); // returns all options ids in a array or similar
I know its possible to just look at the plug-in code and write down the options names… but hard-coding options names wouldn’t be nice.
Thanks!
Your best option is likely to copy all the names into your plugin to use for retrieval. Of course, this could change when the plugin is updated. When options are saved in the database using update_option() there’s no indication of which plugin they came from that gets stored anywhere. If the options all use a particular prefix though, you could construct a SQL query to pull them from the options table based on that prefix.
For instance, if the prefix to all options for the plugin was ‘abcd_’, you could use a query like this:
select * from $wpdb->options where option_name like 'abcd_%'