您可以使用Filesystem API
, 尤其是copy_dir()
功能-source - 似乎正是你在寻找的。查看上述源链接中的docblock,了解更多信息:
/**
* Copies a directory from one location to another via the WordPress Filesystem Abstraction.
* Assumes that WP_Filesystem() has already been called and setup.
*
* @since 2.5.0
*
* @param string $from source directory
* @param string $to destination directory
* @param array $skip_list a list of files/folders to skip copying
* @return mixed WP_Error on failure, True on success.
*/
(非常)基本的使用场景如下所示:
global $wp_filesystem;
copy_dir(
\'/path/you/are/copying/from/\',
\'/path/you/are/copying/to/\'
);
不幸的是
Filesystem API
并没有很好的记录。你肯定应该看看链接的codex文章。另一个(几乎总是)链接的信息来源是@Otto的文章: