/** * Validation callback for all of 'gv_settings' option. * * Referenced in register_setting() for gv_settings, runs whenever update_option('gv_settings') is used. * Must account for every field added to gv_settings via add_settings_field * * @param array $input Full array of data passed into update_option() * @return array Sanitized array of data */ function gv_settings_validate($input){ global $gv; /** * Validate an email address */ $email = sanitize_email( $input['email'] ); // If its valid add the email to the output array if ( $email AND is_email( $email ) ) : $output['email'] = $email; // Otherwise add a message with a slug and text value to be output on the settings page elseif ( $input['email'] ) : $messages['email_error'] = "Email Error: The 'email address' given, " . $input['email'] . " is not a valid email"; endif; /** * Validate a page id */ if ($input['special_page_id']) : $page_object = get_page( $input['special_page_id'] ); // Make sure a valid page object was returned. if ( is_object( $page_object ) AND !is_wp_error($page_object) ) $output['special_page_id'] = $input['special_page_id']; else $messages['page_id_error'] = "Page ID Error: The page id given, " . $input['special_page_id'] . " is not a page on this site"; endif; /** * Add any messages to the array */ if (is_array($messages)) $output['messages'] = $messages; /** * Return the array of new values */ return $output; } /** * Show any messages/errors saved to a setting during automated validation * * Needed because validation system has no error reporting. * Uses a ['messages'] array inside the settings array * Format should be ['messages'][$slug][$message_text], $slug is unique id, $message is just text. * * @param string $setting The setting name as used in get_option() */ function gv_settings_display_errors($setting) { $option = get_option($setting); if (is_array($option['messages'])) : foreach ( (array) $option['messages'] as $slug => $message) : echo "

$message

"; unset($option['messages'][$slug]); endforeach; update_option('gv_settings', $option); endif; } /** * Page display function for GV Settings * * Defined during gv_add_settings_pages() */ function gv_settings_page() { ?>

These settings are related specifically to Global Voices sites and the gv-plugin plugin. They cover various specific and general functionality added by gv-plugin.