Edit File by line
/home/barbar84/www/wp-conte.../plugins/updraftp.../includes/updraftc...
File: temporary-clone-restore.php
<?php
[0] Fix | Delete
[1] Fix | Delete
if (!defined('ABSPATH')) die('No direct access allowed');
[2] Fix | Delete
[3] Fix | Delete
class UpdraftPlus_Temporary_Clone_Restore {
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* Constructor for the class.
[7] Fix | Delete
*/
[8] Fix | Delete
public function __construct() {
[9] Fix | Delete
add_action('updraftplus_temporary_clone_ready_for_restore', array($this, 'clone_ready_for_restore'));
[10] Fix | Delete
add_action('updraftplus_restored_db', array($this, 'remove_maintenance_file'));
[11] Fix | Delete
}
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* This function will add a ready_for_restore file in the updraft backup directory to indicate that we are ready to restore the received backup set
[15] Fix | Delete
*
[16] Fix | Delete
* @param String|Null $job_id - the job that is ready to restore, if known.
[17] Fix | Delete
*
[18] Fix | Delete
* @return void
[19] Fix | Delete
*/
[20] Fix | Delete
public function clone_ready_for_restore($job_id = null) {
[21] Fix | Delete
global $updraftplus, $wp_filesystem;
[22] Fix | Delete
[23] Fix | Delete
$state_file = trailingslashit($updraftplus->backups_dir_location()). 'ready_for_restore';
[24] Fix | Delete
[25] Fix | Delete
error_log("UpdraftPlus_Temporary_Clone_Restore::clone_ready_for_restore($job_id): touching flag file");
[26] Fix | Delete
[27] Fix | Delete
if ($job_id) {
[28] Fix | Delete
file_put_contents($state_file, $job_id);
[29] Fix | Delete
} else {
[30] Fix | Delete
touch($state_file);
[31] Fix | Delete
}
[32] Fix | Delete
[33] Fix | Delete
if (!function_exists('WP_Filesystem')) require_once ABSPATH.'wp-admin/includes/file.php';
[34] Fix | Delete
WP_Filesystem();
[35] Fix | Delete
[36] Fix | Delete
// Create maintenance file with current clone status contents
[37] Fix | Delete
if (!$wp_filesystem->exists(trailingslashit(WP_CONTENT_DIR).'maintenance.php')) {
[38] Fix | Delete
ob_start();
[39] Fix | Delete
if (!class_exists('UpdraftPlus_Temporary_Clone_Status')) {
[40] Fix | Delete
include_once trailingslashit(plugin_dir_path(__FILE__)).'temporary-clone-status.php';
[41] Fix | Delete
}
[42] Fix | Delete
$updraftplus_temporary_clone_status = new UpdraftPlus_Temporary_Clone_Status();
[43] Fix | Delete
$updraftplus_temporary_clone_status->output_status_page(false);
[44] Fix | Delete
$contents = ob_get_clean();
[45] Fix | Delete
$wp_filesystem->put_contents(
[46] Fix | Delete
trailingslashit(WP_CONTENT_DIR).'maintenance.php',
[47] Fix | Delete
$contents,
[48] Fix | Delete
FS_CHMOD_FILE
[49] Fix | Delete
);
[50] Fix | Delete
}
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
/**
[54] Fix | Delete
* Remove maintenance file created before the DB restoration.
[55] Fix | Delete
*/
[56] Fix | Delete
public function remove_maintenance_file() {
[57] Fix | Delete
global $updraftplus, $wp_filesystem;
[58] Fix | Delete
[59] Fix | Delete
$updraft_dir = trailingslashit($updraftplus->backups_dir_location());
[60] Fix | Delete
[61] Fix | Delete
if (!file_exists($updraft_dir . 'ready_for_restore')) return;
[62] Fix | Delete
[63] Fix | Delete
if (!function_exists('WP_Filesystem')) require_once ABSPATH.'wp-admin/includes/file.php';
[64] Fix | Delete
WP_Filesystem();
[65] Fix | Delete
[66] Fix | Delete
$wp_filesystem->delete(trailingslashit(WP_CONTENT_DIR).'maintenance.php');
[67] Fix | Delete
}
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
if (defined('UPDRAFTPLUS_THIS_IS_CLONE') && UPDRAFTPLUS_THIS_IS_CLONE) {
[71] Fix | Delete
new UpdraftPlus_Temporary_Clone_Restore();
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function