WP_Filesystem_SSH2::sftp_path() WordPress Method

The WP_Filesystem_SSH2::sftp_path() method is used to resolve a path relative to the root of the SSH2 server.

WP_Filesystem_SSH2::sftp_path( string $path ) #

Gets the ssh2.sftp PHP stream wrapper path to open for the given file.


Description

This method also works around a PHP bug where the root directory (/) cannot be opened by PHP functions, causing a false failure. In order to work around this, the path is converted to /./ which is semantically the same as / See https://bugs.php.net/bug.php?id=64169 for more details.


Top ↑

Parameters

$path

(string)(Required)The File/Directory path on the remote server to return


Top ↑

Return

(string) The ssh2.sftp:// wrapped path to use.


Top ↑

Source

File: wp-admin/includes/class-wp-filesystem-ssh2.php

	public function sftp_path( $path ) {
		if ( '/' === $path ) {
			$path = '/./';
		}

		return 'ssh2.sftp://' . $this->sftp_link . '/' . ltrim( $path, '/' );
	}


Top ↑

Changelog

Changelog
VersionDescription
4.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.