WP_Filesystem_FTPext::exists
Checks if a file or directory exists.
Метод класса: WP_Filesystem_FTPext{}
Хуков нет.
Возвращает
true|false. Whether $path exists or not.
Использование
$WP_Filesystem_FTPext = new WP_Filesystem_FTPext(); $WP_Filesystem_FTPext->exists( $path );
- $path(строка) (обязательный)
- Path to file or directory.
Список изменений
| С версии 2.5.0 | Введена. |
| С версии 6.3.0 | Returns false for an empty path. |
Код WP_Filesystem_FTPext::exists() WP Filesystem FTPext::exists WP 7.0
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 = ftp_nlist( $this->link, $path );
if ( empty( $list ) && $this->is_dir( $path ) ) {
return true; // File is an empty directory.
}
return ! empty( $list ); // Empty list = no file, so invert.
}