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

This code below works fine as long as I leave the $wpdb query commented out.

However, I'm trying to clear the current settings before I write the new ones into the db. That's the purpose of the $wpdb delete command.

However, something curious is happening. It only writes the values to the database every other time its run. Despite the fact that I can trace echo the correct values each time.

Either the delete is running after the update_options loop (clearing the values) or the values never get written.

function doSettings()

//  global $wpdb;
//  $wpdb->query( "Delete FROM wp_options where option_name like 'mx2|_%' escape '|'");

    $file = WP_PLUGIN_DIR.'/mx-settings/settings.ini';
    if (file_exists($file) && is_readable($file))
        $ini_array = parse_ini_file($file);
        foreach ($ini_array as $key=>$value) {
            if($key != "template" && $key != "stylesheet")
                update_option($key, stripslashes($value));
share|improve this question

Your Answer


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

Browse other questions tagged or ask your own question.