Last active
June 26, 2020 15:28
-
-
Save agiannis/f419758485fe798b7debc3a8e8d0fd19 to your computer and use it in GitHub Desktop.
labels : cs-cart , tools , php , plugin , addon , extract
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
find . -type f -path *plugin_name* | grep -v ".history/" | zip plugin_name.zip -@ |
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
<?php | |
/** | |
* Extracts a cs-cart plugin. This should be placed on the root directory of cs-cart | |
* @param $plugin_name the directory name of the plugin | |
*/ | |
function extract_plugin($plugin_name) | |
{ | |
if (empty($plugin_name)) { | |
return; | |
} | |
$path = __DIR__ . '/'; | |
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST); | |
$filtered = new RegexIterator($files, '/.*' . $plugin_name . '.*/'); | |
$zip = new ZipArchive(); | |
$filename = "./$plugin_name.zip"; | |
if ($zip->open($filename, ZipArchive::CREATE) !== TRUE) { | |
exit("cannot open <$filename>\n"); | |
} | |
foreach ($filtered as $file) { | |
if (is_file($file->getPathname())) { | |
$zip->addFile($file->getPathname(), str_replace($path, '', $file->getPathname())); | |
} | |
} | |
$zip->close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment