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?


2 Answers 2


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;
  • 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. Commented Jul 14, 2013 at 19:46

here is your answer, I believe it will help you out


  • 1
    May you please elaborate on how this article will solve the answer? Commented Sep 28, 2016 at 2:56
  • It would be great if you post the crux of the answer here.
    – bravokeyl
    Commented Sep 28, 2016 at 3:25
  • the question is simple that article is mostly irrelevant to it Commented Sep 28, 2016 at 3:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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