How to get files from loop for zip

As the files are within the same WP installation (not a remote), you don’t need to download the file using get_file_contents(), try to add the file using its absolute path of the attachment. if(isset($_POST[‘download’])){ $tmpFile = tempnam(‘/tmp’, ”); $zip = new ZipArchive(); $zip->open($tmpFile, ZipArchive::CREATE); foreach( $list_posts as $list_item ) : if ( $list_item->post_type == ‘crb_photo’ … Read more

Download a zip folder of selected files

remove the brackets from your name=”checked” It should just be <input type=”checkbox” name=”checked” value=”<?php echo $path; ?>”> Which would only return one value, so you cant do a foreach loop on one value. You need multiple input fields and then put those values into an array to use in the foreach loop

How to prepare (compress/zip) a plugin to enable updating instead of adding new instance?

This is the default behaviour for WordPress. But there is a plugin called “Easy theme and plugin upgrades” that handles this for plugin and template updates: https://de.wordpress.org/plugins/easy-theme-and-plugin-upgrades/ After installing the plugin, you can just upload a new zip and it wont’t install another plugin/theme instance. Instead, the plugin generates a backup of the older version … Read more

WordPress can’t use ZipArchive

I successfully created zip file in root folder of WordPress using following code: $files = array(__DIR__.’/test.jpg’, __DIR__.’/screenshot.png’); $zipname=”images.zip”; $zip = new ZipArchive; $zip->open($zipname, ZipArchive::CREATE) or die(‘ cant open ‘); foreach ($files as $file) { if( $zip->addFile($file)){ echo “<br>$file Added To Zip Sucessfully”; }else { echo “<br>Can not add $file file”; } } $zip->close(); if(file_exists($zipname)){ echo … Read more