Created
March 4, 2016 12:04
-
-
Save pdewouters/b4c9903217ff566c5491 to your computer and use it in GitHub Desktop.
archive contents of directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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