.
*
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
*/
class Ai1wm_Import_Done {
public static function execute( $params ) {
// Check multisite.json file
if ( true === is_file( ai1wm_multisite_path( $params ) ) ) {
// Read multisite.json file
$handle = ai1wm_open( ai1wm_multisite_path( $params ), 'r' );
// Parse multisite.json file
$multisite = ai1wm_read( $handle, filesize( ai1wm_multisite_path( $params ) ) );
$multisite = json_decode( $multisite, true );
// Close handle
ai1wm_close( $handle );
// Activate sitewide plugins
if ( isset( $multisite['Plugins'] ) && ( $plugins = $multisite['Plugins'] ) ) {
ai1wm_activate_plugins( $plugins );
}
// Deactivate sitewide Really Simple SSL, WordPress HTTPS (SSL) and WP Force SSL plugins
if ( ! is_ssl() ) {
ai1wm_deactivate_plugins( array(
'really-simple-ssl/rlrsssl-really-simple-ssl.php',
'wordpress-https/wordpress-https.php',
'wp-force-ssl/wp-force-ssl.php',
) );
}
// Deactivate Jetpack Photon module
ai1wm_deactivate_jetpack_photon_module();
} else {
// Check package.json file
if ( true === is_file( ai1wm_package_path( $params ) ) ) {
// Read package.json file
$handle = ai1wm_open( ai1wm_package_path( $params ), 'r' );
// Parse package.json file
$package = ai1wm_read( $handle, filesize( ai1wm_package_path( $params ) ) );
$package = json_decode( $package, true );
// Close handle
ai1wm_close( $handle );
// Activate plugins
if ( isset( $package['Plugins'] ) && ( $plugins = $package['Plugins'] ) ) {
ai1wm_activate_plugins( $plugins );
}
// Activate template
if ( isset( $package['Template'] ) && ( $template = $package['Template'] ) ) {
ai1wm_activate_template( $template );
}
// Activate stylesheet
if ( isset( $package['Stylesheet'] ) && ( $stylesheet = $package['Stylesheet'] ) ) {
ai1wm_activate_stylesheet( $stylesheet );
}
// Deactivate Really Simple SSL, WordPress HTTPS (SSL) and WP Force SSL plugins
if ( ! is_ssl() ) {
ai1wm_deactivate_plugins( array(
'really-simple-ssl/rlrsssl-really-simple-ssl.php',
'wordpress-https/wordpress-https.php',
'wp-force-ssl/wp-force-ssl.php',
) );
}
// Deactivate Jetpack Photon module
ai1wm_deactivate_jetpack_photon_module();
}
}
// Check blogs.json file
if ( true === is_file( ai1wm_blogs_path( $params ) ) ) {
// Read blogs.json file
$handle = ai1wm_open( ai1wm_blogs_path( $params ), 'r' );
// Parse blogs.json file
$blogs = ai1wm_read( $handle, filesize( ai1wm_blogs_path( $params ) ) );
$blogs = json_decode( $blogs, true );
// Close handle
ai1wm_close( $handle );
// Loop over blogs
foreach ( $blogs as $blog ) {
// Activate plugins
if ( isset( $blog['New']['Plugins'] ) && ( $plugins = $blog['New']['Plugins'] ) ) {
ai1wm_activate_plugins( $plugins );
}
// Activate template
if ( isset( $blog['New']['Template'] ) && ( $template = $blog['New']['Template'] ) ) {
ai1wm_activate_template( $template );
}
// Activate stylesheet
if ( isset( $blog['New']['Stylesheet'] ) && ( $stylesheet = $blog['New']['Stylesheet'] ) ) {
ai1wm_activate_stylesheet( $stylesheet );
}
// Deactivate Really Simple SSL, WordPress HTTPS (SSL) and WP Force SSL plugins
if ( ! is_ssl() ) {
ai1wm_deactivate_plugins( array(
'really-simple-ssl/rlrsssl-really-simple-ssl.php',
'wordpress-https/wordpress-https.php',
'wp-force-ssl/wp-force-ssl.php',
) );
}
// Deactivate Jetpack Photon module
ai1wm_deactivate_jetpack_photon_module();
}
}
// Set progress
Ai1wm_Status::done(
sprintf(
__(
'You need to perform two more steps:
' .
'1. You must save your permalinks structure twice. Permalinks Settings (opens a new window)
' .
'2. Optionally, review the plugin. (opens a new window)',
AI1WM_PLUGIN_NAME
),
admin_url( 'options-permalink.php#submit' )
),
__(
'Your data has been imported successfully!',
AI1WM_PLUGIN_NAME
)
);
return $params;
}
}