I am using the following script to move the files of my directory (in this case My_Theme
) to the zip archive wordpress.zip
.
define('CLIENT_PATH', $_SERVER['DOCUMENT_ROOT'] . '/wp_theme/clients_templates/' . str_replace(' ', '_', $_POST['title']));
$zip = new ZipArchive;
$zip->open('wordpress.zip', ZipArchive::CREATE);
foreach (glob(CLIENT_PATH . "/*.*") as $file) {
echo $file . '<br>';
$zip->addFile($file);
}
$zip->close();
Now when I download and unzip that file, my folder structure looks like this:
What I want is to move the directory My_Theme
to wordpress/wp-content/themes/
The result would be: wordpress/wp-content/themes/My_Theme
(including all the files and sub directories within)
How can I do this?
I answer my own question and the answer is easy: Just define the second parameter:
$zip->addFile($file, 'wordpress/wp-content/themes/' . $theme_name . '/' . $file_name);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With