MainWP Child - Version 4.0.7

Version Description

  • 2-25-20 =
  • Fixed: an issue with saving Bulk Setting Manager keys
  • Fixed: an issue with saving Wordfence extension settings
  • Fixed: an issue with overwriting PHP error reporting configuration
  • Added: pull request #9 to add an action to allow additional post customization when a new post is created - Thanks joshlabau
  • Added: pull request #13 to replace __autoload() with spl_autoload_register - Thanks Christian Foellmann
  • Added: pull request #23 to fix a typo - Thanks Marco Frodl
  • Added: pull request #24 to prevent overwriting PHP error reporting configuration - Thanks Stanislav Khromov
  • Updated: improved premium plugins and themes updates detection system
  • Removed: unused database options
Download this release

Release Info

Developer mainwp
Plugin Icon 128x128 MainWP Child
Version 4.0.7
Comparing to
See all releases

Code changes from version 4.0.6.2 to 4.0.7

class/class-mainwp-child-skeleton-key.php CHANGED
@@ -21,9 +21,11 @@ class MainWP_Child_Skeleton_Key {
21
  $error = error_get_last();
22
  if ( isset( $error['type'] ) && in_array($error['type'], array(1, 4, 16, 64, 256) ) && isset( $error['message'] ) ) {
23
  MainWP_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) );
24
- } else {
25
- MainWP_Helper::write( MainWP_Child_Skeleton_Key::$information );
26
  }
 
 
 
 
27
  }
28
 
29
  register_shutdown_function( 'mainwp_skeleton_key_handle_fatal_error' );
21
  $error = error_get_last();
22
  if ( isset( $error['type'] ) && in_array($error['type'], array(1, 4, 16, 64, 256) ) && isset( $error['message'] ) ) {
23
  MainWP_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) );
 
 
24
  }
25
+ // to fix issue double <mainwp></mainwp> header in response
26
+ // else {
27
+ // MainWP_Helper::write( MainWP_Child_Skeleton_Key::$information );
28
+ // }
29
  }
30
 
31
  register_shutdown_function( 'mainwp_skeleton_key_handle_fatal_error' );
class/class-mainwp-child-wordfence.php CHANGED
@@ -1282,53 +1282,119 @@ SQL
1282
 
1283
  // if saving then validate data
1284
  if (in_array('apiKey', $saving_opts)) {
 
1285
  $apiKey = trim( $_POST['apiKey'] );
1286
- if ( ! $apiKey ) { //Empty API key (after trim above), then try to get one.
 
 
 
 
 
 
 
1287
  $api = new wfAPI( '', wfUtils::getWPVersion() );
1288
  try {
1289
  $keyData = $api->call( 'get_anon_api_key' );
1290
  if ( $keyData['ok'] && $keyData['apiKey'] ) {
1291
  wfConfig::set( 'apiKey', $keyData['apiKey'] );
1292
  wfConfig::set( 'isPaid', 0 );
1293
- $result['apiKey'] = $keyData['apiKey'];
 
 
1294
  $result['isPaid'] = 0;
1295
  $reload = 'reload';
1296
  } else {
1297
- throw new Exception( "We could not understand the Wordfence server's response because it did not contain an 'ok' and 'apiKey' element." );
1298
  }
1299
  } catch ( Exception $e ) {
1300
- $result['error'] = 'Your options have been saved, but we encountered a problem. You left your API key blank, so we tried to get you a free API key from the Wordfence servers. However we encountered a problem fetching the free key: ' . htmlentities( $e->getMessage() );
1301
-
1302
  return $result;
1303
  }
1304
- } else if ( wfConfig::get( 'apiKey' ) !== $apiKey ) {
 
1305
  $api = new wfAPI( $apiKey, wfUtils::getWPVersion() );
1306
  try {
1307
- $res = $api->call( 'check_api_key', array(), array() );
1308
  if ( $res['ok'] && isset( $res['isPaid'] ) ) {
1309
- wfConfig::set( 'apiKey', $apiKey );
1310
- wfConfig::set( 'isPaid', $res['isPaid'] ); //res['isPaid'] is boolean coming back as JSON and turned back into PHP struct. Assuming JSON to PHP handles bools.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1311
  $result['apiKey'] = $apiKey;
1312
- $result['isPaid'] = $res['isPaid'];
1313
- if ( $res['isPaid'] ) {
1314
  $result['paidKeyMsg'] = true;
1315
  }
 
 
1316
  $reload = 'reload';
1317
  } else {
1318
  throw new Exception( 'We could not understand the Wordfence API server reply when updating your API key.' );
1319
  }
1320
  } catch ( Exception $e ) {
1321
  $result['error'] = 'Your options have been saved. However we noticed you changed your API key and we tried to verify it with the Wordfence servers and received an error: ' . htmlentities( $e->getMessage() );
1322
-
1323
  return $result;
1324
  }
1325
  } else {
 
 
 
 
 
 
 
1326
  try {
1327
- $api = new wfAPI( $apiKey, wfUtils::getWPVersion() );
1328
- $res = $api->call( 'ping_api_key', array(), array() );
1329
- } catch ( Exception $e ) {
1330
- $result['error'] = 'Your options have been saved. However we noticed you do not change your API key and we tried to verify it with the Wordfence servers and received an error: ' . htmlentities( $e->getMessage() );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1331
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1332
  return $result;
1333
  }
1334
  }
1282
 
1283
  // if saving then validate data
1284
  if (in_array('apiKey', $saving_opts)) {
1285
+
1286
  $apiKey = trim( $_POST['apiKey'] );
1287
+ $apiKey = strtolower(trim($apiKey));
1288
+ $existingAPIKey = wfConfig::get('apiKey', '');
1289
+
1290
+
1291
+
1292
+ $ping = false;
1293
+ if ( empty( $apiKey ) && empty($existingAPIKey) ) { // then try to get one.
1294
+
1295
  $api = new wfAPI( '', wfUtils::getWPVersion() );
1296
  try {
1297
  $keyData = $api->call( 'get_anon_api_key' );
1298
  if ( $keyData['ok'] && $keyData['apiKey'] ) {
1299
  wfConfig::set( 'apiKey', $keyData['apiKey'] );
1300
  wfConfig::set( 'isPaid', 0 );
1301
+ wfConfig::set('keyType', wfAPI::KEY_TYPE_FREE);
1302
+ wordfence::licenseStatusChanged();
1303
+ $result['apiKey'] = $apiKey = $keyData['apiKey'];
1304
  $result['isPaid'] = 0;
1305
  $reload = 'reload';
1306
  } else {
1307
+ throw new Exception("The Wordfence server's response did not contain the expected elements.");
1308
  }
1309
  } catch ( Exception $e ) {
1310
+ $result['error'] = 'Your options have been saved, but you left your license key blank, so we tried to get you a free license key from the Wordfence servers. There was a problem fetching the free key: ' . wp_kses( $e->getMessage(), array() );
 
1311
  return $result;
1312
  }
1313
+
1314
+ } else if ( !empty( $apiKey ) && $existingAPIKey != $apiKey ) {
1315
  $api = new wfAPI( $apiKey, wfUtils::getWPVersion() );
1316
  try {
1317
+ $res = $api->call('check_api_key', array(), array('previousLicense' => $existingAPIKey));
1318
  if ( $res['ok'] && isset( $res['isPaid'] ) ) {
1319
+
1320
+ // wfConfig::set( 'apiKey', $apiKey );
1321
+ // wfConfig::set( 'isPaid', $res['isPaid'] ); //res['isPaid'] is boolean coming back as JSON and turned back into PHP struct. Assuming JSON to PHP handles bools.
1322
+ // $result['apiKey'] = $apiKey;
1323
+ // $result['isPaid'] = $res['isPaid'];
1324
+ // if ( $res['isPaid'] ) {
1325
+ // $result['paidKeyMsg'] = true;
1326
+ // }
1327
+
1328
+ $isPaid = wfUtils::truthyToBoolean($res['isPaid']);
1329
+ wfConfig::set('apiKey', $apiKey);
1330
+ wfConfig::set('isPaid', $isPaid); //res['isPaid'] is boolean coming back as JSON and turned back into PHP struct. Assuming JSON to PHP handles bools.
1331
+ wordfence::licenseStatusChanged();
1332
+ if (!$isPaid) {
1333
+ wfConfig::set('keyType', wfAPI::KEY_TYPE_FREE);
1334
+ }
1335
+
1336
+
1337
  $result['apiKey'] = $apiKey;
1338
+ $result['isPaid'] = $isPaid;
1339
+ if ( $isPaid ) {
1340
  $result['paidKeyMsg'] = true;
1341
  }
1342
+
1343
+ $ping = true;
1344
  $reload = 'reload';
1345
  } else {
1346
  throw new Exception( 'We could not understand the Wordfence API server reply when updating your API key.' );
1347
  }
1348
  } catch ( Exception $e ) {
1349
  $result['error'] = 'Your options have been saved. However we noticed you changed your API key and we tried to verify it with the Wordfence servers and received an error: ' . htmlentities( $e->getMessage() );
 
1350
  return $result;
1351
  }
1352
  } else {
1353
+ $ping = true;
1354
+ $apiKey = $existingAPIKey;
1355
+ }
1356
+
1357
+ if ( $ping ) {
1358
+
1359
+ $api = new wfAPI($apiKey, wfUtils::getWPVersion());
1360
  try {
1361
+ $keyType = wfAPI::KEY_TYPE_FREE;
1362
+ $keyData = $api->call('ping_api_key', array(), array('supportHash' => wfConfig::get('supportHash', ''), 'whitelistHash' => wfConfig::get('whitelistHash', '')));
1363
+ if (isset($keyData['_isPaidKey'])) {
1364
+ $keyType = wfConfig::get('keyType');
1365
+ }
1366
+ if (isset($keyData['dashboard'])) {
1367
+ wfConfig::set('lastDashboardCheck', time());
1368
+ wfDashboard::processDashboardResponse($keyData['dashboard']);
1369
+ }
1370
+ if (isset($keyData['support']) && isset($keyData['supportHash'])) {
1371
+ wfConfig::set('supportContent', $keyData['support']);
1372
+ wfConfig::set('supportHash', $keyData['supportHash']);
1373
+ }
1374
+ if (isset($keyData['_whitelist']) && isset($keyData['_whitelistHash'])) {
1375
+ wfConfig::setJSON('whitelistPresets', $keyData['_whitelist']);
1376
+ wfConfig::set('whitelistHash', $keyData['_whitelistHash']);
1377
+ }
1378
+ if (isset($keyData['scanSchedule']) && is_array($keyData['scanSchedule'])) {
1379
+ wfConfig::set_ser('noc1ScanSchedule', $keyData['scanSchedule']);
1380
+ if (wfScanner::shared()->schedulingMode() == wfScanner::SCAN_SCHEDULING_MODE_AUTOMATIC) {
1381
+ wfScanner::shared()->scheduleScans();
1382
+ }
1383
+ }
1384
 
1385
+ wfConfig::set('keyType', $keyType);
1386
+
1387
+ if (!isset($result['apiKey'])) {
1388
+ $isPaid = ( $keyType == wfAPI::KEY_TYPE_FREE ) ? false : true;
1389
+ $result['apiKey'] = $apiKey;
1390
+ $result['isPaid'] = $isPaid;
1391
+ if ( $isPaid ) {
1392
+ $result['paidKeyMsg'] = true;
1393
+ }
1394
+ }
1395
+
1396
+ } catch ( Exception $e ) {
1397
+ $result['error'] = 'Your options have been saved. However we tried to verify your license key with the Wordfence servers and received an error: ' . wp_kses($e->getMessage(), array()) ;
1398
  return $result;
1399
  }
1400
  }
class/class-mainwp-child-wpvivid-backuprestore.php CHANGED
@@ -1,310 +1,310 @@
1
- <?php
2
-
3
- class MainWP_Child_WPvivid_BackupRestore
4
- {
5
- public static $instance = null;
6
- public $is_plugin_installed = false;
7
- public $public_intetface;
8
- static function Instance()
9
- {
10
- if ( null === MainWP_Child_WPvivid_BackupRestore::$instance )
11
- {
12
- MainWP_Child_WPvivid_BackupRestore::$instance = new MainWP_Child_WPvivid_BackupRestore();
13
- }
14
-
15
- return MainWP_Child_WPvivid_BackupRestore::$instance;
16
- }
17
-
18
- public function __construct()
19
- {
20
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
21
- if ( is_plugin_active( 'wpvivid-backuprestore/wpvivid-backuprestore.php' ) && defined('WPVIVID_PLUGIN_DIR'))
22
- {
23
- $this->is_plugin_installed = true;
24
- }
25
-
26
- if (!$this->is_plugin_installed)
27
- return;
28
-
29
- add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
30
- $this->public_intetface = new WPvivid_Public_Interface();
31
- }
32
-
33
- public function init()
34
- {
35
-
36
- }
37
-
38
- function syncOthersData( $information, $data = array() )
39
- {
40
- try{
41
-
42
- if ( isset( $data['syncWPvividData'] ))
43
- {
44
- $information['syncWPvividData']=1;
45
- $data = WPvivid_Setting::get_sync_data();
46
- $information['syncWPvividSettingData']=$data['setting'];
47
- $information['syncWPvividRemoteData']=$data['remote'];
48
- $information['syncWPvividScheduleData']=$data['schedule'];
49
- $information['syncWPvividSetting'] = $data;
50
- }
51
-
52
- } catch(Exception $e) {
53
-
54
- }
55
-
56
- return $information;
57
- }
58
-
59
- public function action()
60
- {
61
- $information = array();
62
- if ( ! $this->is_plugin_installed )
63
- {
64
- $information['error'] = 'NO_WPVIVIDBACKUP';
65
- MainWP_Helper::write( $information );
66
- }
67
-
68
- if ( isset( $_POST['mwp_action'] ) )
69
- {
70
- try {
71
- switch ($_POST['mwp_action']) {
72
- case 'prepare_backup':
73
- $information = $this->prepare_backup();
74
- break;
75
- case 'backup_now':
76
- $information = $this->backup_now();
77
- break;
78
- case 'get_status':
79
- $information = $this->get_status();
80
- break;
81
- case 'get_backup_schedule':
82
- $information = $this->get_backup_schedule();
83
- break;
84
- case 'get_backup_list':
85
- $information = $this->get_backup_list();
86
- break;
87
- case 'get_default_remote':
88
- $information = $this->get_default_remote();
89
- break;
90
- case 'delete_backup':
91
- $information = $this->delete_backup();
92
- break;
93
- case 'delete_backup_array':
94
- $information = $this->delete_backup_array();
95
- break;
96
- case 'set_security_lock':
97
- $information = $this->set_security_lock();
98
- break;
99
- case 'view_log':
100
- $information = $this->view_log();
101
- break;
102
- case 'read_last_backup_log':
103
- $information = $this->read_last_backup_log();
104
- break;
105
- case 'view_backup_task_log':
106
- $information = $this->view_backup_task_log();
107
- break;
108
- case 'backup_cancel':
109
- $information = $this->backup_cancel();
110
- break;
111
- case 'init_download_page':
112
- $information = $this->init_download_page();
113
- break;
114
- case 'prepare_download_backup':
115
- $information = $this->prepare_download_backup();
116
- break;
117
- case 'get_download_task':
118
- $information = $this->get_download_task();
119
- break;
120
- case 'download_backup':
121
- $information = $this->download_backup();
122
- break;
123
- case 'set_general_setting':
124
- $information = $this->set_general_setting();
125
- break;
126
- case 'set_schedule':
127
- $information = $this->set_schedule();
128
- break;
129
- case 'set_remote':
130
- $information = $this->set_remote();
131
- break;
132
- default:
133
- $information = $this->post_mainwp_data($_POST);
134
- break;
135
- }
136
- } catch (Exception $e) {
137
- $information = array('error' => $e->getMessage());
138
- }
139
-
140
- MainWP_Helper::write($information);
141
- }
142
- }
143
-
144
- public function post_mainwp_data($data){
145
- global $wpvivid_plugin;
146
-
147
- $ret =$wpvivid_plugin->wpvivid_handle_mainwp_action($data);
148
- return $ret;
149
- }
150
-
151
- public function prepare_backup()
152
- {
153
- global $wpvivid_plugin;
154
- $wpvivid_plugin->ajax_check_security();
155
- $ret = $this->public_intetface->prepare_backup($_POST['backup']);
156
- return $ret;
157
- }
158
-
159
- public function backup_now()
160
- {
161
- global $wpvivid_plugin;
162
- $wpvivid_plugin->ajax_check_security();
163
- $ret = $this->public_intetface->backup_now($_POST['task_id']);
164
- return $ret;
165
- }
166
-
167
- public function get_status()
168
- {
169
- global $wpvivid_plugin;
170
- $wpvivid_plugin->ajax_check_security();
171
- $ret = $this->public_intetface->get_status();
172
- return $ret;
173
- }
174
-
175
- public function get_backup_schedule()
176
- {
177
- global $wpvivid_plugin;
178
- $wpvivid_plugin->ajax_check_security();
179
- $ret = $this->public_intetface->get_backup_schedule();
180
- return $ret;
181
- }
182
-
183
- public function get_backup_list()
184
- {
185
- global $wpvivid_plugin;
186
- $wpvivid_plugin->ajax_check_security();
187
- $ret = $this->public_intetface->get_backup_list();
188
- return $ret;
189
- }
190
-
191
- public function get_default_remote()
192
- {
193
- global $wpvivid_plugin;
194
- $wpvivid_plugin->ajax_check_security();
195
- $ret = $this->public_intetface->get_default_remote();
196
- return $ret;
197
- }
198
-
199
- public function delete_backup()
200
- {
201
- global $wpvivid_plugin;
202
- $wpvivid_plugin->ajax_check_security();
203
- $ret = $this->public_intetface->delete_backup($_POST['backup_id'], $_POST['force']);
204
- return $ret;
205
- }
206
-
207
- public function delete_backup_array()
208
- {
209
- global $wpvivid_plugin;
210
- $wpvivid_plugin->ajax_check_security();
211
- $ret = $this->public_intetface->delete_backup_array($_POST['backup_id']);
212
- return $ret;
213
- }
214
-
215
- public function set_security_lock()
216
- {
217
- global $wpvivid_plugin;
218
- $wpvivid_plugin->ajax_check_security();
219
- $ret = $this->public_intetface->set_security_lock($_POST['backup_id'], $_POST['lock']);
220
- return $ret;
221
- }
222
-
223
- public function view_log()
224
- {
225
- global $wpvivid_plugin;
226
- $wpvivid_plugin->ajax_check_security();
227
- $ret = $this->public_intetface->view_log($_POST['id']);
228
- return $ret;
229
- }
230
-
231
- public function read_last_backup_log()
232
- {
233
- global $wpvivid_plugin;
234
- $wpvivid_plugin->ajax_check_security();
235
- $ret = $this->public_intetface->read_last_backup_log($_POST['log_file_name']);
236
- return $ret;
237
- }
238
-
239
- public function view_backup_task_log()
240
- {
241
- global $wpvivid_plugin;
242
- $wpvivid_plugin->ajax_check_security();
243
- $ret = $this->public_intetface->view_backup_task_log($_POST['id']);
244
- return $ret;
245
- }
246
-
247
- public function backup_cancel()
248
- {
249
- global $wpvivid_plugin;
250
- $wpvivid_plugin->ajax_check_security();
251
- $ret = $this->public_intetface->backup_cancel($_POST['task_id']);
252
- return $ret;
253
- }
254
-
255
- public function init_download_page()
256
- {
257
- global $wpvivid_plugin;
258
- $wpvivid_plugin->ajax_check_security();
259
- $ret = $this->public_intetface->init_download_page($_POST['backup_id']);
260
- return $ret;
261
- }
262
-
263
- public function prepare_download_backup()
264
- {
265
- global $wpvivid_plugin;
266
- $wpvivid_plugin->ajax_check_security();
267
- $ret = $this->public_intetface->prepare_download_backup($_POST['backup_id'], $_POST['file_name']);
268
- return $ret;
269
- }
270
-
271
- public function get_download_task()
272
- {
273
- global $wpvivid_plugin;
274
- $wpvivid_plugin->ajax_check_security();
275
- $ret = $this->public_intetface->get_download_task($_POST['backup_id']);
276
- return $ret;
277
- }
278
-
279
- public function download_backup()
280
- {
281
- global $wpvivid_plugin;
282
- $wpvivid_plugin->ajax_check_security();
283
- $ret = $this->public_intetface->download_backup($_POST['backup_id'], $_POST['file_name']);
284
- return $ret;
285
- }
286
-
287
- public function set_general_setting()
288
- {
289
- global $wpvivid_plugin;
290
- $wpvivid_plugin->ajax_check_security();
291
- $ret = $this->public_intetface->set_general_setting($_POST['setting']);
292
- return $ret;
293
- }
294
-
295
- public function set_schedule()
296
- {
297
- global $wpvivid_plugin;
298
- $wpvivid_plugin->ajax_check_security();
299
- $ret = $this->public_intetface->set_schedule($_POST['schedule']);
300
- return $ret;
301
- }
302
-
303
- public function set_remote()
304
- {
305
- global $wpvivid_plugin;
306
- $wpvivid_plugin->ajax_check_security();
307
- $ret = $this->public_intetface->set_remote($_POST['remote']);
308
- return $ret;
309
- }
310
- }
1
+ <?php
2
+
3
+ class MainWP_Child_WPvivid_BackupRestore
4
+ {
5
+ public static $instance = null;
6
+ public $is_plugin_installed = false;
7
+ public $public_intetface;
8
+ static function Instance()
9
+ {
10
+ if ( null === MainWP_Child_WPvivid_BackupRestore::$instance )
11
+ {
12
+ MainWP_Child_WPvivid_BackupRestore::$instance = new MainWP_Child_WPvivid_BackupRestore();
13
+ }
14
+
15
+ return MainWP_Child_WPvivid_BackupRestore::$instance;
16
+ }
17
+
18
+ public function __construct()
19
+ {
20
+ require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
21
+ if ( is_plugin_active( 'wpvivid-backuprestore/wpvivid-backuprestore.php' ) && defined('WPVIVID_PLUGIN_DIR'))
22
+ {
23
+ $this->is_plugin_installed = true;
24
+ }
25
+
26
+ if (!$this->is_plugin_installed)
27
+ return;
28
+
29
+ add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
30
+ $this->public_intetface = new WPvivid_Public_Interface();
31
+ }
32
+
33
+ public function init()
34
+ {
35
+
36
+ }
37
+
38
+ function syncOthersData( $information, $data = array() )
39
+ {
40
+ try{
41
+
42
+ if ( isset( $data['syncWPvividData'] ))
43
+ {
44
+ $information['syncWPvividData']=1;
45
+ $data = WPvivid_Setting::get_sync_data();
46
+ $information['syncWPvividSettingData']=$data['setting'];
47
+ $information['syncWPvividRemoteData']=$data['remote'];
48
+ $information['syncWPvividScheduleData']=$data['schedule'];
49
+ $information['syncWPvividSetting'] = $data;
50
+ }
51
+
52
+ } catch(Exception $e) {
53
+
54
+ }
55
+
56
+ return $information;
57
+ }
58
+
59
+ public function action()
60
+ {
61
+ $information = array();
62
+ if ( ! $this->is_plugin_installed )
63
+ {
64
+ $information['error'] = 'NO_WPVIVIDBACKUP';
65
+ MainWP_Helper::write( $information );
66
+ }
67
+
68
+ if ( isset( $_POST['mwp_action'] ) )
69
+ {
70
+ try {
71
+ switch ($_POST['mwp_action']) {
72
+ case 'prepare_backup':
73
+ $information = $this->prepare_backup();
74
+ break;
75
+ case 'backup_now':
76
+ $information = $this->backup_now();
77
+ break;
78
+ case 'get_status':
79
+ $information = $this->get_status();
80
+ break;
81
+ case 'get_backup_schedule':
82
+ $information = $this->get_backup_schedule();
83
+ break;
84
+ case 'get_backup_list':
85
+ $information = $this->get_backup_list();
86
+ break;
87
+ case 'get_default_remote':
88
+ $information = $this->get_default_remote();
89
+ break;
90
+ case 'delete_backup':
91
+ $information = $this->delete_backup();
92
+ break;
93
+ case 'delete_backup_array':
94
+ $information = $this->delete_backup_array();
95
+ break;
96
+ case 'set_security_lock':
97
+ $information = $this->set_security_lock();
98
+ break;
99
+ case 'view_log':
100
+ $information = $this->view_log();
101
+ break;
102
+ case 'read_last_backup_log':
103
+ $information = $this->read_last_backup_log();
104
+ break;
105
+ case 'view_backup_task_log':
106
+ $information = $this->view_backup_task_log();
107
+ break;
108
+ case 'backup_cancel':
109
+ $information = $this->backup_cancel();
110
+ break;
111
+ case 'init_download_page':
112
+ $information = $this->init_download_page();
113
+ break;
114
+ case 'prepare_download_backup':
115
+ $information = $this->prepare_download_backup();
116
+ break;
117
+ case 'get_download_task':
118
+ $information = $this->get_download_task();
119
+ break;
120
+ case 'download_backup':
121
+ $information = $this->download_backup();
122
+ break;
123
+ case 'set_general_setting':
124
+ $information = $this->set_general_setting();
125
+ break;
126
+ case 'set_schedule':
127
+ $information = $this->set_schedule();
128
+ break;
129
+ case 'set_remote':
130
+ $information = $this->set_remote();
131
+ break;
132
+ default:
133
+ $information = $this->post_mainwp_data($_POST);
134
+ break;
135
+ }
136
+ } catch (Exception $e) {
137
+ $information = array('error' => $e->getMessage());
138
+ }
139
+
140
+ MainWP_Helper::write($information);
141
+ }
142
+ }
143
+
144
+ public function post_mainwp_data($data){
145
+ global $wpvivid_plugin;
146
+
147
+ $ret =$wpvivid_plugin->wpvivid_handle_mainwp_action($data);
148
+ return $ret;
149
+ }
150
+
151
+ public function prepare_backup()
152
+ {
153
+ global $wpvivid_plugin;
154
+ $wpvivid_plugin->ajax_check_security();
155
+ $ret = $this->public_intetface->prepare_backup($_POST['backup']);
156
+ return $ret;
157
+ }
158
+
159
+ public function backup_now()
160
+ {
161
+ global $wpvivid_plugin;
162
+ $wpvivid_plugin->ajax_check_security();
163
+ $ret = $this->public_intetface->backup_now($_POST['task_id']);
164
+ return $ret;
165
+ }
166
+
167
+ public function get_status()
168
+ {
169
+ global $wpvivid_plugin;
170
+ $wpvivid_plugin->ajax_check_security();
171
+ $ret = $this->public_intetface->get_status();
172
+ return $ret;
173
+ }
174
+
175
+ public function get_backup_schedule()
176
+ {
177
+ global $wpvivid_plugin;
178
+ $wpvivid_plugin->ajax_check_security();
179
+ $ret = $this->public_intetface->get_backup_schedule();
180
+ return $ret;
181
+ }
182
+
183
+ public function get_backup_list()
184
+ {
185
+ global $wpvivid_plugin;
186
+ $wpvivid_plugin->ajax_check_security();
187
+ $ret = $this->public_intetface->get_backup_list();
188
+ return $ret;
189
+ }
190
+
191
+ public function get_default_remote()
192
+ {
193
+ global $wpvivid_plugin;
194
+ $wpvivid_plugin->ajax_check_security();
195
+ $ret = $this->public_intetface->get_default_remote();
196
+ return $ret;
197
+ }
198
+
199
+ public function delete_backup()
200
+ {
201
+ global $wpvivid_plugin;
202
+ $wpvivid_plugin->ajax_check_security();
203
+ $ret = $this->public_intetface->delete_backup($_POST['backup_id'], $_POST['force']);
204
+ return $ret;
205
+ }
206
+
207
+ public function delete_backup_array()
208
+ {
209
+ global $wpvivid_plugin;
210
+ $wpvivid_plugin->ajax_check_security();
211
+ $ret = $this->public_intetface->delete_backup_array($_POST['backup_id']);
212
+ return $ret;
213
+ }
214
+
215
+ public function set_security_lock()
216
+ {
217
+ global $wpvivid_plugin;
218
+ $wpvivid_plugin->ajax_check_security();
219
+ $ret = $this->public_intetface->set_security_lock($_POST['backup_id'], $_POST['lock']);
220
+ return $ret;
221
+ }
222
+
223
+ public function view_log()
224
+ {
225
+ global $wpvivid_plugin;
226
+ $wpvivid_plugin->ajax_check_security();
227
+ $ret = $this->public_intetface->view_log($_POST['id']);
228
+ return $ret;
229
+ }
230
+
231
+ public function read_last_backup_log()
232
+ {
233
+ global $wpvivid_plugin;
234
+ $wpvivid_plugin->ajax_check_security();
235
+ $ret = $this->public_intetface->read_last_backup_log($_POST['log_file_name']);
236
+ return $ret;
237
+ }
238
+
239
+ public function view_backup_task_log()
240
+ {
241
+ global $wpvivid_plugin;
242
+ $wpvivid_plugin->ajax_check_security();
243
+ $ret = $this->public_intetface->view_backup_task_log($_POST['id']);
244
+ return $ret;
245
+ }
246
+
247
+ public function backup_cancel()
248
+ {
249
+ global $wpvivid_plugin;
250
+ $wpvivid_plugin->ajax_check_security();
251
+ $ret = $this->public_intetface->backup_cancel($_POST['task_id']);
252
+ return $ret;
253
+ }
254
+
255
+ public function init_download_page()
256
+ {
257
+ global $wpvivid_plugin;
258
+ $wpvivid_plugin->ajax_check_security();
259
+ $ret = $this->public_intetface->init_download_page($_POST['backup_id']);
260
+ return $ret;
261
+ }
262
+
263
+ public function prepare_download_backup()
264
+ {
265
+ global $wpvivid_plugin;
266
+ $wpvivid_plugin->ajax_check_security();
267
+ $ret = $this->public_intetface->prepare_download_backup($_POST['backup_id'], $_POST['file_name']);
268
+ return $ret;
269
+ }
270
+
271
+ public function get_download_task()
272
+ {
273
+ global $wpvivid_plugin;
274
+ $wpvivid_plugin->ajax_check_security();
275
+ $ret = $this->public_intetface->get_download_task($_POST['backup_id']);
276
+ return $ret;
277
+ }
278
+
279
+ public function download_backup()
280
+ {
281
+ global $wpvivid_plugin;
282
+ $wpvivid_plugin->ajax_check_security();
283
+ $ret = $this->public_intetface->download_backup($_POST['backup_id'], $_POST['file_name']);
284
+ return $ret;
285
+ }
286
+
287
+ public function set_general_setting()
288
+ {
289
+ global $wpvivid_plugin;
290
+ $wpvivid_plugin->ajax_check_security();
291
+ $ret = $this->public_intetface->set_general_setting($_POST['setting']);
292
+ return $ret;
293
+ }
294
+
295
+ public function set_schedule()
296
+ {
297
+ global $wpvivid_plugin;
298
+ $wpvivid_plugin->ajax_check_security();
299
+ $ret = $this->public_intetface->set_schedule($_POST['schedule']);
300
+ return $ret;
301
+ }
302
+
303
+ public function set_remote()
304
+ {
305
+ global $wpvivid_plugin;
306
+ $wpvivid_plugin->ajax_check_security();
307
+ $ret = $this->public_intetface->set_remote($_POST['remote']);
308
+ return $ret;
309
+ }
310
+ }
class/class-mainwp-child.php CHANGED
@@ -4,8 +4,10 @@ if ( defined( 'MAINWP_DEBUG' ) && MAINWP_DEBUG === TRUE ) {
4
  @ini_set( 'display_errors', TRUE );
5
  @ini_set( 'display_startup_errors', TRUE );
6
  } else {
7
- @ini_set( 'display_errors', FALSE );
8
- @error_reporting( 0 );
 
 
9
  }
10
 
11
  define( 'MAINWP_CHILD_NR_OF_COMMENTS', 50 );
@@ -115,7 +117,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
115
  }
116
 
117
  class MainWP_Child {
118
- public static $version = '4.0.6.2';
119
  private $update_version = '1.5';
120
 
121
  private $callableFunctions = array(
@@ -753,7 +755,7 @@ class MainWP_Child {
753
  }
754
  self::$subPages = $sub_pages;
755
  self::$subPagesLoaded = true;
756
- MainWP_Helper::update_option( 'mainwp_child_subpages', self::$subPages );
757
  }
758
  add_action( 'mainwp-child-pageheader', array( __CLASS__, 'render_header' ) );
759
  add_action( 'mainwp-child-pagefooter', array( __CLASS__, 'render_footer' ) );
@@ -2483,7 +2485,7 @@ class MainWP_Child {
2483
  $information['added_id'] = $res['added_id'];
2484
  $information['link'] = $res['link'];
2485
 
2486
- do_action('mainwp_child_after_newpost', $res);
2487
 
2488
  MainWP_Helper::write( $information );
2489
  }
@@ -3786,10 +3788,20 @@ class MainWP_Child {
3786
  $information['plugin_updates'] = array();
3787
  }
3788
  foreach( $cached_plugins_update as $slug => $plugin_update ) {
 
3789
  // to fix incorrect info
3790
- if ( !property_exists( $plugin_update, 'new_version' ) || empty( $plugin_update->new_version ) ) {
 
 
 
3791
  continue;
3792
  }
 
 
 
 
 
 
3793
  if ( !isset( $information['plugin_updates'][ $slug ] ) ) {
3794
  $information['plugin_updates'][ $slug ] = $plugin_update;
3795
  }
4
  @ini_set( 'display_errors', TRUE );
5
  @ini_set( 'display_startup_errors', TRUE );
6
  } else {
7
+ if (isset($_REQUEST['mainwpsignature'])) {
8
+ @ini_set( 'display_errors', FALSE );
9
+ @error_reporting( 0 );
10
+ }
11
  }
12
 
13
  define( 'MAINWP_CHILD_NR_OF_COMMENTS', 50 );
117
  }
118
 
119
  class MainWP_Child {
120
+ public static $version = '4.0.7';
121
  private $update_version = '1.5';
122
 
123
  private $callableFunctions = array(
755
  }
756
  self::$subPages = $sub_pages;
757
  self::$subPagesLoaded = true;
758
+ //MainWP_Helper::update_option( 'mainwp_child_subpages', self::$subPages ); // to fix error for some case
759
  }
760
  add_action( 'mainwp-child-pageheader', array( __CLASS__, 'render_header' ) );
761
  add_action( 'mainwp-child-pagefooter', array( __CLASS__, 'render_footer' ) );
2485
  $information['added_id'] = $res['added_id'];
2486
  $information['link'] = $res['link'];
2487
 
2488
+ do_action('mainwp_child_after_newpost', $res);
2489
 
2490
  MainWP_Helper::write( $information );
2491
  }
3788
  $information['plugin_updates'] = array();
3789
  }
3790
  foreach( $cached_plugins_update as $slug => $plugin_update ) {
3791
+
3792
  // to fix incorrect info
3793
+ if ( !property_exists( $plugin_update, 'new_version' ) || empty( $plugin_update->new_version ) ) { // may do not need to check this?
3794
+ // to fix for some premiums update info
3795
+ if ( property_exists( $plugin_update, 'update' ) ) {
3796
+ if ( !property_exists( $plugin_update->update, 'new_version' ) || empty( $plugin_update->update->new_version ) ) {
3797
  continue;
3798
  }
3799
+ } else {
3800
+ continue;
3801
+ }
3802
+
3803
+ }
3804
+
3805
  if ( !isset( $information['plugin_updates'][ $slug ] ) ) {
3806
  $information['plugin_updates'][ $slug ] = $plugin_update;
3807
  }
class/class-mainwp-helper.php CHANGED
@@ -563,7 +563,7 @@ class MainWP_Helper {
563
  //Save the post to the wp
564
  remove_filter( 'content_save_pre', 'wp_filter_post_kses' ); // to fix brake scripts or html
565
  $post_status = $new_post['post_status'];
566
- $new_post['post_status'] = 'auto-draft';
567
 
568
  // update post
569
  if ( $edit_post_id ) {
@@ -572,6 +572,7 @@ class MainWP_Helper {
572
  if ( $current_post && ( ( !isset( $new_post['post_type'] ) && $current_post->post_type == 'post' ) || ( isset( $new_post['post_type'] ) && $new_post['post_type'] == $current_post->post_type ) ) ) {
573
  $new_post['ID'] = $edit_post_id;
574
  }
 
575
  }
576
 
577
  $new_post_id = wp_insert_post( $new_post, $wp_error );
@@ -584,6 +585,7 @@ class MainWP_Helper {
584
  return array( 'error' => 'Empty post id');
585
  }
586
 
 
587
  wp_update_post( array( 'ID' => $new_post_id, 'post_status' => $post_status ) );
588
 
589
  if ( ! empty( $terms ) ) {
563
  //Save the post to the wp
564
  remove_filter( 'content_save_pre', 'wp_filter_post_kses' ); // to fix brake scripts or html
565
  $post_status = $new_post['post_status'];
566
+ $new_post['post_status'] = 'auto-draft'; // child reports: to logging as created post
567
 
568
  // update post
569
  if ( $edit_post_id ) {
572
  if ( $current_post && ( ( !isset( $new_post['post_type'] ) && $current_post->post_type == 'post' ) || ( isset( $new_post['post_type'] ) && $new_post['post_type'] == $current_post->post_type ) ) ) {
573
  $new_post['ID'] = $edit_post_id;
574
  }
575
+ $new_post['post_status'] = $post_status; // child reports: to logging as update post
576
  }
577
 
578
  $new_post_id = wp_insert_post( $new_post, $wp_error );
585
  return array( 'error' => 'Empty post id');
586
  }
587
 
588
+ if ( !$edit_post_id )
589
  wp_update_post( array( 'ID' => $new_post_id, 'post_status' => $post_status ) );
590
 
591
  if ( ! empty( $terms ) ) {
mainwp-child.php CHANGED
@@ -6,7 +6,7 @@
6
  Author: MainWP
7
  Author URI: https://mainwp.com
8
  Text Domain: mainwp-child
9
- Version: 4.0.6.2
10
  */
11
  include_once( ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'version.php' ); //Version information from wordpress
12
 
6
  Author: MainWP
7
  Author URI: https://mainwp.com
8
  Text Domain: mainwp-child
9
+ Version: 4.0.7
10
  */
11
  include_once( ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'version.php' ); //Version information from wordpress
12
 
readme.txt CHANGED
@@ -5,11 +5,11 @@ Author: mainwp
5
  Author URI: https://mainwp.com
6
  Plugin URI: https://mainwp.com
7
  Requires at least: 3.6
8
- Tested up to: 5.3.2
9
  Requires PHP: 5.6
10
- Stable tag: 4.0.6.2
11
- License: GPLv2 or later
12
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
14
  Provides a secure connection between your MainWP Dashboard and your WordPress sites. MainWP allows you to manage WP sites from one central location.
15
 
@@ -71,6 +71,17 @@ To see full documentation and FAQs please visit [MainWP Documentation](https://m
71
 
72
  == Changelog ==
73
 
 
 
 
 
 
 
 
 
 
 
 
74
  = 4.0.6.2 - 2-3-20 =
75
  * Fixed: connection problems caused by issues with json_encode function
76
 
5
  Author URI: https://mainwp.com
6
  Plugin URI: https://mainwp.com
7
  Requires at least: 3.6
8
+ Tested up to: 5.4
9
  Requires PHP: 5.6
10
+ Stable tag: 4.0.7
11
+ License: GPLv3 or later
12
+ License URI: https://www.gnu.org/licenses/gpl-3.0.html
13
 
14
  Provides a secure connection between your MainWP Dashboard and your WordPress sites. MainWP allows you to manage WP sites from one central location.
15
 
71
 
72
  == Changelog ==
73
 
74
+ = 4.0.7 - 2-25-20 =
75
+ * Fixed: an issue with saving Bulk Setting Manager keys
76
+ * Fixed: an issue with saving Wordfence extension settings
77
+ * Fixed: an issue with overwriting PHP error reporting configuration
78
+ * Added: pull request #9 to add an action to allow additional post customization when a new post is created - Thanks [joshlabau](https://github.com/joshlabau)
79
+ * Added: pull request #13 to replace __autoload() with spl_autoload_register - Thanks [Christian Foellmann](https://github.com/cfoellmann)
80
+ * Added: pull request #23 to fix a typo - Thanks [Marco Frodl](https://github.com/marcofrodl)
81
+ * Added: pull request #24 to prevent overwriting PHP error reporting configuration - Thanks [Stanislav Khromov](https://github.com/khromov)
82
+ * Updated: improved premium plugins and themes updates detection system
83
+ * Removed: unused database options
84
+
85
  = 4.0.6.2 - 2-3-20 =
86
  * Fixed: connection problems caused by issues with json_encode function
87