@Scott B我还没有测试这个脚本,它取自inlcudes/file。php->第559行
_unzip_file_pclzip
假设已经调用了WP\\u Filesystem(),因此需要设置global $wp_filesystem
global $wp_filesystem;
$needed_dirs = array();
$target = trailingslashit($target);
// Determine any parent dir\'s needed (of the upgrade directory)
if ( ! $wp_filesystem->is_dir($target) ) { //Only do parents if no children exist
$path = preg_split(\'![/\\\\\\]!\', untrailingslashit($target));
for ( $i = count($path); $i >= 0; $i-- ) {
if ( empty($path[$i]) )
continue;
$dir = implode(\'/\', array_slice($path, 0, $i+1) );
if ( preg_match(\'!^[a-z]:$!i\', $dir) ) // Skip it if it looks like a Windows Drive letter.
continue;
if ( ! $wp_filesystem->is_dir($dir) )
$needed_dirs[] = $dir;
else
break; // A folder exists, therefor, we dont need the check the levels below this
}
}