不幸的是Filesystem API 是非常基本的。你要找的是dirlist
方法/功能WP_Filesystem_$method
类别。关于它的唯一文档是docblock 超出WP_Filesystem_Base
类别:
/**
* Get details for files in a directory or a specific file.
*
* @since 2.5.0
*
* @param string $path Path to directory or file.
* @param bool $include_hidden Optional. Whether to include details of hidden ("." prefixed) files.
* Default true.
* @param bool $recursive Optional. Whether to recursively include file details in nested directories.
* Default false.
* @return array|bool {
* Array of files. False if unable to list directory contents.
*
* @type string \'name\' Name of the file/directory.
* @type string \'perms\' *nix representation of permissions.
* @type int \'permsn\' Octal representation of permissions.
* @type string \'owner\' Owner name or ID.
* @type int \'size\' Size of file in bytes.
* @type int \'lastmodunix\' Last modified unix timestamp.
* @type mixed \'lastmod\' Last modified month (3 letter) and day (without leading 0).
* @type int \'time\' Last modified time.
* @type string \'type\' Type of resource. \'f\' for file, \'d\' for directory.
* @type mixed \'files\' If a directory and $recursive is true, contains another array of files.
* }
*/
public function dirlist( $path, $include_hidden = true, $recursive = false ) {
return false;
}
在基类中,方法实际上没有功能,为此,请查看(例如)的方法声明
dirlist
内部
WP_Filesystem_Direct
班
现在让我们来看看如何使用它,一个基本示例如下所示:
global $wp_filesystem;
$filelist = $wp_filesystem->dirlist( \'/the/path/to/the/files/\' );