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(__('Preparing blogs...', AI1WM_PLUGIN_NAME)); $blogs = array(); // 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, true); // Close handle fclose($handle); // Validate if (empty($multisite['Network'])) { if (isset($multisite['Sites']) && ($sites = $multisite['Sites'])) { if (count($sites) === 1 && ($site = current($sites))) { $blogs[] = array('Old' => array('BlogID' => $site['BlogID'], 'SiteURL' => $site['SiteURL'], 'HomeURL' => $site['HomeURL']), 'New' => array('BlogID' => null, 'SiteURL' => site_url(), 'HomeURL' => home_url())); } else { throw new Ai1wm_Import_Exception(__('The archive should contain <strong>Single WordPress</strong> site! Please revisit your export settings.', AI1WM_PLUGIN_NAME)); } } else { throw new Ai1wm_Import_Exception(__('At least <strong>one WordPress</strong> site should be presented in the archive.', AI1WM_PLUGIN_NAME)); } } else { throw new Ai1wm_Import_Exception(__('Unable to import <strong>WordPress Network</strong> into WordPress <strong>Single</strong> site.', AI1WM_PLUGIN_NAME)); } } // Save blogs.json file $handle = fopen(ai1wm_blogs_path($params), 'w'); fwrite($handle, json_encode($blogs)); fclose($handle); // Set progress Ai1wm_Status::info(__('Done preparing blogs...', AI1WM_PLUGIN_NAME)); return $params; }
public static function execute($params) { // 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, true); // Close handle fclose($handle); // Activate plugins if (isset($multisite['Plugins']) && ($active_sitewide_plugins = $multisite['Plugins'])) { activate_plugins($active_sitewide_plugins, null, is_multisite(), true); } } // Set progress Ai1wm_Status::done(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">Optionally, review the plugin</a>.</strong> <small>(opens a new window)</small>', AI1WM_PLUGIN_NAME), admin_url('options-permalink.php#submit')), __('Your data has been imported successfuly!', AI1WM_PLUGIN_NAME)); return $params; }