public static function settings_validate($inputs) { // Load current settings from db self::load_settings(TRUE); global $CRAYON_EMAIL; // When reset button is pressed, remove settings so default loads next time if (array_key_exists('reset', $inputs)) { self::clear_cache(); return array(); } // Convert old tags if (array_key_exists('convert', $inputs)) { $encode = array_key_exists('convert_encode', $inputs); CrayonWP::convert_tags($encode); } // Refresh internal tag management if (array_key_exists('refresh_tags', $inputs)) { CrayonWP::refresh_posts(); } // Clear the log if needed if (array_key_exists(self::LOG_CLEAR, $_POST)) { CrayonLog::clear(); } // Send to admin if (array_key_exists(self::LOG_EMAIL_ADMIN, $_POST)) { CrayonLog::email(get_bloginfo('admin_email')); } // Send to developer if (array_key_exists(self::LOG_EMAIL_DEV, $_POST)) { CrayonLog::email($CRAYON_EMAIL, get_bloginfo('admin_email')); } // Clear the cache if (array_key_exists('crayon-cache-clear', $_POST)) { self::clear_cache(); } // Validate inputs foreach ($inputs as $input => $value) { // Convert all array setting values to ints $inputs[$input] = CrayonSettings::validate($input, $value); // Clear cache when changed if ($input == CrayonSettings::CACHE && $value != CrayonGlobalSettings::val(CrayonSettings::CACHE)) { self::clear_cache(); } } // If settings don't exist in input, set them to default $global_settings = CrayonSettings::get_defaults(); $ignored = array(CrayonSettings::HIDE_HELP); foreach ($global_settings as $setting) { // XXX Ignore some settings if (in_array($setting->name(), $ignored)) { $inputs[$setting->name()] = CrayonGlobalSettings::val($setting->name()); continue; } // If boolean setting is not in input, then it is set to FALSE in the form if (!array_key_exists($setting->name(), $inputs)) { // For booleans, set to FALSE (unchecked boxes are not sent as POST) if (is_bool($setting->def())) { $inputs[$setting->name()] = FALSE; } else { /* For array settings, set the input as the value, which by default is the default index */ if (is_array($setting->def())) { $inputs[$setting->name()] = $setting->value(); } else { $inputs[$setting->name()] = $setting->def(); } } } } return $inputs; }