Make WordPress Core

Changeset 4175


Ignore:
Timestamp:
09/08/2006 09:42:05 PM (18 years ago)
Author:
ryan
Message:

Move home and siteurl update events to action hooks.

Location:
trunk/wp-admin
Files:
2 edited

Legend:

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

    r4169 r4175  
    20652065}
    20662066
     2067// If siteurl or home changed, reset cookies and flush rewrite rules.
     2068function update_home_siteurl($old_value, $value) {
     2069    global $wp_rewrite, $user_login, $user_pass_md5;
     2070    // If home changed, write rewrite rules to new location.
     2071    $wp_rewrite->flush_rules();
     2072    // Clear cookies for old paths.
     2073    wp_clearcookie();
     2074    // Set cookies for new paths.
     2075    wp_setcookie($user_login, $user_pass_md5, true, get_option('home'), get_option('siteurl'));
     2076}
     2077
     2078add_action('update_option_home', 'update_home_siteurl');
     2079add_action('update_option_siteurl', 'update_home_siteurl');
     2080
    20672081?>
  • trunk/wp-admin/options.php

    r4144 r4175  
    8787    }
    8888
    89     // Save for later.
    90     $old_siteurl = get_option('siteurl');
    91     $old_home = get_option('home');
    92 
    9389    if ($options) {
    9490        foreach ($options as $option) {
     
    9692            $value = trim(stripslashes($_POST[$option]));
    9793            $value = sanitize_option($option, $value);
    98 
    99             if (update_option($option, $value) ) {
    100                 $any_changed++;
    101             }
     94            update_option($option, $value);
    10295        }
    10396    }
    104    
    105     if ($any_changed) {
    106             // If siteurl or home changed, reset cookies.
    107             if ( get_option('siteurl') != $old_siteurl || get_option('home') != $old_home ) {
    108                 // If home changed, write rewrite rules to new location.
    109                 $wp_rewrite->flush_rules();
    110                 // Clear cookies for old paths.
    111                 wp_clearcookie();
    112                 // Set cookies for new paths.
    113                 wp_setcookie($user_login, $user_pass_md5, true, get_option('home'), get_option('siteurl'));
    114             }
    115 
    116             //$message = sprintf(__('%d setting(s) saved... '), $any_changed);
    117     }
    11897   
    11998    $referred = remove_query_arg('updated' , wp_get_referer());
Note: See TracChangeset for help on using the changeset viewer.