/** * validates the config form output, fills in any gaps by using the defaults, * and ensures that arrayed items are stored as such */ function config_ValidateSettings($in) { //DebugEcho("config_ValidateSettings"); $out = array(); //DebugDump($in); // use the default as a template: // if a field is present in the defaults, we want to store it; otherwise we discard it $allowed_keys = config_GetDefaults(); foreach ($allowed_keys as $key => $default) { if (is_array($in)) { $out[$key] = array_key_exists($key, $in) ? $in[$key] : $default; } else { $out[$key] = $default; } } // some fields are always forced to lower case: $lowercase = array('authorized_addresses', 'smtp', 'supported_file_types', 'video1types', 'video2types', 'audiotypes'); foreach ($lowercase as $field) { $out[$field] = is_array($out[$field]) ? array_map("strtolower", $out[$field]) : strtolower($out[$field]); } $arrays = config_ArrayedSettings(); foreach ($arrays as $sep => $fields) { foreach ($fields as $field) { if (!is_array($out[$field])) { $out[$field] = explode($sep, trim($out[$field])); } foreach ($out[$field] as $key => $val) { $tst = trim($val); if (empty($tst)) { unset($out[$field][$key]); } else { $out[$field][$key] = $tst; } } } } config_Update($out); return $out; }
include 'get_mail.php'; exit; break; default: $message = 2; break; } } global $wpdb, $wp_roles; $title = __('Postie Options', 'postie'); $parent_file = 'options-general.php'; $config = config_Read(); if (empty($config)) { $config = config_ResetToDefault(); } $arrays = config_ArrayedSettings(); // some fields are stored as arrays, because that makes back-end processing much easier // and we need to convert those fields to strings here, for the options form foreach ($arrays as $sep => $fields) { foreach ($fields as $field) { $config[$field] = implode($sep, $config[$field]); } } extract($config); if (!isset($maxemails)) { DebugEcho("New setting: maxemails"); $maxemails = 0; } if (!isset($category_match)) { $category_match = true; }