get_home_path

Get the absolute filesystem path to the root of the WordPress installation.

Description

(string) get_home_path(); 

Returns (string)

Full filesystem path to the root of the WordPress installation


Usage

  1. if ( !function_exists( 'get_home_path' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/file.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = get_home_path(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/file.php  
  1. function get_home_path() { 
  2. $home = set_url_scheme( get_option( 'home' ), 'http' ); 
  3. $siteurl = set_url_scheme( get_option( 'siteurl' ), 'http' ); 
  4. if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) ) { 
  5. $wp_path_rel_to_home = str_ireplace( $home, '', $siteurl ); /** $siteurl - $home */ 
  6. $pos = strripos( str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ), trailingslashit( $wp_path_rel_to_home ) ); 
  7. $home_path = substr( $_SERVER['SCRIPT_FILENAME'], 0, $pos ); 
  8. $home_path = trailingslashit( $home_path ); 
  9. } else { 
  10. $home_path = ABSPATH
  11.  
  12. return str_replace( '\\', '/', $home_path );