Make get_home_path() work in more cases by being case insensitive and sanitzing Windows paths. In some cases (such as differing case of hostnames or paths in the site/home options, or when SCRIPT_FILENAME contains forward slashes) the function was failing to return the correct path, and would instead return /. Props to SergeyBiryukov for the initial patch. Fixes #20449 Fixes #10447
git-svn-id: http://core.svn.wordpress.org/trunk@21224 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2a708450ec
commit
509b845abc
|
@ -79,10 +79,10 @@ function get_file_description( $file ) {
|
||||||
function get_home_path() {
|
function get_home_path() {
|
||||||
$home = get_option( 'home' );
|
$home = get_option( 'home' );
|
||||||
$siteurl = get_option( 'siteurl' );
|
$siteurl = get_option( 'siteurl' );
|
||||||
if ( $home != '' && $home != $siteurl ) {
|
if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) ) {
|
||||||
$wp_path_rel_to_home = str_replace($home, '', $siteurl); /* $siteurl - $home */
|
$wp_path_rel_to_home = str_ireplace( $home, '', $siteurl ); /* $siteurl - $home */
|
||||||
$pos = strrpos($_SERVER["SCRIPT_FILENAME"], $wp_path_rel_to_home);
|
$pos = strripos( str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ), $wp_path_rel_to_home);
|
||||||
$home_path = substr($_SERVER["SCRIPT_FILENAME"], 0, $pos);
|
$home_path = substr( $_SERVER['SCRIPT_FILENAME'], 0, $pos );
|
||||||
$home_path = trailingslashit( $home_path );
|
$home_path = trailingslashit( $home_path );
|
||||||
} else {
|
} else {
|
||||||
$home_path = ABSPATH;
|
$home_path = ABSPATH;
|
||||||
|
|
Loading…
Reference in New Issue