/** * wpuxss_eml_mimes_validate * * @type callback function * @since 1.0 * @created 15/10/13 */ function wpuxss_eml_mimes_validate($input) { if (!$input) { $input = array(); } if (isset($_REQUEST['wpuxss_eml_restore_mimes_backup'])) { $_REQUEST['_wp_http_referer'] .= '&settings-restored=true'; $wpuxss_eml_mimes_backup = get_option('wpuxss_eml_mimes_backup'); $input = $wpuxss_eml_mimes_backup; } else { foreach ($input as $type => $mime) { $sanitized_type = wpuxss_eml_sanitize_extension($type); if ($sanitized_type !== $type) { $input[$sanitized_type] = $input[$type]; unset($input[$type]); $type = $sanitized_type; } if (!isset($input[$type]['filter'])) { $input[$type]['filter'] = 0; } if (!isset($input[$type]['upload'])) { $input[$type]['upload'] = 0; } $input[$type]['filter'] = intval($input[$type]['filter']); $input[$type]['upload'] = intval($input[$type]['upload']); $input[$type]['mime'] = sanitize_mime_type($mime['mime']); $input[$type]['singular'] = sanitize_text_field($mime['singular']); $input[$type]['plural'] = sanitize_text_field($mime['plural']); } } return $input; }
function wpuxss_eml_mimes_validate($input) { if (!$input) { $input = array(); } if (isset($_POST['eml-restore-mime-types-settings'])) { $wpuxss_eml_mimes_backup = get_option('wpuxss_eml_mimes_backup'); $input = $wpuxss_eml_mimes_backup; add_settings_error('wpuxss_eml_mimes', 'eml_mime_types_restored', __('MIME type settings restored.', 'eml'), 'updated'); } elseif (!isset($_POST['eml-settings-import']) && !isset($_POST['eml-settings-restore'])) { add_settings_error('wpuxss_eml_mimes', 'eml_mime_types_saved', __('MIME type settings saved.', 'eml'), 'updated'); } foreach ($input as $type => $mime) { $sanitized_type = wpuxss_eml_sanitize_extension($type); if ($sanitized_type !== $type) { $input[$sanitized_type] = $input[$type]; unset($input[$type]); $type = $sanitized_type; } $input[$type]['filter'] = isset($mime['filter']) && !!$mime['filter'] ? 1 : 0; $input[$type]['upload'] = isset($mime['upload']) && !!$mime['upload'] ? 1 : 0; $input[$type]['mime'] = sanitize_mime_type($mime['mime']); $input[$type]['singular'] = sanitize_text_field($mime['singular']); $input[$type]['plural'] = sanitize_text_field($mime['plural']); } return $input; }