On this page
get_home_path(): string
Gets the absolute filesystem path to the root of the WordPress installation.
Return
string Full filesystem path to the root of the WordPress installation.
Source
File: wp-admin/includes/file.php. View all references
function get_home_path() {
$home = set_url_scheme( get_option( 'home' ), 'http' );
$siteurl = set_url_scheme( get_option( 'siteurl' ), 'http' );
if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) ) {
$wp_path_rel_to_home = str_ireplace( $home, '', $siteurl ); /* $siteurl - $home */
$pos = strripos( str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ), trailingslashit( $wp_path_rel_to_home ) );
$home_path = substr( $_SERVER['SCRIPT_FILENAME'], 0, $pos );
$home_path = trailingslashit( $home_path );
} else {
$home_path = ABSPATH;
}
return str_replace( '\\', '/', $home_path );
}
Related
Uses
| Uses | Description |
|---|---|
| set_url_scheme() wp-includes/link-template.php | Sets the scheme for a URL. |
| trailingslashit() wp-includes/formatting.php | Appends a trailing slash. |
| get_option() wp-includes/option.php | Retrieves an option value based on an option name. |
Used By
| Used By | Description |
|---|---|
| network_step2() wp-admin/includes/network.php | Prints step 2 for Network installation process. |
| save_mod_rewrite_rules() wp-admin/includes/misc.php | Updates the htaccess file with the current rules if it is writable. |
| iis7_save_url_rewrite_rules() wp-admin/includes/misc.php | Updates the IIS web.config file with the current rules if it is writable. |
| make_site_theme_from_oldschool() wp-admin/includes/upgrade.php | Creates a site theme from an existing theme. |
Changelog
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_home_path