/** * validates the config form output, fills in any gaps by using the defaults, * and ensures that arrayed items are stored as such */ function postie_validate_settings($in) { if (defined('POSTIE_DEBUG')) { var_dump($in); } $out = array(); // 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 = get_postie_config_defaults(); foreach ($allowed_keys as $key => $default) { $out[$key] = array_key_exists($key, $in) ? $in[$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 = get_arrayed_settings(); 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; } } } } UpdatePostieConfig($out); return $out; }
default: $message = 2; break; } } global $wpdb, $wp_roles; $title = __('Postie Options', 'postie'); $parent_file = 'options-general.php'; $config = get_option('postie-settings'); if (empty($config)) { $config = ResetPostieConfig(); } if (defined('POSTIE_DEBUG')) { var_dump($config); } $arrays = get_arrayed_settings(); // 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 ($interval == 'manual') { wp_clear_scheduled_hook('check_postie_hook'); } $messages[1] = __("Configuration successfully updated!", 'postie'); $messages[2] = __("Error - unable to save configuration", 'postie'); if (isset($_GET['message'])) { ?>