1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
<?php
namespace SIW\Compatibility;
use SIW\Util;
class UpdraftPlus {
const TS_BACKUP_DB = '04:00';
const TS_BACKUP_FILES = '04:30';
public static function init() {
if ( ! class_exists( '\UpdraftPlus' ) ) {
return;
}
$self = new self();
add_filter( 'updraftplus_schedule_firsttime_db', [ $self, 'set_time_db_backup'] ) ;
add_filter( 'updraftplus_schedule_firsttime_files', [ $self, 'set_time_files_backup'] ) ;
add_filter( 'updraftplus_blog_name', [ $self, 'set_backup_name' ] );
add_action( 'admin_init', [ $self, 'hide_woocommerce_in_plugin_update_message'], PHP_INT_MAX );
define( 'UPDRAFTPLUS_NOADS_B', true );
define( 'UPDRAFTPLUS_NONEWSFEED', true );
define( 'UPDRAFTPLUS_ADMINBAR_DISABLE', true );
define( 'UPDRAFTPLUS_DISABLE_WP_CRON_NOTICE', true );
}
public function set_time_db_backup( int $scheduled_time ) {
$tomorrow = strtotime( 'tomorrow' );
$backup_db_day = date( 'Y-m-d', max( $scheduled_time, $tomorrow ) );
$backup_db_ts = strtotime( $backup_db_day . ' ' . self::TS_BACKUP_DB );
$backup_db_ts_gmt = Util::convert_timestamp_to_gmt( $backup_db_ts );
return $backup_db_ts_gmt;
}
public function set_time_files_backup( int $scheduled_time ) {
$tomorrow = strtotime( 'tomorrow');
$backup_files_day = date( 'Y-m-d', max( $scheduled_time, $tomorrow ) );
$backup_files_ts = strtotime( $backup_files_day . ' ' . self::TS_BACKUP_FILES );
$backup_files_ts_gmt = Util::convert_timestamp_to_gmt( $backup_files_ts );
return $backup_files_ts_gmt;
}
public function set_backup_name() {
return sanitize_title( SIW_SITE_NAME );
}
public function hide_woocommerce_in_plugin_update_message() {
global $updraftplus_admin;
remove_filter('woocommerce_in_plugin_update_message', [ $updraftplus_admin, 'woocommerce_in_plugin_update_message' ] );
}
}