/** * Show maintenance page * * @return void */ public function get_header() { Ai1wm_Maintenance::display(); }
/** * Finish import process * * @return void */ public function finish() { // Set progress Ai1wm_Status::set(array('type' => 'finish', 'title' => __('Your data has been imported successfuly!', AI1WM_PLUGIN_NAME), 'message' => sprintf(__('You need to perform two more steps:<br />' . '<strong>1. You must save your permalinks structure twice. <a class="ai1wm-no-underline" href="%s" target="_blank">Permalinks Settings</a></strong> <small>(opens a new window)</small><br />' . '<strong>2. <a class="ai1wm-no-underline" href="https://wordpress.org/support/view/plugin-reviews/all-in-one-wp-migration?rate=5#postform" target="_blank">Review the plugin</a>.</strong> <small>(opens a new window)</small>', AI1WM_PLUGIN_NAME), admin_url('options-permalink.php#submit')))); // Disable maintenance mode Ai1wm_Maintenance::disable(); }
/** * Add database * * @return void */ public function database() { // Set exclude database if ($this->should_exclude_database()) { // Disable maintenance mode Ai1wm_Maintenance::disable(); // Redirect return $this->route_to('export'); } // Set progress Ai1wm_Status::set(array('message' => __('Exporting database...', AI1WM_PLUGIN_NAME))); // Get databsae file $service = new Ai1wm_Service_Database($this->args); $service->export(); // Get archive file $archive = new Ai1wm_Compressor($this->storage()->archive()); // Add database to archive $archive->add_file($this->storage()->database(), AI1WM_DATABASE_NAME); $archive->close(); // Set progress Ai1wm_Status::set(array('message' => __('Done exporting database.', AI1WM_PLUGIN_NAME))); // Disable maintenance mode Ai1wm_Maintenance::disable(); // Redirect $this->route_to('export'); }
<?php if (Ai1wm_Maintenance::active()) { ?> <div class="ai1wm-message-warning"> <?php _e('Maintenance Mode is <strong>ON</strong>, switch it to ' . '<a href="#" id="ai1wm-maintenance-off">OFF</a>', AI1WM_PLUGIN_NAME); ?> </div> <?php }
/** * Import site * * @return StorageFile */ public function import() { global $wp_version; $storage = StorageArea::getInstance(); // Create import file $import_file = $storage->makeFile($this->options['import']['file']); // Extract archive try { try { $zip = ZipFactory::makeZipArchiver($import_file->getName(), !class_exists('ZipArchive')); $zip->extractTo($storage->getRootPath()); $zip->close(); } catch (Exception $e) { $zip = ZipFactory::makeZipArchiver($import_file->getName(), true); $zip->extractTo($storage->getRootPath()); $zip->close(); } } catch (Exception $e) { throw new Ai1wm_Import_Exception(_('Site could not be imported!<br />' . 'Archive file is broken or is not compatible with the plugin! Please verify your archive file.')); } // Verify package if ($this->should_import_package()) { // Enable maintenance mode Ai1wm_Maintenance::enable(); // Database if ($this->should_import_database()) { $service = new Ai1wm_Service_Database($this->options); $service->import(); } // Media if ($this->should_import_media()) { $service = new Ai1wm_Service_Media($this->options); $service->import(); } // Sites (Network mode) if ($this->should_import_sites()) { $service = new Ai1wm_Service_Sites($this->options); $service->import(); } // Themes if ($this->should_import_themes()) { $service = new Ai1wm_Service_Themes($this->options); $service->import(); } // Plugins if ($this->should_import_plugins()) { $service = new Ai1wm_Service_Plugins($this->options); $service->import(); } // Disable maintenance mode Ai1wm_Maintenance::disable(); } else { throw new Ai1wm_Import_Exception(_('Site could not be imported!<br />' . 'Archive file is not compatible with the plugin! Please verify your archive file.')); } return $import_file; }
/** * Export site * * @return StorageFile */ public function export() { $storage = StorageArea::getInstance(); // Enable maintenance mode Ai1wm_Maintenance::enable(); // Create export file $export_file = $storage->makeFile(); // Make archive file try { $zip = ZipFactory::makeZipArchiver($export_file->getName(), !class_exists('ZipArchive'), true); } catch (Exception $e) { $zip = ZipFactory::makeZipArchiver($export_file->getName(), true, true); } // Package if ($this->should_export_package()) { $service = new Ai1wm_Service_Package($this->options); $zip->addFromString(AI1WM_PACKAGE_NAME, $service->export()); } // Database if ($this->should_export_database()) { $service = new Ai1wm_Service_Database($this->options); // Add database to archive $zip->addFile($service->export(), AI1WM_DATABASE_NAME); } // Media if ($this->should_export_media()) { $service = new Ai1wm_Service_Media($this->options); // Add media to archive $zip->addDir($service->export(), AI1WM_MEDIA_NAME); // Sites (Network mode) $service = new Ai1wm_Service_Sites($this->options); if ($sites = $service->export()) { // Add sites to archive $zip->addDir($sites, AI1WM_SITES_NAME); } } // Themes if ($this->should_export_themes()) { $service = new Ai1wm_Service_Themes($this->options); // Add themes to archive $zip->addDir($service->export(), AI1WM_THEMES_NAME); } // Plugins if ($this->should_export_plugins()) { $service = new Ai1wm_Service_Plugins($this->options); // Add plugins to archive if ($plugins = $service->get_installed_plugins()) { $zip->addDir($service->export(), AI1WM_PLUGINS_NAME, $plugins); } } // Disable maintenance mode Ai1wm_Maintenance::disable(); return $export_file; }