WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Actually I am developing a new free plugin for Wordpress partially based on this plugin FrameWork: Sunrise framewok, each option's name will start like this:


So everytime i need to echo and option i simply write:

echo get_option('my_plugin_option_example') 

And everything is working as expected.

Now I would like to create an import/export page (and this isn't the problem, I have already managed how to create the new tab).

What I can't understand is how to add this funcionality as (for what I know) this function:


is deprecated. I became aware of this function here: wpNettuts And now I am afraid that it will become useless soon. Is there anyone who has a solution for this problem?

share|improve this question
I use this plugin I made for importing/exporting options: github.com/rrikesh/WordPress-Export-Options You can have a look at the source code. – RRikesh Jul 15 '13 at 9:20
up vote 1 down vote accepted

The Codex suggests that you use wp_load_alloptions instead.

I would suggest that you therefore use wp_load_alloptions. That technically answers the question, I think.

wp_load_alloptions will pull all of the options out of the options table and your question does not explain why you need to do that. Are you actually needing to pull only your my_plugin_* options, because that would be a different answer? If so, there is no "get options by wildcard" function that I know of, but it isn't hard to construct.

function get_options_by_wildcard($prefix = '') {
  if (empty($prefix)) return false;
  global $wpdb;
  $ret = array();
  $options = $wpdb->get_results(
    $wpdb->prepare("SELECT option_name,option_value FROM {$wpdb->options} WHERE option_name LIKE %s",$prefix.'%'),
  if (!empty($options)) {
    foreach ($options as $v) {
      $ret[$v['option_name']] = maybe_unserialize($v['option_value']);
  return (!empty($ret)) ? $ret : false;

Your plugin should "know" what its one options are so you should be able to do it by looping through the plugin options without needing another query. For example, assuming your plugin is a class and your available plugin options are stored in the class variable plugin_options:

function get_my_plugin_options() {
  $ret = array();
  foreach ($this->plugin_options as $v) {
    $ret[$v] = get_option($v);
  return $ret;
share|improve this answer
Maybe I was not clear (lack of english knowledge here :D ) anyway what I would like to do is to add Import/Export functionality to my plugin settings so the user will be able to export his Settings and import them into a different installation. Exporting all website options is not needed I only need my plugin's option. – Downloadtaky Jul 14 '13 at 19:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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