$filename =
get_temp_dir() .
$theme_name .
$obscura . '.zip';
$zip =
new ZipArchive();
if ( true !==
$zip->
open( $filename, ZipArchive::CREATE | ZipArchive::OVERWRITE
) ) { return new WP_Error( 'unable_to_create_zip',
__( 'Unable to open export file (archive) for writing.'
) );
} $zip->
addEmptyDir( 'templates'
);
$zip->
addEmptyDir( 'parts'
);
// Get path of the theme.
$theme_path =
wp_normalize_path( get_stylesheet_directory() );
// Create recursive directory iterator.
$theme_files =
new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $theme_path ),
RecursiveIteratorIterator::LEAVES_ONLY
);
// Make a copy of the current theme.
foreach ( $theme_files as $file ) { // Skip directories as they are added automatically.
if ( !
$file->
isDir() ) {