Account for Windows and CLI instances in wp_guess_url(). Props SergeyBiryukov. See #25317
Built from https://develop.svn.wordpress.org/trunk@25436 git-svn-id: http://core.svn.wordpress.org/trunk@25358 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
bc1c732a16
commit
bbd3312389
|
@ -3233,26 +3233,31 @@ function wp_guess_url() {
|
|||
if ( defined('WP_SITEURL') && '' != WP_SITEURL ) {
|
||||
$url = WP_SITEURL;
|
||||
} else {
|
||||
$abspath_fix = str_replace( '\\', '/', ABSPATH );
|
||||
$script_filename_dir = dirname( $_SERVER['SCRIPT_FILENAME'] );
|
||||
|
||||
// The request is for the admin
|
||||
if ( strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) !== false || strpos( $_SERVER['REQUEST_URI'], 'wp-login.php' ) !== false ) {
|
||||
$path = preg_replace( '#/(wp-admin/.*|wp-login.php)#i', '', $_SERVER['REQUEST_URI'] );
|
||||
|
||||
// The request is for a file in ABSPATH
|
||||
} elseif ( dirname( $_SERVER['SCRIPT_FILENAME'] ) . '/' == ABSPATH ) {
|
||||
} elseif ( $script_filename_dir . '/' == $abspath_fix ) {
|
||||
// Strip off any file/query params in the path
|
||||
$path = preg_replace( '#/[^/]*$#i', '', $_SERVER['PHP_SELF'] );
|
||||
|
||||
} else {
|
||||
if ( false !== strpos( $_SERVER['SCRIPT_FILENAME'], ABSPATH ) ) {
|
||||
if ( false !== strpos( $_SERVER['SCRIPT_FILENAME'], $abspath_fix ) ) {
|
||||
// Request is hitting a file inside ABSPATH
|
||||
$directory = str_replace( ABSPATH, '', dirname( $_SERVER['SCRIPT_FILENAME'] ) );
|
||||
$directory = str_replace( ABSPATH, '', $script_filename_dir );
|
||||
// Strip off the sub directory, and any file/query paramss
|
||||
$path = preg_replace( '#/' . preg_quote( $directory, '#' ) . '/[^/]*$#i', '' , $_SERVER['REQUEST_URI'] );
|
||||
} else {
|
||||
} elseif ( false !== strpos( $abspath_fix, $script_filename_dir ) ) {
|
||||
// Request is hitting a file above ABSPATH
|
||||
$subdirectory = str_replace( dirname( $_SERVER['SCRIPT_FILENAME'] ), '', ABSPATH );
|
||||
$subdirectory = str_replace( $script_filename_dir, '', $abspath_fix );
|
||||
// Strip off any file/query params from the path, appending the sub directory to the install
|
||||
$path = preg_replace( '#/[^/]*$#i', '' , $_SERVER['REQUEST_URI'] ) . $subdirectory;
|
||||
} else {
|
||||
$path = $_SERVER['REQUEST_URI'];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue