Function get_home_path() from wp-admin/includes/file.php
function get_home_path() {
$home = get_option( 'home' );
$siteurl = get_option( 'siteurl' );
if ( $home != '' && $home != $siteurl ) {
$wp_path_rel_to_home = str_replace($home, '', $siteurl); /* $siteurl - $home */
$pos = strpos($_SERVER["SCRIPT_FILENAME"], $wp_path_rel_to_home);
$home_path = substr($_SERVER["SCRIPT_FILENAME"], 0, $pos);
echo "HOME_PATH0 = $home_path;
";
$home_path = trailingslashit( $home_path );
echo "HOME_PATH1 = $home_path;
WPPATHREL2H: $wp_path_rel_to_home
POS: $pos
";
} else {
$home_path = ABSPATH;
echo "HOME_PATH2 = $home_path;
ABS: ".ABSPATH."
";
}
echo "HOME: $home
SITEURL: $siteurl
HOME_PATH3: $home_path
";
//exit;
return $home_path;
}
Output when WordPress address (URL) and Blog address (URL) are changed at teh same time to a different value (both the same).
HOME_PATH0 = ;
HOME_PATH1 = /;
WPPATHREL2H: http://site.com
POS:
HOME: http://127.0.0.5
SITEURL: http://site.com
HOME_PATH3: /
HOME_PATH0 = ;
HOME_PATH1 = /;
WPPATHREL2H: http://site.com
POS:
HOME: http://127.0.0.5
SITEURL: http://site.com
HOME_PATH3: /
HOME_PATH2 = C:\websites\site/;
ABS: C:\websites\site/
HOME: http://site.com
SITEURL: http://site.com
HOME_PATH3: C:\websites\site/
HOME_PATH2 = C:\websites\site/;
ABS: C:\websites\site/
HOME: http://site.com
SITEURL: http://site.com
HOME_PATH3: C:\websites\site/