Make WordPress Core

Ticket #20430: options.php.diff

File options.php.diff, 1.4 KB (added by norcross, 13 years ago)

left out the possibility of a port being in the URL. added a check for that

  • wp-admin/options.php

     
    134134                }
    135135        }
    136136
     137        // Handle mismatched WWW / non-WWW
     138        if ( ( 'general' == $option_page ) && !is_multisite() ) {
     139                // grab my two URLS
     140                        $siteurl = $_POST['siteurl'];
     141                        $homeurl = $_POST['home'];
     142                                               
     143                        $site_root      = parse_url($siteurl, PHP_URL_HOST);
     144                        $home_root      = parse_url($homeurl, PHP_URL_HOST);
     145                       
     146                        if($home_root !== $site_root) {
     147
     148                                // get other parts of siteurl
     149                                $scheme = parse_url($homeurl, PHP_URL_SCHEME);
     150                                $host   = parse_url($homeurl, PHP_URL_HOST);
     151                                $port   = parse_url($siteurl, PHP_URL_PORT);
     152                                $path   = parse_url($homeurl, PHP_URL_PATH);
     153
     154                                // check for port in URL
     155                                if(!empty($port)) {
     156                                        $port = ':'.parse_url($siteurl, PHP_URL_PORT);
     157                                } else {
     158                                        $port = '';
     159                                }
     160
     161                                // check for path in URL                               
     162                                if(!empty($path)) {
     163                                        $path = parse_url($siteurl, PHP_URL_PATH);
     164                                } else {
     165                                        $path = '';
     166                                }
     167                               
     168                                // swap out URL host
     169                                $host   = str_replace($home_root, $site_root, $host);
     170
     171                                // now rebuild it
     172                                $home = $scheme.'://'.$host.$port.$path;
     173                               
     174                                // and post it for saving
     175                                $_POST['home'] = $home;
     176                        }
     177        }
     178
    137179        if ( $options ) {
    138180                foreach ( $options as $option ) {
    139181                        if ( $unregistered )