mirror of
https://github.com/mainwp/mainwp-child.git
synced 2025-09-07 11:16:40 +08:00
Fixed: CodeFactor issues
This commit is contained in:
parent
3ce0b519f2
commit
1df25aa2cd
1 changed files with 131 additions and 319 deletions
|
@ -1,8 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Credits
|
* Credits
|
||||||
*
|
*
|
||||||
* Plugin-Name: BackUpWordPress
|
* Plugin-Name: BackUpWordPress
|
||||||
|
@ -14,7 +11,6 @@
|
||||||
*
|
*
|
||||||
* The code is used for the MainWP BackUpWordPress Extension
|
* The code is used for the MainWP BackUpWordPress Extension
|
||||||
* Extension URL: https://mainwp.com/extension/backupwordpress/
|
* Extension URL: https://mainwp.com/extension/backupwordpress/
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class MainWP_Child_Back_Up_Wordpress {
|
class MainWP_Child_Back_Up_Wordpress {
|
||||||
|
@ -49,7 +45,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
|
|
||||||
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
|
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
|
||||||
|
|
||||||
if ( get_option( 'mainwp_backupwordpress_hide_plugin' ) === 'hide' ) {
|
if ( 'hide' === get_option( 'mainwp_backupwordpress_hide_plugin' ) ) {
|
||||||
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
|
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
|
||||||
add_action( 'admin_menu', array( $this, 'remove_menu' ) );
|
add_action( 'admin_menu', array( $this, 'remove_menu' ) );
|
||||||
add_filter( 'site_transient_update_plugins', array( &$this, 'remove_update_nag' ) );
|
add_filter( 'site_transient_update_plugins', array( &$this, 'remove_update_nag' ) );
|
||||||
|
@ -140,7 +136,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
$information = array( 'error' => 'Empty schedule id' );
|
$information = array( 'error' => 'Empty schedule id' );
|
||||||
MainWP_Helper::write( $information );
|
MainWP_Helper::write( $information );
|
||||||
} else {
|
} else {
|
||||||
$schedule_id = sanitize_text_field( urldecode( $schedule_id ) );
|
$schedule_id = sanitize_text_field( rawurldecode( $schedule_id ) );
|
||||||
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
|
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
|
||||||
if ( ! HM\BackUpWordPress\Schedules::get_instance()->get_schedule( $schedule_id ) ) {
|
if ( ! HM\BackUpWordPress\Schedules::get_instance()->get_schedule( $schedule_id ) ) {
|
||||||
$information = array( 'result' => 'NOTFOUND' );
|
$information = array( 'result' => 'NOTFOUND' );
|
||||||
|
@ -164,16 +160,16 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
|
|
||||||
// ok
|
// ok
|
||||||
private function get_sync_data() {
|
private function get_sync_data() {
|
||||||
MainWP_Helper::check_classes_exists('HM\BackUpWordPress\Schedules');
|
MainWP_Helper::check_classes_exists( 'HM\BackUpWordPress\Schedules' );
|
||||||
MainWP_Helper::check_methods('HM\BackUpWordPress\Schedules', array( 'get_instance', 'refresh_schedules', 'get_schedules' ) );
|
MainWP_Helper::check_methods( 'HM\BackUpWordPress\Schedules', array( 'get_instance', 'refresh_schedules', 'get_schedules' ) );
|
||||||
|
|
||||||
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
|
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
|
||||||
$schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
|
$schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
|
||||||
$backups_time = array();
|
$backups_time = array();
|
||||||
|
|
||||||
if ( is_array($schedules) && count($schedules) ) {
|
if ( is_array( $schedules ) && count( $schedules ) ) {
|
||||||
$check = current($schedules);
|
$check = current( $schedules );
|
||||||
MainWP_Helper::check_methods($check, array( 'get_backups' ) );
|
MainWP_Helper::check_methods( $check, array( 'get_backups' ) );
|
||||||
|
|
||||||
foreach ( $schedules as $sche ) {
|
foreach ( $schedules as $sche ) {
|
||||||
$existing_backup = $sche->get_backups();
|
$existing_backup = $sche->get_backups();
|
||||||
|
@ -194,16 +190,15 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
}
|
}
|
||||||
|
|
||||||
function do_site_stats() {
|
function do_site_stats() {
|
||||||
if ( has_action('mainwp_child_reports_log') ) {
|
if ( has_action( 'mainwp_child_reports_log' ) ) {
|
||||||
do_action( 'mainwp_child_reports_log', 'backupwordpress');
|
do_action( 'mainwp_child_reports_log', 'backupwordpress' );
|
||||||
} else {
|
} else {
|
||||||
$this->do_reports_log('backupwordpress');
|
$this->do_reports_log( 'backupwordpress' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ok
|
|
||||||
public function do_reports_log( $ext = '' ) {
|
public function do_reports_log( $ext = '' ) {
|
||||||
if ( $ext !== 'backupwordpress' ) {
|
if ( 'backupwordpress' !== $ext ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( ! $this->is_plugin_installed ) {
|
if ( ! $this->is_plugin_installed ) {
|
||||||
|
@ -211,15 +206,15 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MainWP_Helper::check_classes_exists('HM\BackUpWordPress\Schedules');
|
MainWP_Helper::check_classes_exists( 'HM\BackUpWordPress\Schedules' );
|
||||||
MainWP_Helper::check_methods('HM\BackUpWordPress\Schedules', array( 'get_instance', 'refresh_schedules', 'get_schedules' ));
|
MainWP_Helper::check_methods( 'HM\BackUpWordPress\Schedules', array( 'get_instance', 'refresh_schedules', 'get_schedules' ) );
|
||||||
|
|
||||||
// Refresh the schedules from the database to make sure we have the latest changes
|
// Refresh the schedules from the database to make sure we have the latest changes.
|
||||||
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
|
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
|
||||||
$schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
|
$schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
|
||||||
if ( is_array($schedules) && count($schedules) > 0 ) {
|
if ( is_array( $schedules ) && count( $schedules ) > 0 ) {
|
||||||
$check = current($schedules);
|
$check = current( $schedules );
|
||||||
MainWP_Helper::check_methods($check, array( 'get_backups', 'get_type' ));
|
MainWP_Helper::check_methods( $check, array( 'get_backups', 'get_type' ) );
|
||||||
|
|
||||||
foreach ( $schedules as $schedule ) {
|
foreach ( $schedules as $schedule ) {
|
||||||
foreach ( $schedule->get_backups() as $file ) {
|
foreach ( $schedule->get_backups() as $file ) {
|
||||||
|
@ -230,7 +225,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
$date = @filemtime( $file );
|
$date = @filemtime( $file );
|
||||||
if ( ! empty( $date ) ) {
|
if ( ! empty( $date ) ) {
|
||||||
do_action( 'mainwp_reports_backupwordpress_backup', $destination, $message, 'finished', $backup_type, $date );
|
do_action( 'mainwp_reports_backupwordpress_backup', $destination, $message, 'finished', $backup_type, $date );
|
||||||
MainWP_Helper::update_lasttime_backup('backupwordpress', $date); // to support backup before update feature
|
MainWP_Helper::update_lasttime_backup( 'backupwordpress', $date ); // to support backup before update feature.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -251,7 +246,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
|
|
||||||
function delete_schedule() {
|
function delete_schedule() {
|
||||||
$schedule_id = $this->check_schedule();
|
$schedule_id = $this->check_schedule();
|
||||||
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( urldecode( $schedule_id ) ) );
|
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( rawurldecode( $schedule_id ) ) );
|
||||||
|
|
||||||
if ( $schedule ) {
|
if ( $schedule ) {
|
||||||
$schedule->cancel( true );
|
$schedule->cancel( true );
|
||||||
|
@ -265,10 +260,10 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
|
|
||||||
function hmbkp_request_cancel_backup() {
|
function hmbkp_request_cancel_backup() {
|
||||||
$schedule_id = $this->check_schedule();
|
$schedule_id = $this->check_schedule();
|
||||||
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( urldecode( $schedule_id ) ) );
|
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( rawurldecode( $schedule_id ) ) );
|
||||||
|
|
||||||
// Delete the running backup
|
// Delete the running backup.
|
||||||
if ( method_exists($schedule, 'get_running_backup_filename' ) ) {
|
if ( method_exists( $schedule, 'get_running_backup_filename' ) ) {
|
||||||
if ( $schedule->get_running_backup_filename() && file_exists( trailingslashit( hmbkp_path() ) . $schedule->get_running_backup_filename() ) ) {
|
if ( $schedule->get_running_backup_filename() && file_exists( trailingslashit( hmbkp_path() ) . $schedule->get_running_backup_filename() ) ) {
|
||||||
unlink( trailingslashit( hmbkp_path() ) . $schedule->get_running_backup_filename() );
|
unlink( trailingslashit( hmbkp_path() ) . $schedule->get_running_backup_filename() );
|
||||||
}
|
}
|
||||||
|
@ -277,7 +272,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$status = $schedule->get_status();
|
$status = $schedule->get_status();
|
||||||
// Delete the running backup
|
// Delete the running backup.
|
||||||
if ( $status->get_backup_filename() && file_exists( trailingslashit( HM\BackUpWordPress\Path::get_path() ) . $status->get_backup_filename() ) ) {
|
if ( $status->get_backup_filename() && file_exists( trailingslashit( HM\BackUpWordPress\Path::get_path() ) . $status->get_backup_filename() ) ) {
|
||||||
unlink( trailingslashit( HM\BackUpWordPress\Path::get_path() ) . $status->get_backup_filename() );
|
unlink( trailingslashit( HM\BackUpWordPress\Path::get_path() ) . $status->get_backup_filename() );
|
||||||
}
|
}
|
||||||
|
@ -301,9 +296,9 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
|
|
||||||
function get_backup_status() {
|
function get_backup_status() {
|
||||||
$schedule_id = $this->check_schedule();
|
$schedule_id = $this->check_schedule();
|
||||||
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( urldecode( $schedule_id ) ) );
|
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( rawurldecode( $schedule_id ) ) );
|
||||||
|
|
||||||
if ( method_exists($schedule, 'get_running_backup_filename' ) ) {
|
if ( method_exists( $schedule, 'get_running_backup_filename' ) ) {
|
||||||
$information['scheduleStatus'] = $schedule->get_status();
|
$information['scheduleStatus'] = $schedule->get_status();
|
||||||
} else {
|
} else {
|
||||||
$status = $schedule->get_status();
|
$status = $schedule->get_status();
|
||||||
|
@ -317,16 +312,16 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
|
|
||||||
function run_schedule() {
|
function run_schedule() {
|
||||||
$schedule_id = $this->check_schedule();
|
$schedule_id = $this->check_schedule();
|
||||||
if ( function_exists('hmbkp_run_schedule_async') ) {
|
if ( function_exists( 'hmbkp_run_schedule_async' ) ) {
|
||||||
hmbkp_run_schedule_async($schedule_id);
|
hmbkp_run_schedule_async( $schedule_id );
|
||||||
} elseif ( function_exists('\HM\BackUpWordPress\run_schedule_async') ) {
|
} elseif ( function_exists( '\HM\BackUpWordPress\run_schedule_async' ) ) {
|
||||||
HM\BackUpWordPress\Path::get_instance()->cleanup();
|
HM\BackUpWordPress\Path::get_instance()->cleanup();
|
||||||
// Fixes an issue on servers which only allow a single session per client
|
// Fixes an issue on servers which only allow a single session per client.
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$task = new \HM\Backdrop\Task( '\HM\BackUpWordPress\run_schedule_async', $schedule_id );
|
$task = new \HM\Backdrop\Task( '\HM\BackUpWordPress\run_schedule_async', $schedule_id );
|
||||||
$task->schedule();
|
$task->schedule();
|
||||||
} else {
|
} else {
|
||||||
return array( 'error' => __('Error while trying to trigger the schedule', 'mainwp-child') );
|
return array( 'error' => __( 'Error while trying to trigger the schedule', 'mainwp-child' ) );
|
||||||
}
|
}
|
||||||
return array( 'result' => 'SUCCESS' );
|
return array( 'result' => 'SUCCESS' );
|
||||||
}
|
}
|
||||||
|
@ -351,8 +346,8 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( urldecode( $schedule_id ) ) );
|
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( rawurldecode( $schedule_id ) ) );
|
||||||
$started_ago = method_exists($schedule, 'get_schedule_running_start_time') ? $schedule->get_schedule_running_start_time() : $schedule->get_schedule_start_time();
|
$started_ago = method_exists( $schedule, 'get_schedule_running_start_time' ) ? $schedule->get_schedule_running_start_time() : $schedule->get_schedule_start_time();
|
||||||
$out = array(
|
$out = array(
|
||||||
'b' => $this->get_backupslist_html( $schedule ),
|
'b' => $this->get_backupslist_html( $schedule ),
|
||||||
'count' => count( $schedule->get_backups() ),
|
'count' => count( $schedule->get_backups() ),
|
||||||
|
@ -360,7 +355,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
'started_ago' => human_time_diff( $started_ago ),
|
'started_ago' => human_time_diff( $started_ago ),
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( method_exists($schedule, 'get_running_backup_filename' ) ) {
|
if ( method_exists( $schedule, 'get_running_backup_filename' ) ) {
|
||||||
$out['scheduleStatus'] = $schedule->get_status();
|
$out['scheduleStatus'] = $schedule->get_status();
|
||||||
} else {
|
} else {
|
||||||
$status = $schedule->get_status();
|
$status = $schedule->get_status();
|
||||||
|
@ -378,8 +373,8 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
if ( ! in_array( $sch_id, $scheduleIds ) ) {
|
if ( ! in_array( $sch_id, $scheduleIds ) ) {
|
||||||
$current_option = get_option( 'hmbkp_schedule_' . $sch_id );
|
$current_option = get_option( 'hmbkp_schedule_' . $sch_id );
|
||||||
if ( is_array( $current_option ) ) {
|
if ( is_array( $current_option ) ) {
|
||||||
unset( $current_option['excludes'] ); // not send this value
|
unset( $current_option['excludes'] );
|
||||||
$started_ago = method_exists($schedule, 'get_schedule_running_start_time') ? $schedule->get_schedule_running_start_time() : $schedule->get_schedule_start_time();
|
$started_ago = method_exists( $schedule, 'get_schedule_running_start_time' ) ? $schedule->get_schedule_running_start_time() : $schedule->get_schedule_start_time();
|
||||||
$send_back_schedules[ $sch_id ] = array(
|
$send_back_schedules[ $sch_id ] = array(
|
||||||
'options' => $current_option,
|
'options' => $current_option,
|
||||||
'b' => $this->get_backupslist_html( $schedule ),
|
'b' => $this->get_backupslist_html( $schedule ),
|
||||||
|
@ -388,7 +383,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
'scheduleStatus' => $schedule->get_status(),
|
'scheduleStatus' => $schedule->get_status(),
|
||||||
'started_ago' => human_time_diff( $started_ago ),
|
'started_ago' => human_time_diff( $started_ago ),
|
||||||
);
|
);
|
||||||
if ( method_exists($schedule, 'get_running_backup_filename' ) ) {
|
if ( method_exists( $schedule, 'get_running_backup_filename' ) ) {
|
||||||
$send_back_schedules['scheduleStatus'] = $schedule->get_status();
|
$send_back_schedules['scheduleStatus'] = $schedule->get_status();
|
||||||
} else {
|
} else {
|
||||||
$status = $schedule->get_status();
|
$status = $schedule->get_status();
|
||||||
|
@ -398,7 +393,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( function_exists('HM\BackUpWordPress\Backup::get_home_path') ) {
|
if ( function_exists( 'HM\BackUpWordPress\Backup::get_home_path' ) ) {
|
||||||
$backups_path = str_replace( HM\BackUpWordPress\Backup::get_home_path(), '', hmbkp_path() );
|
$backups_path = str_replace( HM\BackUpWordPress\Backup::get_home_path(), '', hmbkp_path() );
|
||||||
} else {
|
} else {
|
||||||
$backups_path = str_replace( HM\BackUpWordPress\Path::get_home_path(), '', HM\BackUpWordPress\Path::get_path() );
|
$backups_path = str_replace( HM\BackUpWordPress\Path::get_home_path(), '', HM\BackUpWordPress\Path::get_path() );
|
||||||
|
@ -418,9 +413,9 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
|
|
||||||
$schedule_id = $this->check_schedule();
|
$schedule_id = $this->check_schedule();
|
||||||
|
|
||||||
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( urldecode( $schedule_id ) ) );
|
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( rawurldecode( $schedule_id ) ) );
|
||||||
|
|
||||||
$deleted = $schedule->delete_backup(base64_decode( urldecode($_POST['hmbkp_backuparchive'] )));
|
$deleted = $schedule->delete_backup( base64_decode( rawurldecode( $_POST['hmbkp_backuparchive'] ) ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons.
|
||||||
|
|
||||||
if ( is_wp_error( $deleted ) ) {
|
if ( is_wp_error( $deleted ) ) {
|
||||||
return array( 'error' => $deleted->get_error_message() );
|
return array( 'error' => $deleted->get_error_message() );
|
||||||
|
@ -432,7 +427,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
'count' => count( $schedule->get_backups() ),
|
'count' => count( $schedule->get_backups() ),
|
||||||
'file_size_text' => $this->hmbkp_get_site_size_text( $schedule ),
|
'file_size_text' => $this->hmbkp_get_site_size_text( $schedule ),
|
||||||
);
|
);
|
||||||
if ( method_exists($schedule, 'get_running_backup_filename' ) ) {
|
if ( method_exists( $schedule, 'get_running_backup_filename' ) ) {
|
||||||
$ret['scheduleStatus'] = $schedule->get_status();
|
$ret['scheduleStatus'] = $schedule->get_status();
|
||||||
} else {
|
} else {
|
||||||
$status = $schedule->get_status();
|
$status = $schedule->get_status();
|
||||||
|
@ -450,10 +445,10 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<th scope="col"><?php function_exists('hmbkp_backups_number') ? hmbkp_backups_number( $schedule ) : ( function_exists('backups_number') ? backups_number( $schedule ) : '' ); ?></th>
|
<th scope="col"><?php function_exists( 'hmbkp_backups_number' ) ? hmbkp_backups_number( $schedule ) : ( function_exists( 'backups_number' ) ? backups_number( $schedule ) : '' ); ?></th>
|
||||||
<th scope="col"><?php esc_html_e( 'Size', 'mainwp-backupwordpress-extension' ); ?></th>
|
<th scope="col"><?php esc_html_e( 'Size', 'mainwp-child' ); ?></th>
|
||||||
<th scope="col"><?php esc_html_e( 'Type', 'mainwp-backupwordpress-extension' ); ?></th>
|
<th scope="col"><?php esc_html_e( 'Type', 'mainwp-child' ); ?></th>
|
||||||
<th scope="col"><?php esc_html_e( 'Actions', 'mainwp-backupwordpress-extension' ); ?></th>
|
<th scope="col"><?php esc_html_e( 'Actions', 'mainwp-child' ); ?></th>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
@ -480,7 +475,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="hmbkp-no-backups"
|
<td class="hmbkp-no-backups"
|
||||||
colspan="4"><?php esc_html_e( 'This is where your backups will appear once you have some.', 'mainwp-backupwordpress-extension' ); ?></td>
|
colspan="4"><?php esc_html_e( 'This is where your backups will appear once you have some.', 'mainwp-child' ); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
@ -496,23 +491,23 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
|
|
||||||
|
|
||||||
function hmbkp_get_site_size_text( HM\BackUpWordPress\Scheduled_Backup $schedule ) {
|
function hmbkp_get_site_size_text( HM\BackUpWordPress\Scheduled_Backup $schedule ) {
|
||||||
if ( method_exists($schedule, 'is_site_size_cached') ) {
|
if ( method_exists( $schedule, 'is_site_size_cached' ) ) {
|
||||||
if ( ( 'database' === $schedule->get_type() ) || $schedule->is_site_size_cached() ) {
|
if ( ( 'database' === $schedule->get_type() ) || $schedule->is_site_size_cached() ) {
|
||||||
return sprintf( '(<code title="' . __( 'Backups will be compressed and should be smaller than this.', 'mainwp-backupwordpress-extension' ) . '">%s</code>)', esc_attr( $schedule->get_formatted_site_size() ) );
|
return sprintf( '(<code title="' . __( 'Backups will be compressed and should be smaller than this.', 'mainwp-child' ) . '">%s</code>)', esc_attr( $schedule->get_formatted_site_size() ) );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$site_size = new HM\BackUpWordPress\Site_Size( $schedule->get_type(), $schedule->get_excludes() );
|
$site_size = new HM\BackUpWordPress\Site_Size( $schedule->get_type(), $schedule->get_excludes() );
|
||||||
if ( ( 'database' === $schedule->get_type() ) || $site_size->is_site_size_cached() ) {
|
if ( ( 'database' === $schedule->get_type() ) || $site_size->is_site_size_cached() ) {
|
||||||
return sprintf( '(<code title="' . __( 'Backups will be compressed and should be smaller than this.', 'backupwordpress' ) . '">%s</code>)', esc_attr( $site_size->get_formatted_site_size() ) );
|
return sprintf( '(<code title="' . __( 'Backups will be compressed and should be smaller than this.', 'mainwp-child' ) . '">%s</code>)', esc_attr( $site_size->get_formatted_site_size() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sprintf( '(<code class="calculating" title="' . __( 'this shouldn\'t take long…', 'mainwp-backupwordpress-extension' ) . '">' . __( 'calculating the size of your backup…', 'mainwp-backupwordpress-extension' ) . '</code>)' );
|
return sprintf( '(<code class="calculating" title="' . __( 'this shouldn\'t take long…', 'mainwp-child' ) . '">' . __( 'calculating the size of your backup…', 'mainwp-child' ) . '</code>)' );
|
||||||
}
|
}
|
||||||
|
|
||||||
function hmbkp_get_backup_row( $file, HM\BackUpWordPress\Scheduled_Backup $schedule ) {
|
function hmbkp_get_backup_row( $file, HM\BackUpWordPress\Scheduled_Backup $schedule ) {
|
||||||
|
|
||||||
$encoded_file = urlencode( base64_encode( $file ) );
|
$encoded_file = rawurlencode( base64_encode( $file ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons.
|
||||||
$offset = get_option( 'gmt_offset' ) * 3600;
|
$offset = get_option( 'gmt_offset' ) * 3600;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -527,25 +522,25 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
<?php echo esc_html( size_format( @filesize( $file ) ) ); ?>
|
<?php echo esc_html( size_format( @filesize( $file ) ) ); ?>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td><?php echo function_exists('hmbkp_human_get_type') ? esc_html( hmbkp_human_get_type( $file, $schedule ) ) : esc_html( HM\BackUpWordPress\human_get_type( $file, $schedule)); ?></td>
|
<td><?php echo function_exists( 'hmbkp_human_get_type' ) ? esc_html( hmbkp_human_get_type( $file, $schedule ) ) : esc_html( HM\BackUpWordPress\human_get_type( $file, $schedule ) ); ?></td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if ( function_exists('hmbkp_is_path_accessible') ) {
|
if ( function_exists( 'hmbkp_is_path_accessible' ) ) {
|
||||||
if ( hmbkp_is_path_accessible( hmbkp_path() ) ) {
|
if ( hmbkp_is_path_accessible( hmbkp_path() ) ) {
|
||||||
?>
|
?>
|
||||||
<a href="#"
|
<a href="#"
|
||||||
onclick="event.preventDefault(); mainwp_backupwp_download_backup('<?php echo $encoded_file; ?>', <?php echo esc_attr( $schedule->get_id() ); ?>, this);"
|
onclick="event.preventDefault(); mainwp_backupwp_download_backup('<?php echo $encoded_file; ?>', <?php echo esc_attr( $schedule->get_id() ); ?>, this);"
|
||||||
class="download-action"><?php esc_html_e( 'Download', 'backupwordpress' ); ?></a> |
|
class="download-action"><?php esc_html_e( 'Download', 'mainwp-child' ); ?></a> |
|
||||||
<?php
|
<?php
|
||||||
};
|
};
|
||||||
} elseif ( function_exists('HM\BackUpWordPress\is_path_accessible') ) {
|
} elseif ( function_exists( 'HM\BackUpWordPress\is_path_accessible' ) ) {
|
||||||
if ( HM\BackUpWordPress\is_path_accessible(HM\BackUpWordPress\Path::get_path()) ) {
|
if ( HM\BackUpWordPress\is_path_accessible( HM\BackUpWordPress\Path::get_path() ) ) {
|
||||||
?>
|
?>
|
||||||
<a href="#"
|
<a href="#"
|
||||||
onclick="event.preventDefault(); mainwp_backupwp_download_backup('<?php echo $encoded_file; ?>', <?php echo esc_attr( $schedule->get_id() ); ?>, this);"
|
onclick="event.preventDefault(); mainwp_backupwp_download_backup('<?php echo $encoded_file; ?>', <?php echo esc_attr( $schedule->get_id() ); ?>, this);"
|
||||||
class="download-action"><?php esc_html_e( 'Download', 'backupwordpress' ); ?></a> |
|
class="download-action"><?php esc_html_e( 'Download', 'maiwnp-child' ); ?></a> |
|
||||||
<?php
|
<?php
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -553,7 +548,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
|
|
||||||
<a href="#"
|
<a href="#"
|
||||||
onclick="event.preventDefault(); mainwp_backupwp_delete_backup('<?php echo $encoded_file; ?>', <?php echo esc_attr( $schedule->get_id() ); ?>, this);"
|
onclick="event.preventDefault(); mainwp_backupwp_delete_backup('<?php echo $encoded_file; ?>', <?php echo esc_attr( $schedule->get_id() ); ?>, this);"
|
||||||
class="delete-action"><?php esc_html_e( 'Delete', 'backupwordpress' ); ?></a>
|
class="delete-action"><?php esc_html_e( 'Delete', 'mainwp-child' ); ?></a>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
@ -565,10 +560,10 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
function get_excluded( $browse_dir = null ) {
|
function get_excluded( $browse_dir = null ) {
|
||||||
|
|
||||||
$schedule_id = $this->check_schedule();
|
$schedule_id = $this->check_schedule();
|
||||||
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( urldecode( $schedule_id ) ) );
|
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( rawurldecode( $schedule_id ) ) );
|
||||||
|
|
||||||
$new_version = true;
|
$new_version = true;
|
||||||
if ( method_exists($schedule, 'get_running_backup_filename' ) ) {
|
if ( method_exists( $schedule, 'get_running_backup_filename' ) ) {
|
||||||
$new_version = false;
|
$new_version = false;
|
||||||
$user_excludes = array_diff( $schedule->get_excludes(), $schedule->backup->default_excludes() );
|
$user_excludes = array_diff( $schedule->get_excludes(), $schedule->backup->default_excludes() );
|
||||||
$root_dir = $schedule->backup->get_root();
|
$root_dir = $schedule->backup->get_root();
|
||||||
|
@ -584,45 +579,23 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="hmbkp-exclude-settings">
|
<div class="hmbkp-exclude-settings">
|
||||||
|
<h3><?php esc_html_e( 'Currently Excluded', 'mainwp-child' ); ?></h3>
|
||||||
<?php // if ( $schedule->get_excludes() ) : ?>
|
<p><?php esc_html_e( 'We automatically detect and ignore common <abbr title="Version Control Systems">VCS</abbr> folders and other backup plugin folders.', 'mainwp-child' ); ?></p>
|
||||||
|
|
||||||
<h3>
|
|
||||||
<?php esc_html_e( 'Currently Excluded', 'backupwordpress' ); ?>
|
|
||||||
</h3>
|
|
||||||
|
|
||||||
<p><?php esc_html_e( 'We automatically detect and ignore common <abbr title="Version Control Systems">VCS</abbr> folders and other backup plugin folders.', 'backupwordpress' ); ?></p>
|
|
||||||
|
|
||||||
<table class="widefat">
|
<table class="widefat">
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ( $user_excludes as $key => $exclude ) : ?>
|
<?php foreach ( $user_excludes as $key => $exclude ) : ?>
|
||||||
|
|
||||||
<?php $exclude_path = new SplFileInfo( trailingslashit( $root_dir ) . ltrim( str_ireplace( $root_dir, '', $exclude ), '/' ) ); ?>
|
<?php $exclude_path = new SplFileInfo( trailingslashit( $root_dir ) . ltrim( str_ireplace( $root_dir, '', $exclude ), '/' ) ); ?>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<th scope="row">
|
<th scope="row">
|
||||||
|
|
||||||
<?php if ( $exclude_path->isFile() ) { ?>
|
<?php if ( $exclude_path->isFile() ) { ?>
|
||||||
|
|
||||||
<div class="dashicons dashicons-media-default"></div>
|
<div class="dashicons dashicons-media-default"></div>
|
||||||
|
|
||||||
<?php } elseif ( $exclude_path->isDir() ) { ?>
|
<?php } elseif ( $exclude_path->isDir() ) { ?>
|
||||||
|
|
||||||
<div class="dashicons dashicons-portfolio"></div>
|
<div class="dashicons dashicons-portfolio"></div>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
</th>
|
</th>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<code>
|
<code><?php echo esc_html( str_ireplace( $root_dir, '', $exclude ) ); ?></code>
|
||||||
<?php echo esc_html( str_ireplace( $root_dir, '', $exclude ) ); ?>
|
|
||||||
</code>
|
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<?php
|
<?php
|
||||||
if ( $new_version ) {
|
if ( $new_version ) {
|
||||||
|
@ -630,191 +603,123 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
} else {
|
} else {
|
||||||
$is_default_rule = ( in_array( $exclude, $schedule->backup->default_excludes() ) ) || ( hmbkp_path() === untrailingslashit( $exclude ) );
|
$is_default_rule = ( in_array( $exclude, $schedule->backup->default_excludes() ) ) || ( hmbkp_path() === untrailingslashit( $exclude ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $is_default_rule ) :
|
if ( $is_default_rule ) :
|
||||||
?>
|
?>
|
||||||
<?php esc_html_e( 'Default rule', 'backupwordpress' ); ?>
|
<?php esc_html_e( 'Default rule', 'mainwp-child' ); ?>
|
||||||
|
|
||||||
<?php elseif ( defined( 'HMBKP_EXCLUDE' ) && false !== strpos( HMBKP_EXCLUDE, $exclude ) ) : ?>
|
<?php elseif ( defined( 'HMBKP_EXCLUDE' ) && false !== strpos( HMBKP_EXCLUDE, $exclude ) ) : ?>
|
||||||
|
<?php esc_html_e( 'Defined in wp-config.php', 'mainwp-child' ); ?>
|
||||||
<?php esc_html_e( 'Defined in wp-config.php', 'backupwordpress' ); ?>
|
|
||||||
|
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
|
<a href="#" onclick="event.preventDefault(); mainwp_backupwp_remove_exclude_rule('<?php esc_attr_e( $exclude ); ?>', this);" class="delete-action"><?php esc_html_e( 'Stop excluding', 'mainwp-child' ); ?></a>
|
||||||
<a href="#"
|
|
||||||
onclick="event.preventDefault(); mainwp_backupwp_remove_exclude_rule('<?php esc_attr_e( $exclude ); ?>', this);"
|
|
||||||
class="delete-action"><?php esc_html_e( 'Stop excluding', 'backupwordpress' ); ?></a>
|
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
<h3 id="directory-listing"><?php esc_html_e( 'Your Site', 'mainwp-child' ); ?></h3>
|
||||||
<?php // endif; ?>
|
<p><?php esc_html_e( 'Here\'s a directory listing of all files on your site, you can browse through and exclude files or folders that you don\'t want included in your backup.', 'mainwp-child' ); ?></p>
|
||||||
|
|
||||||
<h3 id="directory-listing"><?php esc_html_e( 'Your Site', 'backupwordpress' ); ?></h3>
|
|
||||||
|
|
||||||
<p><?php esc_html_e( 'Here\'s a directory listing of all files on your site, you can browse through and exclude files or folders that you don\'t want included in your backup.', 'backupwordpress' ); ?></p>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
// The directory to display
|
|
||||||
$directory = $root_dir;
|
$directory = $root_dir;
|
||||||
|
|
||||||
if ( isset( $browse_dir ) ) {
|
if ( isset( $browse_dir ) ) {
|
||||||
|
|
||||||
$untrusted_directory = urldecode( $browse_dir );
|
$untrusted_directory = rawurldecode( $browse_dir );
|
||||||
|
|
||||||
// Only allow real sub directories of the site root to be browsed
|
// Only allow real sub directories of the site root to be browsed.
|
||||||
if ( false !== strpos( $untrusted_directory, $root_dir ) && is_dir( $untrusted_directory ) ) {
|
if ( false !== strpos( $untrusted_directory, $root_dir ) && is_dir( $untrusted_directory ) ) {
|
||||||
$directory = $untrusted_directory;
|
$directory = $untrusted_directory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kick off a recursive filesize scan
|
// Kick off a recursive filesize scan.
|
||||||
if ( $new_version ) {
|
if ( $new_version ) {
|
||||||
|
|
||||||
$site_size = new HM\BackUpWordPress\Site_Size();
|
$site_size = new HM\BackUpWordPress\Site_Size();
|
||||||
|
|
||||||
$exclude_string = implode( '|', $excludes->get_excludes_for_regex() );
|
$exclude_string = implode( '|', $excludes->get_excludes_for_regex() );
|
||||||
|
if ( function_exists( 'HM\BackUpWordPress\list_directory_by_total_filesize' ) ) {
|
||||||
if ( function_exists('HM\BackUpWordPress\list_directory_by_total_filesize') ) {
|
|
||||||
$files = HM\BackUpWordPress\list_directory_by_total_filesize( $directory, $excludes );
|
$files = HM\BackUpWordPress\list_directory_by_total_filesize( $directory, $excludes );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$files = $schedule->list_directory_by_total_filesize( $directory );
|
$files = $schedule->list_directory_by_total_filesize( $directory );
|
||||||
$exclude_string = $schedule->backup->exclude_string( 'regex' );
|
$exclude_string = $schedule->backup->exclude_string( 'regex' );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $files ) {
|
if ( $files ) {
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<table class="widefat">
|
<table class="widefat">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th scope="col"><?php esc_html_e( 'Name', 'backupwordpress' ); ?></th>
|
<th scope="col"><?php esc_html_e( 'Name', 'mainwp-child' ); ?></th>
|
||||||
<th scope="col" class="column-format"><?php esc_html_e( 'Size', 'backupwordpress' ); ?></th>
|
<th scope="col" class="column-format"><?php esc_html_e( 'Size', 'mainwp-child' ); ?></th>
|
||||||
<th scope="col"
|
<th scope="col"
|
||||||
class="column-format"><?php esc_html_e( 'Permissions', 'backupwordpress' ); ?></th>
|
class="column-format"><?php esc_html_e( 'Permissions', 'mainwp-child' ); ?></th>
|
||||||
<th scope="col" class="column-format"><?php esc_html_e( 'Type', 'backupwordpress' ); ?></th>
|
<th scope="col" class="column-format"><?php esc_html_e( 'Type', 'mainwp-child' ); ?></th>
|
||||||
<th scope="col" class="column-format"><?php esc_html_e( 'Status', 'backupwordpress' ); ?></th>
|
<th scope="col" class="column-format"><?php esc_html_e( 'Status', 'mainwp-child' ); ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<th scope="row">
|
<th scope="row">
|
||||||
<div class="dashicons dashicons-admin-home"></div>
|
<div class="dashicons dashicons-admin-home"></div>
|
||||||
</th>
|
</th>
|
||||||
|
|
||||||
<th scope="col">
|
<th scope="col">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if ( $root_dir !== $directory ) {
|
if ( $root_dir !== $directory ) {
|
||||||
// echo esc_url( remove_query_arg( 'hmbkp_directory_browse' ) );
|
|
||||||
?>
|
?>
|
||||||
<a href="#"
|
<a href="#" onclick="event.preventDefault(); mainwp_backupwp_directory_browse( '', this )"><?php echo esc_html( $root_dir ); ?></a>
|
||||||
onclick="event.preventDefault(); mainwp_backupwp_directory_browse('', this)"><?php echo esc_html( $root_dir ); ?></a>
|
|
||||||
<code>/</code>
|
<code>/</code>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$parents = array_filter( explode( '/', str_replace( trailingslashit( $root_dir ), '', trailingslashit( dirname( $directory ) ) ) ) );
|
$parents = array_filter( explode( '/', str_replace( trailingslashit( $root_dir ), '', trailingslashit( dirname( $directory ) ) ) ) );
|
||||||
|
|
||||||
foreach ( $parents as $directory_basename ) {
|
foreach ( $parents as $directory_basename ) {
|
||||||
?>
|
?>
|
||||||
|
<a href="#" onclick="event.preventDefault(); mainwp_backupwp_directory_browse('<?php echo rawurlencode( substr( $directory, 0, strpos( $directory, $directory_basename ) ) . $directory_basename ); ?>', this)"><?php echo esc_html( $directory_basename ); ?></a>
|
||||||
<a href="#"
|
|
||||||
onclick="event.preventDefault(); mainwp_backupwp_directory_browse('<?php echo urlencode( substr( $directory, 0, strpos( $directory, $directory_basename ) ) . $directory_basename ); ?>', this)"><?php echo esc_html( $directory_basename ); ?></a>
|
|
||||||
<code>/</code>
|
<code>/</code>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<?php echo esc_html( basename( $directory ) ); ?>
|
<?php echo esc_html( basename( $directory ) ); ?>
|
||||||
|
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
|
|
||||||
<?php echo esc_html( $root_dir ); ?>
|
<?php echo esc_html( $root_dir ); ?>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
</th>
|
</th>
|
||||||
|
|
||||||
<td class="column-filesize">
|
<td class="column-filesize">
|
||||||
|
|
||||||
<?php if ( $is_size_calculated ) : ?>
|
<?php if ( $is_size_calculated ) : ?>
|
||||||
|
<span class="spinner"></span>
|
||||||
<span class="spinner "></span>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
else :
|
else :
|
||||||
|
|
||||||
$root = new SplFileInfo( $root_dir );
|
$root = new SplFileInfo( $root_dir );
|
||||||
|
|
||||||
if ( $new_version ) {
|
if ( $new_version ) {
|
||||||
$size = $site_size->filesize( $root );
|
$size = $site_size->filesize( $root );
|
||||||
} else {
|
} else {
|
||||||
$size = $schedule->filesize( $root, true );
|
$size = $schedule->filesize( $root, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( false !== $size ) {
|
if ( false !== $size ) {
|
||||||
|
|
||||||
$size = size_format( $size );
|
$size = size_format( $size );
|
||||||
|
|
||||||
if ( ! $size ) {
|
if ( ! $size ) {
|
||||||
$size = '0 B';
|
$size = '0 B';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<code>
|
<code>
|
||||||
|
|
||||||
<?php echo esc_html( $size ); ?>
|
<?php echo esc_html( $size ); ?>
|
||||||
|
<a class="dashicons dashicons-update" href="<?php echo esc_attr( wp_nonce_url( add_query_arg( 'hmbkp_recalculate_directory_filesize', rawurlencode( $root_dir ) ), 'hmbkp-recalculate_directory_filesize' ) ); ?>"><span><?php esc_html_e( 'Refresh', 'mainwp-child' ); ?></span></a>
|
||||||
<a class="dashicons dashicons-update"
|
|
||||||
href="<?php echo esc_attr( wp_nonce_url( add_query_arg( 'hmbkp_recalculate_directory_filesize', urlencode( $root_dir ) ), 'hmbkp-recalculate_directory_filesize' ) ); ?>"><span><?php esc_html_e( 'Refresh', 'backupwordpress' ); ?></span></a>
|
|
||||||
|
|
||||||
</code>
|
</code>
|
||||||
|
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<?php echo esc_html( substr( sprintf( '%o', fileperms( $root_dir ) ), - 4 ) ); ?>
|
<?php echo esc_html( substr( sprintf( '%o', fileperms( $root_dir ) ), - 4 ) ); ?>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if ( is_link( $root_dir ) ) {
|
if ( is_link( $root_dir ) ) {
|
||||||
esc_html_e( 'Symlink', 'backupwordpress' );
|
esc_html_e( 'Symlink', 'mainwp-child' );
|
||||||
} elseif ( is_dir( $root_dir ) ) {
|
} elseif ( is_dir( $root_dir ) ) {
|
||||||
esc_html_e( 'Folder', 'backupwordpress' );
|
esc_html_e( 'Folder', 'mainwp-child' );
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td></td>
|
<td></td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
</thead>
|
||||||
</thead>
|
<tbody>
|
||||||
|
|
||||||
<tbody>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
foreach ( $files as $size => $file ) {
|
foreach ( $files as $size => $file ) {
|
||||||
|
|
||||||
$is_excluded = $is_unreadable = false;
|
$is_excluded = $is_unreadable = false;
|
||||||
|
// Check if the file is excluded.
|
||||||
// Check if the file is excluded
|
|
||||||
if ( $new_version ) {
|
if ( $new_version ) {
|
||||||
if ( $exclude_string && preg_match( '(' . $exclude_string . ')', str_ireplace( trailingslashit( $root_dir ), '', wp_normalize_path( $file->getPathname() ) ) ) ) {
|
if ( $exclude_string && preg_match( '(' . $exclude_string . ')', str_ireplace( trailingslashit( $root_dir ), '', wp_normalize_path( $file->getPathname() ) ) ) ) {
|
||||||
$is_excluded = true;
|
$is_excluded = true;
|
||||||
|
@ -824,88 +729,51 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
$is_excluded = true;
|
$is_excluded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Skip unreadable files.
|
||||||
// Skip unreadable files
|
|
||||||
if ( ! @realpath( $file->getPathname() ) || ! $file->isReadable() ) {
|
if ( ! @realpath( $file->getPathname() ) || ! $file->isReadable() ) {
|
||||||
$is_unreadable = true;
|
$is_unreadable = true;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
<?php if ( $is_unreadable ) { ?>
|
<?php if ( $is_unreadable ) { ?>
|
||||||
|
|
||||||
<div class="dashicons dashicons-dismiss"></div>
|
<div class="dashicons dashicons-dismiss"></div>
|
||||||
|
|
||||||
<?php } elseif ( $file->isFile() ) { ?>
|
<?php } elseif ( $file->isFile() ) { ?>
|
||||||
|
|
||||||
<div class="dashicons dashicons-media-default"></div>
|
<div class="dashicons dashicons-media-default"></div>
|
||||||
|
|
||||||
<?php } elseif ( $file->isDir() ) { ?>
|
<?php } elseif ( $file->isDir() ) { ?>
|
||||||
|
|
||||||
<div class="dashicons dashicons-portfolio"></div>
|
<div class="dashicons dashicons-portfolio"></div>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<?php
|
<?php
|
||||||
if ( $new_version ) {
|
if ( $new_version ) {
|
||||||
if ( $is_unreadable ) {
|
if ( $is_unreadable ) {
|
||||||
?>
|
?>
|
||||||
|
<code class="strikethrough" title="<?php echo esc_attr( wp_normalize_path( $file->getRealPath() ) ); ?>"><?php echo esc_html( $file->getBasename() ); ?></code>
|
||||||
<code class="strikethrough"
|
|
||||||
title="<?php echo esc_attr( wp_normalize_path( $file->getRealPath() ) ); ?>"><?php echo esc_html( $file->getBasename() ); ?></code>
|
|
||||||
|
|
||||||
<?php } elseif ( $file->isFile() ) { ?>
|
<?php } elseif ( $file->isFile() ) { ?>
|
||||||
|
<code title="<?php echo esc_attr( wp_normalize_path( $file->getRealPath() ) ); ?>"><?php echo esc_html( $file->getBasename() ); ?></code>
|
||||||
<code
|
|
||||||
title="<?php echo esc_attr( wp_normalize_path( $file->getRealPath() ) ); ?>"><?php echo esc_html( $file->getBasename() ); ?></code>
|
|
||||||
|
|
||||||
<?php } elseif ( $file->isDir() ) { ?>
|
<?php } elseif ( $file->isDir() ) { ?>
|
||||||
<code title="<?php echo esc_attr( $file->getRealPath() ); ?>"><a
|
<code title="<?php echo esc_attr( $file->getRealPath() ); ?>"><a href="#" onclick="event.preventDefault(); mainwp_backupwp_directory_browse('<?php echo rawurlencode( wp_normalize_path( $file->getPathname() ) ); ?>', this)"><?php echo esc_html( $file->getBasename() ); ?></a></code>
|
||||||
href="#"
|
|
||||||
onclick="event.preventDefault(); mainwp_backupwp_directory_browse('<?php echo urlencode( wp_normalize_path( $file->getPathname()) ); ?>', this)"><?php echo esc_html( $file->getBasename() ); ?></a></code>
|
|
||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ( $is_unreadable ) {
|
if ( $is_unreadable ) {
|
||||||
?>
|
?>
|
||||||
|
<code class="strikethrough" title="<?php echo esc_attr( $file->getRealPath() ); ?>"><?php echo esc_html( $file->getBasename() ); ?></code>
|
||||||
<code class="strikethrough"
|
|
||||||
title="<?php echo esc_attr( $file->getRealPath() ); ?>"><?php echo esc_html( $file->getBasename() ); ?></code>
|
|
||||||
|
|
||||||
<?php } elseif ( $file->isFile() ) { ?>
|
<?php } elseif ( $file->isFile() ) { ?>
|
||||||
|
<code title="<?php echo esc_attr( $file->getRealPath() ); ?>"><?php echo esc_html( $file->getBasename() ); ?></code>
|
||||||
<code
|
|
||||||
title="<?php echo esc_attr( $file->getRealPath() ); ?>"><?php echo esc_html( $file->getBasename() ); ?></code>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
} elseif ( $file->isDir() ) {
|
} elseif ( $file->isDir() ) {
|
||||||
// echo add_query_arg( 'hmbkp_directory_browse', urlencode( $file->getPathname() ) );
|
|
||||||
?>
|
?>
|
||||||
<code title="<?php echo esc_attr( $file->getRealPath() ); ?>"><a
|
<code title="<?php echo esc_attr( $file->getRealPath() ); ?>"><a href="#" onclick="event.preventDefault(); mainwp_backupwp_directory_browse('<?php echo rawurlencode( $file->getPathname() ); ?>', this)"><?php echo esc_html( $file->getBasename() ); ?></a></code>
|
||||||
href="#"
|
|
||||||
onclick="event.preventDefault(); mainwp_backupwp_directory_browse('<?php echo urlencode( $file->getPathname() ); ?>', this)"><?php echo esc_html( $file->getBasename() ); ?></a></code>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="column-format column-filesize">
|
<td class="column-format column-filesize">
|
||||||
|
|
||||||
<?php if ( $file->isDir() && $is_size_calculated ) : ?>
|
<?php if ( $file->isDir() && $is_size_calculated ) : ?>
|
||||||
|
|
||||||
<span class="spinner"></span>
|
<span class="spinner"></span>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
else :
|
else :
|
||||||
if ( $new_version ) {
|
if ( $new_version ) {
|
||||||
|
@ -913,113 +781,65 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
} else {
|
} else {
|
||||||
$size = $schedule->filesize( $file );
|
$size = $schedule->filesize( $file );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( false !== $size ) {
|
if ( false !== $size ) {
|
||||||
|
|
||||||
$size = size_format( $size );
|
$size = size_format( $size );
|
||||||
|
|
||||||
if ( ! $size ) {
|
if ( ! $size ) {
|
||||||
$size = '0 B';
|
$size = '0 B';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<code>
|
<code>
|
||||||
|
|
||||||
<?php echo esc_html( $size ); ?>
|
<?php echo esc_html( $size ); ?>
|
||||||
|
|
||||||
<?php if ( $file->isDir() ) { ?>
|
<?php if ( $file->isDir() ) { ?>
|
||||||
|
<a title="<?php esc_attr_e( 'Recalculate the size of this directory', 'maiwnp-child' ); ?>" class="dashicons dashicons-update" href="<?php echo esc_attr( wp_nonce_url( add_query_arg( 'hmbkp_recalculate_directory_filesize', rawurlencode( wp_normalize_path( $file->getPathname() ) ) ), 'hmbkp-recalculate_directory_filesize' ) ); ?>"><span><?php esc_html_e( 'Refresh', 'mainwp-child' ); ?></span></a>
|
||||||
<a title="<?php esc_attr_e( 'Recalculate the size of this directory', 'backupwordpress' ); ?>"
|
|
||||||
class="dashicons dashicons-update"
|
|
||||||
href="<?php echo esc_attr( wp_nonce_url( add_query_arg( 'hmbkp_recalculate_directory_filesize', urlencode( wp_normalize_path( $file->getPathname() ) ) ), 'hmbkp-recalculate_directory_filesize' ) ); ?>"><span><?php esc_html_e( 'Refresh', 'backupwordpress' ); ?></span></a>
|
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
</code>
|
</code>
|
||||||
|
|
||||||
|
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
|
|
||||||
<code>--</code>
|
<code>--</code>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<?php echo esc_html( substr( sprintf( '%o', $file->getPerms() ), - 4 ) ); ?>
|
<?php echo esc_html( substr( sprintf( '%o', $file->getPerms() ), - 4 ) ); ?>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
<?php if ( $file->isLink() ) : ?>
|
<?php if ( $file->isLink() ) : ?>
|
||||||
|
<span title="<?php echo esc_attr( wp_normalize_path( $file->GetRealPath() ) ); ?>"><?php esc_html_e( 'Symlink', 'mainwp-child' ); ?></span>
|
||||||
<span
|
|
||||||
title="<?php echo esc_attr( wp_normalize_path( $file->GetRealPath() ) ); ?>"><?php esc_html_e( 'Symlink', 'backupwordpress' ); ?></span>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
elseif ( $file->isDir() ) :
|
elseif ( $file->isDir() ) :
|
||||||
|
esc_html_e( 'Folder', 'mainwp-child' );
|
||||||
esc_html_e( 'Folder', 'backupwordpress' );
|
|
||||||
|
|
||||||
else :
|
else :
|
||||||
|
esc_html_e( 'File', 'mainwp-child' );
|
||||||
esc_html_e( 'File', 'backupwordpress' );
|
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="column-format">
|
<td class="column-format">
|
||||||
|
|
||||||
<?php if ( $is_unreadable ) : ?>
|
<?php if ( $is_unreadable ) : ?>
|
||||||
|
<strong title="<?php esc_attr_e( 'Unreadable files won\'t be backed up.', 'mainwp-child' ); ?>"><?php esc_html_e( 'Unreadable', 'mainwp-child' ); ?></strong>
|
||||||
<strong
|
|
||||||
title="<?php esc_attr_e( 'Unreadable files won\'t be backed up.', 'backupwordpress' ); ?>"><?php esc_html_e( 'Unreadable', 'backupwordpress' ); ?></strong>
|
|
||||||
|
|
||||||
<?php elseif ( $is_excluded ) : ?>
|
<?php elseif ( $is_excluded ) : ?>
|
||||||
|
<strong><?php esc_html_e( 'Excluded', 'mainwp-child' ); ?></strong>
|
||||||
<strong><?php esc_html_e( 'Excluded', 'backupwordpress' ); ?></strong>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
else :
|
else :
|
||||||
|
|
||||||
$exclude_path = $file->getPathname();
|
$exclude_path = $file->getPathname();
|
||||||
|
|
||||||
// Excluded directories need to be trailingslashed
|
// Excluded directories need to be trailingslashed.
|
||||||
if ( $file->isDir() ) {
|
if ( $file->isDir() ) {
|
||||||
$exclude_path = trailingslashit( wp_normalize_path( $file->getPathname() ) );
|
$exclude_path = trailingslashit( wp_normalize_path( $file->getPathname() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
<a href="#" onclick="event.preventDefault(); mainwp_backupwp_exclude_add_rule('<?php echo rawurlencode( $exclude_path ); ?>', this)" class="button-secondary"><?php esc_html_e( 'Exclude →', 'mainwp-child' ); ?></a>
|
||||||
<a href="#"
|
|
||||||
onclick="event.preventDefault(); mainwp_backupwp_exclude_add_rule('<?php echo urlencode( $exclude_path ); ?>', this)"
|
|
||||||
class="button-secondary"><?php esc_html_e( 'Exclude →', 'backupwordpress' ); ?></a>
|
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<p class="submit">
|
<p class="submit">
|
||||||
<a href="#" onclick="event.preventDefault(); mainwp_backupwp_edit_exclude_done()"
|
<a href="#" onclick="event.preventDefault(); mainwp_backupwp_edit_exclude_done()" class="button-primary"><?php esc_html_e( 'Done', 'mainwp-child' ); ?></a>
|
||||||
class="button-primary"><?php esc_html_e( 'Done', 'backupwordpress' ); ?></a>
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$output = ob_get_clean();
|
$output = ob_get_clean();
|
||||||
$information['e'] = $output;
|
$information['e'] = $output;
|
||||||
|
@ -1040,19 +860,19 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
function hmbkp_add_exclude_rule() {
|
function hmbkp_add_exclude_rule() {
|
||||||
|
|
||||||
if ( ! isset( $_POST['exclude_pathname'] ) || empty( $_POST['exclude_pathname'] ) ) {
|
if ( ! isset( $_POST['exclude_pathname'] ) || empty( $_POST['exclude_pathname'] ) ) {
|
||||||
return array( 'error' => __( 'Error: Empty exclude directory path.' ) );
|
return array( 'error' => __( 'Empty exclude directory path.', 'mainwp-child' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$schedule_id = $this->check_schedule();
|
$schedule_id = $this->check_schedule();
|
||||||
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( $schedule_id ) );
|
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( $schedule_id ) );
|
||||||
|
|
||||||
$exclude_rule = urldecode( $_POST['exclude_pathname'] );
|
$exclude_rule = rawurldecode( $_POST['exclude_pathname'] );
|
||||||
|
|
||||||
$schedule->set_excludes( $exclude_rule, true );
|
$schedule->set_excludes( $exclude_rule, true );
|
||||||
|
|
||||||
$schedule->save();
|
$schedule->save();
|
||||||
|
|
||||||
$current_path = urldecode( $_POST['browse_dir'] );
|
$current_path = rawurldecode( $_POST['browse_dir'] );
|
||||||
|
|
||||||
if ( empty( $current_path ) ) {
|
if ( empty( $current_path ) ) {
|
||||||
$current_path = null;
|
$current_path = null;
|
||||||
|
@ -1068,7 +888,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
function hmbkp_remove_exclude_rule() {
|
function hmbkp_remove_exclude_rule() {
|
||||||
|
|
||||||
if ( ! isset( $_POST['remove_rule'] ) || empty( $_POST['remove_rule'] ) ) {
|
if ( ! isset( $_POST['remove_rule'] ) || empty( $_POST['remove_rule'] ) ) {
|
||||||
return array( 'error' => __( 'Error: Empty exclude directory path.' ) );
|
return array( 'error' => __( 'Empty exclude directory path.', 'mainwp-child' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$schedule_id = $this->check_schedule();
|
$schedule_id = $this->check_schedule();
|
||||||
|
@ -1077,7 +897,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
$excludes = $schedule->get_excludes();
|
$excludes = $schedule->get_excludes();
|
||||||
$exclude_rule_to_remove = stripslashes( sanitize_text_field( $_POST['remove_rule'] ) );
|
$exclude_rule_to_remove = stripslashes( sanitize_text_field( $_POST['remove_rule'] ) );
|
||||||
|
|
||||||
if ( method_exists($excludes, 'get_user_excludes') ) {
|
if ( method_exists( $excludes, 'get_user_excludes' ) ) {
|
||||||
$schedule->set_excludes( array_diff( $excludes->get_user_excludes(), (array) $exclude_rule_to_remove ) );
|
$schedule->set_excludes( array_diff( $excludes->get_user_excludes(), (array) $exclude_rule_to_remove ) );
|
||||||
} else {
|
} else {
|
||||||
$schedule->set_excludes( array_diff( $excludes, $exclude_rule_to_remove ) );
|
$schedule->set_excludes( array_diff( $excludes, $exclude_rule_to_remove ) );
|
||||||
|
@ -1085,7 +905,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
|
|
||||||
$schedule->save();
|
$schedule->save();
|
||||||
|
|
||||||
$current_path = urldecode( $_POST['browse_dir'] );
|
$current_path = rawurldecode( $_POST['browse_dir'] );
|
||||||
|
|
||||||
if ( empty( $current_path ) ) {
|
if ( empty( $current_path ) ) {
|
||||||
$current_path = null;
|
$current_path = null;
|
||||||
|
@ -1105,41 +925,40 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
$sch_id = $this->check_schedule();
|
$sch_id = $this->check_schedule();
|
||||||
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( $sch_id ) );
|
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( $sch_id ) );
|
||||||
|
|
||||||
$exclude_paths = urldecode( $_POST['exclude_paths'] );
|
$exclude_paths = rawurldecode( $_POST['exclude_paths'] );
|
||||||
$exclude_paths = explode("\n", $exclude_paths);
|
$exclude_paths = explode("\n", $exclude_paths);
|
||||||
if ( is_array($exclude_paths) && count($exclude_paths) > 0 ) {
|
if ( is_array( $exclude_paths ) && count( $exclude_paths ) > 0 ) {
|
||||||
foreach ( $exclude_paths as $excl_rule ) {
|
foreach ( $exclude_paths as $excl_rule ) {
|
||||||
$excl_rule = trim($excl_rule);
|
$excl_rule = trim( $excl_rule );
|
||||||
$excl_rule = trim($excl_rule, '/');
|
$excl_rule = trim( $excl_rule, '/' );
|
||||||
|
|
||||||
if ( empty($excl_rule) ) {
|
if ( empty( $excl_rule ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$exclude_rule = ABSPATH . $excl_rule;
|
$exclude_rule = ABSPATH . $excl_rule;
|
||||||
$path = realpath($exclude_rule);
|
$path = realpath( $exclude_rule );
|
||||||
// If it exist
|
if ( false !== $path ) {
|
||||||
if ( $path !== false ) {
|
|
||||||
$schedule->set_excludes( $exclude_rule, true );
|
$schedule->set_excludes( $exclude_rule, true );
|
||||||
$schedule->save();
|
$schedule->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$un_exclude_paths = urldecode( $_POST['un_exclude_paths'] );
|
$un_exclude_paths = rawurldecode( $_POST['un_exclude_paths'] );
|
||||||
$un_exclude_paths = explode("\n", $un_exclude_paths);
|
$un_exclude_paths = explode( "\n", $un_exclude_paths );
|
||||||
|
|
||||||
if ( is_array($un_exclude_paths) && count(get_user_excludes) > 0 ) {
|
if ( is_array( $un_exclude_paths ) && count( get_user_excludes ) > 0 ) {
|
||||||
foreach ( $un_exclude_paths as $exclude_rule_to_remove ) {
|
foreach ( $un_exclude_paths as $exclude_rule_to_remove ) {
|
||||||
$exclude_rule_to_remove = trim($exclude_rule_to_remove);
|
$exclude_rule_to_remove = trim( $exclude_rule_to_remove );
|
||||||
$exclude_rule_to_remove = trim($exclude_rule_to_remove, '/');
|
$exclude_rule_to_remove = trim( $exclude_rule_to_remove, '/' );
|
||||||
|
|
||||||
if ( empty($exclude_rule_to_remove) ) {
|
if ( empty( $exclude_rule_to_remove ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$excludes = $schedule->get_excludes();
|
$excludes = $schedule->get_excludes();
|
||||||
if ( method_exists($excludes, 'get_user_excludes') ) {
|
if ( method_exists( $excludes, 'get_user_excludes' ) ) {
|
||||||
$schedule->set_excludes( array_diff( $excludes->get_user_excludes(), (array) $exclude_rule_to_remove ) );
|
$schedule->set_excludes( array_diff( $excludes->get_user_excludes(), (array) $exclude_rule_to_remove ) );
|
||||||
} else {
|
} else {
|
||||||
$schedule->set_excludes( array_diff( $excludes, $exclude_rule_to_remove ) );
|
$schedule->set_excludes( array_diff( $excludes, $exclude_rule_to_remove ) );
|
||||||
|
@ -1154,19 +973,13 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
|
|
||||||
function update_schedule() {
|
function update_schedule() {
|
||||||
$sch_id = isset( $_POST['schedule_id'] ) ? $_POST['schedule_id'] : 0;
|
$sch_id = isset( $_POST['schedule_id'] ) ? $_POST['schedule_id'] : 0;
|
||||||
$sch_id = sanitize_text_field( urldecode( $sch_id ) );
|
$sch_id = sanitize_text_field( rawurldecode( $sch_id ) );
|
||||||
$options = isset( $_POST['options'] ) ? maybe_unserialize( base64_decode( $_POST['options'] ) ) : false;
|
$options = isset( $_POST['options'] ) ? maybe_unserialize( base64_decode( $_POST['options'] ) ) : false; // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons.
|
||||||
|
|
||||||
if ( ! is_array( $options ) || empty( $options ) || empty( $sch_id ) ) {
|
if ( ! is_array( $options ) || empty( $options ) || empty( $sch_id ) ) {
|
||||||
return array( 'error' => 'Error: Schedule data' );
|
return array( 'error' => __( 'Schedule data', 'mainwp-child' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// $current_value = get_option( 'hmbkp_schedule_' . $sch_id );
|
|
||||||
// if ( is_array( $current_value ) && isset( $current_value['excludes'] ) ) {
|
|
||||||
// do not update 'excludes' value
|
|
||||||
// $options['excludes'] = $current_value['excludes'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
$filter_opts = array(
|
$filter_opts = array(
|
||||||
'type',
|
'type',
|
||||||
'email',
|
'email',
|
||||||
|
@ -1196,7 +1009,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( $sch_id ) );
|
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( $sch_id ) );
|
||||||
|
|
||||||
if ( ! empty( $options['reoccurrence'] ) && ! empty( $options['schedule_start_time'] ) ) {
|
if ( ! empty( $options['reoccurrence'] ) && ! empty( $options['schedule_start_time'] ) ) {
|
||||||
// Calculate the start time depending on the recurrence
|
// Calculate the start time depending on the recurrence.
|
||||||
$start_time = $options['schedule_start_time'];
|
$start_time = $options['schedule_start_time'];
|
||||||
if ( $start_time ) {
|
if ( $start_time ) {
|
||||||
$schedule->set_schedule_start_time( $start_time );
|
$schedule->set_schedule_start_time( $start_time );
|
||||||
|
@ -1212,15 +1025,15 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save_all_schedules() {
|
public function save_all_schedules() {
|
||||||
$schedules = isset( $_POST['all_schedules'] ) ? maybe_unserialize( base64_decode( $_POST['all_schedules'] ) ) : false;
|
$schedules = isset( $_POST['all_schedules'] ) ? maybe_unserialize( base64_decode( $_POST['all_schedules'] ) ) : false; // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons.
|
||||||
|
|
||||||
if ( ! is_array( $schedules ) || empty( $schedules ) ) {
|
if ( ! is_array( $schedules ) || empty( $schedules ) ) {
|
||||||
return array( 'error' => 'Error: Schedule data' );
|
return array( 'error' => __( 'Schedule data', 'mainwp-child' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$out = array();
|
$out = array();
|
||||||
foreach ( $schedules as $sch_id => $sch ) {
|
foreach ( $schedules as $sch_id => $sch ) {
|
||||||
if ( empty($sch_id) || ! isset( $sch['options'] ) || ! is_array( $sch['options'] ) ) {
|
if ( empty( $sch_id ) || ! isset( $sch['options'] ) || ! is_array( $sch['options'] ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$options = $sch['options'];
|
$options = $sch['options'];
|
||||||
|
@ -1246,7 +1059,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( $sch_id ) );
|
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( $sch_id ) );
|
||||||
|
|
||||||
if ( ! empty( $options['reoccurrence'] ) && ! empty( $options['schedule_start_time'] ) ) {
|
if ( ! empty( $options['reoccurrence'] ) && ! empty( $options['schedule_start_time'] ) ) {
|
||||||
// Calculate the start time depending on the recurrence
|
// Calculate the start time depending on the recurrence.
|
||||||
$start_time = $options['schedule_start_time'];
|
$start_time = $options['schedule_start_time'];
|
||||||
if ( $start_time ) {
|
if ( $start_time ) {
|
||||||
$schedule->set_schedule_start_time( $start_time );
|
$schedule->set_schedule_start_time( $start_time );
|
||||||
|
@ -1258,7 +1071,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
}
|
}
|
||||||
$out['result'] = 'SUCCESS';
|
$out['result'] = 'SUCCESS';
|
||||||
}
|
}
|
||||||
delete_transient( 'hmbkp_schedules' );
|
delete_transient( 'hmbkp_schedules' );
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1300,4 +1113,3 @@ class MainWP_Child_Back_Up_Wordpress {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue