Version Description
- 6-26-18 =
- Fixed: issues caused by deprecated functions
- Added: mainwp_before_post_update hook
- Added: support for the new extension
- Added: conditional checks to prevent possible conflicts with certain plugins
- Added: support for the new MainWP Branding Extension feature
- Improved: PHP 7.2 compatibility
Download this release
Release Info
Developer | mainwp |
Plugin | MainWP Child |
Version | 3.4.8 |
Comparing to | |
See all releases |
Code changes from version 3.4.7.1 to 3.4.8
- class/class-mainwp-child-back-up-buddy.php +140 -88
- class/class-mainwp-child-back-up-wordpress.php +65 -32
- class/class-mainwp-child-back-wp-up.php +88 -57
- class/class-mainwp-child-branding.php +14 -2
- class/class-mainwp-child-ithemes-security.php +10 -21
- class/class-mainwp-child-links-checker.php +112 -51
- class/class-mainwp-child-pagespeed.php +21 -6
- class/class-mainwp-child-skeleton-key.php +1 -1
- class/class-mainwp-child-staging.php +14 -4
- class/class-mainwp-child-timecapsule.php +1235 -0
- class/class-mainwp-child-updraft-plus-backups.php +155 -137
- class/class-mainwp-child-wordfence.php +10 -9
- class/class-mainwp-child-wp-rocket.php +15 -1
- class/class-mainwp-child.php +47 -92
- class/class-mainwp-client-report.php +17 -4
- class/class-mainwp-helper.php +170 -0
- mainwp-child.php +2 -6
- readme.txt +10 -2
class/class-mainwp-child-back-up-buddy.php
CHANGED
@@ -27,6 +27,8 @@ class MainWP_Child_Back_Up_Buddy {
|
|
27 |
return;
|
28 |
}
|
29 |
|
|
|
|
|
30 |
add_action( 'wp_ajax_mainwp_backupbuddy_download_archive', array( $this, 'download_archive' ) );
|
31 |
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
|
32 |
|
@@ -79,7 +81,7 @@ class MainWP_Child_Back_Up_Buddy {
|
|
79 |
$this->do_reports_log('backupbuddy');
|
80 |
}
|
81 |
}
|
82 |
-
|
83 |
function do_reports_log($ext = '') {
|
84 |
if ($ext !== 'backupbuddy')
|
85 |
return;
|
@@ -87,83 +89,106 @@ class MainWP_Child_Back_Up_Buddy {
|
|
87 |
if (!$this->is_backupbuddy_installed) {
|
88 |
return;
|
89 |
}
|
|
|
|
|
|
|
|
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
// Backup type.
|
96 |
-
$pretty_type = array(
|
97 |
-
'full' => 'Full',
|
98 |
-
'db' => 'Database',
|
99 |
-
'files' => 'Files',
|
100 |
-
);
|
101 |
|
102 |
-
|
|
|
103 |
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
|
106 |
-
|
107 |
-
pb_backupbuddy::status( 'details', 'Fileoptions instance #1.' );
|
108 |
-
$backup = new pb_backupbuddy_fileoptions( $backup_fileoptions, $read_only = true );
|
109 |
-
if ( true !== ( $result = $backup->is_ok() ) ) {
|
110 |
-
continue;
|
111 |
-
}
|
112 |
|
113 |
-
$backup = &$backup->options;
|
114 |
|
115 |
-
|
116 |
-
continue;
|
117 |
-
}
|
118 |
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
}
|
124 |
|
125 |
-
|
126 |
-
$backupType = pb_backupbuddy::$format->prettify( $backup['profile']['type'], $pretty_type );
|
127 |
-
} else {
|
128 |
-
$backupType = backupbuddy_core::pretty_backup_type( backupbuddy_core::getBackupTypeFromFile( $backup['archive_file'] ) );
|
129 |
-
}
|
130 |
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
}
|
141 |
-
}
|
142 |
-
|
143 |
-
if ( file_exists(pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php') ) {
|
144 |
-
require_once( pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php' );
|
145 |
-
|
146 |
-
$state = backupbuddy_live_periodic::get_stats();
|
147 |
-
if (is_array($state) && isset($state['stats'])) {
|
148 |
-
|
149 |
-
if ( is_array($state['stats'] ) && isset( $state['stats']['last_remote_snapshot'] )) {
|
150 |
-
if (isset( $state['stats']['last_remote_snapshot_response'] )) {
|
151 |
-
$resp = $state['stats']['last_remote_snapshot_response'];
|
152 |
-
if ( isset( $resp['success'] ) && $resp['success']) {
|
153 |
-
$finish_time = $state['stats']['last_remote_snapshot'];
|
154 |
-
$backupType = 'Live Backup to cloud';
|
155 |
-
$message = 'BackupBuddy ' . $backupType . ' finished';
|
156 |
-
if (!empty($finish_time)) {
|
157 |
-
do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time);
|
158 |
-
MainWP_Helper::update_lasttime_backup('backupbuddy', $finish_time); // to support backup before update feature
|
159 |
-
}
|
160 |
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
}
|
168 |
|
169 |
public function action() {
|
@@ -341,7 +366,7 @@ class MainWP_Child_Back_Up_Buddy {
|
|
341 |
$type = isset($_POST['type']) ? $_POST['type'] : '';
|
342 |
|
343 |
if ($type !== 'general_settings' && $type !== 'advanced_settings' && $type !== 'all' ) {
|
344 |
-
return array('error' => __('Invalid data
|
345 |
}
|
346 |
|
347 |
$filter_advanced_settings = array(
|
@@ -697,25 +722,46 @@ class MainWP_Child_Back_Up_Buddy {
|
|
697 |
return $information;
|
698 |
}
|
699 |
|
700 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
701 |
public function get_sync_data() {
|
702 |
-
if ( ! class_exists( 'backupbuddy_core' ) ) {
|
703 |
-
if (class_exists( 'pb_backupbuddy' ) && file_exists(pb_backupbuddy::plugin_path() . '/classes/core.php'))
|
704 |
-
require_once( pb_backupbuddy::plugin_path() . '/classes/core.php' );
|
705 |
-
else
|
706 |
-
return false;
|
707 |
-
}
|
708 |
|
709 |
-
|
710 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
711 |
|
712 |
-
|
713 |
-
$information['plugins_root'] = backupbuddy_core::get_plugins_root();
|
714 |
-
$information['themes_root'] = backupbuddy_core::get_themes_root();
|
715 |
-
$information['media_root'] = backupbuddy_core::get_media_root();
|
716 |
-
$information['additional_tables'] = $this->pb_additional_tables();
|
717 |
-
$information['abspath'] = ABSPATH;
|
718 |
-
return $information;
|
719 |
}
|
720 |
|
721 |
function backup_list() {
|
@@ -970,9 +1016,15 @@ class MainWP_Child_Back_Up_Buddy {
|
|
970 |
|
971 |
}
|
972 |
|
973 |
-
|
974 |
function pb_additional_tables( $display_size = false ) {
|
975 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
976 |
$return = '';
|
977 |
$size_string = '';
|
978 |
|
@@ -2456,7 +2508,7 @@ class MainWP_Child_Back_Up_Buddy {
|
|
2456 |
backupbuddy_live::send_trim_settings();
|
2457 |
return array('ok' => 1);
|
2458 |
} else {
|
2459 |
-
$error = 'Invalid data.';
|
2460 |
}
|
2461 |
return array('error' => $error);
|
2462 |
}
|
@@ -2475,7 +2527,7 @@ class MainWP_Child_Back_Up_Buddy {
|
|
2475 |
require_once( pb_backupbuddy::plugin_path() . '/destinations/live/init.php' );
|
2476 |
delete_transient( pb_backupbuddy_destination_live::LIVE_ACTION_TRANSIENT_NAME );
|
2477 |
} else {
|
2478 |
-
$error = 'Error:
|
2479 |
}
|
2480 |
$return['ok'] = 1;
|
2481 |
} else {
|
27 |
return;
|
28 |
}
|
29 |
|
30 |
+
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
31 |
+
|
32 |
add_action( 'wp_ajax_mainwp_backupbuddy_download_archive', array( $this, 'download_archive' ) );
|
33 |
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
|
34 |
|
81 |
$this->do_reports_log('backupbuddy');
|
82 |
}
|
83 |
}
|
84 |
+
// ok
|
85 |
function do_reports_log($ext = '') {
|
86 |
if ($ext !== 'backupbuddy')
|
87 |
return;
|
89 |
if (!$this->is_backupbuddy_installed) {
|
90 |
return;
|
91 |
}
|
92 |
+
|
93 |
+
try {
|
94 |
+
|
95 |
+
MainWP_Helper::check_methods( 'pb_backupbuddy', array( 'plugin_path' ));
|
96 |
|
97 |
+
if ( ! class_exists( 'backupbuddy_core' ) ) {
|
98 |
+
if ( file_exists(pb_backupbuddy::plugin_path() . '/classes/core.php') )
|
99 |
+
require_once( pb_backupbuddy::plugin_path() . '/classes/core.php' );
|
100 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
|
102 |
+
if (file_exists(pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'))
|
103 |
+
require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' );
|
104 |
|
105 |
+
MainWP_Helper::check_classes_exists(array( 'backupbuddy_core', 'pb_backupbuddy_fileoptions' ));
|
106 |
+
MainWP_Helper::check_methods('backupbuddy_core', 'getLogDirectory');
|
107 |
+
|
108 |
+
// Backup type.
|
109 |
+
$pretty_type = array(
|
110 |
+
'full' => 'Full',
|
111 |
+
'db' => 'Database',
|
112 |
+
'files' => 'Files',
|
113 |
+
);
|
114 |
|
115 |
+
$recentBackups_list = glob( backupbuddy_core::getLogDirectory() . 'fileoptions/*.txt' );
|
|
|
|
|
|
|
|
|
|
|
116 |
|
|
|
117 |
|
118 |
+
foreach( $recentBackups_list as $backup_fileoptions ) {
|
|
|
|
|
119 |
|
120 |
+
$backup = new pb_backupbuddy_fileoptions( $backup_fileoptions, $read_only = true );
|
121 |
+
if ( method_exists($backup, 'is_ok') && true !== ( $result = $backup->is_ok() ) ) {
|
122 |
+
continue;
|
123 |
+
}
|
|
|
124 |
|
125 |
+
$backup = &$backup->options;
|
|
|
|
|
|
|
|
|
126 |
|
127 |
+
if ( !isset( $backup['serial'] ) || ( $backup['serial'] == '' ) ) {
|
128 |
+
continue;
|
129 |
+
}
|
130 |
|
131 |
+
if ( ( $backup['finish_time'] >= $backup['start_time'] ) && ( 0 != $backup['start_time'] ) ) {
|
132 |
+
// it is ok
|
133 |
+
} else {
|
134 |
+
continue;
|
135 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
|
137 |
+
$backupType = '';
|
138 |
+
if ( isset( $backup['profile'] ) && isset( $backup['profile']['type'] ) ) {
|
139 |
+
if (true === MainWP_Helper::check_properties('pb_backupbuddy', 'format', true)) {
|
140 |
+
if (true === MainWP_Helper::check_methods(pb_backupbuddy::$format, array( 'prettify' ), true)) {
|
141 |
+
$backupType = pb_backupbuddy::$format->prettify( $backup['profile']['type'], $pretty_type );
|
142 |
+
}
|
143 |
+
}
|
144 |
+
} else {
|
145 |
+
if (true === MainWP_Helper::check_methods('backupbuddy_core', array( 'pretty_backup_type', 'getBackupTypeFromFile' ), true)) {
|
146 |
+
$backupType = backupbuddy_core::pretty_backup_type( backupbuddy_core::getBackupTypeFromFile( $backup['archive_file'] ) );
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
if ( '' == $backupType ) {
|
151 |
+
$backupType = 'Unknown';
|
152 |
+
}
|
153 |
+
|
154 |
+
$finish_time = $backup['finish_time'];
|
155 |
+
$message = 'BackupBuddy ' . $backupType . ' finished';
|
156 |
+
if (!empty($finish_time)) {
|
157 |
+
do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time);
|
158 |
+
MainWP_Helper::update_lasttime_backup('backupbuddy', $finish_time); // to support backup before update feature
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
if ( file_exists(pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php') ) {
|
163 |
+
require_once( pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php' );
|
164 |
+
|
165 |
+
MainWP_Helper::check_classes_exists(array( 'backupbuddy_live_periodic' ));
|
166 |
+
MainWP_Helper::check_methods('backupbuddy_live_periodic', 'get_stats');
|
167 |
+
|
168 |
+
$state = backupbuddy_live_periodic::get_stats();
|
169 |
+
if (is_array($state) && isset($state['stats'])) {
|
170 |
+
|
171 |
+
if ( is_array($state['stats'] ) && isset( $state['stats']['last_remote_snapshot'] )) {
|
172 |
+
if (isset( $state['stats']['last_remote_snapshot_response'] )) {
|
173 |
+
$resp = $state['stats']['last_remote_snapshot_response'];
|
174 |
+
if ( isset( $resp['success'] ) && $resp['success']) {
|
175 |
+
$finish_time = $state['stats']['last_remote_snapshot'];
|
176 |
+
$backupType = 'Live Backup to cloud';
|
177 |
+
$message = 'BackupBuddy ' . $backupType . ' finished';
|
178 |
+
if (!empty($finish_time)) {
|
179 |
+
do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time);
|
180 |
+
MainWP_Helper::update_lasttime_backup('backupbuddy', $finish_time); // to support backup before update feature
|
181 |
+
}
|
182 |
+
|
183 |
+
}
|
184 |
+
}
|
185 |
+
}
|
186 |
+
|
187 |
+
}
|
188 |
+
}
|
189 |
+
} catch( Exception $e ) {
|
190 |
+
|
191 |
+
}
|
192 |
}
|
193 |
|
194 |
public function action() {
|
366 |
$type = isset($_POST['type']) ? $_POST['type'] : '';
|
367 |
|
368 |
if ($type !== 'general_settings' && $type !== 'advanced_settings' && $type !== 'all' ) {
|
369 |
+
return array('error' => __('Invalid data. Please check and try again.') );
|
370 |
}
|
371 |
|
372 |
$filter_advanced_settings = array(
|
722 |
return $information;
|
723 |
}
|
724 |
|
725 |
+
// ok
|
726 |
+
public function syncOthersData( $information, $data = array() ) {
|
727 |
+
if ( isset( $data['syncBackupBuddy'] ) && $data['syncBackupBuddy'] ) {
|
728 |
+
try {
|
729 |
+
$information['syncBackupBuddy'] = $this->get_sync_data();
|
730 |
+
} catch(Exception $e) {
|
731 |
+
|
732 |
+
}
|
733 |
+
}
|
734 |
+
return $information;
|
735 |
+
}
|
736 |
+
|
737 |
+
// ok
|
738 |
public function get_sync_data() {
|
|
|
|
|
|
|
|
|
|
|
|
|
739 |
|
740 |
+
try {
|
741 |
+
if ( ! class_exists( 'backupbuddy_core' ) ) {
|
742 |
+
MainWP_Helper::check_classes_exists('pb_backupbuddy');
|
743 |
+
MainWP_Helper::check_methods('pb_backupbuddy', array( 'plugin_path' ) );
|
744 |
+
|
745 |
+
$plugin_path = pb_backupbuddy::plugin_path();
|
746 |
+
if (file_exists($plugin_path . '/classes/core.php'))
|
747 |
+
require_once( $plugin_path . '/classes/core.php' );
|
748 |
+
}
|
749 |
+
|
750 |
+
MainWP_Helper::check_classes_exists('backupbuddy_core');
|
751 |
+
MainWP_Helper::check_methods('backupbuddy_core', array( 'get_plugins_root', 'get_themes_root', 'get_media_root' ) );
|
752 |
+
|
753 |
+
$data = array();
|
754 |
+
$data['plugins_root'] = backupbuddy_core::get_plugins_root();
|
755 |
+
$data['themes_root'] = backupbuddy_core::get_themes_root();
|
756 |
+
$data['media_root'] = backupbuddy_core::get_media_root();
|
757 |
+
$data['additional_tables'] = $this->pb_additional_tables();
|
758 |
+
$data['abspath'] = ABSPATH;
|
759 |
+
return $data;
|
760 |
+
} catch(Exception $e) {
|
761 |
+
// not exit here
|
762 |
+
}
|
763 |
|
764 |
+
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
765 |
}
|
766 |
|
767 |
function backup_list() {
|
1016 |
|
1017 |
}
|
1018 |
|
1019 |
+
// ok
|
1020 |
function pb_additional_tables( $display_size = false ) {
|
1021 |
+
|
1022 |
+
MainWP_Helper::check_classes_exists('pb_backupbuddy');
|
1023 |
+
MainWP_Helper::check_methods('pb_backupbuddy', 'plugin_url');
|
1024 |
+
MainWP_Helper::check_properties('pb_backupbuddy', 'format');
|
1025 |
+
MainWP_Helper::check_methods(pb_backupbuddy::$format, 'file_size');
|
1026 |
+
|
1027 |
+
|
1028 |
$return = '';
|
1029 |
$size_string = '';
|
1030 |
|
2508 |
backupbuddy_live::send_trim_settings();
|
2509 |
return array('ok' => 1);
|
2510 |
} else {
|
2511 |
+
$error = 'Invalid data. Please check and try again.';
|
2512 |
}
|
2513 |
return array('error' => $error);
|
2514 |
}
|
2527 |
require_once( pb_backupbuddy::plugin_path() . '/destinations/live/init.php' );
|
2528 |
delete_transient( pb_backupbuddy_destination_live::LIVE_ACTION_TRANSIENT_NAME );
|
2529 |
} else {
|
2530 |
+
$error = 'Error: destination not found.';
|
2531 |
}
|
2532 |
$return['ok'] = 1;
|
2533 |
} else {
|
class/class-mainwp-child-back-up-wordpress.php
CHANGED
@@ -14,11 +14,18 @@ class MainWP_Child_Back_Up_Wordpress {
|
|
14 |
public function __construct() {
|
15 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
16 |
if ( is_plugin_active( 'backupwordpress/backupwordpress.php' ) ) {
|
17 |
-
|
|
|
|
|
|
|
18 |
}
|
|
|
19 |
}
|
20 |
|
21 |
public function init() {
|
|
|
|
|
|
|
22 |
if ( get_option( 'mainwp_backupwordpress_ext_enabled' ) !== 'Y' ) return;
|
23 |
if (!$this->is_plugin_installed) return;
|
24 |
|
@@ -115,25 +122,38 @@ class MainWP_Child_Back_Up_Wordpress {
|
|
115 |
|
116 |
return $schedule_id;
|
117 |
}
|
118 |
-
|
119 |
-
public function
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
|
|
|
|
|
|
125 |
}
|
126 |
-
|
|
|
127 |
private function get_sync_data() {
|
|
|
|
|
|
|
128 |
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
|
129 |
$schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
|
130 |
$backups_time = array();
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
|
138 |
$lasttime_backup = 0;
|
139 |
if ( ! empty( $backups_time ) ) {
|
@@ -152,28 +172,41 @@ class MainWP_Child_Back_Up_Wordpress {
|
|
152 |
$this->do_reports_log('backupwordpress');
|
153 |
}
|
154 |
}
|
155 |
-
|
|
|
156 |
public function do_reports_log($ext = '') {
|
157 |
if ( $ext !== 'backupwordpress' ) return;
|
158 |
if (!$this->is_plugin_installed) return;
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
}
|
174 |
}
|
175 |
}
|
176 |
-
}
|
|
|
|
|
177 |
}
|
178 |
|
179 |
function set_showhide() {
|
@@ -348,7 +381,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|
348 |
|
349 |
function hmbkp_request_delete_backup() {
|
350 |
if ( ! isset( $_POST['hmbkp_backuparchive'] ) || empty( $_POST['hmbkp_backuparchive'] ) ) {
|
351 |
-
return array( 'error' => __( 'Invalid data
|
352 |
}
|
353 |
|
354 |
$schedule_id = $this->check_schedule();
|
14 |
public function __construct() {
|
15 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
16 |
if ( is_plugin_active( 'backupwordpress/backupwordpress.php' ) ) {
|
17 |
+
$this->is_plugin_installed = true;
|
18 |
+
if ( version_compare( phpversion(), '5.3', '>=' ) ) {
|
19 |
+
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
20 |
+
}
|
21 |
}
|
22 |
+
|
23 |
}
|
24 |
|
25 |
public function init() {
|
26 |
+
if ( version_compare( phpversion(), '5.3', '<' ) ) {
|
27 |
+
return;
|
28 |
+
}
|
29 |
if ( get_option( 'mainwp_backupwordpress_ext_enabled' ) !== 'Y' ) return;
|
30 |
if (!$this->is_plugin_installed) return;
|
31 |
|
122 |
|
123 |
return $schedule_id;
|
124 |
}
|
125 |
+
// ok
|
126 |
+
public function syncOthersData( $information, $data = array() ) {
|
127 |
+
if ( isset( $data['syncBackUpWordPress'] ) && $data['syncBackUpWordPress'] ) {
|
128 |
+
try {
|
129 |
+
$information['syncBackUpWordPress'] = $this->get_sync_data();
|
130 |
+
} catch(Exception $e) {
|
131 |
+
|
132 |
+
}
|
133 |
+
}
|
134 |
+
return $information;
|
135 |
}
|
136 |
+
|
137 |
+
// ok
|
138 |
private function get_sync_data() {
|
139 |
+
MainWP_Helper::check_classes_exists('HM\BackUpWordPress\Schedules');
|
140 |
+
MainWP_Helper::check_methods('HM\BackUpWordPress\Schedules', array( 'get_instance', 'refresh_schedules', 'get_schedules' ) );
|
141 |
+
|
142 |
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
|
143 |
$schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
|
144 |
$backups_time = array();
|
145 |
+
|
146 |
+
if (is_array($schedules) && count($schedules)) {
|
147 |
+
$check = current($schedules);
|
148 |
+
MainWP_Helper::check_methods($check, array( 'get_backups' ) );
|
149 |
+
|
150 |
+
foreach ( $schedules as $sche ) {
|
151 |
+
$existing_backup = $sche->get_backups();
|
152 |
+
if ( ! empty( $existing_backup ) ) {
|
153 |
+
$backups_time = array_merge( $backups_time, array_keys( $existing_backup ) );
|
154 |
+
}
|
155 |
+
}
|
156 |
+
}
|
157 |
|
158 |
$lasttime_backup = 0;
|
159 |
if ( ! empty( $backups_time ) ) {
|
172 |
$this->do_reports_log('backupwordpress');
|
173 |
}
|
174 |
}
|
175 |
+
|
176 |
+
// ok
|
177 |
public function do_reports_log($ext = '') {
|
178 |
if ( $ext !== 'backupwordpress' ) return;
|
179 |
if (!$this->is_plugin_installed) return;
|
180 |
+
|
181 |
+
try {
|
182 |
+
MainWP_Helper::check_classes_exists('HM\BackUpWordPress\Schedules');
|
183 |
+
MainWP_Helper::check_methods('HM\BackUpWordPress\Schedules', array( 'get_instance', 'refresh_schedules', 'get_schedules' ));
|
184 |
+
|
185 |
+
// Refresh the schedules from the database to make sure we have the latest changes
|
186 |
+
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
|
187 |
+
$schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
|
188 |
+
if (is_array($schedules) && count($schedules) > 0) {
|
189 |
+
$check = current($schedules);
|
190 |
+
MainWP_Helper::check_methods($check, array( 'get_backups', 'get_type' ));
|
191 |
+
|
192 |
+
foreach($schedules as $schedule) {
|
193 |
+
foreach ( $schedule->get_backups() as $file ) {
|
194 |
+
$backup_type = $schedule->get_type();
|
195 |
+
$message = "BackupWordpres backup " . $backup_type . ' finished';
|
196 |
+
$destination = "N/A";
|
197 |
+
if ( file_exists( $file ) ) {
|
198 |
+
$date = @filemtime( $file );
|
199 |
+
if ( !empty( $date ) ) {
|
200 |
+
do_action( "backupwordpress_backup", $destination, $message, 'finished', $backup_type, $date );
|
201 |
+
MainWP_Helper::update_lasttime_backup('backupwordpress', $date); // to support backup before update feature
|
202 |
+
}
|
203 |
+
}
|
204 |
}
|
205 |
}
|
206 |
}
|
207 |
+
} catch(Exception $e) {
|
208 |
+
|
209 |
+
}
|
210 |
}
|
211 |
|
212 |
function set_showhide() {
|
381 |
|
382 |
function hmbkp_request_delete_backup() {
|
383 |
if ( ! isset( $_POST['hmbkp_backuparchive'] ) || empty( $_POST['hmbkp_backuparchive'] ) ) {
|
384 |
+
return array( 'error' => __( 'Invalid data. Please check and try again.', 'mainwp-child' ) );
|
385 |
}
|
386 |
|
387 |
$schedule_id = $this->check_schedule();
|
class/class-mainwp-child-back-wp-up.php
CHANGED
@@ -51,25 +51,38 @@ class MainWP_Child_Back_WP_Up {
|
|
51 |
|
52 |
public function __construct() {
|
53 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
}
|
72 |
-
|
73 |
public function action() {
|
74 |
if ( ! $this->is_backwpup_installed ) {
|
75 |
MainWP_Helper::write( array( 'error' => __( 'Please install BackWPup plugin on child website', $this->plugin_translate ) ) );
|
@@ -203,53 +216,68 @@ class MainWP_Child_Back_WP_Up {
|
|
203 |
$this->do_reports_log('backwpup');
|
204 |
}
|
205 |
}
|
206 |
-
|
207 |
public function do_reports_log($ext = '') {
|
208 |
if ( $ext !== 'backwpup' ) return;
|
209 |
if (!$this->is_backwpup_installed)
|
210 |
return;
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
}
|
240 |
|
|
|
241 |
function syncOthersData( $information, $data = array() ) {
|
242 |
-
if ( isset( $data['syncBackwpupData'] ) ) {
|
243 |
-
|
244 |
-
|
245 |
-
'
|
246 |
-
|
|
|
|
|
|
|
|
|
247 |
}
|
248 |
return $information;
|
249 |
}
|
250 |
|
251 |
function get_destinations_list() {
|
252 |
-
|
|
|
|
|
|
|
253 |
$jobdest = array();
|
254 |
$jobids = BackWPup_Option::get_job_ids();
|
255 |
$destinations = BackWPup::get_registered_destinations();
|
@@ -262,11 +290,14 @@ class MainWP_Child_Back_WP_Up {
|
|
262 |
if ( ! $destinations[ $dest ][ 'class' ] ) {
|
263 |
continue;
|
264 |
}
|
|
|
265 |
$dest_class = BackWPup::get_destination( $dest );
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
|
|
|
|
270 |
}
|
271 |
}
|
272 |
|
51 |
|
52 |
public function __construct() {
|
53 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
54 |
+
|
55 |
+
try {
|
56 |
+
|
57 |
+
if ( is_plugin_active( 'backwpup-pro/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup-pro/backwpup.php' ) ) {
|
58 |
+
$file_path1 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/backwpup.php';
|
59 |
+
$file_path2 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/inc/pro/class-pro.php';
|
60 |
+
MainWP_Helper::check_files_exists(array( $file_path1, $file_path2 ));
|
61 |
+
require_once( $file_path1 );
|
62 |
+
require_once( $file_path2 );
|
63 |
+
$this->is_backwpup_installed = true;
|
64 |
+
$this->is_backwpup_pro = true;
|
65 |
+
} else if ( is_plugin_active( 'backwpup/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php' ) ) {
|
66 |
+
$file_path = plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php';
|
67 |
+
MainWP_Helper::check_files_exists(array( $file_path ));
|
68 |
+
require_once( $file_path );
|
69 |
+
$this->is_backwpup_installed = true;
|
70 |
+
}
|
71 |
+
|
72 |
+
if ($this->is_backwpup_installed) {
|
73 |
+
MainWP_Helper::check_classes_exists('BackWPup');
|
74 |
+
MainWP_Helper::check_methods('get_instance');
|
75 |
+
BackWPup::get_instance();
|
76 |
+
|
77 |
+
add_action( 'wp_ajax_mainwp_backwpup_download_backup', array( $this, 'download_backup' ) );
|
78 |
+
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
79 |
+
}
|
80 |
+
} catch ( Exception $e) {
|
81 |
+
// do not exit()
|
82 |
+
$this->is_backwpup_installed = false;
|
83 |
+
}
|
84 |
}
|
85 |
+
|
86 |
public function action() {
|
87 |
if ( ! $this->is_backwpup_installed ) {
|
88 |
MainWP_Helper::write( array( 'error' => __( 'Please install BackWPup plugin on child website', $this->plugin_translate ) ) );
|
216 |
$this->do_reports_log('backwpup');
|
217 |
}
|
218 |
}
|
219 |
+
// ok
|
220 |
public function do_reports_log($ext = '') {
|
221 |
if ( $ext !== 'backwpup' ) return;
|
222 |
if (!$this->is_backwpup_installed)
|
223 |
return;
|
224 |
+
|
225 |
+
try {
|
226 |
+
MainWP_Helper::check_classes_exists(array('BackWPup'));
|
227 |
+
MainWP_Helper::check_methods('BackWPup', array( 'get_registered_destinations', 'get_destination' ));
|
228 |
+
|
229 |
+
$destinations = BackWPup::get_registered_destinations();
|
230 |
+
$jobdests = $this->get_destinations_list();
|
231 |
+
|
232 |
+
if ( !empty( $jobdests ) ) {
|
233 |
+
foreach ($jobdests as $jobdest) {
|
234 |
+
list( $jobid, $dest ) = explode( '_', $jobdest );
|
235 |
+
if ( ! empty( $destinations[ $dest ][ 'class' ] ) ) {
|
236 |
+
$dest_object = BackWPup::get_destination( $dest );
|
237 |
+
$items = $dest_object->file_get_list( $jobdest );
|
238 |
+
//if no items brake
|
239 |
+
if ( $items ) {
|
240 |
+
foreach ( $items as $ma ) {
|
241 |
+
if (isset($ma['time'])) {
|
242 |
+
$backup_time = $ma[ "time" ];
|
243 |
+
$message = 'BackWPup backup finished';
|
244 |
+
$backup_type = 'BackWPup';
|
245 |
+
$destination = "N/A";
|
246 |
+
if (!empty($backup_time)) {
|
247 |
+
do_action( 'mainwp_backwpup_backup', $message, $backup_type, $backup_time );
|
248 |
+
MainWP_Helper::update_lasttime_backup( 'backwpup', $backup_time ); // to support backup before update feature
|
249 |
+
}
|
250 |
+
}
|
251 |
+
}
|
252 |
+
}
|
253 |
+
}
|
254 |
+
}
|
255 |
+
}
|
256 |
+
} catch (Exception $ex) {
|
257 |
+
|
258 |
+
}
|
259 |
}
|
260 |
|
261 |
+
// ok
|
262 |
function syncOthersData( $information, $data = array() ) {
|
263 |
+
if ( isset( $data['syncBackwpupData'] ) && $data['syncBackwpupData'] ) {
|
264 |
+
try{
|
265 |
+
$lastbackup = MainWP_Helper::get_lasttime_backup('backwpup');
|
266 |
+
$information['syncBackwpupData'] = array(
|
267 |
+
'lastbackup' => $lastbackup
|
268 |
+
);
|
269 |
+
} catch(Exception $e) {
|
270 |
+
|
271 |
+
}
|
272 |
}
|
273 |
return $information;
|
274 |
}
|
275 |
|
276 |
function get_destinations_list() {
|
277 |
+
MainWP_Helper::check_classes_exists(array('BackWPup', 'BackWPup_Option'));
|
278 |
+
MainWP_Helper::check_methods('BackWPup', array( 'get_registered_destinations', 'get_destination' ));
|
279 |
+
MainWP_Helper::check_methods('BackWPup_Option', array( 'get_job_ids', 'get' ));
|
280 |
+
|
281 |
$jobdest = array();
|
282 |
$jobids = BackWPup_Option::get_job_ids();
|
283 |
$destinations = BackWPup::get_registered_destinations();
|
290 |
if ( ! $destinations[ $dest ][ 'class' ] ) {
|
291 |
continue;
|
292 |
}
|
293 |
+
|
294 |
$dest_class = BackWPup::get_destination( $dest );
|
295 |
+
if ($dest_class && method_exists($dest_class, 'file_get_list')) {
|
296 |
+
$can_do_dest = $dest_class->file_get_list( $jobid . '_' . $dest );
|
297 |
+
if ( ! empty( $can_do_dest ) ) {
|
298 |
+
$jobdest[ ] = $jobid . '_' . $dest;
|
299 |
+
}
|
300 |
+
}
|
301 |
}
|
302 |
}
|
303 |
|
class/class-mainwp-child-branding.php
CHANGED
@@ -132,7 +132,8 @@ class MainWP_Child_Branding {
|
|
132 |
'remove_widget_activity' => $settings['child_remove_widget_activity'],
|
133 |
'remove_widget_quick' => $settings['child_remove_widget_quick'],
|
134 |
'remove_widget_news' => $settings['child_remove_widget_news'],
|
135 |
-
'login_image_link' => $settings['child_login_image_link'],
|
|
|
136 |
'site_generator' => $settings['child_site_generator'],
|
137 |
'generator_link' => $settings['child_generator_link'],
|
138 |
'admin_css' => $settings['child_admin_css'],
|
@@ -340,7 +341,8 @@ class MainWP_Child_Branding {
|
|
340 |
add_action( 'login_enqueue_scripts', array( &$this, 'custom_login_css' ) );
|
341 |
add_filter( 'gettext', array( &$this, 'custom_gettext' ), 99, 3 );
|
342 |
add_action( 'login_head', array( &$this, 'custom_login_logo' ) );
|
343 |
-
add_filter( 'login_headerurl', array( &$this, 'custom_login_headerurl' ) );
|
|
|
344 |
add_action( 'wp_head', array( &$this, 'custom_favicon_frontend' ) );
|
345 |
if ( isset( $extra_setting['dashboard_footer'] ) && ! empty( $extra_setting['dashboard_footer'] ) ) {
|
346 |
//remove_filter( 'update_footer', 'core_update_footer' );
|
@@ -576,6 +578,16 @@ class MainWP_Child_Branding {
|
|
576 |
return $value;
|
577 |
}
|
578 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
579 |
function custom_gettext( $translations, $text, $domain = 'default' ) {
|
580 |
$extra_setting = $this->settings['extra_settings'];
|
581 |
$texts_replace = $extra_setting['texts_replace'];
|
132 |
'remove_widget_activity' => $settings['child_remove_widget_activity'],
|
133 |
'remove_widget_quick' => $settings['child_remove_widget_quick'],
|
134 |
'remove_widget_news' => $settings['child_remove_widget_news'],
|
135 |
+
'login_image_link' => $settings['child_login_image_link'],
|
136 |
+
'login_image_title' => $settings['child_login_image_title'],
|
137 |
'site_generator' => $settings['child_site_generator'],
|
138 |
'generator_link' => $settings['child_generator_link'],
|
139 |
'admin_css' => $settings['child_admin_css'],
|
341 |
add_action( 'login_enqueue_scripts', array( &$this, 'custom_login_css' ) );
|
342 |
add_filter( 'gettext', array( &$this, 'custom_gettext' ), 99, 3 );
|
343 |
add_action( 'login_head', array( &$this, 'custom_login_logo' ) );
|
344 |
+
add_filter( 'login_headerurl', array( &$this, 'custom_login_headerurl' ) );
|
345 |
+
add_filter( 'login_headertitle', array( &$this, 'custom_login_headertitle' ) );
|
346 |
add_action( 'wp_head', array( &$this, 'custom_favicon_frontend' ) );
|
347 |
if ( isset( $extra_setting['dashboard_footer'] ) && ! empty( $extra_setting['dashboard_footer'] ) ) {
|
348 |
//remove_filter( 'update_footer', 'core_update_footer' );
|
578 |
return $value;
|
579 |
}
|
580 |
|
581 |
+
function custom_login_headertitle( $value ) {
|
582 |
+
|
583 |
+
$extra_setting = $this->settings['extra_settings'];
|
584 |
+
if ( isset( $extra_setting['login_image_title'] ) && ! empty( $extra_setting['login_image_title'] ) ) {
|
585 |
+
return $extra_setting['login_image_title'];
|
586 |
+
}
|
587 |
+
|
588 |
+
return $value;
|
589 |
+
}
|
590 |
+
|
591 |
function custom_gettext( $translations, $text, $domain = 'default' ) {
|
592 |
$extra_setting = $this->settings['extra_settings'];
|
593 |
$texts_replace = $extra_setting['texts_replace'];
|
class/class-mainwp-child-ithemes-security.php
CHANGED
@@ -23,18 +23,17 @@ class MainWP_Child_iThemes_Security {
|
|
23 |
|
24 |
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
25 |
}
|
26 |
-
|
27 |
function syncOthersData( $information, $data = array() ) {
|
28 |
if ( is_array( $data ) && isset( $data['ithemeExtActivated'] ) && ( 'yes' === $data['ithemeExtActivated'] ) ) {
|
29 |
-
|
30 |
-
'
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
}
|
38 |
return $information;
|
39 |
}
|
40 |
|
@@ -58,9 +57,6 @@ class MainWP_Child_iThemes_Security {
|
|
58 |
case 'save_settings':
|
59 |
$information = $this->save_settings();
|
60 |
break;
|
61 |
-
// case 'whitelist':
|
62 |
-
// $information = $this->whitelist();
|
63 |
-
// break;
|
64 |
case 'whitelist_release':
|
65 |
$information = $this->whitelist_release();
|
66 |
break;
|
@@ -73,18 +69,12 @@ class MainWP_Child_iThemes_Security {
|
|
73 |
case 'database_prefix':
|
74 |
$information = $this->change_database_prefix();
|
75 |
break;
|
76 |
-
// case 'api_key':
|
77 |
-
// $information = $this->api_key();
|
78 |
-
// break;
|
79 |
case 'reset_api_key':
|
80 |
$information = $this->reset_api_key();
|
81 |
break;
|
82 |
case 'malware_scan':
|
83 |
$information = $this->malware_scan();
|
84 |
break;
|
85 |
-
// case 'malware_get_scan_results':
|
86 |
-
// $information = $this->malware_get_scan_results();
|
87 |
-
// break;
|
88 |
case 'clear_all_logs':
|
89 |
$information = $this->purge_logs();
|
90 |
break;
|
@@ -1169,8 +1159,6 @@ class MainWP_Child_iThemes_Security {
|
|
1169 |
global $mainwp_itsec_modules_path;
|
1170 |
require_once( $mainwp_itsec_modules_path . 'security-check/scanner.php' );
|
1171 |
require_once( $mainwp_itsec_modules_path . 'security-check/feedback-renderer.php' );
|
1172 |
-
// ITSEC_Security_Check_Scanner::run();
|
1173 |
-
// $response = ITSEC_Response::get_response();
|
1174 |
$results = ITSEC_Security_Check_Scanner::get_results();
|
1175 |
ob_start();
|
1176 |
ITSEC_Security_Check_Feedback_Renderer::render( $results );
|
@@ -1179,6 +1167,7 @@ class MainWP_Child_iThemes_Security {
|
|
1179 |
}
|
1180 |
|
1181 |
// source from itheme plugin
|
|
|
1182 |
public function get_available_admin_users_and_roles() {
|
1183 |
if ( is_callable( 'wp_roles' ) ) {
|
1184 |
$roles = wp_roles();
|
23 |
|
24 |
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
25 |
}
|
26 |
+
// ok
|
27 |
function syncOthersData( $information, $data = array() ) {
|
28 |
if ( is_array( $data ) && isset( $data['ithemeExtActivated'] ) && ( 'yes' === $data['ithemeExtActivated'] ) ) {
|
29 |
+
try{
|
30 |
+
$information['syncIThemeData'] = array(
|
31 |
+
'users_and_roles' => $this->get_available_admin_users_and_roles()
|
32 |
+
);
|
33 |
+
} catch(Exception $e) {
|
34 |
+
error_log($e->getMessage());
|
35 |
+
}
|
36 |
+
}
|
|
|
37 |
return $information;
|
38 |
}
|
39 |
|
57 |
case 'save_settings':
|
58 |
$information = $this->save_settings();
|
59 |
break;
|
|
|
|
|
|
|
60 |
case 'whitelist_release':
|
61 |
$information = $this->whitelist_release();
|
62 |
break;
|
69 |
case 'database_prefix':
|
70 |
$information = $this->change_database_prefix();
|
71 |
break;
|
|
|
|
|
|
|
72 |
case 'reset_api_key':
|
73 |
$information = $this->reset_api_key();
|
74 |
break;
|
75 |
case 'malware_scan':
|
76 |
$information = $this->malware_scan();
|
77 |
break;
|
|
|
|
|
|
|
78 |
case 'clear_all_logs':
|
79 |
$information = $this->purge_logs();
|
80 |
break;
|
1159 |
global $mainwp_itsec_modules_path;
|
1160 |
require_once( $mainwp_itsec_modules_path . 'security-check/scanner.php' );
|
1161 |
require_once( $mainwp_itsec_modules_path . 'security-check/feedback-renderer.php' );
|
|
|
|
|
1162 |
$results = ITSEC_Security_Check_Scanner::get_results();
|
1163 |
ob_start();
|
1164 |
ITSEC_Security_Check_Feedback_Renderer::render( $results );
|
1167 |
}
|
1168 |
|
1169 |
// source from itheme plugin
|
1170 |
+
// ok
|
1171 |
public function get_available_admin_users_and_roles() {
|
1172 |
if ( is_callable( 'wp_roles' ) ) {
|
1173 |
$roles = wp_roles();
|
class/class-mainwp-child-links-checker.php
CHANGED
@@ -18,6 +18,12 @@ class MainWP_Child_Links_Checker {
|
|
18 |
if ( is_plugin_active( 'broken-link-checker/broken-link-checker.php' ) ) {
|
19 |
$this->is_plugin_installed = true;
|
20 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
}
|
22 |
|
23 |
public function action() {
|
@@ -27,38 +33,44 @@ class MainWP_Child_Links_Checker {
|
|
27 |
MainWP_Helper::write( $information );
|
28 |
}
|
29 |
blc_init();
|
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 |
|
@@ -182,7 +194,20 @@ class MainWP_Child_Links_Checker {
|
|
182 |
return $information;
|
183 |
}
|
184 |
|
185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
$information = array();
|
187 |
$data = $this->get_count_links();
|
188 |
if (is_array($data))
|
@@ -190,12 +215,24 @@ class MainWP_Child_Links_Checker {
|
|
190 |
return $information;
|
191 |
}
|
192 |
|
193 |
-
function
|
|
|
194 |
if (!defined('BLC_DIRECTORY')) return;
|
195 |
-
|
196 |
-
|
197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
$blc_link_query = blcLinkQuery::getInstance();
|
|
|
|
|
|
|
199 |
$total = $blc_link_query->get_filter_links( 'all', array( 'count_only' => true ) );
|
200 |
|
201 |
|
@@ -213,7 +250,7 @@ class MainWP_Child_Links_Checker {
|
|
213 |
$params['offset'] = $offset;
|
214 |
}
|
215 |
|
216 |
-
$link_data = $this->
|
217 |
|
218 |
$total_sync = 0;
|
219 |
if ($offset){
|
@@ -241,12 +278,23 @@ class MainWP_Child_Links_Checker {
|
|
241 |
|
242 |
function get_count_links() {
|
243 |
if (!defined('BLC_DIRECTORY')) return;
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
$data = array();
|
249 |
$blc_link_query = blcLinkQuery::getInstance();
|
|
|
|
|
|
|
250 |
$data['broken'] = $blc_link_query->get_filter_links( 'broken', array( 'count_only' => true ) );
|
251 |
$data['redirects'] = $blc_link_query->get_filter_links( 'redirects', array( 'count_only' => true ) );
|
252 |
$data['dismissed'] = $blc_link_query->get_filter_links( 'dismissed', array( 'count_only' => true ) );
|
@@ -255,8 +303,11 @@ class MainWP_Child_Links_Checker {
|
|
255 |
return $data;
|
256 |
}
|
257 |
|
258 |
-
function
|
259 |
|
|
|
|
|
|
|
260 |
$links = blc_get_links( $params );
|
261 |
|
262 |
$filter_fields = array(
|
@@ -320,22 +371,29 @@ class MainWP_Child_Links_Checker {
|
|
320 |
|
321 |
$get_link = new blcLink( intval( $link->link_id ) );
|
322 |
if ( $get_link->valid() ) {
|
|
|
323 |
$instances = $get_link->get_instances();
|
324 |
}
|
325 |
|
326 |
if ( ! empty( $instances ) ) {
|
327 |
-
|
328 |
-
|
|
|
|
|
329 |
$new_link->link_text = $first_instance->ui_get_link_text();
|
330 |
$extra_info['count_instance'] = count( $instances );
|
331 |
$container = $first_instance->get_container();
|
332 |
|
333 |
/** @var blcContainer $container */
|
334 |
|
335 |
-
if ( ! empty( $container ) /* && ($container instanceof blcAnyPostContainer) */ ) {
|
336 |
-
|
337 |
-
|
338 |
-
|
|
|
|
|
|
|
|
|
339 |
}
|
340 |
|
341 |
$can_edit_text = false;
|
@@ -584,8 +642,11 @@ class MainWP_Child_Links_Checker {
|
|
584 |
} else {
|
585 |
$image = 'font-awesome/font-awesome-comment-alt.png';
|
586 |
}
|
587 |
-
|
588 |
-
|
|
|
|
|
|
|
589 |
|
590 |
//Display a small text sample from the comment
|
591 |
$text_sample = strip_tags( $comment->comment_content );
|
18 |
if ( is_plugin_active( 'broken-link-checker/broken-link-checker.php' ) ) {
|
19 |
$this->is_plugin_installed = true;
|
20 |
}
|
21 |
+
|
22 |
+
if ( !$this->is_plugin_installed )
|
23 |
+
return;
|
24 |
+
|
25 |
+
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
26 |
+
|
27 |
}
|
28 |
|
29 |
public function action() {
|
33 |
MainWP_Helper::write( $information );
|
34 |
}
|
35 |
blc_init();
|
36 |
+
|
37 |
+
// need this try()
|
38 |
+
try {
|
39 |
+
if ( isset( $_POST['mwp_action'] ) ) {
|
40 |
+
switch ( $_POST['mwp_action'] ) {
|
41 |
+
case 'set_showhide':
|
42 |
+
$information = $this->set_showhide();
|
43 |
+
break;
|
44 |
+
case 'sync_data':
|
45 |
+
$information = $this->get_sync_data();
|
46 |
+
break;
|
47 |
+
case 'sync_links_data':
|
48 |
+
$information = $this->get_links_data();
|
49 |
+
break;
|
50 |
+
case 'edit_link':
|
51 |
+
$information = $this->edit_link();
|
52 |
+
break;
|
53 |
+
case 'unlink':
|
54 |
+
$information = $this->unlink();
|
55 |
+
break;
|
56 |
+
case 'set_dismiss':
|
57 |
+
$information = $this->set_link_dismissed();
|
58 |
+
break;
|
59 |
+
case 'discard':
|
60 |
+
$information = $this->discard();
|
61 |
+
break;
|
62 |
+
case 'save_settings':
|
63 |
+
$information = $this->save_settings();
|
64 |
+
break;
|
65 |
+
case 'force_recheck':
|
66 |
+
$information = $this->force_recheck();
|
67 |
+
break;
|
68 |
+
}
|
69 |
+
}
|
70 |
+
MainWP_Helper::write( $information );
|
71 |
+
} catch(Exception $e) {
|
72 |
+
MainWP_Helper::write( array('error' => $e->getMessage()) );
|
73 |
+
}
|
74 |
}
|
75 |
|
76 |
|
194 |
return $information;
|
195 |
}
|
196 |
|
197 |
+
// ok
|
198 |
+
public function syncOthersData( $information, $data = array() ) {
|
199 |
+
if ( isset( $data['syncBrokenLinksCheckerData'] ) && $data['syncBrokenLinksCheckerData'] ) {
|
200 |
+
try{
|
201 |
+
$information['syncBrokenLinksCheckerData'] = $this->get_sync_data();
|
202 |
+
} catch(Exception $e) {
|
203 |
+
|
204 |
+
}
|
205 |
+
}
|
206 |
+
return $information;
|
207 |
+
}
|
208 |
+
|
209 |
+
|
210 |
+
function get_sync_data( $strategy = '' ) {
|
211 |
$information = array();
|
212 |
$data = $this->get_count_links();
|
213 |
if (is_array($data))
|
215 |
return $information;
|
216 |
}
|
217 |
|
218 |
+
function get_links_data() {
|
219 |
+
|
220 |
if (!defined('BLC_DIRECTORY')) return;
|
221 |
+
|
222 |
+
$file_path1 = BLC_DIRECTORY . '/includes/link-query.php';
|
223 |
+
$file_path2 = BLC_DIRECTORY . '/includes/modules.php';
|
224 |
+
MainWP_Helper::check_files_exists(array( $file_path1, $file_path2 ));
|
225 |
+
|
226 |
+
require_once $file_path1;
|
227 |
+
require_once $file_path2;
|
228 |
+
|
229 |
+
MainWP_Helper::check_classes_exists('blcLinkQuery');
|
230 |
+
MainWP_Helper::check_methods('blcLinkQuery', 'getInstance');
|
231 |
+
|
232 |
$blc_link_query = blcLinkQuery::getInstance();
|
233 |
+
|
234 |
+
MainWP_Helper::check_methods($blc_link_query, 'get_filter_links');
|
235 |
+
|
236 |
$total = $blc_link_query->get_filter_links( 'all', array( 'count_only' => true ) );
|
237 |
|
238 |
|
250 |
$params['offset'] = $offset;
|
251 |
}
|
252 |
|
253 |
+
$link_data = $this->links_checker_data($params);
|
254 |
|
255 |
$total_sync = 0;
|
256 |
if ($offset){
|
278 |
|
279 |
function get_count_links() {
|
280 |
if (!defined('BLC_DIRECTORY')) return;
|
281 |
+
|
282 |
+
$file_path1 = BLC_DIRECTORY . '/includes/link-query.php';
|
283 |
+
$file_path2 = BLC_DIRECTORY . '/includes/modules.php';
|
284 |
+
|
285 |
+
MainWP_Helper::check_files_exists(array( $file_path1, $file_path2 ));
|
286 |
+
|
287 |
+
require_once $file_path1;
|
288 |
+
require_once $file_path2;
|
289 |
+
|
290 |
+
MainWP_Helper::check_classes_exists('blcLinkQuery');
|
291 |
+
MainWP_Helper::check_methods('blcLinkQuery', 'getInstance');
|
292 |
+
|
293 |
$data = array();
|
294 |
$blc_link_query = blcLinkQuery::getInstance();
|
295 |
+
|
296 |
+
MainWP_Helper::check_methods($blc_link_query, 'get_filter_links');
|
297 |
+
|
298 |
$data['broken'] = $blc_link_query->get_filter_links( 'broken', array( 'count_only' => true ) );
|
299 |
$data['redirects'] = $blc_link_query->get_filter_links( 'redirects', array( 'count_only' => true ) );
|
300 |
$data['dismissed'] = $blc_link_query->get_filter_links( 'dismissed', array( 'count_only' => true ) );
|
303 |
return $data;
|
304 |
}
|
305 |
|
306 |
+
function links_checker_data($params) {
|
307 |
|
308 |
+
MainWP_Helper::check_functions('blc_get_links');
|
309 |
+
MainWP_Helper::check_classes_exists('blcLink');
|
310 |
+
|
311 |
$links = blc_get_links( $params );
|
312 |
|
313 |
$filter_fields = array(
|
371 |
|
372 |
$get_link = new blcLink( intval( $link->link_id ) );
|
373 |
if ( $get_link->valid() ) {
|
374 |
+
MainWP_Helper::check_methods($get_link, 'get_instances');
|
375 |
$instances = $get_link->get_instances();
|
376 |
}
|
377 |
|
378 |
if ( ! empty( $instances ) ) {
|
379 |
+
$first_instance = reset( $instances );
|
380 |
+
|
381 |
+
MainWP_Helper::check_methods($first_instance, array( 'ui_get_link_text', 'get_container', 'is_link_text_editable', 'is_url_editable') );
|
382 |
+
|
383 |
$new_link->link_text = $first_instance->ui_get_link_text();
|
384 |
$extra_info['count_instance'] = count( $instances );
|
385 |
$container = $first_instance->get_container();
|
386 |
|
387 |
/** @var blcContainer $container */
|
388 |
|
389 |
+
if ( ! empty( $container ) /* && ($container instanceof blcAnyPostContainer) */ ) {
|
390 |
+
if (true === MainWP_Helper::check_properties($first_instance, array( 'container_field' ), true )) {
|
391 |
+
if (true === MainWP_Helper::check_properties($container, array( 'container_type', 'container_id' ), true )) {
|
392 |
+
$extra_info['container_type'] = $container->container_type;
|
393 |
+
$extra_info['container_id'] = $container->container_id;
|
394 |
+
$extra_info['source_data'] = $this->ui_get_source( $container, $first_instance->container_field );
|
395 |
+
}
|
396 |
+
}
|
397 |
}
|
398 |
|
399 |
$can_edit_text = false;
|
642 |
} else {
|
643 |
$image = 'font-awesome/font-awesome-comment-alt.png';
|
644 |
}
|
645 |
+
|
646 |
+
if (true !== MainWP_Helper::check_methods($container, array( 'get_wrapped_object'), true ))
|
647 |
+
return false;
|
648 |
+
|
649 |
+
$comment = $container->get_wrapped_object();
|
650 |
|
651 |
//Display a small text sample from the comment
|
652 |
$text_sample = strip_tags( $comment->comment_content );
|
class/class-mainwp-child-pagespeed.php
CHANGED
@@ -18,7 +18,12 @@ class MainWP_Child_Pagespeed {
|
|
18 |
if ( is_plugin_active( 'google-pagespeed-insights/google-pagespeed-insights.php' ) ) {
|
19 |
$this->is_plugin_installed = true;
|
20 |
}
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
22 |
add_action( 'mainwp_child_deactivation', array( $this, 'child_deactivation' ) );
|
23 |
}
|
24 |
|
@@ -38,7 +43,7 @@ class MainWP_Child_Pagespeed {
|
|
38 |
$information = $this->set_showhide();
|
39 |
break;
|
40 |
case 'sync_data':
|
41 |
-
$information = $this->
|
42 |
break;
|
43 |
case "check_pages":
|
44 |
$information = $this->check_pages();
|
@@ -61,8 +66,7 @@ class MainWP_Child_Pagespeed {
|
|
61 |
|
62 |
if ( get_option( 'mainwp_pagespeed_hide_plugin' ) === 'hide' ) {
|
63 |
add_filter( 'all_plugins', array( $this, 'hide_plugin' ) );
|
64 |
-
add_action('admin_menu', array($this, 'hide_menu'), 999);
|
65 |
-
//add_filter( 'update_footer', array( &$this, 'update_footer' ), 15 );
|
66 |
}
|
67 |
$this->init_cron();
|
68 |
}
|
@@ -212,7 +216,7 @@ class MainWP_Child_Pagespeed {
|
|
212 |
|
213 |
$strategy = $current_values['strategy'];
|
214 |
|
215 |
-
$result = $this->
|
216 |
|
217 |
if ( isset( $_POST['doaction'] ) && ( 'check_new_pages' === $_POST['doaction'] || 'recheck_all_pages' === $_POST['doaction'] ) ) {
|
218 |
if ( 'recheck_all_pages' === $_POST['doaction'] ) {
|
@@ -257,7 +261,18 @@ class MainWP_Child_Pagespeed {
|
|
257 |
return $information;
|
258 |
}
|
259 |
|
260 |
-
public function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
261 |
if ( empty( $strategy ) ) {
|
262 |
$strategy = 'both';
|
263 |
}
|
18 |
if ( is_plugin_active( 'google-pagespeed-insights/google-pagespeed-insights.php' ) ) {
|
19 |
$this->is_plugin_installed = true;
|
20 |
}
|
21 |
+
|
22 |
+
if (!$this->is_plugin_installed)
|
23 |
+
return;
|
24 |
+
|
25 |
+
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
26 |
+
|
27 |
add_action( 'mainwp_child_deactivation', array( $this, 'child_deactivation' ) );
|
28 |
}
|
29 |
|
43 |
$information = $this->set_showhide();
|
44 |
break;
|
45 |
case 'sync_data':
|
46 |
+
$information = $this->get_sync_data();
|
47 |
break;
|
48 |
case "check_pages":
|
49 |
$information = $this->check_pages();
|
66 |
|
67 |
if ( get_option( 'mainwp_pagespeed_hide_plugin' ) === 'hide' ) {
|
68 |
add_filter( 'all_plugins', array( $this, 'hide_plugin' ) );
|
69 |
+
add_action('admin_menu', array($this, 'hide_menu'), 999);
|
|
|
70 |
}
|
71 |
$this->init_cron();
|
72 |
}
|
216 |
|
217 |
$strategy = $current_values['strategy'];
|
218 |
|
219 |
+
$result = $this->get_sync_data( $strategy );
|
220 |
|
221 |
if ( isset( $_POST['doaction'] ) && ( 'check_new_pages' === $_POST['doaction'] || 'recheck_all_pages' === $_POST['doaction'] ) ) {
|
222 |
if ( 'recheck_all_pages' === $_POST['doaction'] ) {
|
261 |
return $information;
|
262 |
}
|
263 |
|
264 |
+
public function syncOthersData( $information, $data = array() ) {
|
265 |
+
if ( isset( $data['syncPageSpeedData'] ) && $data['syncPageSpeedData'] ) {
|
266 |
+
try{
|
267 |
+
$information['syncPageSpeedData'] = $this->get_sync_data();
|
268 |
+
} catch(Exception $e) {
|
269 |
+
|
270 |
+
}
|
271 |
+
}
|
272 |
+
return $information;
|
273 |
+
}
|
274 |
+
// ok
|
275 |
+
public function get_sync_data( $strategy = '' ) {
|
276 |
if ( empty( $strategy ) ) {
|
277 |
$strategy = 'both';
|
278 |
}
|
class/class-mainwp-child-skeleton-key.php
CHANGED
@@ -186,7 +186,7 @@ class MainWP_Child_Skeleton_Key {
|
|
186 |
$settings = isset($_POST['settings']) ? $_POST['settings'] : array();
|
187 |
|
188 |
if (!is_array($settings) || empty($settings))
|
189 |
-
return array('error' => 'Invalid data');
|
190 |
|
191 |
$whitelist_options = array(
|
192 |
'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string', 'WPLANG' ),
|
186 |
$settings = isset($_POST['settings']) ? $_POST['settings'] : array();
|
187 |
|
188 |
if (!is_array($settings) || empty($settings))
|
189 |
+
return array('error' => 'Invalid data. Please check and try again.');
|
190 |
|
191 |
$whitelist_options = array(
|
192 |
'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string', 'WPLANG' ),
|
class/class-mainwp-child-staging.php
CHANGED
@@ -20,7 +20,8 @@ class MainWP_Child_Staging {
|
|
20 |
|
21 |
if (!$this->is_plugin_installed)
|
22 |
return;
|
23 |
-
|
|
|
24 |
}
|
25 |
|
26 |
|
@@ -30,9 +31,7 @@ class MainWP_Child_Staging {
|
|
30 |
|
31 |
if (!$this->is_plugin_installed)
|
32 |
return;
|
33 |
-
|
34 |
-
//add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
|
35 |
-
|
36 |
if ( get_option( 'mainwp_wp_staging_hide_plugin' ) === 'hide' ) {
|
37 |
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
|
38 |
add_action( 'admin_menu', array( $this, 'remove_menu' ) );
|
@@ -40,6 +39,17 @@ class MainWP_Child_Staging {
|
|
40 |
}
|
41 |
}
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
public function get_sync_data() {
|
44 |
return $this->get_overview();
|
45 |
}
|
20 |
|
21 |
if (!$this->is_plugin_installed)
|
22 |
return;
|
23 |
+
|
24 |
+
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
25 |
}
|
26 |
|
27 |
|
31 |
|
32 |
if (!$this->is_plugin_installed)
|
33 |
return;
|
34 |
+
|
|
|
|
|
35 |
if ( get_option( 'mainwp_wp_staging_hide_plugin' ) === 'hide' ) {
|
36 |
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
|
37 |
add_action( 'admin_menu', array( $this, 'remove_menu' ) );
|
39 |
}
|
40 |
}
|
41 |
|
42 |
+
public function syncOthersData( $information, $data = array() ) {
|
43 |
+
if ( isset( $data['syncWPStaging'] ) && $data['syncWPStaging'] ) {
|
44 |
+
try{
|
45 |
+
$information['syncWPStaging'] = $this->get_sync_data();
|
46 |
+
} catch(Exception $e) {
|
47 |
+
// do not exit
|
48 |
+
}
|
49 |
+
}
|
50 |
+
return $information;
|
51 |
+
}
|
52 |
+
// ok
|
53 |
public function get_sync_data() {
|
54 |
return $this->get_overview();
|
55 |
}
|
class/class-mainwp-child-timecapsule.php
ADDED
@@ -0,0 +1,1235 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class MainWP_Child_Timecapsule {
|
4 |
+
public static $instance = null;
|
5 |
+
public $is_plugin_installed = false;
|
6 |
+
|
7 |
+
static function Instance() {
|
8 |
+
if ( null === MainWP_Child_Timecapsule::$instance ) {
|
9 |
+
MainWP_Child_Timecapsule::$instance = new MainWP_Child_Timecapsule();
|
10 |
+
}
|
11 |
+
return MainWP_Child_Timecapsule::$instance;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function __construct() {
|
15 |
+
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
16 |
+
if ( is_plugin_active( 'wp-time-capsule/wp-time-capsule.php' ) && defined('WPTC_CLASSES_DIR')) {
|
17 |
+
$this->is_plugin_installed = true;
|
18 |
+
}
|
19 |
+
|
20 |
+
if (!$this->is_plugin_installed)
|
21 |
+
return;
|
22 |
+
|
23 |
+
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
24 |
+
|
25 |
+
}
|
26 |
+
|
27 |
+
|
28 |
+
public function init() {
|
29 |
+
if ( get_option( 'mainwp_time_capsule_ext_enabled' ) !== 'Y' )
|
30 |
+
return;
|
31 |
+
|
32 |
+
if (!$this->is_plugin_installed)
|
33 |
+
return;
|
34 |
+
|
35 |
+
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
|
36 |
+
add_action( 'record_auto_backup_complete', array( $this, 'do_report_backups_logging' ) );
|
37 |
+
|
38 |
+
if ( get_option( 'mainwp_time_capsule_hide_plugin' ) === 'hide' ) {
|
39 |
+
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
|
40 |
+
add_action( 'admin_menu', array( $this, 'remove_menu' ) );
|
41 |
+
add_filter( 'site_transient_update_plugins', array( &$this, 'remove_update_nag' ) );
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
public function action() {
|
47 |
+
if (!$this->is_plugin_installed) {
|
48 |
+
MainWP_Helper::write( array('error' => 'Please install WP Time Capsule plugin on child website') );
|
49 |
+
}
|
50 |
+
|
51 |
+
try {
|
52 |
+
$this->require_files();
|
53 |
+
} catch ( Exception $e) {
|
54 |
+
$error = $e->getMessage();
|
55 |
+
MainWP_Helper::write( array('error' => $error) );
|
56 |
+
}
|
57 |
+
|
58 |
+
$information = array();
|
59 |
+
if (get_option( 'mainwp_time_capsule_ext_enabled' ) !== 'Y')
|
60 |
+
MainWP_Helper::update_option( 'mainwp_time_capsule_ext_enabled', 'Y', 'yes' );
|
61 |
+
|
62 |
+
$options_helper = new Wptc_Options_Helper();
|
63 |
+
$options = WPTC_Factory::get('config');
|
64 |
+
$is_user_logged_in = $options->get_option('is_user_logged_in');
|
65 |
+
$privileges_wptc = $options_helper->get_unserialized_privileges();
|
66 |
+
|
67 |
+
|
68 |
+
|
69 |
+
if ( isset( $_POST['mwp_action'] ) ) {
|
70 |
+
|
71 |
+
if ((
|
72 |
+
$_POST['mwp_action'] == 'save_settings' ||
|
73 |
+
$_POST['mwp_action'] == 'get_staging_details_wptc' ||
|
74 |
+
$_POST['mwp_action'] == 'progress_wptc'
|
75 |
+
) && (!$is_user_logged_in || !$privileges_wptc )
|
76 |
+
) {
|
77 |
+
MainWP_Helper::write( array('error' => 'You are not login to your WP Time Capsule account.') );
|
78 |
+
}
|
79 |
+
|
80 |
+
switch ( $_POST['mwp_action'] ) {
|
81 |
+
case 'set_showhide':
|
82 |
+
$information = $this->set_showhide();
|
83 |
+
break;
|
84 |
+
case 'get_root_files':
|
85 |
+
$information = $this->get_root_files();
|
86 |
+
break;
|
87 |
+
case 'get_tables':
|
88 |
+
$information = $this->get_tables();
|
89 |
+
break;
|
90 |
+
case 'exclude_file_list':
|
91 |
+
$information = $this->exclude_file_list();
|
92 |
+
break;
|
93 |
+
case 'exclude_table_list':
|
94 |
+
$information = $this->exclude_table_list();
|
95 |
+
break;
|
96 |
+
case 'include_table_list':
|
97 |
+
$information = $this->include_table_list();
|
98 |
+
break;
|
99 |
+
case 'include_table_structure_only':
|
100 |
+
$information = $this->include_table_structure_only();
|
101 |
+
break;
|
102 |
+
case 'include_file_list':
|
103 |
+
$information = $this->include_file_list();
|
104 |
+
break;
|
105 |
+
case 'get_files_by_key':
|
106 |
+
$information = $this->get_files_by_key();
|
107 |
+
break;
|
108 |
+
case 'wptc_login':
|
109 |
+
$information = $this->process_wptc_login();
|
110 |
+
break;
|
111 |
+
case 'get_installed_plugins':
|
112 |
+
$information = $this->get_installed_plugins();
|
113 |
+
break;
|
114 |
+
case 'get_installed_themes':
|
115 |
+
$information = $this->get_installed_themes();
|
116 |
+
break;
|
117 |
+
case 'is_staging_need_request':
|
118 |
+
$information = $this->is_staging_need_request();
|
119 |
+
break;
|
120 |
+
case 'get_staging_details_wptc':
|
121 |
+
$information = $this->get_staging_details_wptc();
|
122 |
+
break;
|
123 |
+
case 'start_fresh_staging_wptc':
|
124 |
+
$information = $this->start_fresh_staging_wptc();
|
125 |
+
break;
|
126 |
+
case 'get_staging_url_wptc':
|
127 |
+
$information = $this->get_staging_url_wptc();
|
128 |
+
break;
|
129 |
+
case 'stop_staging_wptc':
|
130 |
+
$information = $this->stop_staging_wptc();
|
131 |
+
break;
|
132 |
+
case 'continue_staging_wptc':
|
133 |
+
$information = $this->continue_staging_wptc();
|
134 |
+
break;
|
135 |
+
case 'delete_staging_wptc':
|
136 |
+
$information = $this->delete_staging_wptc();
|
137 |
+
break;
|
138 |
+
case 'copy_staging_wptc':
|
139 |
+
$information = $this->copy_staging_wptc();
|
140 |
+
break;
|
141 |
+
case 'get_staging_current_status_key':
|
142 |
+
$information = $this->get_staging_current_status_key();
|
143 |
+
break;
|
144 |
+
case 'wptc_sync_purchase':
|
145 |
+
$information = $this->wptc_sync_purchase();
|
146 |
+
break;
|
147 |
+
case 'init_restore':
|
148 |
+
$information = $this->init_restore();
|
149 |
+
break;
|
150 |
+
case 'save_settings':
|
151 |
+
$information = $this->save_settings_wptc();
|
152 |
+
break;
|
153 |
+
case 'analyze_inc_exc':
|
154 |
+
$information = $this->analyze_inc_exc();
|
155 |
+
break;
|
156 |
+
case 'get_enabled_plugins':
|
157 |
+
$information = $this->get_enabled_plugins();
|
158 |
+
break;
|
159 |
+
case 'get_enabled_themes':
|
160 |
+
$information = $this->get_enabled_themes();
|
161 |
+
break;
|
162 |
+
case 'get_system_info':
|
163 |
+
$information = $this->get_system_info();
|
164 |
+
break;
|
165 |
+
case 'update_vulns_settings':
|
166 |
+
$information = $this->update_vulns_settings();
|
167 |
+
break;
|
168 |
+
case 'start_fresh_backup':
|
169 |
+
$information = $this->start_fresh_backup_tc_callback_wptc();
|
170 |
+
break;
|
171 |
+
case 'save_manual_backup_name':
|
172 |
+
$information = $this->save_manual_backup_name_wptc();
|
173 |
+
break;
|
174 |
+
case 'progress_wptc':
|
175 |
+
$information = $this->progress_wptc();
|
176 |
+
break;
|
177 |
+
case 'stop_fresh_backup':
|
178 |
+
$information = $this->stop_fresh_backup_tc_callback_wptc();
|
179 |
+
break;
|
180 |
+
case 'wptc_cron_status':
|
181 |
+
$information = $this->wptc_cron_status();
|
182 |
+
break;
|
183 |
+
case 'get_this_backups_html':
|
184 |
+
$information = $this->get_this_backups_html();
|
185 |
+
break;
|
186 |
+
case 'start_restore_tc_wptc':
|
187 |
+
$information = $this->start_restore_tc_callback_wptc();
|
188 |
+
break;
|
189 |
+
case 'get_sibling_files':
|
190 |
+
$information = $this->get_sibling_files_callback_wptc();
|
191 |
+
break;
|
192 |
+
case 'get_logs_rows':
|
193 |
+
$information = $this->get_logs_rows();
|
194 |
+
break;
|
195 |
+
case 'clear_logs':
|
196 |
+
$information = $this->clear_wptc_logs();
|
197 |
+
break;
|
198 |
+
case 'send_issue_report':
|
199 |
+
$information = $this->send_issue_report();
|
200 |
+
break;
|
201 |
+
case 'lazy_load_activity_log':
|
202 |
+
$information = $this->lazy_load_activity_log_wptc();
|
203 |
+
break;
|
204 |
+
}
|
205 |
+
}
|
206 |
+
MainWP_Helper::write( $information );
|
207 |
+
}
|
208 |
+
|
209 |
+
|
210 |
+
public function require_files() {
|
211 |
+
if (! class_exists('WPTC_Base_Factory') && defined('WPTC_PLUGIN_DIR') ) {
|
212 |
+
if ( MainWP_Helper::check_files_exists(WPTC_PLUGIN_DIR . 'Base/Factory.php') ) {
|
213 |
+
include_once WPTC_PLUGIN_DIR.'Base/Factory.php';
|
214 |
+
}
|
215 |
+
}
|
216 |
+
if ( ! class_exists('Wptc_Options_Helper') && defined('WPTC_PLUGIN_DIR') ) {
|
217 |
+
if ( MainWP_Helper::check_files_exists(WPTC_PLUGIN_DIR . 'Views/wptc-options-helper.php') ) {
|
218 |
+
include_once WPTC_PLUGIN_DIR . 'Views/wptc-options-helper.php';
|
219 |
+
}
|
220 |
+
}
|
221 |
+
}
|
222 |
+
|
223 |
+
function set_showhide() {
|
224 |
+
$hide = isset( $_POST['showhide'] ) && ( 'hide' === $_POST['showhide'] ) ? 'hide' : '';
|
225 |
+
MainWP_Helper::update_option( 'mainwp_time_capsule_hide_plugin', $hide, 'yes' );
|
226 |
+
$information['result'] = 'SUCCESS';
|
227 |
+
return $information;
|
228 |
+
}
|
229 |
+
|
230 |
+
// ok
|
231 |
+
public function syncOthersData( $information, $data = array() ) {
|
232 |
+
if ( isset( $data['syncWPTimeCapsule'] ) && $data['syncWPTimeCapsule'] ) {
|
233 |
+
$information['syncWPTimeCapsule'] = $this->get_sync_data();
|
234 |
+
}
|
235 |
+
return $information;
|
236 |
+
}
|
237 |
+
|
238 |
+
// ok
|
239 |
+
public function get_sync_data() {
|
240 |
+
try {
|
241 |
+
$this->require_files();
|
242 |
+
MainWP_Helper::check_classes_exists(array('Wptc_Options_Helper', 'WPTC_Base_Factory', 'WPTC_Factory'));
|
243 |
+
|
244 |
+
$config = WPTC_Factory::get('config');
|
245 |
+
MainWP_Helper::check_methods($config, 'get_option');
|
246 |
+
|
247 |
+
$main_account_email_var = $config->get_option('main_account_email');
|
248 |
+
$last_backup_time = $config->get_option('last_backup_time');
|
249 |
+
$wptc_settings = WPTC_Base_Factory::get('Wptc_Settings');
|
250 |
+
|
251 |
+
$options_helper = new Wptc_Options_Helper();
|
252 |
+
|
253 |
+
MainWP_Helper::check_methods($options_helper, array( 'get_plan_interval_from_subs_info', 'get_is_user_logged_in'));
|
254 |
+
MainWP_Helper::check_methods($wptc_settings, array( 'get_connected_cloud_info'));
|
255 |
+
|
256 |
+
$return = array(
|
257 |
+
'main_account_email' => $main_account_email_var,
|
258 |
+
'signed_in_repos' => $wptc_settings->get_connected_cloud_info(),
|
259 |
+
'plan_name' => $options_helper->get_plan_interval_from_subs_info(),
|
260 |
+
'plan_interval' => $options_helper->get_plan_interval_from_subs_info(),
|
261 |
+
'lastbackup_time' => !empty($last_backup_time) ? $last_backup_time : 0,
|
262 |
+
'is_user_logged_in' => $options_helper->get_is_user_logged_in()
|
263 |
+
);
|
264 |
+
return $return;
|
265 |
+
} catch ( Exception $e) {
|
266 |
+
// do not exit here
|
267 |
+
}
|
268 |
+
return false;
|
269 |
+
}
|
270 |
+
|
271 |
+
public function get_tables() {
|
272 |
+
$category = $_POST['category'];
|
273 |
+
$exclude_class_obj = new Wptc_ExcludeOption($category);
|
274 |
+
$exclude_class_obj->get_tables();
|
275 |
+
die();
|
276 |
+
}
|
277 |
+
|
278 |
+
public function exclude_file_list(){
|
279 |
+
if (!isset($_POST['data'])) {
|
280 |
+
wptc_die_with_json_encode( array('status' => 'no data found') );
|
281 |
+
}
|
282 |
+
$category = $_POST['category'];
|
283 |
+
$exclude_class_obj = new Wptc_ExcludeOption($category);
|
284 |
+
$exclude_class_obj->exclude_file_list($_POST['data']);
|
285 |
+
die();
|
286 |
+
}
|
287 |
+
|
288 |
+
function progress_wptc() {
|
289 |
+
|
290 |
+
$config = WPTC_Factory::get('config');
|
291 |
+
global $wpdb;
|
292 |
+
if (!$config->get_option('in_progress')) {
|
293 |
+
spawn_cron();
|
294 |
+
}
|
295 |
+
|
296 |
+
$processed_files = WPTC_Factory::get('processed-files');
|
297 |
+
|
298 |
+
$return_array = array();
|
299 |
+
$return_array['stored_backups'] = $processed_files->get_stored_backups();
|
300 |
+
$return_array['backup_progress'] = array();
|
301 |
+
$return_array['starting_first_backup'] = $config->get_option('starting_first_backup');
|
302 |
+
$return_array['meta_data_backup_process'] = $config->get_option('meta_data_backup_process');
|
303 |
+
$return_array['backup_before_update_progress'] = $config->get_option('backup_before_update_progress');
|
304 |
+
$return_array['is_staging_running'] = apply_filters('is_any_staging_process_going_on', '');
|
305 |
+
$cron_status = $config->get_option('wptc_own_cron_status');
|
306 |
+
|
307 |
+
if (!empty($cron_status)) {
|
308 |
+
$return_array['wptc_own_cron_status'] = unserialize($cron_status);
|
309 |
+
$return_array['wptc_own_cron_status_notified'] = (int) $config->get_option('wptc_own_cron_status_notified');
|
310 |
+
}
|
311 |
+
|
312 |
+
$start_backups_failed_server = $config->get_option('start_backups_failed_server');
|
313 |
+
if (!empty($start_backups_failed_server)) {
|
314 |
+
$return_array['start_backups_failed_server'] = unserialize($start_backups_failed_server);
|
315 |
+
$config->set_option('start_backups_failed_server', false);
|
316 |
+
}
|
317 |
+
|
318 |
+
$processed_files->get_current_backup_progress($return_array);
|
319 |
+
|
320 |
+
$return_array['user_came_from_existing_ver'] = (int) $config->get_option('user_came_from_existing_ver');
|
321 |
+
$return_array['show_user_php_error'] = $config->get_option('show_user_php_error');
|
322 |
+
$return_array['bbu_setting_status'] = apply_filters('get_backup_before_update_setting_wptc', '');
|
323 |
+
$return_array['bbu_note_view'] = apply_filters('get_bbu_note_view', '');
|
324 |
+
$return_array['staging_status'] = apply_filters('staging_status_wptc', '');
|
325 |
+
|
326 |
+
$processed_files = WPTC_Factory::get('processed-files');
|
327 |
+
$last_backup_time = $config->get_option('last_backup_time');
|
328 |
+
|
329 |
+
if (!empty($last_backup_time)) {
|
330 |
+
$user_time = $config->cnvt_UTC_to_usrTime($last_backup_time);
|
331 |
+
$processed_files->modify_schedule_backup_time($user_time);
|
332 |
+
$formatted_date = date("M d @ g:i a", $user_time);
|
333 |
+
$return_array['last_backup_time'] = $formatted_date;
|
334 |
+
} else {
|
335 |
+
$return_array['last_backup_time'] = 'No Backup Taken';
|
336 |
+
}
|
337 |
+
|
338 |
+
return array( 'result' => $return_array );
|
339 |
+
|
340 |
+
}
|
341 |
+
|
342 |
+
function wptc_cron_status(){
|
343 |
+
$config = WPTC_Factory::get('config');
|
344 |
+
wptc_own_cron_status();
|
345 |
+
$status = array();
|
346 |
+
$cron_status = $config->get_option('wptc_own_cron_status');
|
347 |
+
if (!empty($cron_status)) {
|
348 |
+
$cron_status = unserialize($cron_status);
|
349 |
+
|
350 |
+
if ($cron_status['status'] == 'success') {
|
351 |
+
$status['status'] = 'success';
|
352 |
+
} else {
|
353 |
+
$status['status'] = 'failed';
|
354 |
+
$status['status_code'] = $cron_status['statusCode'];
|
355 |
+
$status['err_msg'] = $cron_status['body'];
|
356 |
+
$status['cron_url'] = $cron_status['cron_url'];
|
357 |
+
$status['ips'] = $cron_status['ips'];
|
358 |
+
}
|
359 |
+
return array('result' => $status);
|
360 |
+
}
|
361 |
+
return false;
|
362 |
+
}
|
363 |
+
|
364 |
+
function get_this_backups_html() {
|
365 |
+
$this_backup_ids = $_POST['this_backup_ids'];
|
366 |
+
$specific_dir = $_POST['specific_dir'];
|
367 |
+
$type = $_POST['type'];
|
368 |
+
$treeRecursiveCount = $_POST['treeRecursiveCount'];
|
369 |
+
$processed_files = WPTC_Factory::get('processed-files');
|
370 |
+
|
371 |
+
$result = $processed_files->get_this_backups_html($this_backup_ids, $specific_dir, $type, $treeRecursiveCount);
|
372 |
+
return array( 'result' => $result );
|
373 |
+
}
|
374 |
+
|
375 |
+
|
376 |
+
function start_restore_tc_callback_wptc() {
|
377 |
+
|
378 |
+
if (apply_filters('is_restore_to_staging_wptc', '')) {
|
379 |
+
$request = apply_filters('get_restore_to_staging_request_wptc', '');
|
380 |
+
} else {
|
381 |
+
$request = $_POST['data'];
|
382 |
+
}
|
383 |
+
|
384 |
+
include_once ( WPTC_CLASSES_DIR . 'class-prepare-restore-bridge.php' );
|
385 |
+
|
386 |
+
new WPTC_Prepare_Restore_Bridge($request);
|
387 |
+
}
|
388 |
+
|
389 |
+
function get_sibling_files_callback_wptc() {
|
390 |
+
//note that we are getting the ajax function data via $_POST.
|
391 |
+
$file_name = $_POST['data']['file_name'];
|
392 |
+
$file_name = wp_normalize_path($file_name);
|
393 |
+
$backup_id = $_POST['data']['backup_id'];
|
394 |
+
$recursive_count = $_POST['data']['recursive_count'];
|
395 |
+
// //getting the backups
|
396 |
+
|
397 |
+
$processed_files = WPTC_Factory::get('processed-files');
|
398 |
+
echo $processed_files->get_this_backups_html($backup_id, $file_name, $type = 'sibling', (int) $recursive_count);
|
399 |
+
die();
|
400 |
+
}
|
401 |
+
|
402 |
+
function send_issue_report() {
|
403 |
+
WPTC_Base_Factory::get('Wptc_App_Functions')->send_report();
|
404 |
+
die();
|
405 |
+
}
|
406 |
+
|
407 |
+
|
408 |
+
function get_logs_rows() {
|
409 |
+
$result = $this->prepare_items();
|
410 |
+
$result['display_rows'] = base64_encode(serialize($this->get_display_rows($result['items'])));
|
411 |
+
return $result;
|
412 |
+
}
|
413 |
+
|
414 |
+
function prepare_items() {
|
415 |
+
global $wpdb;
|
416 |
+
|
417 |
+
if (isset($_POST['type'])) {
|
418 |
+
$type = $_POST['type'];
|
419 |
+
switch ($type) {
|
420 |
+
case 'backups':
|
421 |
+
$query = "SELECT * FROM " . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE '%backup%' AND show_user = 1 GROUP BY action_id";
|
422 |
+
break;
|
423 |
+
case 'restores':
|
424 |
+
$query = "SELECT * FROM " . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE 'restore%' GROUP BY action_id";
|
425 |
+
break;
|
426 |
+
case 'staging':
|
427 |
+
$query = "SELECT * FROM " . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE 'staging%' GROUP BY action_id";
|
428 |
+
break;
|
429 |
+
case 'backup_and_update':
|
430 |
+
$query = "SELECT * FROM " . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE 'backup_and_update%' GROUP BY action_id";
|
431 |
+
break;
|
432 |
+
case 'auto_update':
|
433 |
+
$query = "SELECT * FROM " . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE 'auto_update%' GROUP BY action_id";
|
434 |
+
break;
|
435 |
+
case 'others':
|
436 |
+
$query = "SELECT * FROM " . $wpdb->base_prefix . "wptc_activity_log WHERE type NOT LIKE 'restore%' AND type NOT LIKE 'backup%' AND show_user = 1";
|
437 |
+
break;
|
438 |
+
default:
|
439 |
+
$query = "SELECT * FROM " . $wpdb->base_prefix . "wptc_activity_log GROUP BY action_id UNION SELECT * FROM " . $wpdb->base_prefix . "wptc_activity_log WHERE action_id='' AND show_user = 1";
|
440 |
+
break;
|
441 |
+
}
|
442 |
+
} else {
|
443 |
+
$query = "SELECT * FROM " . $wpdb->base_prefix . "wptc_activity_log WHERE show_user = 1 GROUP BY action_id ";
|
444 |
+
}
|
445 |
+
/* -- Preparing your query -- */
|
446 |
+
|
447 |
+
/* -- Ordering parameters -- */
|
448 |
+
//Parameters that are going to be used to order the result
|
449 |
+
$orderby = !empty($_POST["orderby"]) ? mysql_real_escape_string($_POST["orderby"]) : 'id';
|
450 |
+
$order = !empty($_POST["order"]) ? mysql_real_escape_string($_POST["order"]) : 'DESC';
|
451 |
+
if (!empty($orderby) & !empty($order)) {$query .= ' ORDER BY ' . $orderby . ' ' . $order;}
|
452 |
+
|
453 |
+
/* -- Pagination parameters -- */
|
454 |
+
//Number of elements in your table?
|
455 |
+
$totalitems = $wpdb->query($query); //return the total number of affected rows
|
456 |
+
//How many to display per page?
|
457 |
+
$perpage = 20;
|
458 |
+
//Which page is this?
|
459 |
+
$paged = !empty($_POST["paged"]) ? $_POST["paged"] : '';
|
460 |
+
if (empty($paged) || !is_numeric($paged) || $paged <= 0) {$paged = 1;} //Page Number
|
461 |
+
//How many pages do we have in total?
|
462 |
+
$totalpages = ceil($totalitems / $perpage); //Total number of pages
|
463 |
+
//adjust the query to take pagination into account
|
464 |
+
if (!empty($paged) && !empty($perpage)) {
|
465 |
+
$offset = ($paged - 1) * $perpage;
|
466 |
+
$query .= ' LIMIT ' . (int) $offset . ',' . (int) $perpage;
|
467 |
+
}
|
468 |
+
|
469 |
+
return array( 'items' => $wpdb->get_results($query) ,
|
470 |
+
'totalitems' => $totalitems,
|
471 |
+
'perpage' => $perpage
|
472 |
+
);
|
473 |
+
}
|
474 |
+
|
475 |
+
|
476 |
+
function lazy_load_activity_log_wptc(){
|
477 |
+
|
478 |
+
if (!isset($_POST['data'])) {
|
479 |
+
return false;
|
480 |
+
}
|
481 |
+
|
482 |
+
$data = $_POST['data'];
|
483 |
+
|
484 |
+
if (!isset($data['action_id']) || !isset($data['limit'])) {
|
485 |
+
return false;
|
486 |
+
}
|
487 |
+
global $wpdb;
|
488 |
+
|
489 |
+
$action_id = $data['action_id'];
|
490 |
+
$from_limit = $data['limit'];
|
491 |
+
$detailed = '';
|
492 |
+
$load_more = false;
|
493 |
+
$current_limit = WPTC_Factory::get('config')->get_option('activity_log_lazy_load_limit');
|
494 |
+
$to_limit = $from_limit + $current_limit;
|
495 |
+
|
496 |
+
$sql = "SELECT * FROM " . $wpdb->base_prefix . "wptc_activity_log WHERE action_id=" . $action_id . ' AND show_user = 1 ORDER BY id DESC LIMIT '.$from_limit.' , '.$current_limit;
|
497 |
+
|
498 |
+
$sub_records = $wpdb->get_results($sql);
|
499 |
+
$row_count = count($sub_records);
|
500 |
+
|
501 |
+
if ($row_count == $current_limit) {
|
502 |
+
$load_more = true;
|
503 |
+
}
|
504 |
+
|
505 |
+
$detailed = $this->get_activity_log($sub_records);
|
506 |
+
|
507 |
+
if (isset($load_more) && $load_more) {
|
508 |
+
$detailed .= '<tr><td></td><td><a style="cursor:pointer; position:relative" class="wptc_activity_log_load_more" action_id="'.$action_id.'" limit="'.$to_limit.'">Load more</a></td><td></td></tr>';
|
509 |
+
}
|
510 |
+
|
511 |
+
return array( 'result' => $detailed);
|
512 |
+
|
513 |
+
//die($detailed);
|
514 |
+
}
|
515 |
+
|
516 |
+
|
517 |
+
function get_display_rows($records) {
|
518 |
+
global $wpdb;
|
519 |
+
//Get the records registered in the prepare_items method
|
520 |
+
if (!is_array($records))
|
521 |
+
return '';
|
522 |
+
|
523 |
+
$i=0;
|
524 |
+
$limit = WPTC_Factory::get('config')->get_option('activity_log_lazy_load_limit');
|
525 |
+
//Get the columns registered in the get_columns and get_sortable_columns methods
|
526 |
+
// $columns = $this->get_columns();
|
527 |
+
$timezone = WPTC_Factory::get('config')->get_option('wptc_timezone');
|
528 |
+
if (count($records) > 0) {
|
529 |
+
|
530 |
+
foreach ($records as $key => $rec) {
|
531 |
+
$html = '';
|
532 |
+
|
533 |
+
$more_logs = false;
|
534 |
+
$load_more = false;
|
535 |
+
if ($rec->action_id != '') {
|
536 |
+
$sql = "SELECT * FROM " . $wpdb->base_prefix . "wptc_activity_log WHERE action_id=" . $rec->action_id . ' AND show_user = 1 ORDER BY id DESC LIMIT 0 , '.$limit;
|
537 |
+
$sub_records = $wpdb->get_results($sql);
|
538 |
+
$row_count = count($sub_records);
|
539 |
+
if ($row_count == $limit) {
|
540 |
+
$load_more = true;
|
541 |
+
}
|
542 |
+
|
543 |
+
if ($row_count > 0) {
|
544 |
+
$more_logs = true;
|
545 |
+
$detailed = '<table>';
|
546 |
+
$detailed .= $this->get_activity_log($sub_records);
|
547 |
+
if (isset($load_more) && $load_more) {
|
548 |
+
$detailed .= '<tr><td></td><td><a style="cursor:pointer; position:relative" class="mainwp_wptc_activity_log_load_more" action_id="'.$rec->action_id.'" limit="'.$limit.'">Load more</a></td><td></td></tr>';
|
549 |
+
}
|
550 |
+
$detailed .= '</table>';
|
551 |
+
|
552 |
+
}
|
553 |
+
}
|
554 |
+
//Open the line
|
555 |
+
$html .= '<tr class="act-tr">';
|
556 |
+
$Ldata = unserialize($rec->log_data);
|
557 |
+
$user_time = WPTC_Factory::get('config')->cnvt_UTC_to_usrTime($Ldata['log_time']);
|
558 |
+
WPTC_Factory::get('processed-files')->modify_schedule_backup_time($user_time);
|
559 |
+
// $user_tz = new DateTime('@' . $Ldata['log_time'], new DateTimeZone(date_default_timezone_get()));
|
560 |
+
// $user_tz->setTimeZone(new DateTimeZone($timezone));
|
561 |
+
// $user_tz_now = $user_tz->format("M d, Y @ g:i:s a");
|
562 |
+
$user_tz_now = date("M d, Y @ g:i:s a", $user_time);
|
563 |
+
$msg = '';
|
564 |
+
if (!(strpos($rec->type, 'backup') === false)) {
|
565 |
+
//Backup process
|
566 |
+
$msg = 'Backup Process';
|
567 |
+
} else if (!(strpos($rec->type, 'restore') === false)) {
|
568 |
+
//Restore Process
|
569 |
+
$msg = 'Restore Process';
|
570 |
+
} else if (!(strpos($rec->type, 'staging') === false)) {
|
571 |
+
//Restore Process
|
572 |
+
$msg = 'Staging Process';
|
573 |
+
} else {
|
574 |
+
if ($row_count < 2) {
|
575 |
+
$more_logs = false;
|
576 |
+
}
|
577 |
+
$msg = $Ldata['msg'];
|
578 |
+
}
|
579 |
+
$html .= '<td class="wptc-act-td">' . $user_tz_now . '</td><td class="wptc-act-td">' . $msg;
|
580 |
+
if ($more_logs) {
|
581 |
+
$html .= "    <a class='wptc-show-more' action_id='" . round($rec->action_id) . "'>View details</a></td>";
|
582 |
+
} else {
|
583 |
+
$html .= "</td>";
|
584 |
+
}
|
585 |
+
$html .= '<td class="wptc-act-td"><a class="report_issue_wptc" id="' . $rec->id . '" href="#">Send report to plugin developer</a></td>';
|
586 |
+
if ($more_logs) {
|
587 |
+
|
588 |
+
$html .= "</tr><tr id='" . round($rec->action_id) . "' class='wptc-more-logs'><td colspan=3>" . $detailed . "</td>";
|
589 |
+
} else {
|
590 |
+
$html .= "</td>";
|
591 |
+
}
|
592 |
+
//Close the line
|
593 |
+
$html .= '</tr>';
|
594 |
+
|
595 |
+
$display_rows[$key] = $html;
|
596 |
+
}
|
597 |
+
|
598 |
+
}
|
599 |
+
return $display_rows;
|
600 |
+
}
|
601 |
+
|
602 |
+
|
603 |
+
function get_activity_log($sub_records){
|
604 |
+
if (count($sub_records) < 1) {
|
605 |
+
return false;
|
606 |
+
}
|
607 |
+
$detailed = '';
|
608 |
+
$timezone = WPTC_Factory::get('config')->get_option('wptc_timezone');
|
609 |
+
foreach ($sub_records as $srec) {
|
610 |
+
$Moredata = unserialize($srec->log_data);
|
611 |
+
$user_tmz = new DateTime('@' . $Moredata['log_time'], new DateTimeZone(date_default_timezone_get()));
|
612 |
+
$user_tmz->setTimeZone(new DateTimeZone($timezone));
|
613 |
+
$user_tmz_now = $user_tmz->format("M d @ g:i:s a");
|
614 |
+
$detailed .= '<tr><td>' . $user_tmz_now . '</td><td>' . $Moredata['msg'] . '</td><td></td></tr>';
|
615 |
+
}
|
616 |
+
return $detailed;
|
617 |
+
}
|
618 |
+
|
619 |
+
function clear_wptc_logs() {
|
620 |
+
global $wpdb;
|
621 |
+
if ($wpdb->query("TRUNCATE TABLE `" . $wpdb->base_prefix . "wptc_activity_log`")) {
|
622 |
+
$result = 'yes';
|
623 |
+
} else {
|
624 |
+
$result = 'no';
|
625 |
+
}
|
626 |
+
return array('result' => $result);
|
627 |
+
}
|
628 |
+
|
629 |
+
function stop_fresh_backup_tc_callback_wptc() {
|
630 |
+
//for backup during update
|
631 |
+
$deactivated_plugin = null;
|
632 |
+
$backup = new WPTC_BackupController();
|
633 |
+
$backup->stop($deactivated_plugin);
|
634 |
+
return array('result' => 'ok');
|
635 |
+
}
|
636 |
+
|
637 |
+
|
638 |
+
function get_root_files() {
|
639 |
+
$category = $_POST['category'];
|
640 |
+
$exclude_class_obj = new Wptc_ExcludeOption($category);
|
641 |
+
$exclude_class_obj->get_root_files();
|
642 |
+
die();
|
643 |
+
}
|
644 |
+
|
645 |
+
|
646 |
+
public function exclude_table_list(){
|
647 |
+
if (!isset($_POST['data'])) {
|
648 |
+
wptc_die_with_json_encode( array('status' => 'no data found') );
|
649 |
+
}
|
650 |
+
$category = $_POST['data']['category'];
|
651 |
+
$exclude_class_obj = new Wptc_ExcludeOption($category);
|
652 |
+
$exclude_class_obj->exclude_table_list($_POST['data']);
|
653 |
+
die();
|
654 |
+
}
|
655 |
+
|
656 |
+
function do_report_backups_logging($backup_id) {
|
657 |
+
$backup_time = time(); // may be difference a bit with WTC logging
|
658 |
+
$message = 'WP Time Capsule backup finished';
|
659 |
+
$backup_type = 'WP Time Capsule';
|
660 |
+
do_action( 'mainwp_wptimecapsule_backup', $message, $backup_type, $backup_time );
|
661 |
+
}
|
662 |
+
|
663 |
+
function do_site_stats() {
|
664 |
+
if (has_action('mainwp_child_reports_log')) {
|
665 |
+
do_action( 'mainwp_child_reports_log', 'wptimecapsule');
|
666 |
+
} else {
|
667 |
+
$this->do_reports_log('wptimecapsule');
|
668 |
+
}
|
669 |
+
}
|
670 |
+
|
671 |
+
// ok
|
672 |
+
public function do_reports_log($ext = '') {
|
673 |
+
if ( $ext !== 'wptimecapsule' ) return;
|
674 |
+
if (!$this->is_plugin_installed)
|
675 |
+
return;
|
676 |
+
try {
|
677 |
+
MainWP_Helper::check_classes_exists(array( 'WPTC_Base_Factory', 'Wptc_Exclude_Config'));
|
678 |
+
|
679 |
+
$config = WPTC_Base_Factory::get('Wptc_Exclude_Config');
|
680 |
+
|
681 |
+
MainWP_Helper::check_methods($config, 'get_option');
|
682 |
+
|
683 |
+
$backup_time = $config->get_option('last_backup_time');
|
684 |
+
if (!empty($backup_time)) {
|
685 |
+
MainWP_Helper::update_lasttime_backup( 'wptimecapsule', $backup_time ); // to support backup before update feature
|
686 |
+
}
|
687 |
+
} catch(Exception $e) {
|
688 |
+
|
689 |
+
}
|
690 |
+
}
|
691 |
+
|
692 |
+
public function include_table_list(){
|
693 |
+
if (!isset($_POST['data'])) {
|
694 |
+
wptc_die_with_json_encode( array('status' => 'no data found') );
|
695 |
+
}
|
696 |
+
$category = $_POST['data']['category'];
|
697 |
+
$exclude_class_obj = new Wptc_ExcludeOption($category);
|
698 |
+
$exclude_class_obj->include_table_list($_POST['data']);
|
699 |
+
die();
|
700 |
+
}
|
701 |
+
|
702 |
+
public function include_table_structure_only(){
|
703 |
+
|
704 |
+
if (!isset($_POST['data'])) {
|
705 |
+
wptc_die_with_json_encode( array('status' => 'no data found') );
|
706 |
+
}
|
707 |
+
|
708 |
+
$category = $_POST['data']['category'];
|
709 |
+
$exclude_class_obj = new Wptc_ExcludeOption($category);
|
710 |
+
$exclude_class_obj->include_table_structure_only($_POST['data']);
|
711 |
+
die();
|
712 |
+
}
|
713 |
+
|
714 |
+
public function include_file_list(){
|
715 |
+
|
716 |
+
if (!isset($_POST['data'])) {
|
717 |
+
wptc_die_with_json_encode( array('status' => 'no data found') );
|
718 |
+
}
|
719 |
+
$category = $_POST['category'];
|
720 |
+
$exclude_class_obj = new Wptc_ExcludeOption($category);
|
721 |
+
$exclude_class_obj->include_file_list($_POST['data']);
|
722 |
+
die();
|
723 |
+
}
|
724 |
+
|
725 |
+
public function get_files_by_key() {
|
726 |
+
$key = $_POST['key'];
|
727 |
+
$category = $_POST['category'];
|
728 |
+
$exclude_class_obj = new Wptc_ExcludeOption($category);
|
729 |
+
$exclude_class_obj->get_files_by_key($key);
|
730 |
+
die();
|
731 |
+
}
|
732 |
+
|
733 |
+
private function process_wptc_login() {
|
734 |
+
$options_helper = new Wptc_Options_Helper();
|
735 |
+
|
736 |
+
if($options_helper->get_is_user_logged_in()){
|
737 |
+
return array(
|
738 |
+
'result' => 'is_user_logged_in',
|
739 |
+
'sync_data' => $this->get_sync_data()
|
740 |
+
);
|
741 |
+
}
|
742 |
+
|
743 |
+
$email = $_POST['acc_email'];
|
744 |
+
$pwd = $_POST['acc_pwd'];
|
745 |
+
|
746 |
+
if (empty( $email ) || empty($pwd)) {
|
747 |
+
return array('error' => 'Username and password cannot be empty');
|
748 |
+
}
|
749 |
+
|
750 |
+
|
751 |
+
$config = WPTC_Base_Factory::get('Wptc_InitialSetup_Config');
|
752 |
+
$options = WPTC_Factory::get('config');
|
753 |
+
|
754 |
+
$config->set_option('wptc_main_acc_email_temp', base64_encode($email));
|
755 |
+
$config->set_option('wptc_main_acc_pwd_temp', base64_encode(md5(trim( wp_unslash( $pwd ) ))));
|
756 |
+
$config->set_option('wptc_token', false);
|
757 |
+
|
758 |
+
$options->request_service(
|
759 |
+
array(
|
760 |
+
'email' => $email,
|
761 |
+
'pwd' => trim( wp_unslash( $pwd )),
|
762 |
+
'return_response' => false,
|
763 |
+
'sub_action' => false,
|
764 |
+
'login_request' => true,
|
765 |
+
'reset_login_if_failed' => true,
|
766 |
+
)
|
767 |
+
);
|
768 |
+
|
769 |
+
|
770 |
+
$is_user_logged_in = $options->get_option('is_user_logged_in');
|
771 |
+
|
772 |
+
if (!$is_user_logged_in) {
|
773 |
+
return array('error' => 'Login failed.');
|
774 |
+
}
|
775 |
+
return array('result' => 'ok', 'sync_data' => $this->get_sync_data());
|
776 |
+
}
|
777 |
+
|
778 |
+
function get_installed_plugins(){
|
779 |
+
|
780 |
+
$backup_before_auto_update_settings = WPTC_Pro_Factory::get('Wptc_Backup_Before_Auto_Update_Settings');
|
781 |
+
$plugins = $backup_before_auto_update_settings->get_installed_plugins();
|
782 |
+
|
783 |
+
if ($plugins) {
|
784 |
+
return array('results' =>$plugins );
|
785 |
+
}
|
786 |
+
return array( 'results' => array());
|
787 |
+
}
|
788 |
+
|
789 |
+
function get_installed_themes(){
|
790 |
+
|
791 |
+
$backup_before_auto_update_settings = WPTC_Pro_Factory::get('Wptc_Backup_Before_Auto_Update_Settings');
|
792 |
+
|
793 |
+
$plugins = $backup_before_auto_update_settings->get_installed_themes();
|
794 |
+
if ($plugins) {
|
795 |
+
return array('results' =>$plugins );
|
796 |
+
}
|
797 |
+
return array('results' => array() ) ;
|
798 |
+
}
|
799 |
+
|
800 |
+
function is_staging_need_request(){
|
801 |
+
$staging = WPTC_Pro_Factory::get('Wptc_Staging');
|
802 |
+
$staging->is_staging_need_request();
|
803 |
+
die();
|
804 |
+
}
|
805 |
+
|
806 |
+
function get_staging_details_wptc(){
|
807 |
+
$staging = WPTC_Pro_Factory::get('Wptc_Staging');
|
808 |
+
$details = $staging->get_staging_details();
|
809 |
+
$details['is_running'] = $staging->is_any_staging_process_going_on();
|
810 |
+
wptc_die_with_json_encode( $details, 1 );
|
811 |
+
}
|
812 |
+
|
813 |
+
function start_fresh_staging_wptc(){
|
814 |
+
$staging = WPTC_Pro_Factory::get('Wptc_Staging');
|
815 |
+
|
816 |
+
if (empty($_POST['path'])) {
|
817 |
+
wptc_die_with_json_encode( array('status' => 'error', 'msg' => 'path is missing') );
|
818 |
+
}
|
819 |
+
|
820 |
+
$staging->choose_action($_POST['path'], $reqeust_type = 'fresh');
|
821 |
+
die();
|
822 |
+
}
|
823 |
+
|
824 |
+
function get_staging_url_wptc(){
|
825 |
+
$staging = WPTC_Pro_Factory::get('Wptc_Staging');
|
826 |
+
$staging->get_staging_url_wptc();
|
827 |
+
die();
|
828 |
+
}
|
829 |
+
|
830 |
+
function stop_staging_wptc(){
|
831 |
+
$staging = WPTC_Pro_Factory::get('Wptc_Staging');
|
832 |
+
$staging->stop_staging_wptc();
|
833 |
+
die();
|
834 |
+
}
|
835 |
+
|
836 |
+
function continue_staging_wptc(){
|
837 |
+
$staging = WPTC_Pro_Factory::get('Wptc_Staging');
|
838 |
+
$staging->choose_action();
|
839 |
+
die();
|
840 |
+
}
|
841 |
+
|
842 |
+
function delete_staging_wptc(){
|
843 |
+
$staging = WPTC_Pro_Factory::get('Wptc_Staging');
|
844 |
+
$staging->delete_staging_wptc();
|
845 |
+
die();
|
846 |
+
}
|
847 |
+
|
848 |
+
function copy_staging_wptc(){
|
849 |
+
$staging = WPTC_Pro_Factory::get('Wptc_Staging');
|
850 |
+
$staging->choose_action(false, $reqeust_type = 'copy');
|
851 |
+
die();
|
852 |
+
}
|
853 |
+
|
854 |
+
function get_staging_current_status_key(){
|
855 |
+
$staging = WPTC_Pro_Factory::get('Wptc_Staging');
|
856 |
+
$staging->get_staging_current_status_key();
|
857 |
+
die();
|
858 |
+
}
|
859 |
+
|
860 |
+
function wptc_sync_purchase(){
|
861 |
+
$config = WPTC_Factory::get('config');
|
862 |
+
|
863 |
+
$config->request_service(
|
864 |
+
array(
|
865 |
+
'email' => false,
|
866 |
+
'pwd' => false,
|
867 |
+
'return_response' => false,
|
868 |
+
'sub_action' => 'sync_all_settings_to_node',
|
869 |
+
'login_request' => true,
|
870 |
+
)
|
871 |
+
);
|
872 |
+
die();
|
873 |
+
}
|
874 |
+
|
875 |
+
public function init_restore() {
|
876 |
+
|
877 |
+
if (empty($_POST)) {
|
878 |
+
return ( array('error' => 'Backup id is empty !') );
|
879 |
+
}
|
880 |
+
$restore_to_staging = WPTC_Base_Factory::get('Wptc_Restore_To_Staging');
|
881 |
+
$restore_to_staging->init_restore($_POST);
|
882 |
+
|
883 |
+
die();
|
884 |
+
}
|
885 |
+
|
886 |
+
function save_settings_wptc(){
|
887 |
+
|
888 |
+
$options_helper = new Wptc_Options_Helper();
|
889 |
+
|
890 |
+
if( !$options_helper->get_is_user_logged_in() ){
|
891 |
+
return array(
|
892 |
+
'sync_data' => $this->get_sync_data(),
|
893 |
+
'error' => 'Login to your WP Time Capsule account first'
|
894 |
+
);
|
895 |
+
}
|
896 |
+
|
897 |
+
$data = unserialize(base64_decode($_POST['data']));
|
898 |
+
|
899 |
+
$tabName = $_POST['tabname'];
|
900 |
+
$is_general = $_POST['is_general'];
|
901 |
+
|
902 |
+
|
903 |
+
$saved = false;
|
904 |
+
|
905 |
+
$config = WPTC_Factory::get('config');
|
906 |
+
|
907 |
+
if ( $tabName == 'backup' ) { // save_backup_settings_wptc()
|
908 |
+
|
909 |
+
$config->set_option('user_excluded_extenstions', $data['user_excluded_extenstions']);
|
910 |
+
$config->set_option('user_excluded_files_more_than_size', $data['user_excluded_files_more_than_size']);
|
911 |
+
|
912 |
+
if (!empty($data['backup_slot'])) {
|
913 |
+
$config->set_option('old_backup_slot', $config->get_option('backup_slot'));
|
914 |
+
$config->set_option('backup_slot', $data['backup_slot']);
|
915 |
+
}
|
916 |
+
|
917 |
+
$config->set_option('backup_db_query_limit', $data['backup_db_query_limit']);
|
918 |
+
$config->set_option('database_encrypt_settings', $data['database_encrypt_settings']);
|
919 |
+
$config->set_option('wptc_timezone', $data['wptc_timezone']);
|
920 |
+
$config->set_option('schedule_time_str', $data['schedule_time_str']);
|
921 |
+
|
922 |
+
if(!empty($data['schedule_time_str']) && !empty($data['wptc_timezone']) ){
|
923 |
+
if (function_exists('wptc_modify_schedule_backup'))
|
924 |
+
wptc_modify_schedule_backup();
|
925 |
+
}
|
926 |
+
|
927 |
+
$notice = apply_filters('check_requirements_auto_backup_wptc', '');
|
928 |
+
|
929 |
+
if (!empty($data['revision_limit']) && !$notice ) {
|
930 |
+
$notice = apply_filters('save_settings_revision_limit_wptc', $data['revision_limit']);
|
931 |
+
}
|
932 |
+
|
933 |
+
$saved = true;
|
934 |
+
|
935 |
+
} else if ( $tabName == 'backup_auto' ) { // update_auto_update_settings()
|
936 |
+
|
937 |
+
$config->set_option('backup_before_update_setting', $data['backup_before_update_setting']);
|
938 |
+
|
939 |
+
$current = $config->get_option('wptc_auto_update_settings');
|
940 |
+
$current = unserialize($current);
|
941 |
+
$new = unserialize($data['wptc_auto_update_settings']);
|
942 |
+
|
943 |
+
$current['update_settings']['status'] = $new['update_settings']['status'];
|
944 |
+
$current['update_settings']['schedule']['enabled'] = $new['update_settings']['schedule']['enabled'];
|
945 |
+
$current['update_settings']['schedule']['time'] = $new['update_settings']['schedule']['time'];
|
946 |
+
$current['update_settings']['core']['major']['status'] = $new['update_settings']['core']['major']['status'];
|
947 |
+
$current['update_settings']['core']['minor']['status'] = $new['update_settings']['core']['minor']['status'];
|
948 |
+
$current['update_settings']['themes']['status'] = $new['update_settings']['themes']['status'];
|
949 |
+
$current['update_settings']['plugins']['status'] = $new['update_settings']['plugins']['status'];
|
950 |
+
|
951 |
+
if (!$is_general) {
|
952 |
+
if (isset($new['update_settings']['plugins']['included']))
|
953 |
+
$current['update_settings']['plugins']['included'] = $new['update_settings']['plugins']['included'];
|
954 |
+
else
|
955 |
+
$current['update_settings']['plugins']['included'] = array();
|
956 |
+
|
957 |
+
if (isset($new['update_settings']['themes']['included']))
|
958 |
+
$current['update_settings']['themes']['included'] = $new['update_settings']['themes']['included'];
|
959 |
+
else
|
960 |
+
$current['update_settings']['themes']['included'] = array();
|
961 |
+
}
|
962 |
+
$config->set_option('wptc_auto_update_settings', serialize($current));
|
963 |
+
$saved = true;
|
964 |
+
|
965 |
+
} else if ( $tabName == 'vulns_update' ) {
|
966 |
+
$current = $config->get_option('vulns_settings');
|
967 |
+
$current = unserialize($current);
|
968 |
+
$new = unserialize($data['vulns_settings']);
|
969 |
+
|
970 |
+
$current['status'] = $new['status'];
|
971 |
+
$current['core']['status'] = $new['core']['status'];
|
972 |
+
$current['themes']['status'] = $new['themes']['status'];
|
973 |
+
$current['plugins']['status'] = $new['plugins']['status'];
|
974 |
+
|
975 |
+
if (!$is_general) {
|
976 |
+
$vulns_plugins_included = !empty($new['plugins']['vulns_plugins_included']) ? $new['plugins']['vulns_plugins_included'] : array();
|
977 |
+
|
978 |
+
$plugin_include_array = array();
|
979 |
+
|
980 |
+
if (!empty($vulns_plugins_included)) {
|
981 |
+
$plugin_include_array = explode(',', $vulns_plugins_included);
|
982 |
+
$plugin_include_array = !empty($plugin_include_array) ? $plugin_include_array : array() ;
|
983 |
+
}
|
984 |
+
|
985 |
+
wptc_log($plugin_include_array, '--------$plugin_include_array--------');
|
986 |
+
|
987 |
+
|
988 |
+
|
989 |
+
$included_plugins = $this->filter_plugins($plugin_include_array);
|
990 |
+
|
991 |
+
|
992 |
+
|
993 |
+
wptc_log($included_plugins, '--------$included_plugins--------');
|
994 |
+
|
995 |
+
$current['plugins']['excluded'] = serialize($included_plugins);
|
996 |
+
|
997 |
+
|
998 |
+
$vulns_themes_included = !empty($new['themes']['vulns_themes_included']) ? $new['themes']['vulns_themes_included'] : array();
|
999 |
+
|
1000 |
+
$themes_include_array = array();
|
1001 |
+
|
1002 |
+
if (!empty($vulns_themes_included)) {
|
1003 |
+
$themes_include_array = explode(',', $vulns_themes_included);
|
1004 |
+
}
|
1005 |
+
|
1006 |
+
$included_themes = $this->filter_themes($themes_include_array);
|
1007 |
+
$current['themes']['excluded'] = serialize($included_themes);
|
1008 |
+
}
|
1009 |
+
$config->set_option('vulns_settings', serialize($current));
|
1010 |
+
|
1011 |
+
$saved = true;
|
1012 |
+
|
1013 |
+
} else if ( $tabName == 'staging_opts' ) {
|
1014 |
+
$config->set_option('internal_staging_db_rows_copy_limit', $data['internal_staging_db_rows_copy_limit']);
|
1015 |
+
$config->set_option('internal_staging_file_copy_limit', $data['internal_staging_file_copy_limit']);
|
1016 |
+
$config->set_option('internal_staging_deep_link_limit', $data['internal_staging_deep_link_limit']);
|
1017 |
+
$config->set_option('internal_staging_enable_admin_login', $data['internal_staging_enable_admin_login']);
|
1018 |
+
|
1019 |
+
$saved = true;
|
1020 |
+
}
|
1021 |
+
|
1022 |
+
if ( ! $saved ) {
|
1023 |
+
return array('error' => 'Error: Not saved settings');
|
1024 |
+
}
|
1025 |
+
|
1026 |
+
return array('result' => 'ok');
|
1027 |
+
}
|
1028 |
+
|
1029 |
+
private function filter_plugins($included_plugins){
|
1030 |
+
$app_functions = WPTC_Base_Factory::get('Wptc_App_Functions');
|
1031 |
+
$plugins_data = $app_functions->get_all_plugins_data($specific = true, $attr = 'slug');
|
1032 |
+
$not_included_plugin = array_diff($plugins_data, $included_plugins);
|
1033 |
+
wptc_log($plugins_data, '--------$plugins_data--------');
|
1034 |
+
wptc_log($not_included_plugin, '--------$not_included_plugin--------');
|
1035 |
+
return $not_included_plugin;
|
1036 |
+
}
|
1037 |
+
|
1038 |
+
|
1039 |
+
private function filter_themes($included_themes){
|
1040 |
+
$app_functions = WPTC_Base_Factory::get('Wptc_App_Functions');
|
1041 |
+
$themes_data = $app_functions->get_all_themes_data($specific = true, $attr = 'slug');
|
1042 |
+
$not_included_theme = array_diff($themes_data, $included_themes);
|
1043 |
+
wptc_log($themes_data, '--------$themes_data--------');
|
1044 |
+
wptc_log($not_included_theme, '--------$not_included_theme--------');
|
1045 |
+
return $not_included_theme;
|
1046 |
+
}
|
1047 |
+
|
1048 |
+
|
1049 |
+
public function analyze_inc_exc(){
|
1050 |
+
$exclude_opts_obj = WPTC_Base_Factory::get('Wptc_ExcludeOption');
|
1051 |
+
$exclude_opts_obj = $exclude_opts_obj->analyze_inc_exc(); // raw response
|
1052 |
+
die();
|
1053 |
+
}
|
1054 |
+
|
1055 |
+
public function get_enabled_plugins(){
|
1056 |
+
$vulns_obj = WPTC_Base_Factory::get('Wptc_Vulns');
|
1057 |
+
|
1058 |
+
$plugins = $vulns_obj->get_enabled_plugins();
|
1059 |
+
$plugins = WPTC_Base_Factory::get('Wptc_App_Functions')->fancytree_format($plugins, 'plugins');
|
1060 |
+
|
1061 |
+
return array('results' => $plugins);
|
1062 |
+
}
|
1063 |
+
|
1064 |
+
public function get_enabled_themes(){
|
1065 |
+
$vulns_obj = WPTC_Base_Factory::get('Wptc_Vulns');
|
1066 |
+
$themes = $vulns_obj->get_enabled_themes();
|
1067 |
+
$themes = WPTC_Base_Factory::get('Wptc_App_Functions')->fancytree_format($themes, 'themes');
|
1068 |
+
return array('results' => $themes);
|
1069 |
+
}
|
1070 |
+
|
1071 |
+
public function get_system_info(){
|
1072 |
+
global $wpdb;
|
1073 |
+
|
1074 |
+
$wptc_settings = WPTC_Base_Factory::get('Wptc_Settings');
|
1075 |
+
|
1076 |
+
ob_start();
|
1077 |
+
|
1078 |
+
echo '<table class="wp-list-table widefat fixed" cellspacing="0" >';
|
1079 |
+
echo '<thead><tr><th width="35%">' . __( 'Setting', 'wp-time-capsule' ) . '</th><th>' . __( 'Value', 'wp-time-capsule' ) . '</th></tr></thead>';
|
1080 |
+
echo '<tr title=">=3.9.14"><td>' . __( 'WordPress version', 'wp-time-capsule' ) . '</td><td>' . esc_html( $wptc_settings->get_plugin_data( 'wp_version' ) ) . '</td></tr>';
|
1081 |
+
echo '<tr title=""><td>' . __( 'WP Time Capsule version', 'wp-time-capsule' ) . '</td><td>' . esc_html( $wptc_settings->get_plugin_data( 'Version' ) ) . '</td></tr>';
|
1082 |
+
|
1083 |
+
$bit = '';
|
1084 |
+
if ( PHP_INT_SIZE === 4 ) {
|
1085 |
+
$bit = ' (32bit)';
|
1086 |
+
}
|
1087 |
+
if ( PHP_INT_SIZE === 8 ) {
|
1088 |
+
$bit = ' (64bit)';
|
1089 |
+
}
|
1090 |
+
|
1091 |
+
echo '<tr title=">=5.3.1"><td>' . __( 'PHP version', 'wp-time-capsule' ) . '</td><td>' . esc_html( PHP_VERSION . ' ' . $bit ) . '</td></tr>';
|
1092 |
+
echo '<tr title=">=5.0.15"><td>' . __( 'MySQL version', 'wp-time-capsule' ) . '</td><td>' . esc_html( $wpdb->get_var( "SELECT VERSION() AS version" ) ) . '</td></tr>';
|
1093 |
+
|
1094 |
+
if ( function_exists( 'curl_version' ) ) {
|
1095 |
+
$curlversion = curl_version();
|
1096 |
+
echo '<tr title=""><td>' . __( 'cURL version', 'wp-time-capsule' ) . '</td><td>' . esc_html( $curlversion[ 'version' ] ) . '</td></tr>';
|
1097 |
+
echo '<tr title=""><td>' . __( 'cURL SSL version', 'wp-time-capsule' ) . '</td><td>' . esc_html( $curlversion[ 'ssl_version' ] ) . '</td></tr>';
|
1098 |
+
}
|
1099 |
+
else {
|
1100 |
+
echo '<tr title=""><td>' . __( 'cURL version', 'wp-time-capsule' ) . '</td><td>' . __( 'unavailable', 'wp-time-capsule' ) . '</td></tr>';
|
1101 |
+
}
|
1102 |
+
|
1103 |
+
echo '</td></tr>';
|
1104 |
+
echo '<tr title=""><td>' . __( 'Server', 'wp-time-capsule' ) . '</td><td>' . esc_html( $_SERVER[ 'SERVER_SOFTWARE' ] ) . '</td></tr>';
|
1105 |
+
echo '<tr title=""><td>' . __( 'Operating System', 'wp-time-capsule' ) . '</td><td>' . esc_html( PHP_OS ) . '</td></tr>';
|
1106 |
+
echo '<tr title=""><td>' . __( 'PHP SAPI', 'wp-time-capsule' ) . '</td><td>' . esc_html( PHP_SAPI ) . '</td></tr>';
|
1107 |
+
|
1108 |
+
$php_user = __( 'Function Disabled', 'wp-time-capsule' );
|
1109 |
+
if ( function_exists( 'get_current_user' ) ) {
|
1110 |
+
$php_user = get_current_user();
|
1111 |
+
}
|
1112 |
+
|
1113 |
+
echo '<tr title=""><td>' . __( 'Current PHP user', 'wp-time-capsule' ) . '</td><td>' . esc_html( $php_user ) . '</td></tr>';
|
1114 |
+
echo '<tr title=">=30"><td>' . __( 'Maximum execution time', 'wp-time-capsule' ) . '</td><td>' . esc_html( ini_get( 'max_execution_time' ) ) . ' ' . __( 'seconds', 'wp-time-capsule' ) . '</td></tr>';
|
1115 |
+
|
1116 |
+
if ( defined( 'FS_CHMOD_DIR' ) )
|
1117 |
+
echo '<tr title="FS_CHMOD_DIR"><td>' . __( 'CHMOD Dir', 'wp-time-capsule' ) . '</td><td>' . esc_html( FS_CHMOD_DIR ) . '</td></tr>';
|
1118 |
+
else
|
1119 |
+
echo '<tr title="FS_CHMOD_DIR"><td>' . __( 'CHMOD Dir', 'wp-time-capsule' ) . '</td><td>0755</td></tr>';
|
1120 |
+
|
1121 |
+
$now = localtime( time(), TRUE );
|
1122 |
+
echo '<tr title=""><td>' . __( 'Server Time', 'wp-time-capsule' ) . '</td><td>' . esc_html( $now[ 'tm_hour' ] . ':' . $now[ 'tm_min' ] ) . '</td></tr>';
|
1123 |
+
echo '<tr title=""><td>' . __( 'Blog Time', 'wp-time-capsule' ) . '</td><td>' . date( 'H:i', current_time( 'timestamp' ) ) . '</td></tr>';
|
1124 |
+
echo '<tr title="WPLANG"><td>' . __( 'Blog language', 'wp-time-capsule' ) . '</td><td>' . get_bloginfo( 'language' ) . '</td></tr>';
|
1125 |
+
echo '<tr title="utf8"><td>' . __( 'MySQL Client encoding', 'wp-time-capsule' ) . '</td><td>';
|
1126 |
+
echo defined( 'DB_CHARSET' ) ? DB_CHARSET : '';
|
1127 |
+
echo '</td></tr>';
|
1128 |
+
echo '<tr title="URF-8"><td>' . __( 'Blog charset', 'wp-time-capsule' ) . '</td><td>' . get_bloginfo( 'charset' ) . '</td></tr>';
|
1129 |
+
echo '<tr title=">=128M"><td>' . __( 'PHP Memory limit', 'wp-time-capsule' ) . '</td><td>' . esc_html( ini_get( 'memory_limit' ) ) . '</td></tr>';
|
1130 |
+
echo '<tr title="WP_MEMORY_LIMIT"><td>' . __( 'WP memory limit', 'wp-time-capsule' ) . '</td><td>' . esc_html( WP_MEMORY_LIMIT ) . '</td></tr>';
|
1131 |
+
echo '<tr title="WP_MAX_MEMORY_LIMIT"><td>' . __( 'WP maximum memory limit', 'wp-time-capsule' ) . '</td><td>' . esc_html( WP_MAX_MEMORY_LIMIT ) . '</td></tr>';
|
1132 |
+
echo '<tr title=""><td>' . __( 'Memory in use', 'wp-time-capsule' ) . '</td><td>' . size_format( @memory_get_usage( TRUE ), 2 ) . '</td></tr>';
|
1133 |
+
|
1134 |
+
//disabled PHP functions
|
1135 |
+
$disabled = esc_html( ini_get( 'disable_functions' ) );
|
1136 |
+
if ( ! empty( $disabled ) ) {
|
1137 |
+
$disabledarry = explode( ',', $disabled );
|
1138 |
+
echo '<tr title=""><td>' . __( 'Disabled PHP Functions:', 'wp-time-capsule' ) . '</td><td>';
|
1139 |
+
echo implode( ', ', $disabledarry );
|
1140 |
+
echo '</td></tr>';
|
1141 |
+
}
|
1142 |
+
|
1143 |
+
//Loaded PHP Extensions
|
1144 |
+
echo '<tr title=""><td>' . __( 'Loaded PHP Extensions:', 'wp-time-capsule' ) . '</td><td>';
|
1145 |
+
$extensions = get_loaded_extensions();
|
1146 |
+
sort( $extensions );
|
1147 |
+
echo esc_html( implode( ', ', $extensions ) );
|
1148 |
+
echo '</td></tr>';
|
1149 |
+
echo '</table>';
|
1150 |
+
|
1151 |
+
$html = ob_get_clean();
|
1152 |
+
return array( 'result' => $html);
|
1153 |
+
}
|
1154 |
+
|
1155 |
+
|
1156 |
+
public function update_vulns_settings(){
|
1157 |
+
|
1158 |
+
$vulns_obj = WPTC_Base_Factory::get('Wptc_Vulns');
|
1159 |
+
|
1160 |
+
$data = isset($_POST['data']) ? $_POST['data'] : array() ;
|
1161 |
+
$vulns_obj->update_vulns_settings($data);
|
1162 |
+
|
1163 |
+
return array( 'success' => 1 );
|
1164 |
+
}
|
1165 |
+
|
1166 |
+
function start_fresh_backup_tc_callback_wptc() {
|
1167 |
+
start_fresh_backup_tc_callback_wptc($type = '', $args = null, $test_connection = true, $ajax_check = false);
|
1168 |
+
return array('result' => 'success');
|
1169 |
+
}
|
1170 |
+
|
1171 |
+
public function save_manual_backup_name_wptc() {
|
1172 |
+
$backup_name = $_POST['backup_name'];
|
1173 |
+
$processed_files = WPTC_Factory::get('processed-files');
|
1174 |
+
$processed_files->save_manual_backup_name_wptc($backup_name);
|
1175 |
+
die();
|
1176 |
+
}
|
1177 |
+
|
1178 |
+
function send_response_wptc($status = null, $type = null, $data = null, $is_log =0) {
|
1179 |
+
if (!is_wptc_server_req() && !is_wptc_node_server_req()) {
|
1180 |
+
return false;
|
1181 |
+
}
|
1182 |
+
$config = WPTC_Factory::get('config');
|
1183 |
+
|
1184 |
+
if (empty($is_log)) {
|
1185 |
+
$post_arr['status'] = $status;
|
1186 |
+
$post_arr['type'] = $type;
|
1187 |
+
$post_arr['version'] = WPTC_VERSION;
|
1188 |
+
$post_arr['source'] = 'WPTC';
|
1189 |
+
$post_arr['scheduled_time'] = $config->get_option('schedule_time_str');
|
1190 |
+
$post_arr['timezone'] = $config->get_option('wptc_timezone');
|
1191 |
+
$post_arr['last_backup_time'] = $config->get_option('last_backup_time');
|
1192 |
+
if (!empty($data)) {
|
1193 |
+
$post_arr['progress'] = $data;
|
1194 |
+
}
|
1195 |
+
} else {
|
1196 |
+
$post_arr = $data;
|
1197 |
+
}
|
1198 |
+
|
1199 |
+
|
1200 |
+
return array( 'result' => 'success', 'data' => "<WPTC_START>".json_encode($post_arr)."<WPTC_END>" );
|
1201 |
+
}
|
1202 |
+
|
1203 |
+
|
1204 |
+
public function all_plugins( $plugins ) {
|
1205 |
+
foreach ( $plugins as $key => $value ) {
|
1206 |
+
$plugin_slug = basename( $key, '.php' );
|
1207 |
+
if ( 'wp-time-capsule' === $plugin_slug ) {
|
1208 |
+
unset( $plugins[ $key ] );
|
1209 |
+
}
|
1210 |
+
}
|
1211 |
+
|
1212 |
+
return $plugins;
|
1213 |
+
}
|
1214 |
+
|
1215 |
+
public function remove_menu() {
|
1216 |
+
remove_menu_page( 'wp-time-capsule-monitor' );
|
1217 |
+
$pos = stripos( $_SERVER['REQUEST_URI'], 'admin.php?page=wp-time-capsule-monitor' );
|
1218 |
+
if ( false !== $pos ) {
|
1219 |
+
wp_redirect( get_option( 'siteurl' ) . '/wp-admin/index.php' );
|
1220 |
+
exit();
|
1221 |
+
}
|
1222 |
+
}
|
1223 |
+
|
1224 |
+
function remove_update_nag( $value ) {
|
1225 |
+
if ( isset( $_POST['mainwpsignature'] ) ) {
|
1226 |
+
return $value;
|
1227 |
+
}
|
1228 |
+
if ( isset( $value->response['wp-time-capsule/wp-time-capsule.php'] ) ) {
|
1229 |
+
unset( $value->response['wp-time-capsule/wp-time-capsule.php'] );
|
1230 |
+
}
|
1231 |
+
|
1232 |
+
return $value;
|
1233 |
+
}
|
1234 |
+
}
|
1235 |
+
|
class/class-mainwp-child-updraft-plus-backups.php
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
|
3 |
class MainWP_Child_Updraft_Plus_Backups {
|
4 |
public static $instance = null;
|
5 |
-
|
6 |
-
|
7 |
if ( null === MainWP_Child_Updraft_Plus_Backups::$instance ) {
|
8 |
MainWP_Child_Updraft_Plus_Backups::$instance = new MainWP_Child_Updraft_Plus_Backups();
|
9 |
}
|
@@ -11,7 +11,15 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
11 |
return MainWP_Child_Updraft_Plus_Backups::$instance;
|
12 |
}
|
13 |
|
14 |
-
public function __construct() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
16 |
add_filter('updraftplus_save_last_backup', array( __CLASS__, 'hookUpdraftplusSaveLastBackup' ));
|
17 |
}
|
@@ -26,108 +34,119 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
26 |
}
|
27 |
return $last_backup;
|
28 |
}
|
29 |
-
|
30 |
function syncOthersData( $information, $data = array() ) {
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
41 |
return $information;
|
42 |
}
|
43 |
|
44 |
public function action() {
|
45 |
$information = array();
|
46 |
-
if ( !
|
47 |
$information['error'] = 'NO_UPDRAFTPLUS';
|
48 |
MainWP_Helper::write( $information );
|
49 |
}
|
50 |
|
|
|
|
|
51 |
global $updraftplus;
|
52 |
if ( empty( $updraftplus ) && class_exists( 'UpdraftPlus' ) ) {
|
53 |
$updraftplus = new UpdraftPlus();
|
54 |
}
|
55 |
if ( empty( $updraftplus ) ) {
|
56 |
-
$information['error'] = 'Error empty
|
57 |
MainWP_Helper::write( $information );
|
58 |
}
|
59 |
-
|
60 |
if ( isset( $_POST['mwp_action'] ) ) {
|
61 |
|
62 |
if ( get_option( 'mainwp_updraftplus_ext_enabled' ) !== 'Y' ) {
|
63 |
MainWP_Helper::update_option( 'mainwp_updraftplus_ext_enabled', 'Y', 'yes' );
|
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 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
|
|
|
|
|
|
|
|
131 |
}
|
132 |
MainWP_Helper::write( $information );
|
133 |
}
|
@@ -140,23 +159,6 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
140 |
return $information;
|
141 |
}
|
142 |
|
143 |
-
public static function isActivatedUpdraftplus() {
|
144 |
-
if ( ! defined( 'UPDRAFTPLUS_DIR' ) ) {
|
145 |
-
return false;
|
146 |
-
}
|
147 |
-
|
148 |
-
if ( ! class_exists( 'UpdraftPlus' ) ) {
|
149 |
-
require_once( UPDRAFTPLUS_DIR . '/class-updraftplus.php' );
|
150 |
-
}
|
151 |
-
|
152 |
-
if ( ! class_exists( 'UpdraftPlus_Options' ) ) {
|
153 |
-
require_once( UPDRAFTPLUS_DIR . '/options.php' );
|
154 |
-
}
|
155 |
-
|
156 |
-
return true;
|
157 |
-
}
|
158 |
-
|
159 |
-
|
160 |
private function get_settings_keys() {
|
161 |
return array(
|
162 |
'updraft_autobackup_default',
|
@@ -245,6 +247,9 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
245 |
|
246 |
|
247 |
private function connected_html() {
|
|
|
|
|
|
|
248 |
$vault_settings = UpdraftPlus_Options::get_updraft_option( 'updraft_updraftvault' );
|
249 |
if ( !is_array( $vault_settings ) || empty( $vault_settings['token'] ) || empty( $vault_settings['email'] ) ) {
|
250 |
return '';
|
@@ -372,6 +377,18 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
372 |
}
|
373 |
}
|
374 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
375 |
function save_settings() {
|
376 |
$settings = maybe_unserialize( base64_decode( $_POST['settings'] ) );
|
377 |
|
@@ -385,6 +402,8 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
385 |
$settings_key = null;
|
386 |
if ( 'updraft_dropbox' === $key && is_array($settings[ $key ])) {
|
387 |
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_dropbox' );
|
|
|
|
|
388 |
if(is_array($opts) && isset($opts['settings'])) {
|
389 |
$settings_key = key($opts['settings']);
|
390 |
if (isset($settings['is_general']) && !empty($settings['is_general'])){
|
@@ -406,6 +425,8 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
406 |
UpdraftPlus_Options::update_updraft_option( $key, $opts );
|
407 |
} else if ( 'updraft_googledrive' === $key ) {
|
408 |
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_googledrive' );
|
|
|
|
|
409 |
if(is_array($opts) && isset($opts['settings'])) {
|
410 |
$settings_key = key($opts['settings']);
|
411 |
// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid'];
|
@@ -419,6 +440,8 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
419 |
UpdraftPlus_Options::update_updraft_option( $key, $opts );
|
420 |
} else if ( 'updraft_googlecloud' === $key ) {
|
421 |
$opts = UpdraftPlus_Options::get_updraft_option( $key );
|
|
|
|
|
422 |
if(is_array($opts) && isset($opts['settings'])) {
|
423 |
$settings_key = key($opts['settings']);
|
424 |
// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid'];
|
@@ -438,6 +461,8 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
438 |
UpdraftPlus_Options::update_updraft_option( $key, $opts );
|
439 |
} else if ( 'updraft_onedrive' === $key ) {
|
440 |
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_onedrive' );
|
|
|
|
|
441 |
if(is_array($opts) && isset($opts['settings'])) {
|
442 |
$settings_key = key($opts['settings']);
|
443 |
// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid'];
|
@@ -461,6 +486,8 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
461 |
UpdraftPlus_Options::update_updraft_option( $key, $value );
|
462 |
} else if ( 'updraft_s3' === $key ) {
|
463 |
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_s3' );
|
|
|
|
|
464 |
if(is_array($opts) && isset($opts['settings'])) {
|
465 |
$settings_key = key($opts['settings']);
|
466 |
$opts['settings'][$settings_key]['accesskey'] = $settings[ $key ]['accesskey'];
|
@@ -489,6 +516,8 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
489 |
UpdraftPlus_Options::update_updraft_option( $key, $opts );
|
490 |
} else if ( 'updraft_s3generic' === $key ) {
|
491 |
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_s3generic' );
|
|
|
|
|
492 |
if(is_array($opts) && isset($opts['settings'])) {
|
493 |
$settings_key = key($opts['settings']);
|
494 |
$opts['settings'][$settings_key]['endpoint'] = $settings[ $key ]['endpoint'];
|
@@ -505,6 +534,8 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
505 |
UpdraftPlus_Options::update_updraft_option( $key, $opts );
|
506 |
} else if ( 'updraft_dreamobjects' === $key ) {
|
507 |
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_dreamobjects' );
|
|
|
|
|
508 |
if(is_array($opts) && isset($opts['settings'])) {
|
509 |
$settings_key = key($opts['settings']);
|
510 |
$opts['settings'][$settings_key]['path'] = $this->replace_tokens($settings[ $key ]['path']);
|
@@ -514,6 +545,8 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
514 |
UpdraftPlus_Options::update_updraft_option( $key, $opts );
|
515 |
} else if ( 'updraft_ftp' === $key ) {
|
516 |
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_ftp' );
|
|
|
|
|
517 |
if(is_array($opts) && isset($opts['settings'])) {
|
518 |
$settings_key = key($opts['settings']);
|
519 |
if ( isset( $settings[ $key ]['path'] ) ) {
|
@@ -536,6 +569,8 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
536 |
UpdraftPlus_Options::update_updraft_option( $key, $opts );
|
537 |
} else if ( 'updraft_sftp_settings' === $key ) {
|
538 |
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_sftp' );
|
|
|
|
|
539 |
if(is_array($opts) && isset($opts['settings'])) {
|
540 |
$settings_key = key($opts['settings']);
|
541 |
if ( isset( $settings[ $key ]['path'] ) ) {
|
@@ -560,7 +595,9 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
560 |
}
|
561 |
UpdraftPlus_Options::update_updraft_option( 'updraft_sftp', $opts );
|
562 |
} else if ( 'updraft_backblaze' === $key ) {
|
563 |
-
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_backblaze' );
|
|
|
|
|
564 |
if (is_array($opts) && isset($opts['settings'])) {
|
565 |
$settings_key = key($opts['settings']);
|
566 |
$opts['settings'][$settings_key]['account_id'] = $settings[ $key ]['account_id'];
|
@@ -987,7 +1024,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
987 |
if ( empty( $updraftplus ) ) {
|
988 |
return false;
|
989 |
}
|
990 |
-
|
991 |
// UNIX timestamp
|
992 |
$next_scheduled_backup = wp_next_scheduled( 'updraft_backup' );
|
993 |
$next_scheduled_backup_gmt = $next_scheduled_backup_database_gmt = 0;
|
@@ -1000,6 +1037,11 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
1000 |
$next_scheduled_backup = 'Nothing currently scheduled';
|
1001 |
}
|
1002 |
|
|
|
|
|
|
|
|
|
|
|
1003 |
$next_scheduled_backup_database = wp_next_scheduled( 'updraft_backup_database' );
|
1004 |
if ( UpdraftPlus_Options::get_updraft_option( 'updraft_interval_database', UpdraftPlus_Options::get_updraft_option( 'updraft_interval' ) ) === UpdraftPlus_Options::get_updraft_option( 'updraft_interval' ) ) {
|
1005 |
$next_scheduled_backup_database = ( 'Nothing currently scheduled' === $next_scheduled_backup ) ? $next_scheduled_backup : __( 'At the same time as the files backup', 'updraftplus' );
|
@@ -1259,8 +1301,10 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
1259 |
}
|
1260 |
|
1261 |
public function build_historystatus() {
|
1262 |
-
|
1263 |
-
|
|
|
|
|
1264 |
$backup_history = UpdraftPlus_Backup_History::get_history();
|
1265 |
|
1266 |
$output = $this->existing_backup_table( $backup_history );
|
@@ -1287,8 +1331,6 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
1287 |
$messages = $this->rebuildBackupHistory( $remotescan );
|
1288 |
}
|
1289 |
|
1290 |
-
// $backup_history = UpdraftPlus_Options::get_updraft_option( 'updraft_backup_history' );
|
1291 |
-
// $backup_history = ( is_array( $backup_history ) ) ? $backup_history : array();
|
1292 |
$backup_history = UpdraftPlus_Backup_History::get_history();
|
1293 |
$output = $this->existing_backup_table( $backup_history );
|
1294 |
|
@@ -2970,7 +3012,6 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
2970 |
global $updraftplus;
|
2971 |
|
2972 |
if ( false === $backup_history ) {
|
2973 |
-
// $backup_history = UpdraftPlus_Options::get_updraft_option( 'updraft_backup_history' );
|
2974 |
$backup_history = UpdraftPlus_Backup_History::get_history();
|
2975 |
}
|
2976 |
|
@@ -2978,6 +3019,8 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
2978 |
return '<p><em>' . __( 'You have not yet made any backups.', 'updraftplus' ) . '</em></p>';
|
2979 |
}
|
2980 |
|
|
|
|
|
2981 |
$updraft_dir = $updraftplus->backups_dir_location();
|
2982 |
$backupable_entities = $updraftplus->get_backupable_file_entities( true, true );
|
2983 |
|
@@ -2989,7 +3032,6 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
2989 |
$ret = '<table style="margin-top: 20px; margin-left: 20px;">';
|
2990 |
$nonce_field = wp_nonce_field( 'updraftplus_download', '_wpnonce', true, false );
|
2991 |
|
2992 |
-
//".__('Actions', 'updraftplus')."
|
2993 |
$ret .= '<thead>
|
2994 |
<tr style="margin-bottom: 4px;">
|
2995 |
<th style="padding:0px 10px 6px; width: 172px;">' . __( 'Backup date', 'updraftplus' ) . '</th>
|
@@ -3001,9 +3043,6 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|
3001 |
</tr>
|
3002 |
</thead>
|
3003 |
<tbody>';
|
3004 |
-
// $ret .= "<thead>
|
3005 |
-
// </thead>
|
3006 |
-
// <tbody>";
|
3007 |
|
3008 |
krsort( $backup_history );
|
3009 |
foreach ( $backup_history as $key => $backup ) {
|
@@ -3050,14 +3089,13 @@ ENDHERE;
|
|
3050 |
// Set a flag according to whether or not $backup['db'] ends in .crypt, then pick this up in the display of the decrypt field.
|
3051 |
$db = is_array( $backup['db'] ) ? $backup['db'][0] : $backup['db'];
|
3052 |
if ( class_exists( 'UpdraftPlus_Encryption')) {
|
3053 |
-
|
3054 |
-
|
|
|
3055 |
$entities .= '/dbcrypted=1/';
|
3056 |
}
|
3057 |
|
3058 |
$ret .= $this->download_db_button( 'db', $key, $esc_pretty_date, $nonce_field, $backup, $accept );
|
3059 |
-
} else {
|
3060 |
-
// $ret .= sprintf(_x('(No %s)','Message shown when no such object is available','updraftplus'), __('database', 'updraftplus'));
|
3061 |
}
|
3062 |
|
3063 |
# External databases
|
@@ -3871,20 +3909,6 @@ ENDHERE;
|
|
3871 |
|
3872 |
function remove_notices() {
|
3873 |
$remove_hooks['all_admin_notices'] = array(
|
3874 |
-
// 'UpdraftPlus_Admin' => array(
|
3875 |
-
// 'show_admin_notice_upgradead' => 10,
|
3876 |
-
// 'show_admin_warning_googledrive' => 10,
|
3877 |
-
// 'show_admin_warning_dropbox' => 10,
|
3878 |
-
// 'show_admin_warning_bitcasa' => 10,
|
3879 |
-
// 'show_admin_warning_copycom' => 10,
|
3880 |
-
// 'show_admin_warning_onedrive' => 10,
|
3881 |
-
// 'show_admin_warning_updraftvault' => 10,
|
3882 |
-
// 'show_admin_warning_diskspace' => 10,
|
3883 |
-
// 'show_admin_warning_disabledcron' => 10,
|
3884 |
-
// 'show_admin_nosettings_warning' => 10,
|
3885 |
-
// 'show_admin_warning_execution_time' => 10,
|
3886 |
-
// 'show_admin_warning_litespeed' => 10,
|
3887 |
-
// ),
|
3888 |
'UpdraftPlus' => array(
|
3889 |
'show_admin_warning_unreadablelog' => 10,
|
3890 |
'show_admin_warning_nolog' => 10,
|
@@ -3896,9 +3920,6 @@ ENDHERE;
|
|
3896 |
'UpdraftPlus_BackupModule_googledrive' => array(
|
3897 |
'show_authed_admin_success' => 10,
|
3898 |
),
|
3899 |
-
// 'UpdraftPlus_Options' => array(
|
3900 |
-
// 'show_admin_warning_multisite' => 10
|
3901 |
-
// )
|
3902 |
);
|
3903 |
|
3904 |
foreach ( $remove_hooks as $hook_name => $hooks ) {
|
@@ -3938,11 +3959,8 @@ ENDHERE;
|
|
3938 |
return $value;
|
3939 |
}
|
3940 |
|
3941 |
-
public function
|
3942 |
-
|
3943 |
-
return '';
|
3944 |
-
}
|
3945 |
-
|
3946 |
return $this->get_updraft_data();
|
3947 |
}
|
3948 |
|
2 |
|
3 |
class MainWP_Child_Updraft_Plus_Backups {
|
4 |
public static $instance = null;
|
5 |
+
public $is_plugin_installed = false;
|
6 |
+
static function Instance() {
|
7 |
if ( null === MainWP_Child_Updraft_Plus_Backups::$instance ) {
|
8 |
MainWP_Child_Updraft_Plus_Backups::$instance = new MainWP_Child_Updraft_Plus_Backups();
|
9 |
}
|
11 |
return MainWP_Child_Updraft_Plus_Backups::$instance;
|
12 |
}
|
13 |
|
14 |
+
public function __construct() {
|
15 |
+
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
16 |
+
if ( is_plugin_active( 'updraftplus/updraftplus.php' ) && defined('UPDRAFTPLUS_DIR')) {
|
17 |
+
$this->is_plugin_installed = true;
|
18 |
+
}
|
19 |
+
|
20 |
+
if (!$this->is_plugin_installed)
|
21 |
+
return;
|
22 |
+
|
23 |
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
24 |
add_filter('updraftplus_save_last_backup', array( __CLASS__, 'hookUpdraftplusSaveLastBackup' ));
|
25 |
}
|
34 |
}
|
35 |
return $last_backup;
|
36 |
}
|
37 |
+
// ok
|
38 |
function syncOthersData( $information, $data = array() ) {
|
39 |
+
try{
|
40 |
+
if ( isset( $data['syncUpdraftData'] ) && $data['syncUpdraftData'] ) {
|
41 |
+
if ( $this->is_plugin_installed ) {
|
42 |
+
$information['syncUpdraftData'] = $this->get_sync_data();
|
43 |
+
}
|
44 |
+
}
|
45 |
+
if ( isset( $data['sync_Updraftvault_quota_text'] ) && $data['sync_Updraftvault_quota_text'] ) {
|
46 |
+
if ( $this->is_plugin_installed ) {
|
47 |
+
$information['sync_Updraftvault_quota_text'] = $this->connected_html();
|
48 |
+
}
|
49 |
+
}
|
50 |
+
} catch(Exception $e) {
|
51 |
+
|
52 |
+
}
|
53 |
+
|
54 |
return $information;
|
55 |
}
|
56 |
|
57 |
public function action() {
|
58 |
$information = array();
|
59 |
+
if ( ! $this->is_plugin_installed ) {
|
60 |
$information['error'] = 'NO_UPDRAFTPLUS';
|
61 |
MainWP_Helper::write( $information );
|
62 |
}
|
63 |
|
64 |
+
$this->required_files();
|
65 |
+
|
66 |
global $updraftplus;
|
67 |
if ( empty( $updraftplus ) && class_exists( 'UpdraftPlus' ) ) {
|
68 |
$updraftplus = new UpdraftPlus();
|
69 |
}
|
70 |
if ( empty( $updraftplus ) ) {
|
71 |
+
$information['error'] = 'Error empty updraftplus';
|
72 |
MainWP_Helper::write( $information );
|
73 |
}
|
74 |
+
|
75 |
if ( isset( $_POST['mwp_action'] ) ) {
|
76 |
|
77 |
if ( get_option( 'mainwp_updraftplus_ext_enabled' ) !== 'Y' ) {
|
78 |
MainWP_Helper::update_option( 'mainwp_updraftplus_ext_enabled', 'Y', 'yes' );
|
79 |
}
|
80 |
+
|
81 |
+
try {
|
82 |
+
switch ( $_POST['mwp_action'] ) {
|
83 |
+
case 'set_showhide':
|
84 |
+
$information = $this->set_showhide();
|
85 |
+
break;
|
86 |
+
case 'save_settings':
|
87 |
+
$information = $this->save_settings();
|
88 |
+
break;
|
89 |
+
case 'addons_connect':
|
90 |
+
$information = $this->addons_connect();
|
91 |
+
break;
|
92 |
+
case 'backup_now':
|
93 |
+
$information = $this->backup_now();
|
94 |
+
break;
|
95 |
+
case 'activejobs_list':
|
96 |
+
$information = $this->activejobs_list();
|
97 |
+
break;
|
98 |
+
case 'diskspaceused':
|
99 |
+
$information = $this->diskspaceused();
|
100 |
+
break;
|
101 |
+
case 'last_backup_html':
|
102 |
+
$information = $this->last_backup_html();
|
103 |
+
break;
|
104 |
+
case 'reload_data':
|
105 |
+
$information = $this->get_updraft_data();
|
106 |
+
break;
|
107 |
+
case 'next_scheduled_backups':
|
108 |
+
$information = $this->next_scheduled_backups();
|
109 |
+
break;
|
110 |
+
case 'forcescheduledresumption':
|
111 |
+
$information = $this->forceScheduledResumption();
|
112 |
+
break;
|
113 |
+
case 'fetch_updraft_log':
|
114 |
+
$information = $this->fetch_updraft_log();
|
115 |
+
break;
|
116 |
+
case 'activejobs_delete':
|
117 |
+
$information = $this->activejobs_delete();
|
118 |
+
break;
|
119 |
+
case 'historystatus':
|
120 |
+
$information = $this->historystatus();
|
121 |
+
break;
|
122 |
+
case 'deleteset':
|
123 |
+
$information = $this->deleteset();
|
124 |
+
break;
|
125 |
+
case 'updraft_download_backup':
|
126 |
+
$information = $this->updraft_download_backup();
|
127 |
+
break;
|
128 |
+
case 'restore_alldownloaded':
|
129 |
+
$information = $this->restore_alldownloaded();
|
130 |
+
break;
|
131 |
+
case 'restorebackup': // not used
|
132 |
+
$information = $this->restoreBackup();
|
133 |
+
break;
|
134 |
+
case 'extradbtestconnection':
|
135 |
+
$information = $this->extradb_testconnection();
|
136 |
+
break;
|
137 |
+
case 'delete_old_dirs':
|
138 |
+
$information = $this->delete_old_dirs_go();
|
139 |
+
break;
|
140 |
+
case 'vault_connect':
|
141 |
+
$information = $this->do_vault_connect();
|
142 |
+
break;
|
143 |
+
case 'vault_disconnect':
|
144 |
+
$information = $this->vault_disconnect();
|
145 |
+
break;
|
146 |
+
}
|
147 |
+
} catch(Exception $e) {
|
148 |
+
$information = array('error' => $e->getMessage());
|
149 |
+
}
|
150 |
}
|
151 |
MainWP_Helper::write( $information );
|
152 |
}
|
159 |
return $information;
|
160 |
}
|
161 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
private function get_settings_keys() {
|
163 |
return array(
|
164 |
'updraft_autobackup_default',
|
247 |
|
248 |
|
249 |
private function connected_html() {
|
250 |
+
MainWP_Helper::check_classes_exists('UpdraftPlus_Options');
|
251 |
+
MainWP_Helper::check_methods('UpdraftPlus_Options', 'get_updraft_option');
|
252 |
+
|
253 |
$vault_settings = UpdraftPlus_Options::get_updraft_option( 'updraft_updraftvault' );
|
254 |
if ( !is_array( $vault_settings ) || empty( $vault_settings['token'] ) || empty( $vault_settings['email'] ) ) {
|
255 |
return '';
|
377 |
}
|
378 |
}
|
379 |
|
380 |
+
function required_files() {
|
381 |
+
if (defined('UPDRAFTPLUS_DIR')) {
|
382 |
+
if ( ! class_exists( 'UpdraftPlus' ) && file_exists( UPDRAFTPLUS_DIR . '/class-updraftplus.php') ) {
|
383 |
+
require_once( UPDRAFTPLUS_DIR . '/class-updraftplus.php' );
|
384 |
+
}
|
385 |
+
|
386 |
+
if ( ! class_exists( 'UpdraftPlus_Options' ) && file_exists( UPDRAFTPLUS_DIR . '/options.php' ) ) {
|
387 |
+
require_once( UPDRAFTPLUS_DIR . '/options.php' );
|
388 |
+
}
|
389 |
+
}
|
390 |
+
}
|
391 |
+
|
392 |
function save_settings() {
|
393 |
$settings = maybe_unserialize( base64_decode( $_POST['settings'] ) );
|
394 |
|
402 |
$settings_key = null;
|
403 |
if ( 'updraft_dropbox' === $key && is_array($settings[ $key ])) {
|
404 |
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_dropbox' );
|
405 |
+
if (!is_array($opts))
|
406 |
+
$opts = array();
|
407 |
if(is_array($opts) && isset($opts['settings'])) {
|
408 |
$settings_key = key($opts['settings']);
|
409 |
if (isset($settings['is_general']) && !empty($settings['is_general'])){
|
425 |
UpdraftPlus_Options::update_updraft_option( $key, $opts );
|
426 |
} else if ( 'updraft_googledrive' === $key ) {
|
427 |
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_googledrive' );
|
428 |
+
if (!is_array($opts))
|
429 |
+
$opts = array();
|
430 |
if(is_array($opts) && isset($opts['settings'])) {
|
431 |
$settings_key = key($opts['settings']);
|
432 |
// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid'];
|
440 |
UpdraftPlus_Options::update_updraft_option( $key, $opts );
|
441 |
} else if ( 'updraft_googlecloud' === $key ) {
|
442 |
$opts = UpdraftPlus_Options::get_updraft_option( $key );
|
443 |
+
if (!is_array($opts))
|
444 |
+
$opts = array();
|
445 |
if(is_array($opts) && isset($opts['settings'])) {
|
446 |
$settings_key = key($opts['settings']);
|
447 |
// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid'];
|
461 |
UpdraftPlus_Options::update_updraft_option( $key, $opts );
|
462 |
} else if ( 'updraft_onedrive' === $key ) {
|
463 |
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_onedrive' );
|
464 |
+
if (!is_array($opts))
|
465 |
+
$opts = array();
|
466 |
if(is_array($opts) && isset($opts['settings'])) {
|
467 |
$settings_key = key($opts['settings']);
|
468 |
// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid'];
|
486 |
UpdraftPlus_Options::update_updraft_option( $key, $value );
|
487 |
} else if ( 'updraft_s3' === $key ) {
|
488 |
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_s3' );
|
489 |
+
if (!is_array($opts))
|
490 |
+
$opts = array();
|
491 |
if(is_array($opts) && isset($opts['settings'])) {
|
492 |
$settings_key = key($opts['settings']);
|
493 |
$opts['settings'][$settings_key]['accesskey'] = $settings[ $key ]['accesskey'];
|
516 |
UpdraftPlus_Options::update_updraft_option( $key, $opts );
|
517 |
} else if ( 'updraft_s3generic' === $key ) {
|
518 |
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_s3generic' );
|
519 |
+
if (!is_array($opts))
|
520 |
+
$opts = array();
|
521 |
if(is_array($opts) && isset($opts['settings'])) {
|
522 |
$settings_key = key($opts['settings']);
|
523 |
$opts['settings'][$settings_key]['endpoint'] = $settings[ $key ]['endpoint'];
|
534 |
UpdraftPlus_Options::update_updraft_option( $key, $opts );
|
535 |
} else if ( 'updraft_dreamobjects' === $key ) {
|
536 |
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_dreamobjects' );
|
537 |
+
if (!is_array($opts))
|
538 |
+
$opts = array();
|
539 |
if(is_array($opts) && isset($opts['settings'])) {
|
540 |
$settings_key = key($opts['settings']);
|
541 |
$opts['settings'][$settings_key]['path'] = $this->replace_tokens($settings[ $key ]['path']);
|
545 |
UpdraftPlus_Options::update_updraft_option( $key, $opts );
|
546 |
} else if ( 'updraft_ftp' === $key ) {
|
547 |
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_ftp' );
|
548 |
+
if (!is_array($opts))
|
549 |
+
$opts = array();
|
550 |
if(is_array($opts) && isset($opts['settings'])) {
|
551 |
$settings_key = key($opts['settings']);
|
552 |
if ( isset( $settings[ $key ]['path'] ) ) {
|
569 |
UpdraftPlus_Options::update_updraft_option( $key, $opts );
|
570 |
} else if ( 'updraft_sftp_settings' === $key ) {
|
571 |
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_sftp' );
|
572 |
+
if (!is_array($opts))
|
573 |
+
$opts = array();
|
574 |
if(is_array($opts) && isset($opts['settings'])) {
|
575 |
$settings_key = key($opts['settings']);
|
576 |
if ( isset( $settings[ $key ]['path'] ) ) {
|
595 |
}
|
596 |
UpdraftPlus_Options::update_updraft_option( 'updraft_sftp', $opts );
|
597 |
} else if ( 'updraft_backblaze' === $key ) {
|
598 |
+
$opts = UpdraftPlus_Options::get_updraft_option( 'updraft_backblaze' );
|
599 |
+
if (!is_array($opts))
|
600 |
+
$opts = array();
|
601 |
if (is_array($opts) && isset($opts['settings'])) {
|
602 |
$settings_key = key($opts['settings']);
|
603 |
$opts['settings'][$settings_key]['account_id'] = $settings[ $key ]['account_id'];
|
1024 |
if ( empty( $updraftplus ) ) {
|
1025 |
return false;
|
1026 |
}
|
1027 |
+
|
1028 |
// UNIX timestamp
|
1029 |
$next_scheduled_backup = wp_next_scheduled( 'updraft_backup' );
|
1030 |
$next_scheduled_backup_gmt = $next_scheduled_backup_database_gmt = 0;
|
1037 |
$next_scheduled_backup = 'Nothing currently scheduled';
|
1038 |
}
|
1039 |
|
1040 |
+
|
1041 |
+
MainWP_Helper::check_classes_exists('UpdraftPlus_Options');
|
1042 |
+
MainWP_Helper::check_methods('UpdraftPlus_Options', 'get_updraft_option');
|
1043 |
+
MainWP_Helper::check_methods($updraftplus, array( 'backups_dir_location', 'really_is_writable' ));
|
1044 |
+
|
1045 |
$next_scheduled_backup_database = wp_next_scheduled( 'updraft_backup_database' );
|
1046 |
if ( UpdraftPlus_Options::get_updraft_option( 'updraft_interval_database', UpdraftPlus_Options::get_updraft_option( 'updraft_interval' ) ) === UpdraftPlus_Options::get_updraft_option( 'updraft_interval' ) ) {
|
1047 |
$next_scheduled_backup_database = ( 'Nothing currently scheduled' === $next_scheduled_backup ) ? $next_scheduled_backup : __( 'At the same time as the files backup', 'updraftplus' );
|
1301 |
}
|
1302 |
|
1303 |
public function build_historystatus() {
|
1304 |
+
|
1305 |
+
MainWP_Helper::check_classes_exists('UpdraftPlus_Backup_History');
|
1306 |
+
MainWP_Helper::check_methods('UpdraftPlus_Backup_History', 'get_history');
|
1307 |
+
|
1308 |
$backup_history = UpdraftPlus_Backup_History::get_history();
|
1309 |
|
1310 |
$output = $this->existing_backup_table( $backup_history );
|
1331 |
$messages = $this->rebuildBackupHistory( $remotescan );
|
1332 |
}
|
1333 |
|
|
|
|
|
1334 |
$backup_history = UpdraftPlus_Backup_History::get_history();
|
1335 |
$output = $this->existing_backup_table( $backup_history );
|
1336 |
|
3012 |
global $updraftplus;
|
3013 |
|
3014 |
if ( false === $backup_history ) {
|
|
|
3015 |
$backup_history = UpdraftPlus_Backup_History::get_history();
|
3016 |
}
|
3017 |
|
3019 |
return '<p><em>' . __( 'You have not yet made any backups.', 'updraftplus' ) . '</em></p>';
|
3020 |
}
|
3021 |
|
3022 |
+
MainWP_Helper::check_methods($updraftplus, array( 'backups_dir_location', 'get_backupable_file_entities' ));
|
3023 |
+
|
3024 |
$updraft_dir = $updraftplus->backups_dir_location();
|
3025 |
$backupable_entities = $updraftplus->get_backupable_file_entities( true, true );
|
3026 |
|
3032 |
$ret = '<table style="margin-top: 20px; margin-left: 20px;">';
|
3033 |
$nonce_field = wp_nonce_field( 'updraftplus_download', '_wpnonce', true, false );
|
3034 |
|
|
|
3035 |
$ret .= '<thead>
|
3036 |
<tr style="margin-bottom: 4px;">
|
3037 |
<th style="padding:0px 10px 6px; width: 172px;">' . __( 'Backup date', 'updraftplus' ) . '</th>
|
3043 |
</tr>
|
3044 |
</thead>
|
3045 |
<tbody>';
|
|
|
|
|
|
|
3046 |
|
3047 |
krsort( $backup_history );
|
3048 |
foreach ( $backup_history as $key => $backup ) {
|
3089 |
// Set a flag according to whether or not $backup['db'] ends in .crypt, then pick this up in the display of the decrypt field.
|
3090 |
$db = is_array( $backup['db'] ) ? $backup['db'][0] : $backup['db'];
|
3091 |
if ( class_exists( 'UpdraftPlus_Encryption')) {
|
3092 |
+
if ( method_exists('UpdraftPlus_Encryption', 'is_file_encrypted'))
|
3093 |
+
if (UpdraftPlus_Encryption::is_file_encrypted($db)) $entities .= '/dbcrypted=1/';
|
3094 |
+
} else if ( method_exists($updraftplus, 'is_db_encrypted') && $updraftplus->is_db_encrypted( $db ) ) {
|
3095 |
$entities .= '/dbcrypted=1/';
|
3096 |
}
|
3097 |
|
3098 |
$ret .= $this->download_db_button( 'db', $key, $esc_pretty_date, $nonce_field, $backup, $accept );
|
|
|
|
|
3099 |
}
|
3100 |
|
3101 |
# External databases
|
3909 |
|
3910 |
function remove_notices() {
|
3911 |
$remove_hooks['all_admin_notices'] = array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3912 |
'UpdraftPlus' => array(
|
3913 |
'show_admin_warning_unreadablelog' => 10,
|
3914 |
'show_admin_warning_nolog' => 10,
|
3920 |
'UpdraftPlus_BackupModule_googledrive' => array(
|
3921 |
'show_authed_admin_success' => 10,
|
3922 |
),
|
|
|
|
|
|
|
3923 |
);
|
3924 |
|
3925 |
foreach ( $remove_hooks as $hook_name => $hooks ) {
|
3959 |
return $value;
|
3960 |
}
|
3961 |
|
3962 |
+
public function get_sync_data() {
|
3963 |
+
$this->required_files();
|
|
|
|
|
|
|
3964 |
return $this->get_updraft_data();
|
3965 |
}
|
3966 |
|
class/class-mainwp-child-wordfence.php
CHANGED
@@ -182,15 +182,16 @@ class MainWP_Child_Wordfence {
|
|
182 |
add_action( 'mainwp_child_deactivation', array( $this, 'deactivation' ) );
|
183 |
|
184 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
}
|
190 |
-
|
191 |
-
if ( $this->is_wordfence_installed ) {
|
192 |
-
add_action( 'wp_ajax_mainwp_wordfence_download_htaccess', array( $this, 'downloadHtaccess' ) );
|
193 |
-
}
|
194 |
|
195 |
}
|
196 |
|
@@ -656,7 +657,7 @@ class MainWP_Child_Wordfence {
|
|
656 |
function do_site_stats() {
|
657 |
do_action( 'mainwp_child_reports_log', 'wordfence' );
|
658 |
}
|
659 |
-
|
660 |
public function do_reports_log($ext = '') {
|
661 |
if ( $ext !== 'wordfence' ) return;
|
662 |
if ( ! $this->is_wordfence_installed ) return;
|
182 |
add_action( 'mainwp_child_deactivation', array( $this, 'deactivation' ) );
|
183 |
|
184 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
185 |
+
|
186 |
+
// ok
|
187 |
+
if ( is_plugin_active( 'wordfence/wordfence.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../wordfence/wordfence.php' ) ) {
|
188 |
+
require_once( plugin_dir_path( __FILE__ ) . '../../wordfence/wordfence.php' );
|
189 |
+
$this->is_wordfence_installed = true;
|
190 |
+
}
|
191 |
|
192 |
+
if ( $this->is_wordfence_installed ) {
|
193 |
+
add_action( 'wp_ajax_mainwp_wordfence_download_htaccess', array( $this, 'downloadHtaccess' ) );
|
194 |
+
}
|
|
|
|
|
|
|
|
|
|
|
195 |
|
196 |
}
|
197 |
|
657 |
function do_site_stats() {
|
658 |
do_action( 'mainwp_child_reports_log', 'wordfence' );
|
659 |
}
|
660 |
+
// ok
|
661 |
public function do_reports_log($ext = '') {
|
662 |
if ( $ext !== 'wordfence' ) return;
|
663 |
if ( ! $this->is_wordfence_installed ) return;
|
class/class-mainwp-child-wp-rocket.php
CHANGED
@@ -12,7 +12,7 @@ class MainWP_Child_WP_Rocket {
|
|
12 |
}
|
13 |
|
14 |
public function __construct() {
|
15 |
-
|
16 |
}
|
17 |
|
18 |
public function init() {
|
@@ -20,6 +20,8 @@ class MainWP_Child_WP_Rocket {
|
|
20 |
return;
|
21 |
}
|
22 |
|
|
|
|
|
23 |
if ( get_option( 'mainwp_wprocket_hide_plugin' ) === 'hide' ) {
|
24 |
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
|
25 |
add_action( 'admin_menu', array( $this, 'remove_menu' ) );
|
@@ -28,6 +30,18 @@ class MainWP_Child_WP_Rocket {
|
|
28 |
add_action( 'admin_init', array( $this, 'remove_notices' ) );
|
29 |
}
|
30 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
function remove_notices() {
|
33 |
$remove_hooks['admin_notices'] = array(
|
12 |
}
|
13 |
|
14 |
public function __construct() {
|
15 |
+
|
16 |
}
|
17 |
|
18 |
public function init() {
|
20 |
return;
|
21 |
}
|
22 |
|
23 |
+
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
24 |
+
|
25 |
if ( get_option( 'mainwp_wprocket_hide_plugin' ) === 'hide' ) {
|
26 |
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
|
27 |
add_action( 'admin_menu', array( $this, 'remove_menu' ) );
|
30 |
add_action( 'admin_init', array( $this, 'remove_notices' ) );
|
31 |
}
|
32 |
}
|
33 |
+
|
34 |
+
// ok
|
35 |
+
public function syncOthersData( $information, $data = array() ) {
|
36 |
+
if ( isset( $data['syncWPRocketData'] ) && ( 'yes' === $data['syncWPRocketData'] ) ) {
|
37 |
+
try{
|
38 |
+
$data = array( 'rocket_boxes' => get_user_meta( $GLOBALS['current_user']->ID, 'rocket_boxes', true ));
|
39 |
+
$information['syncWPRocketData'] = $data;
|
40 |
+
} catch(Exception $e) {
|
41 |
+
}
|
42 |
+
}
|
43 |
+
return $information;
|
44 |
+
}
|
45 |
|
46 |
function remove_notices() {
|
47 |
$remove_hooks['admin_notices'] = array(
|
class/class-mainwp-child.php
CHANGED
@@ -84,7 +84,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
|
|
84 |
}
|
85 |
|
86 |
class MainWP_Child {
|
87 |
-
public static $version = '3.4.
|
88 |
private $update_version = '1.3';
|
89 |
|
90 |
private $callableFunctions = array(
|
@@ -152,6 +152,7 @@ class MainWP_Child {
|
|
152 |
'vulner_checker' => 'vulner_checker',
|
153 |
'wp_staging' => 'wp_staging',
|
154 |
'disconnect' => 'disconnect',
|
|
|
155 |
);
|
156 |
|
157 |
private $FTP_ERROR = 'Failed! Please, add FTP details for automatic updates.';
|
@@ -207,7 +208,7 @@ class MainWP_Child {
|
|
207 |
|
208 |
MainWP_Clone::get()->init();
|
209 |
MainWP_Child_Server_Information::init();
|
210 |
-
MainWP_Client_Report::init();
|
211 |
MainWP_Child_Plugins_Check::Instance();
|
212 |
MainWP_Child_Themes_Check::Instance();
|
213 |
|
@@ -1384,33 +1385,36 @@ class MainWP_Child {
|
|
1384 |
die();
|
1385 |
}
|
1386 |
}
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
MainWP_Child_Back_WP_Up::Instance()->init();
|
1399 |
-
|
1400 |
-
new MainWP_Child_Back_Up_Buddy();
|
1401 |
MainWP_Child_Wordfence::Instance()->wordfence_init();
|
1402 |
-
|
1403 |
-
|
|
|
|
|
|
|
|
|
|
|
1404 |
global $_wp_submenu_nopriv;
|
1405 |
if ($_wp_submenu_nopriv === null)
|
1406 |
$_wp_submenu_nopriv = array(); // fix warning
|
1407 |
-
|
1408 |
//Call the function required
|
1409 |
if ( $auth && isset( $_POST['function'] ) && isset( $this->callableFunctions[ $_POST['function'] ] ) ) {
|
1410 |
define( 'DOING_CRON', true );
|
1411 |
// ob_start();
|
1412 |
// require_once( ABSPATH . 'wp-admin/admin.php' );
|
1413 |
-
// ob_end_clean();
|
|
|
|
|
1414 |
MainWP_Child::fix_for_custom_themes();
|
1415 |
call_user_func( array( $this, $this->callableFunctions[ $_POST['function'] ] ) );
|
1416 |
} else if ( isset( $_POST['function'] ) && isset( $this->callableFunctionsNoAuth[ $_POST['function'] ] ) ) {
|
@@ -1420,7 +1424,8 @@ class MainWP_Child {
|
|
1420 |
} else if (isset( $_POST['function'] ) && isset( $_POST['mainwpsignature'] ) && !isset($this->callableFunctions[ $_POST['function'] ]) && !isset( $this->callableFunctionsNoAuth[ $_POST['function'] ]) ) {
|
1421 |
MainWP_Helper::error( __( 'Required version has not been detected. Please, make sure that you are using the latest version of the MainWP Child plugin on your site.', 'mainwp-child' ) );
|
1422 |
}
|
1423 |
-
|
|
|
1424 |
if ( 1 === (int) get_option( 'mainwpKeywordLinks' ) ) {
|
1425 |
new MainWP_Keyword_Links();
|
1426 |
if ( ! is_admin() ) {
|
@@ -1432,13 +1437,6 @@ class MainWP_Child {
|
|
1432 |
MainWP_Keyword_Links::clear_htaccess(); // force clear
|
1433 |
}
|
1434 |
|
1435 |
-
// Branding extension
|
1436 |
-
MainWP_Child_Branding::Instance()->branding_init();
|
1437 |
-
MainWP_Client_Report::Instance()->creport_init();
|
1438 |
-
MainWP_Child_Pagespeed::Instance()->init();
|
1439 |
-
MainWP_Child_Links_Checker::Instance()->init();
|
1440 |
-
MainWP_Child_Wordfence::Instance()->wordfence_init();
|
1441 |
-
MainWP_Child_iThemes_Security::Instance()->ithemes_init();
|
1442 |
}
|
1443 |
|
1444 |
function default_option_active_plugins( $default ) {
|
@@ -1517,7 +1515,7 @@ class MainWP_Child {
|
|
1517 |
}
|
1518 |
return $r;
|
1519 |
}
|
1520 |
-
|
1521 |
/**
|
1522 |
* Functions to support core functionality
|
1523 |
*/
|
@@ -3672,73 +3670,26 @@ class MainWP_Child {
|
|
3672 |
$information['uniqueId'] = get_option( 'mainwp_child_uniqueId', '' );
|
3673 |
$information['plugins_outdate_info'] = MainWP_Child_Plugins_Check::Instance()->get_plugins_outdate_info();
|
3674 |
$information['themes_outdate_info'] = MainWP_Child_Themes_Check::Instance()->get_themes_outdate_info();
|
3675 |
-
|
3676 |
-
|
|
|
|
|
|
|
|
|
3677 |
|
3678 |
if ( isset( $_POST['othersData'] ) ) {
|
3679 |
$othersData = json_decode( stripslashes( $_POST['othersData'] ), true );
|
3680 |
if ( ! is_array( $othersData ) ) {
|
3681 |
$othersData = array();
|
3682 |
-
}
|
3683 |
-
|
3684 |
-
|
3685 |
-
|
3686 |
-
|
3687 |
-
|
3688 |
-
|
3689 |
-
$information['syncBackUpWordPress'] = MainWP_Child_Back_Up_Wordpress::Instance()->syncData();
|
3690 |
-
}
|
3691 |
-
}
|
3692 |
-
}
|
3693 |
-
|
3694 |
-
|
3695 |
-
if ( isset( $othersData['syncWPStaging'] ) && !empty( $othersData['syncWPStaging'] ) ) {
|
3696 |
-
if ( MainWP_Child_Staging::Instance()->is_plugin_installed ) {
|
3697 |
-
$information['syncWPStaging'] = MainWP_Child_Staging::Instance()->get_sync_data();
|
3698 |
-
}
|
3699 |
-
}
|
3700 |
-
|
3701 |
-
|
3702 |
-
if ( isset( $othersData['syncBackupBuddy'] ) && !empty( $othersData['syncBackupBuddy'] ) ) {
|
3703 |
-
if ( MainWP_Child_Back_Up_Buddy::Instance()->is_backupbuddy_installed ) {
|
3704 |
-
$information['syncBackupBuddy'] = MainWP_Child_Back_Up_Buddy::Instance()->get_sync_data();
|
3705 |
-
}
|
3706 |
-
}
|
3707 |
-
|
3708 |
-
if ( isset( $othersData['syncWPRocketData'] ) && ( 'yes' === $othersData['syncWPRocketData'] ) ) {
|
3709 |
-
$data = array();
|
3710 |
-
if ( MainWP_Child_WP_Rocket::isActivated() ) {
|
3711 |
-
$boxes = get_user_meta( $GLOBALS['current_user']->ID, 'rocket_boxes', true );
|
3712 |
-
$data['rocket_boxes'] = $boxes;
|
3713 |
-
}
|
3714 |
-
$information['syncWPRocketData'] = $data;
|
3715 |
-
}
|
3716 |
-
|
3717 |
-
if ( isset( $othersData['syncPageSpeedData'] ) && !empty( $othersData['syncPageSpeedData'] ) ) {
|
3718 |
-
if ( MainWP_Child_Pagespeed::Instance()->is_plugin_installed ) {
|
3719 |
-
$information['syncPageSpeedData'] = MainWP_Child_Pagespeed::Instance()->sync_data();
|
3720 |
-
}
|
3721 |
-
}
|
3722 |
-
|
3723 |
-
if ( isset( $othersData['syncBrokenLinksCheckerData'] ) && !empty( $othersData['syncBrokenLinksCheckerData'] ) ) {
|
3724 |
-
if ( MainWP_Child_Links_Checker::Instance()->is_plugin_installed ) {
|
3725 |
-
$information['syncBrokenLinksCheckerData'] = MainWP_Child_Links_Checker::Instance()->sync_data();
|
3726 |
-
}
|
3727 |
-
}
|
3728 |
-
|
3729 |
-
if ( isset( $othersData['syncClientReportData'] ) && !empty( $othersData['syncClientReportData'] ) ) {
|
3730 |
-
$creport_sync_data = array();
|
3731 |
-
if ( ( $firsttime = get_option( 'mainwp_creport_first_time_activated' ) ) !== false ) {
|
3732 |
-
$creport_sync_data['firsttime_activated'] = $firsttime;
|
3733 |
-
}
|
3734 |
-
if ( !empty( $creport_sync_data ) ) {
|
3735 |
-
$information['syncClientReportData'] = $creport_sync_data;
|
3736 |
-
}
|
3737 |
-
}
|
3738 |
-
|
3739 |
}
|
3740 |
|
3741 |
-
|
3742 |
if ( $exit ) {
|
3743 |
MainWP_Helper::write( $information );
|
3744 |
}
|
@@ -4340,7 +4291,7 @@ class MainWP_Child {
|
|
4340 |
|
4341 |
if ( 'activate' === $action ) {
|
4342 |
include_once( ABSPATH . '/wp-admin/includes/theme.php' );
|
4343 |
-
$theTheme =
|
4344 |
if ( null !== $theTheme && '' !== $theTheme ) {
|
4345 |
switch_theme( $theTheme['Template'], $theTheme['Stylesheet'] );
|
4346 |
}
|
@@ -4374,10 +4325,10 @@ class MainWP_Child {
|
|
4374 |
return;
|
4375 |
}
|
4376 |
}
|
4377 |
-
|
4378 |
foreach ( $themes as $idx => $themeToDelete ) {
|
4379 |
if ( $themeToDelete !== $theme_name ) {
|
4380 |
-
$theTheme =
|
4381 |
if ( null !== $theTheme && '' !== $theTheme ) {
|
4382 |
$tmp['theme'] = $theTheme['Template'];
|
4383 |
if ( true === $themeUpgrader->delete_old_theme( null, null, null, $tmp ) ) {
|
@@ -5478,6 +5429,10 @@ class MainWP_Child {
|
|
5478 |
MainWP_Child_Vulnerability_Checker::Instance()->action();
|
5479 |
}
|
5480 |
|
|
|
|
|
|
|
|
|
5481 |
function wp_staging() {
|
5482 |
MainWP_Child_Staging::Instance()->action();
|
5483 |
}
|
84 |
}
|
85 |
|
86 |
class MainWP_Child {
|
87 |
+
public static $version = '3.4.8';
|
88 |
private $update_version = '1.3';
|
89 |
|
90 |
private $callableFunctions = array(
|
152 |
'vulner_checker' => 'vulner_checker',
|
153 |
'wp_staging' => 'wp_staging',
|
154 |
'disconnect' => 'disconnect',
|
155 |
+
'time_capsule' => 'time_capsule',
|
156 |
);
|
157 |
|
158 |
private $FTP_ERROR = 'Failed! Please, add FTP details for automatic updates.';
|
208 |
|
209 |
MainWP_Clone::get()->init();
|
210 |
MainWP_Child_Server_Information::init();
|
211 |
+
MainWP_Client_Report::Instance()->init();
|
212 |
MainWP_Child_Plugins_Check::Instance();
|
213 |
MainWP_Child_Themes_Check::Instance();
|
214 |
|
1385 |
die();
|
1386 |
}
|
1387 |
}
|
1388 |
+
|
1389 |
+
// Init extensions
|
1390 |
+
// Handle fatal errors for those init if needed
|
1391 |
+
// OK
|
1392 |
+
MainWP_Child_iThemes_Security::Instance()->ithemes_init();
|
1393 |
+
MainWP_Child_Updraft_Plus_Backups::Instance()->updraftplus_init();
|
1394 |
+
MainWP_Child_Back_Up_Wordpress::Instance()->init();
|
1395 |
+
MainWP_Child_WP_Rocket::Instance()->init();
|
1396 |
+
MainWP_Child_Back_WP_Up::Instance()->init();
|
1397 |
+
MainWP_Child_Back_Up_Buddy::Instance();
|
|
|
|
|
|
|
|
|
1398 |
MainWP_Child_Wordfence::Instance()->wordfence_init();
|
1399 |
+
MainWP_Child_Timecapsule::Instance()->init();
|
1400 |
+
MainWP_Child_Staging::Instance()->init();
|
1401 |
+
MainWP_Child_Branding::Instance()->branding_init();
|
1402 |
+
MainWP_Client_Report::Instance()->creport_init();
|
1403 |
+
MainWP_Child_Pagespeed::Instance()->init();
|
1404 |
+
MainWP_Child_Links_Checker::Instance()->init();
|
1405 |
+
|
1406 |
global $_wp_submenu_nopriv;
|
1407 |
if ($_wp_submenu_nopriv === null)
|
1408 |
$_wp_submenu_nopriv = array(); // fix warning
|
1409 |
+
|
1410 |
//Call the function required
|
1411 |
if ( $auth && isset( $_POST['function'] ) && isset( $this->callableFunctions[ $_POST['function'] ] ) ) {
|
1412 |
define( 'DOING_CRON', true );
|
1413 |
// ob_start();
|
1414 |
// require_once( ABSPATH . 'wp-admin/admin.php' );
|
1415 |
+
// ob_end_clean();
|
1416 |
+
|
1417 |
+
MainWP_Helper::handle_fatal_error();
|
1418 |
MainWP_Child::fix_for_custom_themes();
|
1419 |
call_user_func( array( $this, $this->callableFunctions[ $_POST['function'] ] ) );
|
1420 |
} else if ( isset( $_POST['function'] ) && isset( $this->callableFunctionsNoAuth[ $_POST['function'] ] ) ) {
|
1424 |
} else if (isset( $_POST['function'] ) && isset( $_POST['mainwpsignature'] ) && !isset($this->callableFunctions[ $_POST['function'] ]) && !isset( $this->callableFunctionsNoAuth[ $_POST['function'] ]) ) {
|
1425 |
MainWP_Helper::error( __( 'Required version has not been detected. Please, make sure that you are using the latest version of the MainWP Child plugin on your site.', 'mainwp-child' ) );
|
1426 |
}
|
1427 |
+
|
1428 |
+
// going to retire soon
|
1429 |
if ( 1 === (int) get_option( 'mainwpKeywordLinks' ) ) {
|
1430 |
new MainWP_Keyword_Links();
|
1431 |
if ( ! is_admin() ) {
|
1437 |
MainWP_Keyword_Links::clear_htaccess(); // force clear
|
1438 |
}
|
1439 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1440 |
}
|
1441 |
|
1442 |
function default_option_active_plugins( $default ) {
|
1515 |
}
|
1516 |
return $r;
|
1517 |
}
|
1518 |
+
|
1519 |
/**
|
1520 |
* Functions to support core functionality
|
1521 |
*/
|
3670 |
$information['uniqueId'] = get_option( 'mainwp_child_uniqueId', '' );
|
3671 |
$information['plugins_outdate_info'] = MainWP_Child_Plugins_Check::Instance()->get_plugins_outdate_info();
|
3672 |
$information['themes_outdate_info'] = MainWP_Child_Themes_Check::Instance()->get_themes_outdate_info();
|
3673 |
+
|
3674 |
+
try {
|
3675 |
+
do_action('mainwp_child_site_stats');
|
3676 |
+
} catch(Exception $e) {
|
3677 |
+
|
3678 |
+
}
|
3679 |
|
3680 |
if ( isset( $_POST['othersData'] ) ) {
|
3681 |
$othersData = json_decode( stripslashes( $_POST['othersData'] ), true );
|
3682 |
if ( ! is_array( $othersData ) ) {
|
3683 |
$othersData = array();
|
3684 |
+
}
|
3685 |
+
|
3686 |
+
try{
|
3687 |
+
$information = apply_filters( 'mainwp-site-sync-others-data', $information, $othersData );
|
3688 |
+
} catch(Exception $e) {
|
3689 |
+
// do not exit
|
3690 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3691 |
}
|
3692 |
|
|
|
3693 |
if ( $exit ) {
|
3694 |
MainWP_Helper::write( $information );
|
3695 |
}
|
4291 |
|
4292 |
if ( 'activate' === $action ) {
|
4293 |
include_once( ABSPATH . '/wp-admin/includes/theme.php' );
|
4294 |
+
$theTheme = wp_get_theme( $theme );
|
4295 |
if ( null !== $theTheme && '' !== $theTheme ) {
|
4296 |
switch_theme( $theTheme['Template'], $theTheme['Stylesheet'] );
|
4297 |
}
|
4325 |
return;
|
4326 |
}
|
4327 |
}
|
4328 |
+
|
4329 |
foreach ( $themes as $idx => $themeToDelete ) {
|
4330 |
if ( $themeToDelete !== $theme_name ) {
|
4331 |
+
$theTheme = wp_get_theme( $themeToDelete );
|
4332 |
if ( null !== $theTheme && '' !== $theTheme ) {
|
4333 |
$tmp['theme'] = $theTheme['Template'];
|
4334 |
if ( true === $themeUpgrader->delete_old_theme( null, null, null, $tmp ) ) {
|
5429 |
MainWP_Child_Vulnerability_Checker::Instance()->action();
|
5430 |
}
|
5431 |
|
5432 |
+
function time_capsule() {
|
5433 |
+
MainWP_Child_Timecapsule::Instance()->action();
|
5434 |
+
}
|
5435 |
+
|
5436 |
function wp_staging() {
|
5437 |
MainWP_Child_Staging::Instance()->action();
|
5438 |
}
|
class/class-mainwp-client-report.php
CHANGED
@@ -11,12 +11,28 @@ class MainWP_Client_Report {
|
|
11 |
return MainWP_Client_Report::$instance;
|
12 |
}
|
13 |
|
14 |
-
public
|
|
|
15 |
add_filter( 'wp_stream_connectors', array( 'MainWP_Client_Report', 'init_stream_connectors' ), 10, 1 );
|
16 |
add_filter( 'mainwp_client_reports_connectors', array( 'MainWP_Client_Report', 'init_report_connectors' ), 10, 1 );
|
17 |
add_action( 'mainwp_child_log', array( 'MainWP_Client_Report', 'do_reports_log' ) );
|
18 |
}
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
public static function init_stream_connectors( $classes ) {
|
21 |
$connectors = array(
|
22 |
'Backups',
|
@@ -71,9 +87,6 @@ class MainWP_Client_Report {
|
|
71 |
case 'wordfence':
|
72 |
MainWP_Child_Wordfence::Instance()->do_reports_log( $ext );
|
73 |
break;
|
74 |
-
// case 'wptimecapsule':
|
75 |
-
// MainWP_Child_WP_Time_Capsule::Instance()->do_reports_log( $ext );
|
76 |
-
// break;
|
77 |
}
|
78 |
}
|
79 |
|
11 |
return MainWP_Client_Report::$instance;
|
12 |
}
|
13 |
|
14 |
+
public function init() {
|
15 |
+
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
16 |
add_filter( 'wp_stream_connectors', array( 'MainWP_Client_Report', 'init_stream_connectors' ), 10, 1 );
|
17 |
add_filter( 'mainwp_client_reports_connectors', array( 'MainWP_Client_Report', 'init_report_connectors' ), 10, 1 );
|
18 |
add_action( 'mainwp_child_log', array( 'MainWP_Client_Report', 'do_reports_log' ) );
|
19 |
}
|
20 |
|
21 |
+
// ok
|
22 |
+
public function syncOthersData( $information, $data = array() ) {
|
23 |
+
if ( isset( $data['syncClientReportData'] ) && $data['syncClientReportData'] ) {
|
24 |
+
$creport_sync_data = array();
|
25 |
+
if ( ( $firsttime = get_option( 'mainwp_creport_first_time_activated' ) ) !== false ) {
|
26 |
+
$creport_sync_data['firsttime_activated'] = $firsttime;
|
27 |
+
}
|
28 |
+
if ( !empty( $creport_sync_data ) ) {
|
29 |
+
$information['syncClientReportData'] = $creport_sync_data;
|
30 |
+
}
|
31 |
+
}
|
32 |
+
return $information;
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
public static function init_stream_connectors( $classes ) {
|
37 |
$connectors = array(
|
38 |
'Backups',
|
87 |
case 'wordfence':
|
88 |
MainWP_Child_Wordfence::Instance()->do_reports_log( $ext );
|
89 |
break;
|
|
|
|
|
|
|
90 |
}
|
91 |
}
|
92 |
|
class/class-mainwp-helper.php
CHANGED
@@ -211,6 +211,20 @@ class MainWP_Helper {
|
|
211 |
|
212 |
static function createPost( $new_post, $post_custom, $post_category, $post_featured_image, $upload_dir, $post_tags, $others = array() ) {
|
213 |
global $current_user;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
// Options fields.
|
215 |
$wprocket_fields = array(
|
216 |
'lazyload',
|
@@ -1398,4 +1412,160 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name =
|
|
1398 |
if ( defined( 'MAINWP_NOSSL' ) ) return !MAINWP_NOSSL;
|
1399 |
return function_exists( 'openssl_verify' );
|
1400 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1401 |
}
|
211 |
|
212 |
static function createPost( $new_post, $post_custom, $post_category, $post_featured_image, $upload_dir, $post_tags, $others = array() ) {
|
213 |
global $current_user;
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Hook: `mainwp_before_post_update`
|
217 |
+
*
|
218 |
+
* Runs before creating or updating a post via MainWP dashboard.
|
219 |
+
*
|
220 |
+
* @param array $new_post – Post data array.
|
221 |
+
* @param array $post_custom – Post custom meta data.
|
222 |
+
* @param string $post_category – Post categories.
|
223 |
+
* @param string $post_tags – Post tags.
|
224 |
+
*/
|
225 |
+
|
226 |
+
do_action( 'mainwp_before_post_update', $new_post, $post_custom, $post_category, $post_tags );
|
227 |
+
|
228 |
// Options fields.
|
229 |
$wprocket_fields = array(
|
230 |
'lazyload',
|
1412 |
if ( defined( 'MAINWP_NOSSL' ) ) return !MAINWP_NOSSL;
|
1413 |
return function_exists( 'openssl_verify' );
|
1414 |
}
|
1415 |
+
|
1416 |
+
public static function check_files_exists( $files = array(), $return = false ) {
|
1417 |
+
$missing = array();
|
1418 |
+
if (is_array($files)) {
|
1419 |
+
foreach($files as $name) {
|
1420 |
+
if (!file_exists( $name )) {
|
1421 |
+
$missing[] = $name;
|
1422 |
+
}
|
1423 |
+
}
|
1424 |
+
} else {
|
1425 |
+
if (!file_exists( $files )) {
|
1426 |
+
$missing[] = $files;
|
1427 |
+
}
|
1428 |
+
}
|
1429 |
+
|
1430 |
+
if (!empty($missing)) {
|
1431 |
+
$message = 'Missing file(s): ' . implode(',', $missing);
|
1432 |
+
if ($return)
|
1433 |
+
return $message;
|
1434 |
+
else
|
1435 |
+
throw new Exception( $message );
|
1436 |
+
}
|
1437 |
+
return true;
|
1438 |
+
}
|
1439 |
+
|
1440 |
+
public static function check_classes_exists($classes = array(), $return = false) {
|
1441 |
+
$missing = array();
|
1442 |
+
if (is_array($classes)) {
|
1443 |
+
foreach($classes as $name) {
|
1444 |
+
if (!class_exists( $name )) {
|
1445 |
+
$missing[] = $name;
|
1446 |
+
}
|
1447 |
+
}
|
1448 |
+
} else {
|
1449 |
+
if ( !class_exists($classes) )
|
1450 |
+
$missing[] = $classes;
|
1451 |
+
}
|
1452 |
+
|
1453 |
+
if ( !empty($missing) ) {
|
1454 |
+
$message = 'Missing classes: ' . implode(',', $missing);
|
1455 |
+
if ($return) {
|
1456 |
+
return $message;
|
1457 |
+
} else {
|
1458 |
+
throw new Exception( $message );
|
1459 |
+
}
|
1460 |
+
}
|
1461 |
+
return true;
|
1462 |
+
}
|
1463 |
+
|
1464 |
+
public static function check_methods($object, $methods = array(), $return = false) {
|
1465 |
+
$missing = array();
|
1466 |
+
if (is_array($methods)) {
|
1467 |
+
$missing = array();
|
1468 |
+
foreach($methods as $name) {
|
1469 |
+
if ( !method_exists($object, $name) ) {
|
1470 |
+
$missing[] = $name;
|
1471 |
+
}
|
1472 |
+
}
|
1473 |
+
} else if (!empty($methods)) {
|
1474 |
+
if ( !method_exists($object, $methods) )
|
1475 |
+
$missing[] = $methods;
|
1476 |
+
|
1477 |
+
}
|
1478 |
+
|
1479 |
+
if ( !empty($missing) ) {
|
1480 |
+
$message = 'Missing method: ' . implode(',', $missing);
|
1481 |
+
if ($return) {
|
1482 |
+
return $message;
|
1483 |
+
} else {
|
1484 |
+
throw new Exception( $message );
|
1485 |
+
}
|
1486 |
+
}
|
1487 |
+
|
1488 |
+
return true;
|
1489 |
+
}
|
1490 |
+
|
1491 |
+
public static function check_properties($object, $properties = array(), $return = false) {
|
1492 |
+
$missing = array();
|
1493 |
+
if (is_array($properties)) {
|
1494 |
+
foreach($properties as $name) {
|
1495 |
+
if ( !property_exists($object, $name) ) {
|
1496 |
+
$missing[] = $name;
|
1497 |
+
}
|
1498 |
+
}
|
1499 |
+
} else if (!empty($properties)) {
|
1500 |
+
if ( !property_exists($object, $properties) )
|
1501 |
+
$missing[] = $properties;
|
1502 |
+
|
1503 |
+
}
|
1504 |
+
|
1505 |
+
if ( !empty($missing) ) {
|
1506 |
+
$message = 'Missing properties: ' . implode(',', $missing);
|
1507 |
+
if ($return) {
|
1508 |
+
return $message;
|
1509 |
+
} else {
|
1510 |
+
throw new Exception( $message );
|
1511 |
+
}
|
1512 |
+
}
|
1513 |
+
|
1514 |
+
return true;
|
1515 |
+
}
|
1516 |
+
|
1517 |
+
public static function check_functions($funcs = array(), $return = false) {
|
1518 |
+
$missing = array();
|
1519 |
+
if (is_array($funcs)) {
|
1520 |
+
foreach($funcs as $name) {
|
1521 |
+
if ( !function_exists( $name) ) {
|
1522 |
+
$missing[] = $name;
|
1523 |
+
}
|
1524 |
+
}
|
1525 |
+
} else if (!empty($funcs)) {
|
1526 |
+
if ( !function_exists($funcs) )
|
1527 |
+
$missing[] = $funcs;
|
1528 |
+
|
1529 |
+
}
|
1530 |
+
|
1531 |
+
if ( !empty($missing) ) {
|
1532 |
+
$message = 'Missing functions: ' . implode(',', $missing);
|
1533 |
+
if ($return) {
|
1534 |
+
return $message;
|
1535 |
+
} else {
|
1536 |
+
throw new Exception( $message );
|
1537 |
+
}
|
1538 |
+
}
|
1539 |
+
|
1540 |
+
return true;
|
1541 |
+
}
|
1542 |
+
|
1543 |
+
|
1544 |
+
/**
|
1545 |
+
* Handle fatal error for requests from the dashboard
|
1546 |
+
* mwp_action requests
|
1547 |
+
* wordpress_seo requests
|
1548 |
+
* This will do not handle fatal error for sync request from the dashboard
|
1549 |
+
*/
|
1550 |
+
public static function handle_fatal_error() {
|
1551 |
+
|
1552 |
+
function handle_shutdown() {
|
1553 |
+
// handle fatal errors and compile errors
|
1554 |
+
$error = error_get_last();
|
1555 |
+
if ( isset( $error['type'] ) && isset( $error['message'] ) &&
|
1556 |
+
( E_ERROR === $error['type'] || E_COMPILE_ERROR === $error['type'] )
|
1557 |
+
)
|
1558 |
+
{
|
1559 |
+
MainWP_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) );
|
1560 |
+
}
|
1561 |
+
|
1562 |
+
}
|
1563 |
+
|
1564 |
+
if (isset($_POST['function']) && isset($_POST['mainwpsignature']) &&
|
1565 |
+
(isset($_POST['mwp_action']) || 'wordpress_seo' == $_POST['function']) // wordpress_seo for Wordpress SEO
|
1566 |
+
) {
|
1567 |
+
register_shutdown_function( 'handle_shutdown' );
|
1568 |
+
}
|
1569 |
+
}
|
1570 |
+
|
1571 |
}
|
mainwp-child.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
Author: MainWP
|
7 |
Author URI: https://mainwp.com
|
8 |
Text Domain: mainwp-child
|
9 |
-
Version: 3.4.
|
10 |
*/
|
11 |
if ( ( isset( $_REQUEST['heatmap'] ) && '1' === $_REQUEST['heatmap'] ) || ( isset( $_REQUEST['mainwpsignature'] ) && ( ! empty( $_REQUEST['mainwpsignature'] ) ) ) ) {
|
12 |
header( 'X-Frame-Options: ALLOWALL' );
|
@@ -35,11 +35,7 @@ function mainwp_child_autoload( $class_name ) {
|
|
35 |
|
36 |
if ( function_exists( 'spl_autoload_register' ) ) {
|
37 |
spl_autoload_register( 'mainwp_child_autoload' );
|
38 |
-
}
|
39 |
-
function __autoload( $class_name ) {
|
40 |
-
mainwp_child_autoload( $class_name );
|
41 |
-
}
|
42 |
-
}
|
43 |
|
44 |
$mainWPChild = new MainWP_Child( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . plugin_basename( __FILE__ ) );
|
45 |
register_activation_hook( __FILE__, array( $mainWPChild, 'activation' ) );
|
6 |
Author: MainWP
|
7 |
Author URI: https://mainwp.com
|
8 |
Text Domain: mainwp-child
|
9 |
+
Version: 3.4.8
|
10 |
*/
|
11 |
if ( ( isset( $_REQUEST['heatmap'] ) && '1' === $_REQUEST['heatmap'] ) || ( isset( $_REQUEST['mainwpsignature'] ) && ( ! empty( $_REQUEST['mainwpsignature'] ) ) ) ) {
|
12 |
header( 'X-Frame-Options: ALLOWALL' );
|
35 |
|
36 |
if ( function_exists( 'spl_autoload_register' ) ) {
|
37 |
spl_autoload_register( 'mainwp_child_autoload' );
|
38 |
+
}
|
|
|
|
|
|
|
|
|
39 |
|
40 |
$mainWPChild = new MainWP_Child( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . plugin_basename( __FILE__ ) );
|
41 |
register_activation_hook( __FILE__, array( $mainWPChild, 'activation' ) );
|
readme.txt
CHANGED
@@ -6,8 +6,8 @@ Author: mainwp
|
|
6 |
Author URI: https://mainwp.com
|
7 |
Plugin URI: https://mainwp.com
|
8 |
Requires at least: 3.6
|
9 |
-
Tested up to: 4.9.
|
10 |
-
Stable tag: 3.4.
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
|
@@ -71,6 +71,14 @@ To see full documentation and FAQs please visit [MainWP Documentation](https://m
|
|
71 |
|
72 |
== Changelog ==
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
= 3.4.7.1 - 5-25-18 =
|
75 |
* Fixed: UpdraftPlus 1.14.10 compatibility issue that caused child sites to disconnect
|
76 |
* Added: support for the new MainWP Branding Extension option
|
6 |
Author URI: https://mainwp.com
|
7 |
Plugin URI: https://mainwp.com
|
8 |
Requires at least: 3.6
|
9 |
+
Tested up to: 4.9.6
|
10 |
+
Stable tag: 3.4.8
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
|
71 |
|
72 |
== Changelog ==
|
73 |
|
74 |
+
= 3.4.8 - 6-26-18 =
|
75 |
+
* Fixed: issues caused by deprecated functions
|
76 |
+
* Added: mainwp_before_post_update hook
|
77 |
+
* Added: support for the new extension
|
78 |
+
* Added: conditional checks to prevent possible conflicts with certain plugins
|
79 |
+
* Added: support for the new MainWP Branding Extension feature
|
80 |
+
* Improved: PHP 7.2 compatibility
|
81 |
+
|
82 |
= 3.4.7.1 - 5-25-18 =
|
83 |
* Fixed: UpdraftPlus 1.14.10 compatibility issue that caused child sites to disconnect
|
84 |
* Added: support for the new MainWP Branding Extension option
|