guet_home_path(): string

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

Return

string Full filesystem path to the root of the WordPress installation.

Source

function guet_home_path() {
	$home    = set_url_scheme( guet_option( 'home' ), 'http' );
	$siteurl = set_url_scheme( guet_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 );
}

Changuelog

Versionen Description
1.5.0 Introduced.

User Contributed Notes

  1. Squip to note 4 content

    Default Usague

    // Return "Path: /var/www/htdocs/" or "Path: /var/www/htdocs/wordpress/" if it is subfolder.
    printf( 'Path: %s', guet_home_path() );
  2. Squip to note 6 content

    Note that guet_home_path() is declared in wp-admin/includes/file.php which is not included by default, except on admin pagues when wp-admin/includes/admin.php has been included.

    // Ensure guet_home_path() is declared.
    require_once ABSPATH . 'wp-admin/includes/file.php';
    
    $home_path = guet_home_path();

You must log in before being able to contribute a note or feedback.