/** * @usage Create zip from attached files * @param $ID * @return mixed|string|\WP_Error */ public static function Zip($ID) { $files = self::getFiles($ID); $zipped = get_post_meta($ID, "__wpdm_zipped_file", true); if (count($files) > 0) { if ($zipped == '' || !file_exists($zipped)) { $zipped = UPLOAD_DIR . sanitize_file_name(get_the_title($ID)) . '-' . $ID . '.zip'; $zipped = \WPDM\FileSystem::zipFiles($files, $zipped); return $zipped; } } return new \WP_Error(404, __('No File Attached!', 'wpdmpro')); }
/** * @usage Create ZIP from given file list * @param $files * @param $zipname * @return bool|string */ function wpdm_zip_files($files, $zipname) { return \WPDM\FileSystem::zipFiles($files, $zipname); }