Make WordPress Core

Changeset 25436


Ignore:
Timestamp:
09/14/2013 03:42:38 AM (11 years ago)
Author:
dd32
Message:

Account for Windows and CLI instances in wp_guess_url(). Props SergeyBiryukov. See #25317

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r25400 r25436  
    32343234        $url = WP_SITEURL;
    32353235    } else {
     3236        $abspath_fix = str_replace( '\\', '/', ABSPATH );
     3237        $script_filename_dir = dirname( $_SERVER['SCRIPT_FILENAME'] );
     3238
    32363239        // The request is for the admin
    32373240        if ( strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) !== false || strpos( $_SERVER['REQUEST_URI'], 'wp-login.php' ) !== false ) {
     
    32393242
    32403243        // The request is for a file in ABSPATH
    3241         } elseif ( dirname( $_SERVER['SCRIPT_FILENAME'] ) . '/' == ABSPATH ) {
     3244        } elseif ( $script_filename_dir . '/' == $abspath_fix ) {
    32423245            // Strip off any file/query params in the path
    32433246            $path = preg_replace( '#/[^/]*$#i', '', $_SERVER['PHP_SELF'] );
    32443247
    32453248        } else {
    3246             if ( false !== strpos( $_SERVER['SCRIPT_FILENAME'], ABSPATH ) ) {
     3249            if ( false !== strpos( $_SERVER['SCRIPT_FILENAME'], $abspath_fix ) ) {
    32473250                // Request is hitting a file inside ABSPATH
    3248                 $directory = str_replace( ABSPATH, '', dirname( $_SERVER['SCRIPT_FILENAME'] ) );
     3251                $directory = str_replace( ABSPATH, '', $script_filename_dir );
    32493252                // Strip off the sub directory, and any file/query paramss
    32503253                $path = preg_replace( '#/' . preg_quote( $directory, '#' ) . '/[^/]*$#i', '' , $_SERVER['REQUEST_URI'] );
    3251             } else {
     3254            } elseif ( false !== strpos( $abspath_fix, $script_filename_dir ) ) {
    32523255                // Request is hitting a file above ABSPATH
    3253                 $subdirectory = str_replace( dirname( $_SERVER['SCRIPT_FILENAME'] ), '', ABSPATH );
     3256                $subdirectory = str_replace( $script_filename_dir, '', $abspath_fix );
    32543257                // Strip off any file/query params from the path, appending the sub directory to the install
    32553258                $path = preg_replace( '#/[^/]*$#i', '' , $_SERVER['REQUEST_URI'] ) . $subdirectory;
     3259            } else {
     3260                $path = $_SERVER['REQUEST_URI'];
    32563261            }
    32573262        }
Note: See TracChangeset for help on using the changeset viewer.