Initial commit: WordPress wp-content (themes, plugins, languages)
- Theme: momentry (custom theme with REST API routes) - Plugins: code-snippets (contains all API proxies) - Languages: zh_TW translations - Excludes: cache, backups, uploads, logs
This commit is contained in:
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Attribution: This code is part of the All-in-One WP Migration plugin, developed by
|
||||
*
|
||||
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
||||
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
||||
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
||||
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
||||
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
||||
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
class Ai1wm_Import_Blogs {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Preparing blogs...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
$blogs = array();
|
||||
|
||||
// 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 );
|
||||
|
||||
// Validate
|
||||
if ( empty( $multisite['Network'] ) ) {
|
||||
if ( isset( $multisite['Sites'] ) && ( $sites = $multisite['Sites'] ) ) {
|
||||
if ( count( $sites ) === 1 && ( $subsite = current( $sites ) ) ) {
|
||||
|
||||
// Set internal Site URL (backward compatibility)
|
||||
if ( empty( $subsite['InternalSiteURL'] ) ) {
|
||||
$subsite['InternalSiteURL'] = null;
|
||||
}
|
||||
|
||||
// Set internal Home URL (backward compatibility)
|
||||
if ( empty( $subsite['InternalHomeURL'] ) ) {
|
||||
$subsite['InternalHomeURL'] = null;
|
||||
}
|
||||
|
||||
// Set active plugins (backward compatibility)
|
||||
if ( empty( $subsite['Plugins'] ) ) {
|
||||
$subsite['Plugins'] = array();
|
||||
}
|
||||
|
||||
// Set active template (backward compatibility)
|
||||
if ( empty( $subsite['Template'] ) ) {
|
||||
$subsite['Template'] = null;
|
||||
}
|
||||
|
||||
// Set active stylesheet (backward compatibility)
|
||||
if ( empty( $subsite['Stylesheet'] ) ) {
|
||||
$subsite['Stylesheet'] = null;
|
||||
}
|
||||
|
||||
// Set uploads path (backward compatibility)
|
||||
if ( empty( $subsite['Uploads'] ) ) {
|
||||
$subsite['Uploads'] = null;
|
||||
}
|
||||
|
||||
// Set uploads URL path (backward compatibility)
|
||||
if ( empty( $subsite['UploadsURL'] ) ) {
|
||||
$subsite['UploadsURL'] = null;
|
||||
}
|
||||
|
||||
// Set uploads path (backward compatibility)
|
||||
if ( empty( $subsite['WordPress']['Uploads'] ) ) {
|
||||
$subsite['WordPress']['Uploads'] = null;
|
||||
}
|
||||
|
||||
// Set uploads URL path (backward compatibility)
|
||||
if ( empty( $subsite['WordPress']['UploadsURL'] ) ) {
|
||||
$subsite['WordPress']['UploadsURL'] = null;
|
||||
}
|
||||
|
||||
// Set blog items
|
||||
$blogs[] = array(
|
||||
'Old' => array(
|
||||
'BlogID' => $subsite['BlogID'],
|
||||
'SiteURL' => $subsite['SiteURL'],
|
||||
'HomeURL' => $subsite['HomeURL'],
|
||||
'InternalSiteURL' => $subsite['InternalSiteURL'],
|
||||
'InternalHomeURL' => $subsite['InternalHomeURL'],
|
||||
'Plugins' => $subsite['Plugins'],
|
||||
'Template' => $subsite['Template'],
|
||||
'Stylesheet' => $subsite['Stylesheet'],
|
||||
'Uploads' => $subsite['Uploads'],
|
||||
'UploadsURL' => $subsite['UploadsURL'],
|
||||
'WordPress' => $subsite['WordPress'],
|
||||
),
|
||||
'New' => array(
|
||||
'BlogID' => null,
|
||||
'SiteURL' => site_url(),
|
||||
'HomeURL' => home_url(),
|
||||
'InternalSiteURL' => site_url(),
|
||||
'InternalHomeURL' => home_url(),
|
||||
'Plugins' => $subsite['Plugins'],
|
||||
'Template' => $subsite['Template'],
|
||||
'Stylesheet' => $subsite['Stylesheet'],
|
||||
'Uploads' => get_option( 'upload_path' ),
|
||||
'UploadsURL' => get_option( 'upload_url_path' ),
|
||||
'WordPress' => array(
|
||||
'UploadsURL' => ai1wm_get_uploads_url(),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
throw new Ai1wm_Import_Exception( esc_html__( 'The archive must contain only a single WordPress site. The process cannot continue. Please revisit your export settings.', 'all-in-one-wp-migration' ) );
|
||||
}
|
||||
} else {
|
||||
throw new Ai1wm_Import_Exception( esc_html__( 'The archive must contain at least one WordPress site. The process cannot continue. Please check your export settings.', 'all-in-one-wp-migration' ) );
|
||||
}
|
||||
} else {
|
||||
throw new Ai1wm_Import_Exception( esc_html__( 'Could not import a WordPress Network into a single WordPress site. The process cannot continue. Please check your import settings.', 'all-in-one-wp-migration' ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Write blogs.json file
|
||||
$handle = ai1wm_open( ai1wm_blogs_path( $params ), 'w' );
|
||||
ai1wm_write( $handle, json_encode( $blogs ) );
|
||||
ai1wm_close( $handle );
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Blogs prepared.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Attribution: This code is part of the All-in-One WP Migration plugin, developed by
|
||||
*
|
||||
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
||||
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
||||
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
||||
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
||||
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
||||
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
class Ai1wm_Import_Check_Compression {
|
||||
|
||||
public static function execute( $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 );
|
||||
|
||||
// No compression provided
|
||||
if ( empty( $package['Compression']['Enabled'] ) || empty( $package['Compression']['Type'] ) ) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
// Check if server supports decompression
|
||||
if ( ! ai1wm_has_compression_type( $package['Compression']['Type'] ) ) {
|
||||
throw new Ai1wm_Import_Exception(
|
||||
wp_kses(
|
||||
sprintf(
|
||||
__(
|
||||
'Importing a compressed backup is not supported on this server.
|
||||
Please ensure <strong>%s</strong> extension is enabled. <a href="https://help.servmask.com/knowledgebase/compressed-backups/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
$package['Compression']['Type']
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Set progres
|
||||
Ai1wm_Status::info( __( 'Compressed backup detected. Compression will be handled automatically.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Attribution: This code is part of the All-in-One WP Migration plugin, developed by
|
||||
*
|
||||
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
||||
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
||||
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
||||
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
||||
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
||||
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
class Ai1wm_Import_Check_Encryption {
|
||||
|
||||
public static function execute( $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 );
|
||||
|
||||
// No encryption provided
|
||||
if ( empty( $package['Encrypted'] ) || empty( $package['EncryptedSignature'] ) ) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
// Check decryption support
|
||||
if ( ! ai1wm_can_decrypt() ) {
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
WP_CLI::error( __( 'Importing an encrypted backup is not supported on this server. The process cannot continue. Technical details: https://help.servmask.com/knowledgebase/unable-to-encrypt-and-decrypt-backups/', 'all-in-one-wp-migration' ) );
|
||||
} else {
|
||||
Ai1wm_Status::server_cannot_decrypt( __( 'Importing an encrypted backup is not supported on this server. The process cannot continue. <a href="https://help.servmask.com/knowledgebase/unable-to-encrypt-and-decrypt-backups/" target="_blank">Technical details</a>', 'all-in-one-wp-migration' ) );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Get WP CLI decryption password
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
$params['decryption_password'] = readline( __( 'Backup is encrypted. Please provide decryption password: ', 'all-in-one-wp-migration' ) );
|
||||
}
|
||||
|
||||
// Validate decryption password
|
||||
if ( ! empty( $params['decryption_password'] ) ) {
|
||||
if ( ai1wm_is_decryption_password_valid( $package['EncryptedSignature'], $params['decryption_password'] ) ) {
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Decryption password validated.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
$decryption_password_error = __( 'The decryption password is not valid. The process cannot continue.', 'all-in-one-wp-migration' );
|
||||
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
WP_CLI::error( $decryption_password_error );
|
||||
} else {
|
||||
Ai1wm_Status::backup_is_encrypted( $decryption_password_error );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
Ai1wm_Status::backup_is_encrypted( null );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Attribution: This code is part of the All-in-One WP Migration plugin, developed by
|
||||
*
|
||||
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
||||
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
||||
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
||||
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
||||
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
||||
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
class Ai1wm_Import_Clean {
|
||||
|
||||
public static function execute( $params ) {
|
||||
// Get database client
|
||||
$db_client = Ai1wm_Database_Utility::get_client();
|
||||
|
||||
// Flush mainsite tables
|
||||
$db_client->add_table_prefix_filter( ai1wm_table_prefix( 'mainsite' ) );
|
||||
$db_client->flush();
|
||||
|
||||
// Trigger import cancel action
|
||||
if ( isset( $params['ai1wm_import_cancel'] ) ) {
|
||||
do_action( 'ai1wm_status_import_canceled', $params );
|
||||
} else {
|
||||
do_action( 'ai1wm_status_import_done', $params );
|
||||
}
|
||||
|
||||
// Delete storage files
|
||||
Ai1wm_Directory::delete( ai1wm_storage_path( $params ) );
|
||||
|
||||
// Exit in console
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Attribution: This code is part of the All-in-One WP Migration plugin, developed by
|
||||
*
|
||||
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
||||
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
||||
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
||||
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
||||
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
||||
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
class Ai1wm_Import_Compatibility {
|
||||
|
||||
public static function execute( $params ) {
|
||||
do_action( 'ai1wm_status_import_start', $params );
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Checking for compatibility...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Get messages
|
||||
$messages = Ai1wm_Compatibility::get( $params );
|
||||
|
||||
// Set messages
|
||||
if ( empty( $messages ) ) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
// Error message
|
||||
throw new Ai1wm_Compatibility_Exception( wp_kses( implode( $messages ), ai1wm_allowed_html_tags() ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Attribution: This code is part of the All-in-One WP Migration plugin, developed by
|
||||
*
|
||||
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
||||
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
||||
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
||||
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
||||
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
||||
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
class Ai1wm_Import_Confirm {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
$messages = array();
|
||||
|
||||
// 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 );
|
||||
|
||||
// Confirm message
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
$messages[] = sprintf(
|
||||
/* translators: Link to Unlimited Extension */
|
||||
__(
|
||||
'Importing this file will only replace matching content. Other items stay unchanged.
|
||||
Need a full reset first? Try Reset Hub in our Unlimited Extension (%s).
|
||||
Ensure you have a current backup. Proceed?',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
'https://servmask.com/products/unlimited-extension'
|
||||
);
|
||||
} else {
|
||||
$messages[] = sprintf(
|
||||
/* translators: Link to Unlimited Extension */
|
||||
__(
|
||||
'Importing this file will only replace matching content. Other items stay unchanged.
|
||||
Need a full reset first? Try Reset Hub in our <a href="%s" target="_blank">Unlimited Extension</a>.<br />
|
||||
Ensure you have a current backup. Proceed?',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
'https://servmask.com/products/unlimited-extension?utm_source=import-confirm&utm_medium=plugin&utm_campaign=ai1wm'
|
||||
);
|
||||
}
|
||||
|
||||
// Check compatibility of PHP versions
|
||||
if ( isset( $package['PHP']['Version'] ) ) {
|
||||
// Extract major and minor version numbers
|
||||
$source_versions = explode( '.', $package['PHP']['Version'] );
|
||||
$target_versions = explode( '.', PHP_VERSION );
|
||||
|
||||
$source_major_version = intval( $source_versions[0] );
|
||||
$source_minor_version = intval( isset( $source_versions[1] ) ? $source_versions[1] : 0 );
|
||||
|
||||
$target_major_version = intval( $target_versions[0] );
|
||||
$target_minor_version = intval( isset( $target_versions[1] ) ? $target_versions[1] : 0 );
|
||||
|
||||
if ( $source_major_version !== $target_major_version ) {
|
||||
$from_php = $source_major_version;
|
||||
$to_php = $target_major_version;
|
||||
} elseif ( $source_minor_version !== $target_minor_version ) {
|
||||
$from_php = sprintf( '%s.%s', $source_major_version, $source_minor_version );
|
||||
$to_php = sprintf( '%s.%s', $target_major_version, $target_minor_version );
|
||||
}
|
||||
|
||||
if ( isset( $from_php, $to_php ) ) {
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
$messages[] = sprintf(
|
||||
/* translators: 1: Source PHP version, 2: Target PHP version. */
|
||||
__(
|
||||
'Your backup is from a PHP %1$s but the site that you are importing to is PHP %2$s.
|
||||
This could cause the import to fail. Technical details: https://help.servmask.com/knowledgebase/migrate-wordpress-from-php-5-to-php-7/',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
$from_php,
|
||||
$to_php
|
||||
);
|
||||
} else {
|
||||
$messages[] = sprintf(
|
||||
'<i class="ai1wm-import-info">' .
|
||||
/* translators: 1: Source PHP version, 2: Target PHP version. */
|
||||
__(
|
||||
'Your backup is from a PHP %1$s but the site that you are importing to is PHP %2$s. This could cause the import to fail. <a href="https://help.servmask.com/knowledgebase/migrate-wordpress-from-php-5-to-php-7/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
) . '</i>',
|
||||
$from_php,
|
||||
$to_php
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( defined( 'WP_CLI' ) ) {
|
||||
$assoc_args = array();
|
||||
if ( isset( $params['cli_args'] ) ) {
|
||||
$assoc_args = $params['cli_args'];
|
||||
}
|
||||
|
||||
WP_CLI::confirm( implode( PHP_EOL, $messages ), $assoc_args );
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::confirm( implode( $messages ) );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,306 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Attribution: This code is part of the All-in-One WP Migration plugin, developed by
|
||||
*
|
||||
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
||||
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
||||
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
||||
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
||||
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
||||
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
class Ai1wm_Import_Content {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Set decryption password
|
||||
$decryption_password = null;
|
||||
if ( isset( $params['decryption_password'] ) ) {
|
||||
$decryption_password = $params['decryption_password'];
|
||||
}
|
||||
|
||||
// Set archive bytes offset
|
||||
if ( isset( $params['archive_bytes_offset'] ) ) {
|
||||
$archive_bytes_offset = (int) $params['archive_bytes_offset'];
|
||||
} else {
|
||||
$archive_bytes_offset = 0;
|
||||
}
|
||||
|
||||
// Set file bytes offset
|
||||
if ( isset( $params['file_bytes_offset'] ) ) {
|
||||
$file_bytes_offset = (int) $params['file_bytes_offset'];
|
||||
} else {
|
||||
$file_bytes_offset = 0;
|
||||
}
|
||||
|
||||
// Set file bytes written
|
||||
if ( isset( $params['file_bytes_written'] ) ) {
|
||||
$file_bytes_written = (int) $params['file_bytes_written'];
|
||||
} else {
|
||||
$file_bytes_written = 0;
|
||||
}
|
||||
|
||||
// Get processed files size
|
||||
if ( isset( $params['processed_files_size'] ) ) {
|
||||
$processed_files_size = (int) $params['processed_files_size'];
|
||||
} else {
|
||||
$processed_files_size = 0;
|
||||
}
|
||||
|
||||
// Get total files size
|
||||
if ( isset( $params['total_files_size'] ) ) {
|
||||
$total_files_size = (int) $params['total_files_size'];
|
||||
} else {
|
||||
$total_files_size = 1;
|
||||
}
|
||||
|
||||
// Get total files count
|
||||
if ( isset( $params['total_files_count'] ) ) {
|
||||
$total_files_count = (int) $params['total_files_count'];
|
||||
} else {
|
||||
$total_files_count = 1;
|
||||
}
|
||||
|
||||
// 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 );
|
||||
|
||||
// Read package.json file
|
||||
$handle = ai1wm_open( ai1wm_package_path( $params ), 'r' );
|
||||
|
||||
// Parse package.json file
|
||||
$config = ai1wm_read( $handle, filesize( ai1wm_package_path( $params ) ) );
|
||||
$config = json_decode( $config, true );
|
||||
|
||||
// Close handle
|
||||
ai1wm_close( $handle );
|
||||
|
||||
// What percent of files have we processed?
|
||||
$progress = (int) min( ( $processed_files_size / $total_files_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
/* translators: 1: Number of files, 2: Progress. */
|
||||
Ai1wm_Status::info( sprintf( __( 'Restoring %1$d files...<br />%2$d%% complete', 'all-in-one-wp-migration' ), $total_files_count, $progress ) );
|
||||
|
||||
// Flag to hold if file data has been processed
|
||||
$completed = true;
|
||||
|
||||
// Start time
|
||||
$start = microtime( true );
|
||||
|
||||
// Get compression type
|
||||
$compression_type = null;
|
||||
if ( ! empty( $config['Compression']['Enabled'] ) ) {
|
||||
$compression_type = $config['Compression']['Type'];
|
||||
}
|
||||
|
||||
// Open the archive file for reading
|
||||
$archive = new Ai1wm_Extractor( ai1wm_archive_path( $params ), $decryption_password, $compression_type );
|
||||
|
||||
// Set the file pointer to the one that we have saved
|
||||
$archive->set_file_pointer( $archive_bytes_offset );
|
||||
|
||||
$old_paths = array( 'plugins', 'themes' );
|
||||
$new_paths = array( ai1wm_get_plugins_dir(), get_theme_root() );
|
||||
|
||||
// Set extract paths
|
||||
foreach ( $blogs as $blog ) {
|
||||
if ( ai1wm_is_mainsite( $blog['Old']['BlogID'] ) === false ) {
|
||||
if ( defined( 'UPLOADBLOGSDIR' ) ) {
|
||||
// Old files dir style
|
||||
$old_paths[] = ai1wm_blog_files_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_files_abspath( $blog['New']['BlogID'] );
|
||||
|
||||
// Old blogs.dir style
|
||||
$old_paths[] = ai1wm_blog_blogsdir_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_blogsdir_abspath( $blog['New']['BlogID'] );
|
||||
|
||||
// New sites dir style
|
||||
$old_paths[] = ai1wm_blog_sites_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_files_abspath( $blog['New']['BlogID'] );
|
||||
} else {
|
||||
// Old files dir style
|
||||
$old_paths[] = ai1wm_blog_files_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_sites_abspath( $blog['New']['BlogID'] );
|
||||
|
||||
// Old blogs.dir style
|
||||
$old_paths[] = ai1wm_blog_blogsdir_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_sites_abspath( $blog['New']['BlogID'] );
|
||||
|
||||
// New sites dir style
|
||||
$old_paths[] = ai1wm_blog_sites_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_sites_abspath( $blog['New']['BlogID'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set base site extract paths (should be added at the end of arrays)
|
||||
foreach ( $blogs as $blog ) {
|
||||
if ( ai1wm_is_mainsite( $blog['Old']['BlogID'] ) === true ) {
|
||||
if ( defined( 'UPLOADBLOGSDIR' ) ) {
|
||||
// Old files dir style
|
||||
$old_paths[] = ai1wm_blog_files_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_files_abspath( $blog['New']['BlogID'] );
|
||||
|
||||
// Old blogs.dir style
|
||||
$old_paths[] = ai1wm_blog_blogsdir_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_blogsdir_abspath( $blog['New']['BlogID'] );
|
||||
|
||||
// New sites dir style
|
||||
$old_paths[] = ai1wm_blog_sites_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_files_abspath( $blog['New']['BlogID'] );
|
||||
} else {
|
||||
// Old files dir style
|
||||
$old_paths[] = ai1wm_blog_files_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_sites_abspath( $blog['New']['BlogID'] );
|
||||
|
||||
// Old blogs.dir style
|
||||
$old_paths[] = ai1wm_blog_blogsdir_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_sites_abspath( $blog['New']['BlogID'] );
|
||||
|
||||
// New sites dir style
|
||||
$old_paths[] = ai1wm_blog_sites_relpath( $blog['Old']['BlogID'] );
|
||||
$new_paths[] = ai1wm_blog_sites_abspath( $blog['New']['BlogID'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$old_paths[] = ai1wm_blog_sites_relpath();
|
||||
$new_paths[] = ai1wm_blog_sites_abspath();
|
||||
|
||||
while ( $archive->has_not_reached_eof() ) {
|
||||
$file_bytes_read = 0;
|
||||
|
||||
// Exclude WordPress files
|
||||
$exclude_files = array_keys( _get_dropins() );
|
||||
|
||||
// Exclude plugin files
|
||||
$exclude_files = array_merge(
|
||||
$exclude_files,
|
||||
array(
|
||||
AI1WM_PACKAGE_NAME,
|
||||
AI1WM_MULTISITE_NAME,
|
||||
AI1WM_DATABASE_NAME,
|
||||
AI1WM_MUPLUGINS_NAME,
|
||||
)
|
||||
);
|
||||
|
||||
// Exclude theme files
|
||||
$exclude_files = array_merge( $exclude_files, array( AI1WM_THEMES_FUNCTIONS_NAME ) );
|
||||
|
||||
// Exclude Elementor files
|
||||
$exclude_files = array_merge( $exclude_files, array( AI1WM_ELEMENTOR_CSS_NAME ) );
|
||||
|
||||
// Exclude CiviCRM files
|
||||
$exclude_files = array_merge( $exclude_files, array( AI1WM_CIVICRM_UPLOADS_NAME ) );
|
||||
|
||||
// Exclude content extensions
|
||||
$exclude_extensions = array( AI1WM_LESS_CACHE_EXTENSION, AI1WM_SQLITE_DATABASE_EXTENSION );
|
||||
|
||||
// Extract a file from archive to WP_CONTENT_DIR
|
||||
if ( ( $completed = $archive->extract_one_file_to( WP_CONTENT_DIR, $exclude_files, $exclude_extensions, $old_paths, $new_paths, $file_bytes_read, $file_bytes_offset, $file_bytes_written ) ) ) {
|
||||
$file_bytes_offset = $file_bytes_written = 0;
|
||||
}
|
||||
|
||||
// Get archive bytes offset
|
||||
$archive_bytes_offset = $archive->get_file_pointer();
|
||||
|
||||
// Increment processed files size
|
||||
$processed_files_size += $file_bytes_read;
|
||||
|
||||
// What percent of files have we processed?
|
||||
$progress = (int) min( ( $processed_files_size / $total_files_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
/* translators: 1: Number of files, 2: Progress. */
|
||||
Ai1wm_Status::info( sprintf( __( 'Restoring %1$d files...<br />%2$d%% complete', 'all-in-one-wp-migration' ), $total_files_count, $progress ) );
|
||||
|
||||
// More than 10 seconds have passed, break and do another request
|
||||
if ( ( $timeout = apply_filters( 'ai1wm_completed_timeout', 10 ) ) ) {
|
||||
if ( ( microtime( true ) - $start ) > $timeout ) {
|
||||
$completed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// End of the archive?
|
||||
if ( $archive->has_reached_eof() ) {
|
||||
|
||||
// Unset archive bytes offset
|
||||
unset( $params['archive_bytes_offset'] );
|
||||
|
||||
// Unset file bytes offset
|
||||
unset( $params['file_bytes_offset'] );
|
||||
|
||||
// Unset file bytes written
|
||||
unset( $params['file_bytes_written'] );
|
||||
|
||||
// Unset processed files size
|
||||
unset( $params['processed_files_size'] );
|
||||
|
||||
// Unset total files size
|
||||
unset( $params['total_files_size'] );
|
||||
|
||||
// Unset total files count
|
||||
unset( $params['total_files_count'] );
|
||||
|
||||
// Unset completed flag
|
||||
unset( $params['completed'] );
|
||||
|
||||
} else {
|
||||
|
||||
// Set archive bytes offset
|
||||
$params['archive_bytes_offset'] = $archive_bytes_offset;
|
||||
|
||||
// Set file bytes offset
|
||||
$params['file_bytes_offset'] = $file_bytes_offset;
|
||||
|
||||
// Set file bytes written
|
||||
$params['file_bytes_written'] = $file_bytes_written;
|
||||
|
||||
// Set processed files size
|
||||
$params['processed_files_size'] = $processed_files_size;
|
||||
|
||||
// Set total files size
|
||||
$params['total_files_size'] = $total_files_size;
|
||||
|
||||
// Set total files count
|
||||
$params['total_files_count'] = $total_files_count;
|
||||
|
||||
// Set completed flag
|
||||
$params['completed'] = $completed;
|
||||
}
|
||||
|
||||
// Close the archive file
|
||||
$archive->close();
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Attribution: This code is part of the All-in-One WP Migration plugin, developed by
|
||||
*
|
||||
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
||||
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
||||
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
||||
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
||||
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
||||
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
class Ai1wm_Import_Database_File {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Set decryption password
|
||||
$decryption_password = null;
|
||||
if ( isset( $params['decryption_password'] ) ) {
|
||||
$decryption_password = $params['decryption_password'];
|
||||
}
|
||||
|
||||
// Set archive bytes offset
|
||||
if ( isset( $params['archive_bytes_offset'] ) ) {
|
||||
$archive_bytes_offset = (int) $params['archive_bytes_offset'];
|
||||
} else {
|
||||
$archive_bytes_offset = 0;
|
||||
}
|
||||
|
||||
// Set file bytes offset
|
||||
if ( isset( $params['file_bytes_offset'] ) ) {
|
||||
$file_bytes_offset = (int) $params['file_bytes_offset'];
|
||||
} else {
|
||||
$file_bytes_offset = 0;
|
||||
}
|
||||
|
||||
// Set file bytes written
|
||||
if ( isset( $params['file_bytes_written'] ) ) {
|
||||
$file_bytes_written = (int) $params['file_bytes_written'];
|
||||
} else {
|
||||
$file_bytes_written = 0;
|
||||
}
|
||||
|
||||
// Get total archive size
|
||||
if ( isset( $params['total_archive_size'] ) ) {
|
||||
$total_archive_size = (int) $params['total_archive_size'];
|
||||
} else {
|
||||
$total_archive_size = ai1wm_archive_bytes( $params );
|
||||
}
|
||||
|
||||
// Read package.json file
|
||||
$handle = ai1wm_open( ai1wm_package_path( $params ), 'r' );
|
||||
|
||||
// Parse package.json file
|
||||
$config = ai1wm_read( $handle, filesize( ai1wm_package_path( $params ) ) );
|
||||
$config = json_decode( $config, true );
|
||||
|
||||
// Close handle
|
||||
ai1wm_close( $handle );
|
||||
|
||||
// What percent of archive have we processed?
|
||||
$progress = (int) min( ( $archive_bytes_offset / $total_archive_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
/* translators: Progress. */
|
||||
Ai1wm_Status::info( sprintf( __( 'Unpacking database...<br />%d%% complete', 'all-in-one-wp-migration' ), $progress ) );
|
||||
|
||||
// Get compression type
|
||||
$compression_type = null;
|
||||
if ( ! empty( $config['Compression']['Enabled'] ) ) {
|
||||
$compression_type = $config['Compression']['Type'];
|
||||
}
|
||||
|
||||
// Open the archive file for reading
|
||||
$archive = new Ai1wm_Extractor( ai1wm_archive_path( $params ), $decryption_password, $compression_type );
|
||||
|
||||
// Set the file pointer to the one that we have saved
|
||||
$archive->set_file_pointer( $archive_bytes_offset );
|
||||
|
||||
// Flag to hold if file data has been processed
|
||||
$completed = true;
|
||||
|
||||
if ( $archive->has_not_reached_eof() ) {
|
||||
$file_bytes_read = 0;
|
||||
|
||||
// Unpack database.sql file
|
||||
if ( ( $completed = $archive->extract_by_files_array( ai1wm_storage_path( $params ), array( AI1WM_DATABASE_NAME ), array(), array(), $file_bytes_read, $file_bytes_offset, $file_bytes_written ) ) ) {
|
||||
$file_bytes_offset = $file_bytes_written = 0;
|
||||
}
|
||||
|
||||
// Get archive bytes offset
|
||||
$archive_bytes_offset = $archive->get_file_pointer();
|
||||
}
|
||||
|
||||
// End of the archive?
|
||||
if ( $archive->has_reached_eof() ) {
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Database unpacked.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Unset archive bytes offset
|
||||
unset( $params['archive_bytes_offset'] );
|
||||
|
||||
// Unset file bytes offset
|
||||
unset( $params['file_bytes_offset'] );
|
||||
|
||||
// Unset file bytes written
|
||||
unset( $params['file_bytes_written'] );
|
||||
|
||||
// Unset total archive size
|
||||
unset( $params['total_archive_size'] );
|
||||
|
||||
// Unset completed flag
|
||||
unset( $params['completed'] );
|
||||
|
||||
} else {
|
||||
|
||||
// What percent of archive have we processed?
|
||||
$progress = (int) min( ( $archive_bytes_offset / $total_archive_size ) * 100, 100 );
|
||||
|
||||
// Set progress
|
||||
/* translators: Progress. */
|
||||
Ai1wm_Status::info( sprintf( __( 'Unpacking database...<br />%d%% complete', 'all-in-one-wp-migration' ), $progress ) );
|
||||
|
||||
// Set archive bytes offset
|
||||
$params['archive_bytes_offset'] = $archive_bytes_offset;
|
||||
|
||||
// Set file bytes offset
|
||||
$params['file_bytes_offset'] = $file_bytes_offset;
|
||||
|
||||
// Set file bytes written
|
||||
$params['file_bytes_written'] = $file_bytes_written;
|
||||
|
||||
// Set total archive size
|
||||
$params['total_archive_size'] = $total_archive_size;
|
||||
|
||||
// Set completed flag
|
||||
$params['completed'] = $completed;
|
||||
}
|
||||
|
||||
// Close the archive file
|
||||
$archive->close();
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,376 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Attribution: This code is part of the All-in-One WP Migration plugin, developed by
|
||||
*
|
||||
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
||||
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
||||
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
||||
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
||||
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
||||
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
class Ai1wm_Import_Done {
|
||||
|
||||
public static function execute( $params ) {
|
||||
global $wp_rewrite;
|
||||
|
||||
// Check multisite.json file
|
||||
if ( 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 WordPress plugins
|
||||
if ( isset( $multisite['Plugins'] ) && ( $plugins = $multisite['Plugins'] ) ) {
|
||||
ai1wm_activate_plugins( $plugins );
|
||||
}
|
||||
|
||||
// Deactivate WordPress SSL plugins
|
||||
if ( ! is_ssl() ) {
|
||||
ai1wm_deactivate_plugins(
|
||||
array(
|
||||
ai1wm_discover_plugin_basename( 'really-simple-ssl/rlrsssl-really-simple-ssl.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wordpress-https/wordpress-https.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wp-force-ssl/wp-force-ssl.php' ),
|
||||
ai1wm_discover_plugin_basename( 'force-https-littlebizzy/force-https.php' ),
|
||||
)
|
||||
);
|
||||
|
||||
ai1wm_woocommerce_force_ssl( false );
|
||||
}
|
||||
|
||||
// Deactivate WordPress plugins
|
||||
ai1wm_deactivate_plugins(
|
||||
array(
|
||||
ai1wm_discover_plugin_basename( 'invisible-recaptcha/invisible-recaptcha.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wps-hide-login/wps-hide-login.php' ),
|
||||
ai1wm_discover_plugin_basename( 'hide-my-wp/index.php' ),
|
||||
ai1wm_discover_plugin_basename( 'hide-my-wordpress/index.php' ),
|
||||
ai1wm_discover_plugin_basename( 'mycustomwidget/my_custom_widget.php' ),
|
||||
ai1wm_discover_plugin_basename( 'lockdown-wp-admin/lockdown-wp-admin.php' ),
|
||||
ai1wm_discover_plugin_basename( 'rename-wp-login/rename-wp-login.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wp-simple-firewall/icwp-wpsf.php' ),
|
||||
ai1wm_discover_plugin_basename( 'join-my-multisite/joinmymultisite.php' ),
|
||||
ai1wm_discover_plugin_basename( 'multisite-clone-duplicator/multisite-clone-duplicator.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wordpress-mu-domain-mapping/domain_mapping.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wordpress-starter/siteground-wizard.php' ),
|
||||
ai1wm_discover_plugin_basename( 'pro-sites/pro-sites.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wpide/WPide.php' ),
|
||||
ai1wm_discover_plugin_basename( 'page-optimize/page-optimize.php' ),
|
||||
ai1wm_discover_plugin_basename( 'update-services/update-services.php' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Deactivate Swift Optimizer rules
|
||||
ai1wm_deactivate_swift_optimizer_rules(
|
||||
array(
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration/all-in-one-wp-migration.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-azure-storage-extension/all-in-one-wp-migration-azure-storage-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-b2-extension/all-in-one-wp-migration-b2-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-backup/all-in-one-wp-migration-backup.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-box-extension/all-in-one-wp-migration-box-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-digitalocean-extension/all-in-one-wp-migration-digitalocean-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-direct-extension/all-in-one-wp-migration-direct-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-dropbox-extension/all-in-one-wp-migration-dropbox-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-file-extension/all-in-one-wp-migration-file-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-ftp-extension/all-in-one-wp-migration-ftp-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-gcloud-storage-extension/all-in-one-wp-migration-gcloud-storage-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-gdrive-extension/all-in-one-wp-migration-gdrive-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-glacier-extension/all-in-one-wp-migration-glacier-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-mega-extension/all-in-one-wp-migration-mega-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-multisite-extension/all-in-one-wp-migration-multisite-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-onedrive-extension/all-in-one-wp-migration-onedrive-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-pcloud-extension/all-in-one-wp-migration-pcloud-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-pro/all-in-one-wp-migration-pro.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-s3-client-extension/all-in-one-wp-migration-s3-client-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-s3-extension/all-in-one-wp-migration-s3-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-unlimited-extension/all-in-one-wp-migration-unlimited-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-url-extension/all-in-one-wp-migration-url-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-webdav-extension/all-in-one-wp-migration-webdav-extension.php' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Deactivate Revolution Slider
|
||||
ai1wm_deactivate_revolution_slider( ai1wm_discover_plugin_basename( 'revslider/revslider.php' ) );
|
||||
|
||||
// Deactivate Jetpack modules
|
||||
ai1wm_deactivate_jetpack_modules( array( 'photon', 'sso' ) );
|
||||
|
||||
// Flush Elementor cache
|
||||
ai1wm_elementor_cache_flush();
|
||||
|
||||
// Initial DB version
|
||||
ai1wm_initial_db_version();
|
||||
|
||||
} else {
|
||||
|
||||
// Check package.json file
|
||||
if ( 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 WordPress plugins
|
||||
if ( isset( $package['Plugins'] ) && ( $plugins = $package['Plugins'] ) ) {
|
||||
ai1wm_activate_plugins( $plugins );
|
||||
}
|
||||
|
||||
// Activate WordPress template
|
||||
if ( isset( $package['Template'] ) && ( $template = $package['Template'] ) ) {
|
||||
ai1wm_activate_template( $template );
|
||||
}
|
||||
|
||||
// Activate WordPress stylesheet
|
||||
if ( isset( $package['Stylesheet'] ) && ( $stylesheet = $package['Stylesheet'] ) ) {
|
||||
ai1wm_activate_stylesheet( $stylesheet );
|
||||
}
|
||||
|
||||
// Deactivate WordPress SSL plugins
|
||||
if ( ! is_ssl() ) {
|
||||
ai1wm_deactivate_plugins(
|
||||
array(
|
||||
ai1wm_discover_plugin_basename( 'really-simple-ssl/rlrsssl-really-simple-ssl.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wordpress-https/wordpress-https.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wp-force-ssl/wp-force-ssl.php' ),
|
||||
ai1wm_discover_plugin_basename( 'force-https-littlebizzy/force-https.php' ),
|
||||
)
|
||||
);
|
||||
|
||||
ai1wm_woocommerce_force_ssl( false );
|
||||
}
|
||||
|
||||
// Deactivate WordPress plugins
|
||||
ai1wm_deactivate_plugins(
|
||||
array(
|
||||
ai1wm_discover_plugin_basename( 'invisible-recaptcha/invisible-recaptcha.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wps-hide-login/wps-hide-login.php' ),
|
||||
ai1wm_discover_plugin_basename( 'hide-my-wp/index.php' ),
|
||||
ai1wm_discover_plugin_basename( 'hide-my-wordpress/index.php' ),
|
||||
ai1wm_discover_plugin_basename( 'mycustomwidget/my_custom_widget.php' ),
|
||||
ai1wm_discover_plugin_basename( 'lockdown-wp-admin/lockdown-wp-admin.php' ),
|
||||
ai1wm_discover_plugin_basename( 'rename-wp-login/rename-wp-login.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wp-simple-firewall/icwp-wpsf.php' ),
|
||||
ai1wm_discover_plugin_basename( 'join-my-multisite/joinmymultisite.php' ),
|
||||
ai1wm_discover_plugin_basename( 'multisite-clone-duplicator/multisite-clone-duplicator.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wordpress-mu-domain-mapping/domain_mapping.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wordpress-starter/siteground-wizard.php' ),
|
||||
ai1wm_discover_plugin_basename( 'pro-sites/pro-sites.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wpide/WPide.php' ),
|
||||
ai1wm_discover_plugin_basename( 'page-optimize/page-optimize.php' ),
|
||||
ai1wm_discover_plugin_basename( 'update-services/update-services.php' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Deactivate Swift Optimizer rules
|
||||
ai1wm_deactivate_swift_optimizer_rules(
|
||||
array(
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration/all-in-one-wp-migration.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-azure-storage-extension/all-in-one-wp-migration-azure-storage-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-b2-extension/all-in-one-wp-migration-b2-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-backup/all-in-one-wp-migration-backup.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-box-extension/all-in-one-wp-migration-box-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-digitalocean-extension/all-in-one-wp-migration-digitalocean-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-direct-extension/all-in-one-wp-migration-direct-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-dropbox-extension/all-in-one-wp-migration-dropbox-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-file-extension/all-in-one-wp-migration-file-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-ftp-extension/all-in-one-wp-migration-ftp-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-gcloud-storage-extension/all-in-one-wp-migration-gcloud-storage-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-gdrive-extension/all-in-one-wp-migration-gdrive-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-glacier-extension/all-in-one-wp-migration-glacier-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-mega-extension/all-in-one-wp-migration-mega-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-multisite-extension/all-in-one-wp-migration-multisite-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-onedrive-extension/all-in-one-wp-migration-onedrive-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-pcloud-extension/all-in-one-wp-migration-pcloud-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-pro/all-in-one-wp-migration-pro.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-s3-client-extension/all-in-one-wp-migration-s3-client-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-s3-extension/all-in-one-wp-migration-s3-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-unlimited-extension/all-in-one-wp-migration-unlimited-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-url-extension/all-in-one-wp-migration-url-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-webdav-extension/all-in-one-wp-migration-webdav-extension.php' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Deactivate Revolution Slider
|
||||
ai1wm_deactivate_revolution_slider( ai1wm_discover_plugin_basename( 'revslider/revslider.php' ) );
|
||||
|
||||
// Deactivate Jetpack modules
|
||||
ai1wm_deactivate_jetpack_modules( array( 'photon', 'sso' ) );
|
||||
|
||||
// Flush Elementor cache
|
||||
ai1wm_elementor_cache_flush();
|
||||
|
||||
// Initial DB version
|
||||
ai1wm_initial_db_version();
|
||||
}
|
||||
}
|
||||
|
||||
// Check blogs.json file
|
||||
if ( 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 WordPress plugins
|
||||
if ( isset( $blog['New']['Plugins'] ) && ( $plugins = $blog['New']['Plugins'] ) ) {
|
||||
ai1wm_activate_plugins( $plugins );
|
||||
}
|
||||
|
||||
// Activate WordPress template
|
||||
if ( isset( $blog['New']['Template'] ) && ( $template = $blog['New']['Template'] ) ) {
|
||||
ai1wm_activate_template( $template );
|
||||
}
|
||||
|
||||
// Activate WordPress stylesheet
|
||||
if ( isset( $blog['New']['Stylesheet'] ) && ( $stylesheet = $blog['New']['Stylesheet'] ) ) {
|
||||
ai1wm_activate_stylesheet( $stylesheet );
|
||||
}
|
||||
|
||||
// Deactivate WordPress SSL plugins
|
||||
if ( ! is_ssl() ) {
|
||||
ai1wm_deactivate_plugins(
|
||||
array(
|
||||
ai1wm_discover_plugin_basename( 'really-simple-ssl/rlrsssl-really-simple-ssl.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wordpress-https/wordpress-https.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wp-force-ssl/wp-force-ssl.php' ),
|
||||
ai1wm_discover_plugin_basename( 'force-https-littlebizzy/force-https.php' ),
|
||||
)
|
||||
);
|
||||
|
||||
ai1wm_woocommerce_force_ssl( false );
|
||||
}
|
||||
|
||||
// Deactivate WordPress plugins
|
||||
ai1wm_deactivate_plugins(
|
||||
array(
|
||||
ai1wm_discover_plugin_basename( 'invisible-recaptcha/invisible-recaptcha.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wps-hide-login/wps-hide-login.php' ),
|
||||
ai1wm_discover_plugin_basename( 'hide-my-wp/index.php' ),
|
||||
ai1wm_discover_plugin_basename( 'hide-my-wordpress/index.php' ),
|
||||
ai1wm_discover_plugin_basename( 'mycustomwidget/my_custom_widget.php' ),
|
||||
ai1wm_discover_plugin_basename( 'lockdown-wp-admin/lockdown-wp-admin.php' ),
|
||||
ai1wm_discover_plugin_basename( 'rename-wp-login/rename-wp-login.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wp-simple-firewall/icwp-wpsf.php' ),
|
||||
ai1wm_discover_plugin_basename( 'join-my-multisite/joinmymultisite.php' ),
|
||||
ai1wm_discover_plugin_basename( 'multisite-clone-duplicator/multisite-clone-duplicator.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wordpress-mu-domain-mapping/domain_mapping.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wordpress-starter/siteground-wizard.php' ),
|
||||
ai1wm_discover_plugin_basename( 'pro-sites/pro-sites.php' ),
|
||||
ai1wm_discover_plugin_basename( 'wpide/WPide.php' ),
|
||||
ai1wm_discover_plugin_basename( 'page-optimize/page-optimize.php' ),
|
||||
ai1wm_discover_plugin_basename( 'update-services/update-services.php' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Deactivate Swift Optimizer rules
|
||||
ai1wm_deactivate_swift_optimizer_rules(
|
||||
array(
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration/all-in-one-wp-migration.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-azure-storage-extension/all-in-one-wp-migration-azure-storage-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-b2-extension/all-in-one-wp-migration-b2-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-backup/all-in-one-wp-migration-backup.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-box-extension/all-in-one-wp-migration-box-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-digitalocean-extension/all-in-one-wp-migration-digitalocean-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-direct-extension/all-in-one-wp-migration-direct-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-dropbox-extension/all-in-one-wp-migration-dropbox-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-file-extension/all-in-one-wp-migration-file-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-ftp-extension/all-in-one-wp-migration-ftp-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-gcloud-storage-extension/all-in-one-wp-migration-gcloud-storage-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-gdrive-extension/all-in-one-wp-migration-gdrive-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-glacier-extension/all-in-one-wp-migration-glacier-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-mega-extension/all-in-one-wp-migration-mega-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-multisite-extension/all-in-one-wp-migration-multisite-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-onedrive-extension/all-in-one-wp-migration-onedrive-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-pcloud-extension/all-in-one-wp-migration-pcloud-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-pro/all-in-one-wp-migration-pro.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-s3-client-extension/all-in-one-wp-migration-s3-client-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-s3-extension/all-in-one-wp-migration-s3-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-unlimited-extension/all-in-one-wp-migration-unlimited-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-url-extension/all-in-one-wp-migration-url-extension.php' ),
|
||||
ai1wm_discover_plugin_basename( 'all-in-one-wp-migration-webdav-extension/all-in-one-wp-migration-webdav-extension.php' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Deactivate Revolution Slider
|
||||
ai1wm_deactivate_revolution_slider( ai1wm_discover_plugin_basename( 'revslider/revslider.php' ) );
|
||||
|
||||
// Deactivate Jetpack modules
|
||||
ai1wm_deactivate_jetpack_modules( array( 'photon', 'sso' ) );
|
||||
|
||||
// Flush Elementor cache
|
||||
ai1wm_elementor_cache_flush();
|
||||
|
||||
// Initial DB version
|
||||
ai1wm_initial_db_version();
|
||||
}
|
||||
}
|
||||
|
||||
// Clear auth cookie (WP Cerber)
|
||||
if ( ai1wm_validate_plugin_basename( 'wp-cerber/wp-cerber.php' ) ) {
|
||||
wp_clear_auth_cookie();
|
||||
}
|
||||
|
||||
$should_reset_permalinks = false;
|
||||
|
||||
// Switch to default permalink structure
|
||||
if ( ( $should_reset_permalinks = ai1wm_should_reset_permalinks( $params ) ) ) {
|
||||
$wp_rewrite->set_permalink_structure( '' );
|
||||
}
|
||||
|
||||
// Set progress
|
||||
if ( ai1wm_validate_plugin_basename( 'fusion-builder/fusion-builder.php' ) ) {
|
||||
Ai1wm_Status::done( __( 'Your site has been imported successfully!', 'all-in-one-wp-migration' ), Ai1wm_Template::get_content( 'import/avada', array( 'should_reset_permalinks' => $should_reset_permalinks ) ) );
|
||||
} elseif ( ai1wm_validate_plugin_basename( 'oxygen/functions.php' ) ) {
|
||||
Ai1wm_Status::done( __( 'Your site has been imported successfully!', 'all-in-one-wp-migration' ), Ai1wm_Template::get_content( 'import/oxygen', array( 'should_reset_permalinks' => $should_reset_permalinks ) ) );
|
||||
} else {
|
||||
Ai1wm_Status::done( __( 'Your site has been imported successfully!', 'all-in-one-wp-migration' ), Ai1wm_Template::get_content( 'import/done', array( 'should_reset_permalinks' => $should_reset_permalinks ) ) );
|
||||
}
|
||||
|
||||
do_action( 'ai1wm_status_import_done', $params );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Attribution: This code is part of the All-in-One WP Migration plugin, developed by
|
||||
*
|
||||
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
||||
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
||||
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
||||
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
||||
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
||||
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
class Ai1wm_Import_Enumerate {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Gathering WordPress files...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Open the archive file for reading
|
||||
$archive = new Ai1wm_Extractor( ai1wm_archive_path( $params ) );
|
||||
|
||||
// Get total files count
|
||||
$params['total_files_count'] = $archive->get_total_files_count();
|
||||
|
||||
// Get total files size
|
||||
$params['total_files_size'] = $archive->get_total_files_size();
|
||||
|
||||
// Close the archive file
|
||||
$archive->close();
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'WordPress files gathered.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Attribution: This code is part of the All-in-One WP Migration plugin, developed by
|
||||
*
|
||||
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
||||
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
||||
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
||||
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
||||
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
||||
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
class Ai1wm_Import_Mu_Plugins {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Activating mu-plugins...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Set decryption password
|
||||
$decryption_password = null;
|
||||
if ( isset( $params['decryption_password'] ) ) {
|
||||
$decryption_password = $params['decryption_password'];
|
||||
}
|
||||
|
||||
// Read package.json file
|
||||
$handle = ai1wm_open( ai1wm_package_path( $params ), 'r' );
|
||||
|
||||
// Parse package.json file
|
||||
$config = ai1wm_read( $handle, filesize( ai1wm_package_path( $params ) ) );
|
||||
$config = json_decode( $config, true );
|
||||
|
||||
// Close handle
|
||||
ai1wm_close( $handle );
|
||||
|
||||
// Get compression type
|
||||
$compression_type = null;
|
||||
if ( ! empty( $config['Compression']['Enabled'] ) ) {
|
||||
$compression_type = $config['Compression']['Type'];
|
||||
}
|
||||
|
||||
// List of must-use plugins
|
||||
$exclude_files = array(
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_ENDURANCE_PAGE_CACHE_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_ENDURANCE_PHP_EDGE_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_ENDURANCE_BROWSER_CACHE_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_GD_SYSTEM_PLUGIN_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_WP_STACK_CACHE_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_WP_COMSH_LOADER_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_WP_COMSH_HELPER_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_WP_ENGINE_SYSTEM_PLUGIN_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_WPE_SIGN_ON_PLUGIN_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_WP_ENGINE_SECURITY_AUDITOR_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_WP_CERBER_SECURITY_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_SQLITE_DATABASE_INTEGRATION_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_SQLITE_DATABASE_ZERO_NAME,
|
||||
AI1WM_MUPLUGINS_NAME . DIRECTORY_SEPARATOR . AI1WM_EOS_DEACTIVATE_PLUGINS_NAME,
|
||||
);
|
||||
|
||||
// Open the archive file for reading
|
||||
$archive = new Ai1wm_Extractor( ai1wm_archive_path( $params ), $decryption_password, $compression_type );
|
||||
|
||||
// Unpack mu-plugins files
|
||||
$archive->extract_by_files_array( WP_CONTENT_DIR, array( AI1WM_MUPLUGINS_NAME ), $exclude_files );
|
||||
|
||||
// Close the archive file
|
||||
$archive->close();
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Mu-plugins activated.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Attribution: This code is part of the All-in-One WP Migration plugin, developed by
|
||||
*
|
||||
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
||||
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
||||
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
||||
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
||||
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
||||
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
class Ai1wm_Import_Options {
|
||||
|
||||
public static function execute( $params ) {
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Preparing WordPress options...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Get database client
|
||||
$db_client = Ai1wm_Database_Utility::get_client();
|
||||
|
||||
$tables = $db_client->get_tables();
|
||||
|
||||
// Get base prefix
|
||||
$base_prefix = ai1wm_table_prefix();
|
||||
|
||||
// Get mainsite prefix
|
||||
$mainsite_prefix = ai1wm_table_prefix( 'mainsite' );
|
||||
|
||||
// Check WP sitemeta table exists
|
||||
if ( in_array( "{$mainsite_prefix}sitemeta", $tables ) ) {
|
||||
|
||||
// Get fs_accounts option value (Freemius)
|
||||
$result = $db_client->query( "SELECT meta_value FROM `{$mainsite_prefix}sitemeta` WHERE meta_key = 'fs_accounts'" );
|
||||
if ( ( $row = $db_client->fetch_assoc( $result ) ) ) {
|
||||
$fs_accounts = get_option( 'fs_accounts', array() );
|
||||
$meta_value = maybe_unserialize( $row['meta_value'] );
|
||||
|
||||
// Update fs_accounts option value (Freemius)
|
||||
if ( ( $fs_accounts = array_merge( $fs_accounts, $meta_value ) ) ) {
|
||||
if ( isset( $fs_accounts['users'], $fs_accounts['sites'] ) ) {
|
||||
update_option( 'fs_accounts', $fs_accounts );
|
||||
} else {
|
||||
delete_option( 'fs_accounts' );
|
||||
delete_option( 'fs_dbg_accounts' );
|
||||
delete_option( 'fs_active_plugins' );
|
||||
delete_option( 'fs_api_cache' );
|
||||
delete_option( 'fs_dbg_api_cache' );
|
||||
delete_option( 'fs_debug_mode' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'WordPress options prepared.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Attribution: This code is part of the All-in-One WP Migration plugin, developed by
|
||||
*
|
||||
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
||||
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
||||
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
||||
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
||||
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
||||
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
class Ai1wm_Import_Permalinks {
|
||||
|
||||
public static function execute( $params ) {
|
||||
global $wp_rewrite;
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Retrieving WordPress permalinks settings...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Get using permalinks
|
||||
$params['using_permalinks'] = (int) $wp_rewrite->using_permalinks();
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'WordPress permalinks settings retrieved.', 'all-in-one-wp-migration' ) );
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Attribution: This code is part of the All-in-One WP Migration plugin, developed by
|
||||
*
|
||||
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
||||
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
||||
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
||||
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
||||
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
||||
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
class Ai1wm_Import_Upload {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Get upload tmp name
|
||||
if ( isset( $_FILES['upload_file']['tmp_name'] ) ) {
|
||||
$upload_tmp_name = $_FILES['upload_file']['tmp_name'];
|
||||
} else {
|
||||
throw new Ai1wm_Upload_Exception(
|
||||
wp_kses(
|
||||
__(
|
||||
'The uploaded file is missing a temporary path. The process cannot continue.
|
||||
<a href="https://help.servmask.com/knowledgebase/upload-file-error/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
),
|
||||
400
|
||||
);
|
||||
}
|
||||
|
||||
// Get upload error
|
||||
if ( isset( $_FILES['upload_file']['error'] ) ) {
|
||||
$upload_error = $_FILES['upload_file']['error'];
|
||||
} else {
|
||||
throw new Ai1wm_Upload_Exception(
|
||||
wp_kses(
|
||||
__(
|
||||
'The uploaded file is missing an error code. The process cannot continue.
|
||||
<a href="https://help.servmask.com/knowledgebase/upload-file-error/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
),
|
||||
400
|
||||
);
|
||||
}
|
||||
|
||||
// Verify file extension
|
||||
if ( ! ai1wm_is_filename_supported( ai1wm_archive_path( $params ) ) ) {
|
||||
throw new Ai1wm_Upload_Exception(
|
||||
wp_kses(
|
||||
__(
|
||||
'Invalid file type. Please ensure your file is a <strong>.wpress</strong> backup created with All-in-One WP Migration.
|
||||
<a href="https://help.servmask.com/knowledgebase/invalid-backup-file/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
),
|
||||
415
|
||||
);
|
||||
}
|
||||
|
||||
// Verify file data
|
||||
if ( ! ai1wm_is_filedata_supported( $upload_tmp_name ) ) {
|
||||
throw new Ai1wm_Upload_Exception(
|
||||
wp_kses(
|
||||
__(
|
||||
'Invalid file data. Please ensure your file is a <strong>.wpress</strong> backup created with All-in-One WP Migration.
|
||||
<a href="https://help.servmask.com/knowledgebase/invalid-backup-file/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
),
|
||||
415
|
||||
);
|
||||
}
|
||||
|
||||
// Upload file data
|
||||
switch ( $upload_error ) {
|
||||
case UPLOAD_ERR_OK:
|
||||
try {
|
||||
ai1wm_copy( $upload_tmp_name, ai1wm_archive_path( $params ) );
|
||||
ai1wm_unlink( $upload_tmp_name );
|
||||
} catch ( Exception $e ) {
|
||||
/* translators: Error message. */
|
||||
throw new Ai1wm_Upload_Exception(
|
||||
wp_kses(
|
||||
sprintf(
|
||||
__(
|
||||
'Could not upload the file because %s. The process cannot continue.
|
||||
<a href="https://help.servmask.com/knowledgebase/upload-file-error/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
$e->getMessage()
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
),
|
||||
400
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case UPLOAD_ERR_INI_SIZE:
|
||||
case UPLOAD_ERR_FORM_SIZE:
|
||||
case UPLOAD_ERR_PARTIAL:
|
||||
case UPLOAD_ERR_NO_FILE:
|
||||
throw new Ai1wm_Upload_Exception(
|
||||
wp_kses(
|
||||
__(
|
||||
'The uploaded file is too large for this server. The process cannot continue.
|
||||
<a href="https://help.servmask.com/knowledgebase/upload-file-error/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
),
|
||||
413
|
||||
);
|
||||
|
||||
case UPLOAD_ERR_NO_TMP_DIR:
|
||||
throw new Ai1wm_Upload_Exception(
|
||||
wp_kses(
|
||||
__(
|
||||
'No temporary folder is available on the server. The process cannot continue.
|
||||
<a href="https://help.servmask.com/knowledgebase/upload-file-error/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
),
|
||||
400
|
||||
);
|
||||
|
||||
case UPLOAD_ERR_CANT_WRITE:
|
||||
throw new Ai1wm_Upload_Exception(
|
||||
wp_kses(
|
||||
__(
|
||||
'Could not save the uploaded file. Please check file permissions and try again.
|
||||
<a href="https://help.servmask.com/knowledgebase/upload-file-error/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
),
|
||||
400
|
||||
);
|
||||
|
||||
case UPLOAD_ERR_EXTENSION:
|
||||
throw new Ai1wm_Upload_Exception(
|
||||
wp_kses(
|
||||
__(
|
||||
'A PHP extension blocked this file upload. The process cannot continue.
|
||||
<a href="https://help.servmask.com/knowledgebase/upload-file-error/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
),
|
||||
400
|
||||
);
|
||||
|
||||
default:
|
||||
/* translators: Error code. */
|
||||
throw new Ai1wm_Upload_Exception(
|
||||
wp_kses(
|
||||
sprintf(
|
||||
__(
|
||||
'An unknown error (code: %s) occurred during the file upload. The process cannot continue.
|
||||
<a href="https://help.servmask.com/knowledgebase/upload-file-error/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
$upload_error
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
),
|
||||
400
|
||||
);
|
||||
}
|
||||
|
||||
ai1wm_json_response( array( 'errors' => array() ) );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Attribution: This code is part of the All-in-One WP Migration plugin, developed by
|
||||
*
|
||||
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
||||
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
||||
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
||||
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
||||
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
||||
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
class Ai1wm_Import_Users {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Check multisite.json file
|
||||
if ( is_file( ai1wm_multisite_path( $params ) ) ) {
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Preparing WordPress users...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// 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 );
|
||||
|
||||
ai1wm_populate_roles();
|
||||
|
||||
// Set WordPress super admins
|
||||
if ( isset( $multisite['Admins'] ) && ( $admins = $multisite['Admins'] ) ) {
|
||||
foreach ( $admins as $username ) {
|
||||
if ( ( $user = get_user_by( 'login', $username ) ) ) {
|
||||
if ( $user->exists() ) {
|
||||
$user->set_role( 'administrator' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'WordPress users prepared.', 'all-in-one-wp-migration' ) );
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Attribution: This code is part of the All-in-One WP Migration plugin, developed by
|
||||
*
|
||||
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
||||
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
||||
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
||||
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
||||
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
||||
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
class Ai1wm_Import_Validate_Crc {
|
||||
|
||||
public static function execute( $params ) {
|
||||
$archive_bytes_read = 0;
|
||||
|
||||
// Skip validation for v1 archives (no CRC available)
|
||||
if ( empty( $params['archive_crc_value'] ) ) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Validating archive checksum...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// Set archive bytes remaining
|
||||
if ( isset( $params['archive_bytes_remaining'] ) ) {
|
||||
$archive_bytes_remaining = (int) $params['archive_bytes_remaining'];
|
||||
} elseif ( isset( $params['archive_crc_size'] ) ) {
|
||||
$archive_bytes_remaining = (int) $params['archive_crc_size'];
|
||||
} else {
|
||||
$archive_bytes_remaining = 0;
|
||||
}
|
||||
|
||||
// Set archive bytes offset
|
||||
if ( isset( $params['archive_bytes_offset'] ) ) {
|
||||
$archive_bytes_offset = (int) $params['archive_bytes_offset'];
|
||||
} else {
|
||||
$archive_bytes_offset = 0;
|
||||
}
|
||||
|
||||
// Set file CRC
|
||||
$file_crc = null;
|
||||
if ( isset( $params['file_crc'] ) ) {
|
||||
$file_crc = $params['file_crc'];
|
||||
}
|
||||
|
||||
// Flag to hold if file data has been processed
|
||||
$completed = true;
|
||||
|
||||
// Start time
|
||||
$start = microtime( true );
|
||||
|
||||
// Initialize CRC context
|
||||
$hash_ctx = Ai1wm_Crc::init_crc32();
|
||||
|
||||
// Open archive for reading
|
||||
if ( ( $file_handle = ai1wm_open( ai1wm_archive_path( $params ), 'rb' ) ) ) {
|
||||
if ( fseek( $file_handle, $archive_bytes_offset, SEEK_SET ) !== -1 ) {
|
||||
|
||||
// Process file in chunks
|
||||
while ( $archive_bytes_remaining > 0 ) {
|
||||
if ( ( $file_content = ai1wm_read( $file_handle, min( Ai1wm_Archiver::READ_CHUNK_SIZE, $archive_bytes_remaining ) ) ) !== false ) {
|
||||
|
||||
// Empty read indicates EOF
|
||||
if ( strlen( $file_content ) === 0 ) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Add the amount of bytes we read
|
||||
$archive_bytes_read += strlen( $file_content );
|
||||
|
||||
// Subtract the amount of bytes we read
|
||||
$archive_bytes_remaining -= strlen( $file_content );
|
||||
|
||||
// Update CRC with original content
|
||||
Ai1wm_Crc::update_crc32( $hash_ctx, $file_content );
|
||||
}
|
||||
|
||||
// Time elapsed
|
||||
if ( ( $timeout = apply_filters( 'ai1wm_completed_timeout', 10 ) ) ) {
|
||||
if ( ( microtime( true ) - $start ) > $timeout ) {
|
||||
$completed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get archive bytes offset
|
||||
$archive_bytes_offset += $archive_bytes_read;
|
||||
}
|
||||
|
||||
ai1wm_close( $file_handle );
|
||||
}
|
||||
|
||||
// Combine and finalize CRC
|
||||
if ( empty( $file_crc ) ) {
|
||||
$params['file_crc'] = Ai1wm_Crc::finalize_crc32( $hash_ctx );
|
||||
} else {
|
||||
$params['file_crc'] = Ai1wm_Crc::combine_crc32( $file_crc, Ai1wm_Crc::finalize_crc32( $hash_ctx ), $archive_bytes_read );
|
||||
}
|
||||
|
||||
// End of the archive file?
|
||||
if ( $completed ) {
|
||||
|
||||
// Validate CRC value
|
||||
if ( $params['archive_crc_value'] !== $params['file_crc'] ) {
|
||||
throw new Ai1wm_CRC_Exception(
|
||||
wp_kses(
|
||||
__(
|
||||
'This backup file is damaged and can\'t be imported.<br />' .
|
||||
'Try downloading or transferring the file again.<br /><br />' .
|
||||
'<strong>Reason:</strong> File integrity check failed (CRC mismatch). <a href="https://help.servmask.com/knowledgebase/import-failed-crc-mismatch/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Unset file CRC
|
||||
unset( $params['file_crc'] );
|
||||
|
||||
// Unset archive bytes remaining
|
||||
unset( $params['archive_bytes_remaining'] );
|
||||
|
||||
// Unset archive bytes offset
|
||||
unset( $params['archive_bytes_offset'] );
|
||||
|
||||
// Unset completed flag
|
||||
unset( $params['completed'] );
|
||||
|
||||
} else {
|
||||
|
||||
// St archive bytes remaining
|
||||
$params['archive_bytes_remaining'] = $archive_bytes_remaining;
|
||||
|
||||
// Set archive bytes offset
|
||||
$params['archive_bytes_offset'] = $archive_bytes_offset;
|
||||
|
||||
// Set completed flag
|
||||
$params['completed'] = $completed;
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2025 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Attribution: This code is part of the All-in-One WP Migration plugin, developed by
|
||||
*
|
||||
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
||||
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
||||
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
||||
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
||||
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
||||
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
class Ai1wm_Import_Validate {
|
||||
|
||||
public static function execute( $params ) {
|
||||
|
||||
// Verify file if size > 2GB and PHP = 32-bit
|
||||
if ( ! ai1wm_is_filesize_supported( ai1wm_archive_path( $params ) ) ) {
|
||||
throw new Ai1wm_Import_Exception(
|
||||
wp_kses(
|
||||
__(
|
||||
'Your server uses 32-bit PHP and cannot process files larger than 2GB. Please switch to 64-bit PHP and try again.
|
||||
<a href="https://help.servmask.com/knowledgebase/php-32bit/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Verify file name extension
|
||||
if ( ! ai1wm_is_filename_supported( ai1wm_archive_path( $params ) ) ) {
|
||||
throw new Ai1wm_Import_Exception(
|
||||
wp_kses(
|
||||
__(
|
||||
'Invalid file type. Please ensure your file is a <strong>.wpress</strong> backup created with All-in-One WP Migration.
|
||||
<a href="https://help.servmask.com/knowledgebase/invalid-backup-file/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Set progress
|
||||
Ai1wm_Status::info( __( 'Unpacking configuration...', 'all-in-one-wp-migration' ) );
|
||||
|
||||
// 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(
|
||||
wp_kses(
|
||||
__( 'The archive file appears to be corrupted. Follow <a href="https://help.servmask.com/knowledgebase/corrupted-archive/" target="_blank">this article</a> for possible fixes.', 'all-in-one-wp-migration' ),
|
||||
ai1wm_allowed_html_tags()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Unpack package.json and multisite.json files
|
||||
$archive->extract_by_files_array( ai1wm_storage_path( $params ), array( AI1WM_PACKAGE_NAME, AI1WM_MULTISITE_NAME ) );
|
||||
|
||||
// Check package.json file
|
||||
if ( false === is_file( ai1wm_package_path( $params ) ) ) {
|
||||
throw new Ai1wm_Import_Exception(
|
||||
wp_kses(
|
||||
__(
|
||||
'Please ensure your file was created with the All-in-One WP Migration plugin.
|
||||
<a href="https://help.servmask.com/knowledgebase/invalid-backup-file/" target="_blank">Technical details</a>',
|
||||
'all-in-one-wp-migration'
|
||||
),
|
||||
ai1wm_allowed_html_tags()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Set archive CRC value
|
||||
$params['archive_crc_value'] = $archive->get_archive_crc_value();
|
||||
|
||||
// Set archive CRC size
|
||||
$params['archive_crc_size'] = $archive->get_archive_crc_size();
|
||||
|
||||
// Close the archive file
|
||||
$archive->close();
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user