Skip to content

Instantly share code, notes, and snippets.

@pdewouters
Created March 4, 2016 12:04
Show Gist options
  • Save pdewouters/b4c9903217ff566c5491 to your computer and use it in GitHub Desktop.
Save pdewouters/b4c9903217ff566c5491 to your computer and use it in GitHub Desktop.
archive contents of directory
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local;
use League\Flysystem\ZipArchive\ZipArchiveAdapter;
use Symfony\Component\Finder\Finder;
add_action( 'plugins_loaded', function(){
require_once __DIR__ . '/vendor/autoload.php';
$zip_archive = new Filesystem( new ZipArchiveAdapter( __DIR__ . '/archive.zip' ) );
$finder = new Finder();
$finder->files();
$finder->followLinks();
$finder->ignoreDotFiles( false );
$finder->ignoreUnreadableDirs();
foreach ( $finder->in( ABSPATH ) as $entry ) {
$zip_archive->put( $entry->getPathname(), $entry->getContents() );
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment