Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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()
{
/* FIRST CLEAR ALL SETTINGS */

//  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));
        } 
    }
    return;
}
share|improve this question

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.