WP_Filesystem_FTPext::exists( string $file )
Checks if a file or directory exists.
Parameters
- $file
-
(string) (Required) Path to file or directory.
Return
(bool) Whether $file exists or not.
Source
File: wp-admin/includes/class-wp-filesystem-ftpext.php
public function exists( $file ) {
$list = ftp_nlist( $this->link, $file );
if ( empty( $list ) && $this->is_dir( $file ) ) {
return true; // File is an empty directory.
}
return ! empty( $list ); // Empty list = no file, so invert.
} Changelog
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |
© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_filesystem_ftpext/exists