public static function execute( $params ) {

		// Set shutdown handler
		@register_shutdown_function( 'Ai1wm_Import_Done::shutdown' );

		// Check multisite.json file
		if ( true === is_file( ai1wm_multisite_path( $params ) ) ) {

			// Read multisite.json file
			$handle = fopen( ai1wm_multisite_path( $params ), 'r' );
			if ( $handle === false ) {
				throw new Ai1wm_Import_Exception( __( 'Unable to read multisite.json file', AI1WM_PLUGIN_NAME ) );
			}

			// Parse multisite.json file
			$multisite = fread( $handle, filesize( ai1wm_multisite_path( $params ) ) );
			$multisite = json_decode( $multisite );

			// Close handle
			fclose( $handle );

			// Activate plugins
			if ( isset( $multisite->Plugins ) && ( $active_sitewide_plugins = $multisite->Plugins ) ) {
				activate_plugins( $active_sitewide_plugins, null, is_multisite() );
			}
		}

		// Set the new MS files rewriting
		if ( get_site_option( AI1WM_MS_FILES_REWRITING ) ) {
			update_site_option( AI1WM_MS_FILES_REWRITING, 0 );
		}

		// Open the archive file for reading
		$archive = new Ai1wm_Extractor( ai1wm_archive_path( $params ) );

		// Unpack must-use plugins
		$archive->extract_by_files_array( WP_CONTENT_DIR, array( AI1WM_MUPLUGINS_NAME ) );

		// Close the archive file
		$archive->close();

		// Load must-use plugins
		foreach ( wp_get_mu_plugins() as $mu_plugin ) {
			include_once( $mu_plugin );
		}

		return $params;
	}
 public static function execute($params)
 {
     // Set progress
     Ai1wm_Status::info(__('Activating plugins...', AI1WM_PLUGIN_NAME));
     // Open the archive file for reading
     $archive = new Ai1wm_Extractor(ai1wm_archive_path($params));
     // Include WordPress files
     $include_files = array_keys(_get_dropins());
     // Include mu-plugins files
     $include_files = array_merge($include_files, array(AI1WM_MUPLUGINS_NAME));
     // Unpack WordPress files and mu-plugins files
     $archive->extract_by_files_array(WP_CONTENT_DIR, $include_files);
     // Close the archive file
     $archive->close();
     // Set progress
     Ai1wm_Status::info(__('Done activating plugins...', AI1WM_PLUGIN_NAME));
     return $params;
 }
	/**
	 * Unpack archive
	 *
	 * @return void
	 */
	public function start() {
		// Set default progress
		Ai1wm_Status::set( array(
			'total'     => 0,
			'processed' => 0,
			'type'      => 'info',
			'message'   => __( 'Unpacking archive...', AI1WM_PLUGIN_NAME ),
		) );

		// Open the archive file for reading
		$archive = new Ai1wm_Extractor( $this->storage()->archive() );

		// Unpack package.json and database.sql files
		$archive->extract_by_files_array(
			$this->storage()->path(),
			array(
				AI1WM_PACKAGE_NAME,
				AI1WM_DATABASE_NAME,
			)
		);

		// Close the archive file
		$archive->close();

		// Validate the archive file
		if ( $this->validate() ) {

			// Parse the package file
			$service = new Ai1wm_Service_Package( $this->args );
			if ( $service->import() ) {
				$this->route_to( 'confirm' );
			} else {
				throw new Ai1wm_Import_Exception( __( 'Invalid package.json file.', AI1WM_PLUGIN_NAME ) );
			}

		} else {
			throw new Ai1wm_Import_Exception(
				__( 'Invalid archive file. It should contain <strong>package.json</strong> file.', AI1WM_PLUGIN_NAME )
			);
		}
	}
	public static function execute( $params ) {

		// Set progress
		Ai1wm_Status::info( __( 'Unpacking archive...', AI1WM_PLUGIN_NAME ) );

		// Open the archive file for reading
		$archive = new Ai1wm_Extractor( ai1wm_archive_path( $params ) );

		// Validate the archive file consistency
		if ( ! $archive->is_valid() ) {
			throw new Ai1wm_Import_Exception(
				__(
					'The archive file is corrupted. Follow this article to resolve the problem: ' .
					'<a href="https://help.servmask.com/knowledgebase/corrupted-archive/" target="_blank">https://help.servmask.com/knowledgebase/corrupted-archive/</a>',
					AI1WM_PLUGIN_NAME
				)
			);
		}

		// Obtain the name of the archive
		$name = ai1wm_archive_name( $params );

		// Obtain the size of the archive
		$size = ai1wm_archive_bytes( $params );

		// Check file size of the archive
		if ( false === $size ) {
			throw new Ai1wm_Not_Accesible_Exception(
				sprintf( __( 'Unable to get the file size of <strong>%s</strong>', AI1WM_PLUGIN_NAME ), $name )
			);
		}

		$allowed_size = apply_filters( 'ai1wm_max_file_size', AI1WM_MAX_FILE_SIZE );

		// Let's check the size of the file to make sure it is less than the maximum allowed
		if ( ( $allowed_size > 0 ) && ( $size > $allowed_size ) ) {
			throw new Ai1wm_Import_Exception(
				sprintf(
					__(
						'The file that you are trying to import is over the maximum upload file size limit of <strong>%s</strong>.<br />' .
						'You can remove this restriction by purchasing our ' .
						'<a href="https://servmask.com/products/unlimited-extension" target="_blank">Unlimited Extension</a>.',
						AI1WM_PLUGIN_NAME
					),
					size_format( $allowed_size )
				)
			);
		}

		// Unpack package.json, multisite.json and database.sql files
		$archive->extract_by_files_array(
			ai1wm_storage_path( $params ),
			array(
				AI1WM_PACKAGE_NAME,
				AI1WM_MULTISITE_NAME,
				AI1WM_DATABASE_NAME,
			)
		);

		// Close the archive file
		$archive->close();

		// Check package.json file
		if ( false === is_file( ai1wm_package_path( $params ) ) ) {
			throw new Ai1wm_Import_Exception(
				__( 'Invalid archive file. It should contain <strong>package.json</strong> file.', AI1WM_PLUGIN_NAME )
			);
		}

		return $params;
	}