WordPress.org

Make WordPress Core

Changeset 18536


Ignore:
Timestamp:
08/11/2011 10:32:35 PM (7 years ago)
Author:
nacin
Message:

Move network/settings.php POST handling out of network/edit.php. props PeteMall, see #18379.

Location:
trunk/wp-admin/network
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/network/edit.php

    r18460 r18536  
    9797
    9898switch ( $_GET['action'] ) {
    99     case 'siteoptions':
    100         check_admin_referer( 'siteoptions' );
    101         if ( ! current_user_can( 'manage_network_options' ) )
    102             wp_die( __( 'You do not have permission to access this page.' ) );
    103 
    104         if ( empty( $_POST ) )
    105             wp_die( sprintf( __( 'You probably need to go back to the <a href="%s">options page</a>.' ), esc_url( admin_url( 'settings.php' ) ) ) );
    106 
    107         if ( isset($_POST['WPLANG']) && ( '' === $_POST['WPLANG'] || in_array( $_POST['WPLANG'], get_available_languages() ) ) )
    108             update_site_option( 'WPLANG', $_POST['WPLANG'] );
    109 
    110         if ( is_email( $_POST['admin_email'] ) )
    111             update_site_option( 'admin_email', $_POST['admin_email'] );
    112 
    113         $illegal_names = split( ' ', $_POST['illegal_names'] );
    114         foreach ( (array) $illegal_names as $name ) {
    115             $name = trim( $name );
    116             if ( $name != '' )
    117                 $names[] = trim( $name );
    118         }
    119         update_site_option( 'illegal_names', $names );
    120 
    121         if ( $_POST['limited_email_domains'] != '' ) {
    122             $limited_email_domains = str_replace( ' ', "\n", $_POST['limited_email_domains'] );
    123             $limited_email_domains = split( "\n", stripslashes( $limited_email_domains ) );
    124             $limited_email = array();
    125             foreach ( (array) $limited_email_domains as $domain ) {
    126                     $domain = trim( $domain );
    127                 if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) )
    128                     $limited_email[] = trim( $domain );
    129             }
    130             update_site_option( 'limited_email_domains', $limited_email );
    131         } else {
    132             update_site_option( 'limited_email_domains', '' );
    133         }
    134 
    135         if ( $_POST['banned_email_domains'] != '' ) {
    136             $banned_email_domains = split( "\n", stripslashes( $_POST['banned_email_domains'] ) );
    137             $banned = array();
    138             foreach ( (array) $banned_email_domains as $domain ) {
    139                 $domain = trim( $domain );
    140                 if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) )
    141                     $banned[] = trim( $domain );
    142             }
    143             update_site_option( 'banned_email_domains', $banned );
    144         } else {
    145             update_site_option( 'banned_email_domains', '' );
    146         }
    147 
    148         $options = array( 'registrationnotification', 'registration', 'add_new_users', 'menu_items', 'mu_media_buttons', 'upload_space_check_disabled', 'blog_upload_space', 'upload_filetypes', 'site_name', 'first_post', 'first_page', 'first_comment', 'first_comment_url', 'first_comment_author', 'welcome_email', 'welcome_user_email', 'fileupload_maxk', 'global_terms_enabled' );
    149         $checked_options = array( 'mu_media_buttons' => array(), 'menu_items' => array(), 'registrationnotification' => 'no', 'upload_space_check_disabled' => 1, 'add_new_users' => 0 );
    150         foreach ( $checked_options as $option_name => $option_unchecked_value ) {
    151             if ( ! isset( $_POST[$option_name] ) )
    152                 $_POST[$option_name] = $option_unchecked_value;
    153         }
    154         foreach ( $options as $option_name ) {
    155             if ( ! isset($_POST[$option_name]) )
    156                 continue;
    157             $value = stripslashes_deep( $_POST[$option_name] );
    158             update_site_option( $option_name, $value );
    159         }
    160 
    161         // Update more options here
    162         do_action( 'update_wpmu_options' );
    163 
    164         wp_redirect( add_query_arg( 'updated', 'true', network_admin_url( 'settings.php' ) ) );
    165         exit();
    166     break;
    167 
    16899    case 'updateblog':
    169100        // No longer used.
  • trunk/wp-admin/network/settings.php

    r17921 r18536  
    2020$parent_file = 'settings.php';
    2121
    22 add_contextual_help($current_screen,
     22add_contextual_help( $current_screen,
    2323    '<p>' . __('This screen sets and changes options for the network as a whole. The first site is the main site in the network and network options are pulled from that original site&#8217;s options.') . '</p>' .
    2424    '<p>' . __('Operational settings has fields for the network&#8217;s name and admin email.') . '</p>' .
     
    3535);
    3636
     37if ( $_POST ) {
     38    do_action( 'wpmuadminedit' , '' );
     39
     40    check_admin_referer( 'siteoptions' );
     41
     42    if ( isset( $_POST['WPLANG'] ) && ( '' === $_POST['WPLANG'] || in_array( $_POST['WPLANG'], get_available_languages() ) ) )
     43        update_site_option( 'WPLANG', $_POST['WPLANG'] );
     44
     45    if ( is_email( $_POST['admin_email'] ) )
     46        update_site_option( 'admin_email', $_POST['admin_email'] );
     47
     48    $illegal_names = split( ' ', $_POST['illegal_names'] );
     49    foreach ( (array) $illegal_names as $name ) {
     50        $name = trim( $name );
     51        if ( $name != '' )
     52            $names[] = trim( $name );
     53        }
     54    update_site_option( 'illegal_names', $names );
     55
     56    if ( $_POST['limited_email_domains'] != '' ) {
     57        $limited_email_domains = str_replace( ' ', "\n", $_POST['limited_email_domains'] );
     58        $limited_email_domains = split( "\n", stripslashes( $limited_email_domains ) );
     59        $limited_email = array();
     60        foreach ( (array) $limited_email_domains as $domain ) {
     61            $domain = trim( $domain );
     62            if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) )
     63                $limited_email[] = trim( $domain );
     64        }
     65        update_site_option( 'limited_email_domains', $limited_email );
     66    } else {
     67            update_site_option( 'limited_email_domains', '' );
     68    }
     69
     70    if ( $_POST['banned_email_domains'] != '' ) {
     71        $banned_email_domains = split( "\n", stripslashes( $_POST['banned_email_domains'] ) );
     72        $banned = array();
     73        foreach ( (array) $banned_email_domains as $domain ) {
     74            $domain = trim( $domain );
     75            if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) )
     76                $banned[] = trim( $domain );
     77        }
     78        update_site_option( 'banned_email_domains', $banned );
     79    } else {
     80        update_site_option( 'banned_email_domains', '' );
     81    }
     82
     83    $options = array( 'registrationnotification', 'registration', 'add_new_users', 'menu_items', 'mu_media_buttons', 'upload_space_check_disabled', 'blog_upload_space', 'upload_filetypes', 'site_name', 'first_post', 'first_page', 'first_comment', 'first_comment_url', 'first_comment_author', 'welcome_email', 'welcome_user_email', 'fileupload_maxk', 'global_terms_enabled' );
     84    $checked_options = array( 'mu_media_buttons' => array(), 'menu_items' => array(), 'registrationnotification' => 'no', 'upload_space_check_disabled' => 1, 'add_new_users' => 0 );
     85    foreach ( $checked_options as $option_name => $option_unchecked_value ) {
     86        if ( ! isset( $_POST[$option_name] ) )
     87            $_POST[$option_name] = $option_unchecked_value;
     88    }
     89    foreach ( $options as $option_name ) {
     90        if ( ! isset($_POST[$option_name]) )
     91            continue;
     92        $value = stripslashes_deep( $_POST[$option_name] );
     93        update_site_option( $option_name, $value );
     94    }
     95
     96    // Update more options here
     97    do_action( 'update_wpmu_options' );
     98
     99    wp_redirect( add_query_arg( 'updated', 'true', network_admin_url( 'settings.php' ) ) );
     100    exit();
     101}
     102
    37103include( '../admin-header.php' );
    38104
    39 if (isset($_GET['updated'])) {
    40     ?>
    41     <div id="message" class="updated"><p><?php _e( 'Options saved.' ) ?></p></div>
    42     <?php
     105if ( isset( $_GET['updated'] ) ) {
     106    ?><div id="message" class="updated"><p><?php _e( 'Options saved.' ) ?></p></div><?php
    43107}
    44108?>
     
    47111    <?php screen_icon('options-general'); ?>
    48112    <h2><?php _e( 'Settings' ) ?></h2>
    49     <form method="post" action="edit.php?action=siteoptions">
     113    <form method="post" action="settings.php">
    50114        <?php wp_nonce_field( 'siteoptions' ); ?>
    51115        <h3><?php _e( 'Operational Settings' ); ?></h3>
Note: See TracChangeset for help on using the changeset viewer.