Make WordPress Core


Ignore:
Timestamp:
02/17/2010 05:50:42 PM (15 years ago)
Author:
ryan
Message:

Option validation error reporting. Props jeremyclarke. see #11474

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/options.php

    r12825 r13177  
    33 * Options Management Administration Panel.
    44 *
    5  * Just allows for displaying of options.
     5 * If accessed directly in a browser this page shows a list of all saved options
     6 * along with editable fields for their values. Serialized data is not supported
     7 * and there is no way to remove options via this page. It is not linked to from
     8 * anywhere else in the admin.
    69 *
    7  * This isn't referenced or linked to, but will show all of the options and
    8  * allow editing. The issue is that serialized data is not supported to be
    9  * modified. Options can not be removed.
     10 * This file is also the target of the forms in core and custom options pages
     11 * that use the Settings API. In this case it saves the new option values
     12 * and returns the user to their page of origin.
    1013 *
    1114 * @package WordPress
     
    7780switch($action) {
    7881
     82/**
     83 * If $_GET['action'] == 'update' we are saving settings sent from a settings page
     84 */
    7985case 'update':
    8086    if ( isset($_POST[ 'option_page' ]) ) {
     
    124130    }
    125131
    126     $goback = add_query_arg( 'updated', 'true', wp_get_referer() );
     132    /**
     133     *  Handle settings errors and return to options page
     134     */
     135    // If no settings errors were registered add a general 'updated' message.
     136    if ( !count( get_settings_errors() ) )
     137        add_settings_error('general', 'settings_updated', __('Settings saved.'), 'updated');
     138    set_transient('settings_errors', get_settings_errors(), 30);
     139
     140    /**
     141     * Redirect back to the settings page that was submitted
     142     */
     143    $goback = add_query_arg( 'updated', 'true',  wp_get_referer() );
    127144    wp_redirect( $goback );
    128145    break;
Note: See TracChangeset for help on using the changeset viewer.