What should I pass for $needed_dirs when calling _unzip_file_pclzip (aka PclZip)?
I'm trying to create a fallback method when ZipArchive is not present. I'm seeking to use the _unzip_file_pclzip() function contained in wp-admin/includes/file.php
However, I'm not sure what is expected for the $needed_dirs argument.
My target folder for the zip will be the "styles" folder under my theme folder, so the path would be "wp-content/themes/mytheme/styles/"
Is that what's expected for $needed_dirs?
function openZip($file_to_open) {
global $wp_filesystem;//required if _unzip_file_pclzip is used directly
global $target;
if(class_exists('ZipArchive'))
{
$zip = new ZipArchive();
$x = $zip-open($file_to_open);
if($x === true)
{
$zip-extractTo($target);
$zip-close();
unlink($file_to_open);
} else {
die("There was a problem. Please try again!");
}
}
else
{
$needed_dirs = array();
_unzip_file_pclzip($file_to_open, $target, $needed_dirs);
}
}
Topic ziparchive plugin-development Wordpress
Category Web