Make WordPress Core


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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.