| 1 | Index: wp-admin/options.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-admin/options.php (revision 20450) |
|---|
| 4 | +++ wp-admin/options.php (working copy) |
|---|
| 5 | @@ -134,6 +134,48 @@ |
|---|
| 6 | } |
|---|
| 7 | } |
|---|
| 8 | |
|---|
| 9 | + // Handle mismatched WWW / non-WWW |
|---|
| 10 | + if ( ( 'general' == $option_page ) && !is_multisite() ) { |
|---|
| 11 | + // grab my two URLS |
|---|
| 12 | + $siteurl = $_POST['siteurl']; |
|---|
| 13 | + $homeurl = $_POST['home']; |
|---|
| 14 | + |
|---|
| 15 | + $site_root = parse_url($siteurl, PHP_URL_HOST); |
|---|
| 16 | + $home_root = parse_url($homeurl, PHP_URL_HOST); |
|---|
| 17 | + |
|---|
| 18 | + if($home_root !== $site_root) { |
|---|
| 19 | + |
|---|
| 20 | + // get other parts of siteurl |
|---|
| 21 | + $scheme = parse_url($homeurl, PHP_URL_SCHEME); |
|---|
| 22 | + $host = parse_url($homeurl, PHP_URL_HOST); |
|---|
| 23 | + $port = parse_url($siteurl, PHP_URL_PORT); |
|---|
| 24 | + $path = parse_url($homeurl, PHP_URL_PATH); |
|---|
| 25 | + |
|---|
| 26 | + // check for port in URL |
|---|
| 27 | + if(!empty($port)) { |
|---|
| 28 | + $port = ':'.parse_url($siteurl, PHP_URL_PORT); |
|---|
| 29 | + } else { |
|---|
| 30 | + $port = ''; |
|---|
| 31 | + } |
|---|
| 32 | + |
|---|
| 33 | + // check for path in URL |
|---|
| 34 | + if(!empty($path)) { |
|---|
| 35 | + $path = parse_url($siteurl, PHP_URL_PATH); |
|---|
| 36 | + } else { |
|---|
| 37 | + $path = ''; |
|---|
| 38 | + } |
|---|
| 39 | + |
|---|
| 40 | + // swap out URL host |
|---|
| 41 | + $host = str_replace($home_root, $site_root, $host); |
|---|
| 42 | + |
|---|
| 43 | + // now rebuild it |
|---|
| 44 | + $home = $scheme.'://'.$host.$port.$path; |
|---|
| 45 | + |
|---|
| 46 | + // and post it for saving |
|---|
| 47 | + $_POST['home'] = $home; |
|---|
| 48 | + } |
|---|
| 49 | + } |
|---|
| 50 | + |
|---|
| 51 | if ( $options ) { |
|---|
| 52 | foreach ( $options as $option ) { |
|---|
| 53 | if ( $unregistered ) |
|---|