public static function execute( $params ) {

		// Set progress
		Ai1wm_Status::info( __( 'Renaming exported file...', AI1WM_PLUGIN_NAME ) );

		// Close achive file
		$archive = new Ai1wm_Compressor( ai1wm_archive_path( $params ) );

		// Append EOF block
		$archive->close( true );

		// Rename archive file
		if ( rename( ai1wm_archive_path( $params ), ai1wm_download_path( $params ) ) ) {

			// Set archive details
			$link = ai1wm_backups_url( $params );
			$size = ai1wm_download_size( $params );
			$name = ai1wm_site_name();

			// Set progress
			Ai1wm_Status::download(
				sprintf(
					__(
						'<a href="%s" class="ai1wm-button-green ai1wm-emphasize">' .
						'<span>Download %s</span>' .
						'<em>Size: %s</em>' .
						'</a>',
						AI1WM_PLUGIN_NAME
					),
					$link,
					$name,
					$size
				)
			);
		}

		return $params;
	}
示例#2
0
/**
 * Get download size as text
 *
 * @param  array  $params Request parameters
 * @return string
 */
function ai1wm_download_size($params)
{
    return size_format(filesize(ai1wm_download_path($params)));
}