WP_Filesystem_ftpsockets::exists()
Checks if a file or directory exists.
Method of the class: WP_Filesystem_ftpsockets{}
No Hooks.
Return
true|false
. Whether $path exists or not.
Usage
$WP_Filesystem_ftpsockets = new WP_Filesystem_ftpsockets(); $WP_Filesystem_ftpsockets->exists( $path );
- $path(string) (required)
- Path to file or directory.
Changelog
Since 2.5.0 | Introduced. |
Since 6.3.0 | Returns false for an empty path. |
WP_Filesystem_ftpsockets::exists() WP Filesystem ftpsockets::exists code WP 6.6.1
public function exists( $path ) { /* * Check for empty path. If ftp::nlist() receives an empty path, * it checks the current working directory and may return true. * * See https://core.trac.wordpress.org/ticket/33058. */ if ( '' === $path ) { return false; } $list = $this->ftp->nlist( $path ); if ( empty( $list ) && $this->is_dir( $path ) ) { return true; // File is an empty directory. } return ! empty( $list ); // Empty list = no file, so invert. // Return $this->ftp->is_exists($file); has issues with ABOR+426 responses on the ncFTPd server. }