MainWP Child - Version 4.1.7.1

Version Description

  • 10-1-2021 =
  • Updated: OpenSSL version requirement to 1.1.0 or greater
Download this release

Release Info

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

Code changes from version 4.1.7 to 4.1.7.1

class/class-mainwp-child-server-information-base.php CHANGED
@@ -204,18 +204,18 @@ class MainWP_Child_Server_Information_Base {
204
  /**
205
  * Compare current cURL & SSL versions to required values.
206
  *
207
- * @param string $value Required values to compare to.
208
- * @param string $operator Comparison operator.
209
  *
210
  * @return bool|int When using the optional operator argument, the function will return TRUE if the
211
  * relationship is the one specified by the operator, FALSE otherwise. Returns -1 if the first version
212
  * is lower than the second, 0 if they are equal, and 1 if the second is lower.
213
  */
214
- protected static function curlssl_compare( $value, $operator = null ) {
215
- if ( isset( $value['version_number'] ) && defined( 'OPENSSL_VERSION_NUMBER' ) ) {
216
- return version_compare( OPENSSL_VERSION_NUMBER, $value['version_number'], $operator );
 
217
  }
218
-
219
  return false;
220
  }
221
 
204
  /**
205
  * Compare current cURL & SSL versions to required values.
206
  *
207
+ * @param string $version Required values to compare to.
208
+ * @param null $operator Comparison operator.
209
  *
210
  * @return bool|int When using the optional operator argument, the function will return TRUE if the
211
  * relationship is the one specified by the operator, FALSE otherwise. Returns -1 if the first version
212
  * is lower than the second, 0 if they are equal, and 1 if the second is lower.
213
  */
214
+ public static function curlssl_compare( $version, $operator ) {
215
+ if ( function_exists( 'curl_version' ) ) {
216
+ $ver = self::get_curl_ssl_version();
217
+ return version_compare( $ver, $version, $operator );
218
  }
 
219
  return false;
220
  }
221
 
class/class-mainwp-child-server-information.php CHANGED
@@ -697,13 +697,11 @@ class MainWP_Child_Server_Information extends MainWP_Child_Server_Information_Ba
697
  self::render_row_sec( 'cURL Timeout', '>=', '300', 'get_curl_timeout', 'seconds', '=', '0' );
698
  if ( function_exists( 'curl_version' ) ) {
699
  self::render_row_sec( 'cURL Version', '>=', '7.18.1', 'get_curl_version', '', '', null );
 
700
  self::render_row_sec(
701
  'cURL SSL Version',
702
  '>=',
703
- array(
704
- 'version_number' => 0x009080cf,
705
- 'version' => 'OpenSSL/0.9.8l',
706
- ),
707
  'get_curl_ssl_version',
708
  '',
709
  '',
@@ -711,6 +709,9 @@ class MainWP_Child_Server_Information extends MainWP_Child_Server_Information_Ba
711
  '',
712
  'curlssl'
713
  );
 
 
 
714
  }
715
  }
716
 
@@ -1166,7 +1167,7 @@ class MainWP_Child_Server_Information extends MainWP_Child_Server_Information_Ba
1166
  <td><?php echo( true === $currentVersion ? 'true' : $currentVersion ); ?></td>
1167
  <?php if ( 'filesize' === $whatType ) { ?>
1168
  <td><?php echo( self::filesize_compare( $currentVersion, $version, $compare ) ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : self::render_warning_text( $errorType ) ); ?></td>
1169
- <?php } elseif ( 'curlssl' === $whatType ) { ?>
1170
  <td><?php echo( self::curlssl_compare( $version, $compare ) ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : self::render_warning_text( $errorType ) ); ?></td>
1171
  <?php } elseif ( ( 'get_max_input_time' === $getter || 'get_max_execution_time' === $getter ) && -1 == $currentVersion ) { ?>
1172
  <td><?php echo '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>'; ?></td>
697
  self::render_row_sec( 'cURL Timeout', '>=', '300', 'get_curl_timeout', 'seconds', '=', '0' );
698
  if ( function_exists( 'curl_version' ) ) {
699
  self::render_row_sec( 'cURL Version', '>=', '7.18.1', 'get_curl_version', '', '', null );
700
+ $openssl_version = 'OpenSSL/1.1.0';
701
  self::render_row_sec(
702
  'cURL SSL Version',
703
  '>=',
704
+ $openssl_version,
 
 
 
705
  'get_curl_ssl_version',
706
  '',
707
  '',
709
  '',
710
  'curlssl'
711
  );
712
+ if ( ! self::curlssl_compare( $openssl_version, '>=' ) ) {
713
+ echo "<tr style=\"background:#fffaf3\"><td colspan='5'><span class=\"mainwp-warning\"><i class='fa fa-exclamation-circle'>" . sprintf( __( 'Your host needs to update OpenSSL to at least version 1.1.0 which is already over 4 years old and contains patches for over 60 vulnerabilities.%1$sThese range from Denial of Service to Remote Code Execution. %2$sClick here for more information.%3$s', 'mainwp' ), '<br/>', '<a href="https://community.letsencrypt.org/t/openssl-client-compatibility-changes-for-let-s-encrypt-certificates/143816" target="_blank">', '</a>' ) . '</span></td></tr>';
714
+ }
715
  }
716
  }
717
 
1167
  <td><?php echo( true === $currentVersion ? 'true' : $currentVersion ); ?></td>
1168
  <?php if ( 'filesize' === $whatType ) { ?>
1169
  <td><?php echo( self::filesize_compare( $currentVersion, $version, $compare ) ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : self::render_warning_text( $errorType ) ); ?></td>
1170
+ <?php } elseif ( 'get_curl_ssl_version' === $getter ) { ?>
1171
  <td><?php echo( self::curlssl_compare( $version, $compare ) ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : self::render_warning_text( $errorType ) ); ?></td>
1172
  <?php } elseif ( ( 'get_max_input_time' === $getter || 'get_max_execution_time' === $getter ) && -1 == $currentVersion ) { ?>
1173
  <td><?php echo '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>'; ?></td>
class/class-mainwp-child.php CHANGED
@@ -1,456 +1,456 @@
1
- <?php
2
- /**
3
- * MainWP Child
4
- *
5
- * @package MainWP\Child
6
- */
7
-
8
- namespace MainWP\Child;
9
-
10
- // phpcs:disable -- required for debugging.
11
- if ( isset( $_REQUEST['mainwpsignature'] ) ) {
12
- // if not debug.
13
- if ( ! defined('MAINWP_CHILD_DEBUG') || false == MAINWP_CHILD_DEBUG ) {
14
- ini_set( 'display_errors', false );
15
- error_reporting( 0 );
16
- }
17
- }
18
-
19
- // phpcs:enable
20
-
21
- require_once ABSPATH . '/wp-admin/includes/file.php';
22
- require_once ABSPATH . '/wp-admin/includes/plugin.php';
23
-
24
- /**
25
- * Class MainWP_Child
26
- *
27
- * Manage all MainWP features.
28
- */
29
- class MainWP_Child {
30
-
31
- /**
32
- * Public static variable containing the latest MainWP Child plugin version.
33
- *
34
- * @var string MainWP Child plugin version.
35
- */
36
- public static $version = '4.1.7';
37
-
38
- /**
39
- * Private variable containing the latest MainWP Child update version.
40
- *
41
- * @var string MainWP Child update version.
42
- */
43
- private $update_version = '1.5';
44
-
45
- /**
46
- * Public variable containing the MainWP Child plugin slug.
47
- *
48
- * @var string MainWP Child plugin slug.
49
- */
50
- public $plugin_slug;
51
-
52
- /**
53
- * Private variable containing the MainWP Child plugin directory.
54
- *
55
- * @var string MainWP Child plugin directory.
56
- */
57
- private $plugin_dir;
58
-
59
- /**
60
- * MainWP_Child constructor.
61
- *
62
- * Run any time class is called.
63
- *
64
- * @param resource $plugin_file MainWP Child plugin file.
65
- *
66
- * @uses \MainWP\Child\MainWP_Child_Branding::save_branding_options()
67
- * @uses \MainWP\Child\MainWP_Child_Plugins_Check::instance()
68
- * @uses \MainWP\Child\MainWP_Child_Server_Information::init()
69
- * @uses \MainWP\Child\MainWP_Child_Themes_Check::instance()
70
- * @uses \MainWP\Child\MainWP_Child_Updates::get_instance()
71
- * @uses \MainWP\Child\MainWP_Client_Report::init()
72
- * @uses \MainWP\Child\MainWP_Clone::init()
73
- * @uses \MainWP\Child\MainWP_Connect::check_other_auth()
74
- * @uses \MainWP\Child\MainWP_Pages::init()
75
- * @uses \MainWP\Child\MainWP_Helper::update_option()
76
- * @uses \MainWP\Child\MainWP_Utility::run_saved_snippets()
77
- * @uses \MainWP\Child\MainWP_Utility::get_class_name()
78
- */
79
- public function __construct( $plugin_file ) {
80
- $this->update();
81
- $this->load_all_options();
82
-
83
- $this->plugin_slug = plugin_basename( $plugin_file );
84
-
85
- add_action( 'template_redirect', array( $this, 'template_redirect' ) );
86
- add_action( 'init', array( &$this, 'init_check_login' ), 1 );
87
- add_action( 'init', array( &$this, 'parse_init' ), 9999 );
88
- add_action( 'init', array( &$this, 'localization' ), 33 );
89
- add_action( 'admin_init', array( &$this, 'admin_init' ) );
90
-
91
- // support for better detection for premium plugins.
92
- add_action( 'pre_current_active_plugins', array( MainWP_Child_Updates::get_instance(), 'detect_premium_themesplugins_updates' ) );
93
-
94
- // support for better detection for premium themes.
95
- add_action( 'core_upgrade_preamble', array( MainWP_Child_Updates::get_instance(), 'detect_premium_themesplugins_updates' ) );
96
-
97
- MainWP_Pages::get_instance()->init();
98
-
99
- if ( is_admin() ) {
100
- MainWP_Helper::update_option( 'mainwp_child_plugin_version', self::$version, 'yes' );
101
- }
102
-
103
- MainWP_Connect::instance()->check_other_auth();
104
-
105
- MainWP_Clone::instance()->init();
106
- MainWP_Child_Server_Information::init();
107
- MainWP_Client_Report::instance()->init();
108
- MainWP_Child_Plugins_Check::instance();
109
- MainWP_Child_Themes_Check::instance();
110
- MainWP_Utility::instance()->run_saved_snippets();
111
-
112
- if ( ! get_option( 'mainwp_child_pubkey' ) ) {
113
- MainWP_Child_Branding::instance()->save_branding_options( 'branding_disconnected', 'yes' );
114
- }
115
-
116
- if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
117
- if ( isset( $_GET['mainwp_child_run'] ) && ! empty( $_GET['mainwp_child_run'] ) ) {
118
- add_action( 'init', array( MainWP_Utility::get_class_name(), 'cron_active' ), PHP_INT_MAX );
119
- }
120
- }
121
- }
122
-
123
- /**
124
- * Method load_all_options()
125
- *
126
- * Load all MainWP Child plugin options.
127
- *
128
- * @return array|bool Return array of options or false on failure.
129
- */
130
- public function load_all_options() {
131
-
132
- /**
133
- * WP Database object.
134
- *
135
- * @global object $wpdb WordPress object.
136
- */
137
- global $wpdb;
138
-
139
- if ( ! defined( 'WP_INSTALLING' ) || ! is_multisite() ) {
140
- $alloptions = wp_cache_get( 'alloptions', 'options' );
141
- } else {
142
- $alloptions = false;
143
- }
144
-
145
- if ( ! defined( 'WP_INSTALLING' ) || ! is_multisite() ) {
146
- $notoptions = wp_cache_get( 'notoptions', 'options' );
147
- } else {
148
- $notoptions = false;
149
- }
150
-
151
- if ( ! isset( $alloptions['mainwp_child_server'] ) ) {
152
- $suppress = $wpdb->suppress_errors();
153
- $options = array(
154
- 'mainwp_child_auth',
155
- 'mainwp_child_reports_db',
156
- 'mainwp_child_pluginDir',
157
- 'mainwp_updraftplus_hide_plugin',
158
- 'mainwp_backwpup_ext_enabled',
159
- 'mainwp_child_server',
160
- 'mainwp_pagespeed_hide_plugin',
161
- 'mainwp_child_clone_permalink',
162
- 'mainwp_child_restore_permalink',
163
- 'mainwp_ext_snippets_enabled',
164
- 'mainwp_child_pubkey',
165
- 'mainwp_child_nossl',
166
- 'mainwp_security',
167
- 'mainwp_backupwordpress_ext_enabled',
168
- 'mainwp_pagespeed_ext_enabled',
169
- 'mainwp_linkschecker_ext_enabled',
170
- 'mainwp_child_branding_settings',
171
- 'mainwp_child_plugintheme_days_outdate',
172
- 'mainwp_wp_staging_ext_enabled',
173
- );
174
- $query = "SELECT option_name, option_value FROM $wpdb->options WHERE option_name in (";
175
- foreach ( $options as $option ) {
176
- $query .= "'" . $option . "', ";
177
- }
178
- $query = substr( $query, 0, strlen( $query ) - 2 );
179
- $query .= ")"; // phpcs:ignore -- simple style problem.
180
-
181
- $alloptions_db = $wpdb->get_results( $query ); // phpcs:ignore -- safe query, required to achieve desired results, pull request solutions appreciated.
182
- $wpdb->suppress_errors( $suppress );
183
- if ( ! is_array( $alloptions ) ) {
184
- $alloptions = array();
185
- }
186
- if ( is_array( $alloptions_db ) ) {
187
- foreach ( (array) $alloptions_db as $o ) {
188
- $alloptions[ $o->option_name ] = $o->option_value;
189
- unset( $options[ array_search( $o->option_name, $options ) ] );
190
- }
191
- foreach ( $options as $option ) {
192
- $notoptions[ $option ] = true;
193
- }
194
- if ( ! defined( 'WP_INSTALLING' ) || ! is_multisite() ) {
195
- wp_cache_set( 'alloptions', $alloptions, 'options' );
196
- wp_cache_set( 'notoptions', $notoptions, 'options' );
197
- }
198
- }
199
- }
200
-
201
- return $alloptions;
202
- }
203
-
204
- /**
205
- * Method update()
206
- *
207
- * Update the MainWP Child plugin version (mainwp_child_update_version) option.
208
- *
209
- * @return void
210
- *
211
- * @uses \MainWP\Child\MainWP_Helper::update_option()
212
- */
213
- public function update() {
214
- $update_version = get_option( 'mainwp_child_update_version' );
215
-
216
- if ( $update_version === $this->update_version ) {
217
- return;
218
- }
219
-
220
- MainWP_Helper::update_option( 'mainwp_child_update_version', $this->update_version, 'yes' );
221
- }
222
-
223
- /**
224
- * Method localization()
225
- *
226
- * Load the MainWP Child plugin textdomains.
227
- */
228
- public function localization() {
229
- load_plugin_textdomain( 'mainwp-child', false, dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' );
230
- }
231
-
232
- /**
233
- * Method template_redirect()
234
- *
235
- * Handle the template redirect for 404 maintenance alerts.
236
- *
237
- * @uses \MainWP\Child\MainWP_Utility::maintenance_alert()
238
- */
239
- public function template_redirect() {
240
- MainWP_Utility::instance()->maintenance_alert();
241
- }
242
-
243
- /**
244
- * Method parse_init()
245
- *
246
- * Parse the init hook.
247
- *
248
- * @return void
249
- *
250
- * @uses \MainWP\Child\MainWP_Child_Callable::init_call_functions()
251
- * @uses \MainWP\Child\MainWP_Clone::request_clone_funct()
252
- * @uses \MainWP\Child\MainWP_Connect::parse_login_required()
253
- * @uses \MainWP\Child\MainWP_Connect::register_site()
254
- * @uses \MainWP\Child\MainWP_Connect::auth()
255
- * @uses \MainWP\Child\MainWP_Connect::parse_init_auth()
256
- * @uses \MainWP\Child\MainWP_Security::fix_all()
257
- * @uses \MainWP\Child\MainWP_Utility::fix_for_custom_themes()
258
- */
259
- public function parse_init() {
260
-
261
- if ( isset( $_REQUEST['cloneFunc'] ) ) {
262
- $valid_clone = MainWP_Clone::instance()->request_clone_funct();
263
- if ( ! $valid_clone ) {
264
- return;
265
- }
266
- }
267
-
268
- // if login required.
269
- if ( isset( $_REQUEST['login_required'] ) && ( '1' === $_REQUEST['login_required'] ) && isset( $_REQUEST['user'] ) ) {
270
- $valid_login_required = MainWP_Connect::instance()->parse_login_required();
271
- // return if login required are not valid, if login is valid will redirect to admin side.
272
- if ( ! $valid_login_required ) {
273
- return;
274
- }
275
- }
276
-
277
- MainWP_Security::fix_all();
278
-
279
- // Register does not require auth, so we register here.
280
- if ( isset( $_POST['function'] ) && 'register' === $_POST['function'] ) {
281
-
282
- /**
283
- * Checks whether cron is in progress.
284
- *
285
- * @const ( bool ) Default: true
286
- * @source https://code-reference.mainwp.com/classes/MainWP.Child.MainWP_Child.html
287
- */
288
- define( 'DOING_CRON', true );
289
-
290
- MainWP_Utility::fix_for_custom_themes();
291
- MainWP_Connect::instance()->register_site(); // register the site and exit.
292
- }
293
-
294
- $mainwpsignature = isset( $_POST['mainwpsignature'] ) ? rawurldecode( wp_unslash( $_POST['mainwpsignature'] ) ) : '';
295
- $function = isset( $_POST['function'] ) ? sanitize_text_field( wp_unslash( $_POST['function'] ) ) : null;
296
- $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : '';
297
- $nossl = isset( $_POST['nossl'] ) ? sanitize_text_field( wp_unslash( $_POST['nossl'] ) ) : 0;
298
-
299
- // Authenticate here.
300
- $auth = MainWP_Connect::instance()->auth( $mainwpsignature, $function, $nonce, $nossl );
301
-
302
- // Parse auth, if it is not correct actions then exit with message or return.
303
- if ( ! MainWP_Connect::instance()->parse_init_auth( $auth ) ) {
304
- return;
305
- }
306
-
307
- $this->parse_init_extensions();
308
-
309
- /**
310
- * WordPress submenu no privilege.
311
- *
312
- * @global string
313
- */
314
- global $_wp_submenu_nopriv;
315
-
316
- if ( null === $_wp_submenu_nopriv ) {
317
- $_wp_submenu_nopriv = array(); // phpcs:ignore -- Required to fix warnings, pull request solutions appreciated.
318
- }
319
-
320
- // execute callable functions here.
321
- MainWP_Child_Callable::get_instance()->init_call_functions( $auth );
322
- }
323
-
324
- /**
325
- * Method init_check_login()
326
- *
327
- * Initiate the check login process.
328
- *
329
- * @uses MainWP_Connect::check_login()
330
- */
331
- public function init_check_login() {
332
- MainWP_Connect::instance()->check_login();
333
- }
334
-
335
- /**
336
- * Method admin_init()
337
- *
338
- * If the current user is administrator initiate the admin ajax.
339
- *
340
- * @uses \MainWP\Child\MainWP_Clone::init_ajax()
341
- * @uses \MainWP\Child\MainWP_Helper::is_admin()
342
- */
343
- public function admin_init() {
344
- if ( MainWP_Helper::is_admin() && is_admin() ) {
345
- MainWP_Clone::instance()->init_ajax();
346
- }
347
- }
348
-
349
- /**
350
- * Method parse_init_extensions()
351
- *
352
- * Parse MainWP Extension initiations.
353
- *
354
- * @uses \MainWP\Child\MainWP_Child_Branding::branding_init()
355
- * @uses \MainWP\Child\MainWP_Client_Report::creport_init()
356
- * @uses \MainWP\Child\MainWP_Child_IThemes_Security::ithemes_init()
357
- * @uses \MainWP\Child\MainWP_Child_Updraft_Plus_Backups::updraftplus_init()
358
- * @uses \MainWP\Child\MainWP_Child_Back_Up_WordPress::init()
359
- * @uses \MainWP\Child\MainWP_Child_WP_Rocket::init()
360
- * @uses \MainWP\Child\MainWP_Child_Back_WP_Up::init()
361
- * @uses \MainWP\Child\MainWP_Child_Back_Up_Buddy::instance()
362
- * @uses \MainWP\Child\MainWP_Child_Wordfence::wordfence_init()
363
- * @uses \MainWP\Child\MainWP_Child_Timecapsule::init()
364
- * @uses \MainWP\Child\MainWP_Child_Staging::init()
365
- * @uses \MainWP\Child\MainWP_Child_Pagespeed::init()
366
- * @uses \MainWP\Child\MainWP_Child_Links_Checker::init()
367
- * @uses \MainWP\Child\MainWP_Child_WPvivid_BackupRestore::init()
368
- */
369
- private function parse_init_extensions() {
370
- MainWP_Child_Branding::instance()->branding_init();
371
- MainWP_Client_Report::instance()->creport_init();
372
- MainWP_Child_IThemes_Security::instance()->ithemes_init();
373
- MainWP_Child_Updraft_Plus_Backups::instance()->updraftplus_init();
374
- MainWP_Child_Back_Up_WordPress::instance()->init();
375
- MainWP_Child_WP_Rocket::instance()->init();
376
- MainWP_Child_Back_WP_Up::instance()->init();
377
- MainWP_Child_Back_Up_Buddy::instance();
378
- MainWP_Child_Wordfence::instance()->wordfence_init();
379
- MainWP_Child_Timecapsule::instance()->init();
380
- MainWP_Child_Staging::instance()->init();
381
- MainWP_Child_Pagespeed::instance()->init();
382
- MainWP_Child_Links_Checker::instance()->init();
383
- MainWP_Child_WPvivid_BackupRestore::instance()->init();
384
- }
385
-
386
- /**
387
- * Method deactivation()
388
- *
389
- * Deactivate the MainWP Child plugin and delete unwanted data.
390
- *
391
- * @param bool $deact Whether or not to deactivate pugin. Default: true.
392
- */
393
- public function deactivation( $deact = true ) {
394
-
395
- $mu_plugin_enabled = apply_filters( 'mainwp_child_mu_plugin_enabled', false );
396
- if ( $mu_plugin_enabled ) {
397
- return;
398
- }
399
-
400
- $to_delete = array(
401
- 'mainwp_child_pubkey',
402
- 'mainwp_child_nonce',
403
- 'mainwp_child_nossl',
404
- 'mainwp_child_nossl_key',
405
- 'mainwp_security',
406
- 'mainwp_child_server',
407
- );
408
- $to_delete[] = 'mainwp_ext_snippets_enabled';
409
- $to_delete[] = 'mainwp_ext_code_snippets';
410
-
411
- foreach ( $to_delete as $delete ) {
412
- if ( get_option( $delete ) ) {
413
- delete_option( $delete );
414
- wp_cache_delete( $delete, 'options' );
415
- }
416
- }
417
-
418
- if ( $deact ) {
419
- do_action( 'mainwp_child_deactivation' );
420
- }
421
- }
422
-
423
- /**
424
- * Method activation()
425
- *
426
- * Activate the MainWP Child plugin and delete unwanted data.
427
- *
428
- * @uses \MainWP\Child\MainWP_Helper::update_option()
429
- */
430
- public function activation() {
431
- $mu_plugin_enabled = apply_filters( 'mainwp_child_mu_plugin_enabled', false );
432
- if ( $mu_plugin_enabled ) {
433
- return;
434
- }
435
-
436
- $to_delete = array(
437
- 'mainwp_child_pubkey',
438
- 'mainwp_child_nonce',
439
- 'mainwp_child_nossl',
440
- 'mainwp_child_nossl_key',
441
- );
442
- foreach ( $to_delete as $delete ) {
443
- if ( get_option( $delete ) ) {
444
- delete_option( $delete );
445
- }
446
- }
447
-
448
- MainWP_Helper::update_option( 'mainwp_child_activated_once', true );
449
-
450
- $to_delete = array( 'mainwp_ext_snippets_enabled', 'mainwp_ext_code_snippets' );
451
- foreach ( $to_delete as $delete ) {
452
- delete_option( $delete );
453
- }
454
- }
455
-
456
- }
1
+ <?php
2
+ /**
3
+ * MainWP Child
4
+ *
5
+ * @package MainWP\Child
6
+ */
7
+
8
+ namespace MainWP\Child;
9
+
10
+ // phpcs:disable -- required for debugging.
11
+ if ( isset( $_REQUEST['mainwpsignature'] ) ) {
12
+ // if not debug.
13
+ if ( ! defined('MAINWP_CHILD_DEBUG') || false == MAINWP_CHILD_DEBUG ) {
14
+ ini_set( 'display_errors', false );
15
+ error_reporting( 0 );
16
+ }
17
+ }
18
+
19
+ // phpcs:enable
20
+
21
+ require_once ABSPATH . '/wp-admin/includes/file.php';
22
+ require_once ABSPATH . '/wp-admin/includes/plugin.php';
23
+
24
+ /**
25
+ * Class MainWP_Child
26
+ *
27
+ * Manage all MainWP features.
28
+ */
29
+ class MainWP_Child {
30
+
31
+ /**
32
+ * Public static variable containing the latest MainWP Child plugin version.
33
+ *
34
+ * @var string MainWP Child plugin version.
35
+ */
36
+ public static $version = '4.1.7.1';
37
+
38
+ /**
39
+ * Private variable containing the latest MainWP Child update version.
40
+ *
41
+ * @var string MainWP Child update version.
42
+ */
43
+ private $update_version = '1.5';
44
+
45
+ /**
46
+ * Public variable containing the MainWP Child plugin slug.
47
+ *
48
+ * @var string MainWP Child plugin slug.
49
+ */
50
+ public $plugin_slug;
51
+
52
+ /**
53
+ * Private variable containing the MainWP Child plugin directory.
54
+ *
55
+ * @var string MainWP Child plugin directory.
56
+ */
57
+ private $plugin_dir;
58
+
59
+ /**
60
+ * MainWP_Child constructor.
61
+ *
62
+ * Run any time class is called.
63
+ *
64
+ * @param resource $plugin_file MainWP Child plugin file.
65
+ *
66
+ * @uses \MainWP\Child\MainWP_Child_Branding::save_branding_options()
67
+ * @uses \MainWP\Child\MainWP_Child_Plugins_Check::instance()
68
+ * @uses \MainWP\Child\MainWP_Child_Server_Information::init()
69
+ * @uses \MainWP\Child\MainWP_Child_Themes_Check::instance()
70
+ * @uses \MainWP\Child\MainWP_Child_Updates::get_instance()
71
+ * @uses \MainWP\Child\MainWP_Client_Report::init()
72
+ * @uses \MainWP\Child\MainWP_Clone::init()
73
+ * @uses \MainWP\Child\MainWP_Connect::check_other_auth()
74
+ * @uses \MainWP\Child\MainWP_Pages::init()
75
+ * @uses \MainWP\Child\MainWP_Helper::update_option()
76
+ * @uses \MainWP\Child\MainWP_Utility::run_saved_snippets()
77
+ * @uses \MainWP\Child\MainWP_Utility::get_class_name()
78
+ */
79
+ public function __construct( $plugin_file ) {
80
+ $this->update();
81
+ $this->load_all_options();
82
+
83
+ $this->plugin_slug = plugin_basename( $plugin_file );
84
+
85
+ add_action( 'template_redirect', array( $this, 'template_redirect' ) );
86
+ add_action( 'init', array( &$this, 'init_check_login' ), 1 );
87
+ add_action( 'init', array( &$this, 'parse_init' ), 9999 );
88
+ add_action( 'init', array( &$this, 'localization' ), 33 );
89
+ add_action( 'admin_init', array( &$this, 'admin_init' ) );
90
+
91
+ // support for better detection for premium plugins.
92
+ add_action( 'pre_current_active_plugins', array( MainWP_Child_Updates::get_instance(), 'detect_premium_themesplugins_updates' ) );
93
+
94
+ // support for better detection for premium themes.
95
+ add_action( 'core_upgrade_preamble', array( MainWP_Child_Updates::get_instance(), 'detect_premium_themesplugins_updates' ) );
96
+
97
+ MainWP_Pages::get_instance()->init();
98
+
99
+ if ( is_admin() ) {
100
+ MainWP_Helper::update_option( 'mainwp_child_plugin_version', self::$version, 'yes' );
101
+ }
102
+
103
+ MainWP_Connect::instance()->check_other_auth();
104
+
105
+ MainWP_Clone::instance()->init();
106
+ MainWP_Child_Server_Information::init();
107
+ MainWP_Client_Report::instance()->init();
108
+ MainWP_Child_Plugins_Check::instance();
109
+ MainWP_Child_Themes_Check::instance();
110
+ MainWP_Utility::instance()->run_saved_snippets();
111
+
112
+ if ( ! get_option( 'mainwp_child_pubkey' ) ) {
113
+ MainWP_Child_Branding::instance()->save_branding_options( 'branding_disconnected', 'yes' );
114
+ }
115
+
116
+ if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
117
+ if ( isset( $_GET['mainwp_child_run'] ) && ! empty( $_GET['mainwp_child_run'] ) ) {
118
+ add_action( 'init', array( MainWP_Utility::get_class_name(), 'cron_active' ), PHP_INT_MAX );
119
+ }
120
+ }
121
+ }
122
+
123
+ /**
124
+ * Method load_all_options()
125
+ *
126
+ * Load all MainWP Child plugin options.
127
+ *
128
+ * @return array|bool Return array of options or false on failure.
129
+ */
130
+ public function load_all_options() {
131
+
132
+ /**
133
+ * WP Database object.
134
+ *
135
+ * @global object $wpdb WordPress object.
136
+ */
137
+ global $wpdb;
138
+
139
+ if ( ! defined( 'WP_INSTALLING' ) || ! is_multisite() ) {
140
+ $alloptions = wp_cache_get( 'alloptions', 'options' );
141
+ } else {
142
+ $alloptions = false;
143
+ }
144
+
145
+ if ( ! defined( 'WP_INSTALLING' ) || ! is_multisite() ) {
146
+ $notoptions = wp_cache_get( 'notoptions', 'options' );
147
+ } else {
148
+ $notoptions = false;
149
+ }
150
+
151
+ if ( ! isset( $alloptions['mainwp_child_server'] ) ) {
152
+ $suppress = $wpdb->suppress_errors();
153
+ $options = array(
154
+ 'mainwp_child_auth',
155
+ 'mainwp_child_reports_db',
156
+ 'mainwp_child_pluginDir',
157
+ 'mainwp_updraftplus_hide_plugin',
158
+ 'mainwp_backwpup_ext_enabled',
159
+ 'mainwp_child_server',
160
+ 'mainwp_pagespeed_hide_plugin',
161
+ 'mainwp_child_clone_permalink',
162
+ 'mainwp_child_restore_permalink',
163
+ 'mainwp_ext_snippets_enabled',
164
+ 'mainwp_child_pubkey',
165
+ 'mainwp_child_nossl',
166
+ 'mainwp_security',
167
+ 'mainwp_backupwordpress_ext_enabled',
168
+ 'mainwp_pagespeed_ext_enabled',
169
+ 'mainwp_linkschecker_ext_enabled',
170
+ 'mainwp_child_branding_settings',
171
+ 'mainwp_child_plugintheme_days_outdate',
172
+ 'mainwp_wp_staging_ext_enabled',
173
+ );
174
+ $query = "SELECT option_name, option_value FROM $wpdb->options WHERE option_name in (";
175
+ foreach ( $options as $option ) {
176
+ $query .= "'" . $option . "', ";
177
+ }
178
+ $query = substr( $query, 0, strlen( $query ) - 2 );
179
+ $query .= ")"; // phpcs:ignore -- simple style problem.
180
+
181
+ $alloptions_db = $wpdb->get_results( $query ); // phpcs:ignore -- safe query, required to achieve desired results, pull request solutions appreciated.
182
+ $wpdb->suppress_errors( $suppress );
183
+ if ( ! is_array( $alloptions ) ) {
184
+ $alloptions = array();
185
+ }
186
+ if ( is_array( $alloptions_db ) ) {
187
+ foreach ( (array) $alloptions_db as $o ) {
188
+ $alloptions[ $o->option_name ] = $o->option_value;
189
+ unset( $options[ array_search( $o->option_name, $options ) ] );
190
+ }
191
+ foreach ( $options as $option ) {
192
+ $notoptions[ $option ] = true;
193
+ }
194
+ if ( ! defined( 'WP_INSTALLING' ) || ! is_multisite() ) {
195
+ wp_cache_set( 'alloptions', $alloptions, 'options' );
196
+ wp_cache_set( 'notoptions', $notoptions, 'options' );
197
+ }
198
+ }
199
+ }
200
+
201
+ return $alloptions;
202
+ }
203
+
204
+ /**
205
+ * Method update()
206
+ *
207
+ * Update the MainWP Child plugin version (mainwp_child_update_version) option.
208
+ *
209
+ * @return void
210
+ *
211
+ * @uses \MainWP\Child\MainWP_Helper::update_option()
212
+ */
213
+ public function update() {
214
+ $update_version = get_option( 'mainwp_child_update_version' );
215
+
216
+ if ( $update_version === $this->update_version ) {
217
+ return;
218
+ }
219
+
220
+ MainWP_Helper::update_option( 'mainwp_child_update_version', $this->update_version, 'yes' );
221
+ }
222
+
223
+ /**
224
+ * Method localization()
225
+ *
226
+ * Load the MainWP Child plugin textdomains.
227
+ */
228
+ public function localization() {
229
+ load_plugin_textdomain( 'mainwp-child', false, dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' );
230
+ }
231
+
232
+ /**
233
+ * Method template_redirect()
234
+ *
235
+ * Handle the template redirect for 404 maintenance alerts.
236
+ *
237
+ * @uses \MainWP\Child\MainWP_Utility::maintenance_alert()
238
+ */
239
+ public function template_redirect() {
240
+ MainWP_Utility::instance()->maintenance_alert();
241
+ }
242
+
243
+ /**
244
+ * Method parse_init()
245
+ *
246
+ * Parse the init hook.
247
+ *
248
+ * @return void
249
+ *
250
+ * @uses \MainWP\Child\MainWP_Child_Callable::init_call_functions()
251
+ * @uses \MainWP\Child\MainWP_Clone::request_clone_funct()
252
+ * @uses \MainWP\Child\MainWP_Connect::parse_login_required()
253
+ * @uses \MainWP\Child\MainWP_Connect::register_site()
254
+ * @uses \MainWP\Child\MainWP_Connect::auth()
255
+ * @uses \MainWP\Child\MainWP_Connect::parse_init_auth()
256
+ * @uses \MainWP\Child\MainWP_Security::fix_all()
257
+ * @uses \MainWP\Child\MainWP_Utility::fix_for_custom_themes()
258
+ */
259
+ public function parse_init() {
260
+
261
+ if ( isset( $_REQUEST['cloneFunc'] ) ) {
262
+ $valid_clone = MainWP_Clone::instance()->request_clone_funct();
263
+ if ( ! $valid_clone ) {
264
+ return;
265
+ }
266
+ }
267
+
268
+ // if login required.
269
+ if ( isset( $_REQUEST['login_required'] ) && ( '1' === $_REQUEST['login_required'] ) && isset( $_REQUEST['user'] ) ) {
270
+ $valid_login_required = MainWP_Connect::instance()->parse_login_required();
271
+ // return if login required are not valid, if login is valid will redirect to admin side.
272
+ if ( ! $valid_login_required ) {
273
+ return;
274
+ }
275
+ }
276
+
277
+ MainWP_Security::fix_all();
278
+
279
+ // Register does not require auth, so we register here.
280
+ if ( isset( $_POST['function'] ) && 'register' === $_POST['function'] ) {
281
+
282
+ /**
283
+ * Checks whether cron is in progress.
284
+ *
285
+ * @const ( bool ) Default: true
286
+ * @source https://code-reference.mainwp.com/classes/MainWP.Child.MainWP_Child.html
287
+ */
288
+ define( 'DOING_CRON', true );
289
+
290
+ MainWP_Utility::fix_for_custom_themes();
291
+ MainWP_Connect::instance()->register_site(); // register the site and exit.
292
+ }
293
+
294
+ $mainwpsignature = isset( $_POST['mainwpsignature'] ) ? rawurldecode( wp_unslash( $_POST['mainwpsignature'] ) ) : '';
295
+ $function = isset( $_POST['function'] ) ? sanitize_text_field( wp_unslash( $_POST['function'] ) ) : null;
296
+ $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : '';
297
+ $nossl = isset( $_POST['nossl'] ) ? sanitize_text_field( wp_unslash( $_POST['nossl'] ) ) : 0;
298
+
299
+ // Authenticate here.
300
+ $auth = MainWP_Connect::instance()->auth( $mainwpsignature, $function, $nonce, $nossl );
301
+
302
+ // Parse auth, if it is not correct actions then exit with message or return.
303
+ if ( ! MainWP_Connect::instance()->parse_init_auth( $auth ) ) {
304
+ return;
305
+ }
306
+
307
+ $this->parse_init_extensions();
308
+
309
+ /**
310
+ * WordPress submenu no privilege.
311
+ *
312
+ * @global string
313
+ */
314
+ global $_wp_submenu_nopriv;
315
+
316
+ if ( null === $_wp_submenu_nopriv ) {
317
+ $_wp_submenu_nopriv = array(); // phpcs:ignore -- Required to fix warnings, pull request solutions appreciated.
318
+ }
319
+
320
+ // execute callable functions here.
321
+ MainWP_Child_Callable::get_instance()->init_call_functions( $auth );
322
+ }
323
+
324
+ /**
325
+ * Method init_check_login()
326
+ *
327
+ * Initiate the check login process.
328
+ *
329
+ * @uses MainWP_Connect::check_login()
330
+ */
331
+ public function init_check_login() {
332
+ MainWP_Connect::instance()->check_login();
333
+ }
334
+
335
+ /**
336
+ * Method admin_init()
337
+ *
338
+ * If the current user is administrator initiate the admin ajax.
339
+ *
340
+ * @uses \MainWP\Child\MainWP_Clone::init_ajax()
341
+ * @uses \MainWP\Child\MainWP_Helper::is_admin()
342
+ */
343
+ public function admin_init() {
344
+ if ( MainWP_Helper::is_admin() && is_admin() ) {
345
+ MainWP_Clone::instance()->init_ajax();
346
+ }
347
+ }
348
+
349
+ /**
350
+ * Method parse_init_extensions()
351
+ *
352
+ * Parse MainWP Extension initiations.
353
+ *
354
+ * @uses \MainWP\Child\MainWP_Child_Branding::branding_init()
355
+ * @uses \MainWP\Child\MainWP_Client_Report::creport_init()
356
+ * @uses \MainWP\Child\MainWP_Child_IThemes_Security::ithemes_init()
357
+ * @uses \MainWP\Child\MainWP_Child_Updraft_Plus_Backups::updraftplus_init()
358
+ * @uses \MainWP\Child\MainWP_Child_Back_Up_WordPress::init()
359
+ * @uses \MainWP\Child\MainWP_Child_WP_Rocket::init()
360
+ * @uses \MainWP\Child\MainWP_Child_Back_WP_Up::init()
361
+ * @uses \MainWP\Child\MainWP_Child_Back_Up_Buddy::instance()
362
+ * @uses \MainWP\Child\MainWP_Child_Wordfence::wordfence_init()
363
+ * @uses \MainWP\Child\MainWP_Child_Timecapsule::init()
364
+ * @uses \MainWP\Child\MainWP_Child_Staging::init()
365
+ * @uses \MainWP\Child\MainWP_Child_Pagespeed::init()
366
+ * @uses \MainWP\Child\MainWP_Child_Links_Checker::init()
367
+ * @uses \MainWP\Child\MainWP_Child_WPvivid_BackupRestore::init()
368
+ */
369
+ private function parse_init_extensions() {
370
+ MainWP_Child_Branding::instance()->branding_init();
371
+ MainWP_Client_Report::instance()->creport_init();
372
+ MainWP_Child_IThemes_Security::instance()->ithemes_init();
373
+ MainWP_Child_Updraft_Plus_Backups::instance()->updraftplus_init();
374
+ MainWP_Child_Back_Up_WordPress::instance()->init();
375
+ MainWP_Child_WP_Rocket::instance()->init();
376
+ MainWP_Child_Back_WP_Up::instance()->init();
377
+ MainWP_Child_Back_Up_Buddy::instance();
378
+ MainWP_Child_Wordfence::instance()->wordfence_init();
379
+ MainWP_Child_Timecapsule::instance()->init();
380
+ MainWP_Child_Staging::instance()->init();
381
+ MainWP_Child_Pagespeed::instance()->init();
382
+ MainWP_Child_Links_Checker::instance()->init();
383
+ MainWP_Child_WPvivid_BackupRestore::instance()->init();
384
+ }
385
+
386
+ /**
387
+ * Method deactivation()
388
+ *
389
+ * Deactivate the MainWP Child plugin and delete unwanted data.
390
+ *
391
+ * @param bool $deact Whether or not to deactivate pugin. Default: true.
392
+ */
393
+ public function deactivation( $deact = true ) {
394
+
395
+ $mu_plugin_enabled = apply_filters( 'mainwp_child_mu_plugin_enabled', false );
396
+ if ( $mu_plugin_enabled ) {
397
+ return;
398
+ }
399
+
400
+ $to_delete = array(
401
+ 'mainwp_child_pubkey',
402
+ 'mainwp_child_nonce',
403
+ 'mainwp_child_nossl',
404
+ 'mainwp_child_nossl_key',
405
+ 'mainwp_security',
406
+ 'mainwp_child_server',
407
+ );
408
+ $to_delete[] = 'mainwp_ext_snippets_enabled';
409
+ $to_delete[] = 'mainwp_ext_code_snippets';
410
+
411
+ foreach ( $to_delete as $delete ) {
412
+ if ( get_option( $delete ) ) {
413
+ delete_option( $delete );
414
+ wp_cache_delete( $delete, 'options' );
415
+ }
416
+ }
417
+
418
+ if ( $deact ) {
419
+ do_action( 'mainwp_child_deactivation' );
420
+ }
421
+ }
422
+
423
+ /**
424
+ * Method activation()
425
+ *
426
+ * Activate the MainWP Child plugin and delete unwanted data.
427
+ *
428
+ * @uses \MainWP\Child\MainWP_Helper::update_option()
429
+ */
430
+ public function activation() {
431
+ $mu_plugin_enabled = apply_filters( 'mainwp_child_mu_plugin_enabled', false );
432
+ if ( $mu_plugin_enabled ) {
433
+ return;
434
+ }
435
+
436
+ $to_delete = array(
437
+ 'mainwp_child_pubkey',
438
+ 'mainwp_child_nonce',
439
+ 'mainwp_child_nossl',
440
+ 'mainwp_child_nossl_key',
441
+ );
442
+ foreach ( $to_delete as $delete ) {
443
+ if ( get_option( $delete ) ) {
444
+ delete_option( $delete );
445
+ }
446
+ }
447
+
448
+ MainWP_Helper::update_option( 'mainwp_child_activated_once', true );
449
+
450
+ $to_delete = array( 'mainwp_ext_snippets_enabled', 'mainwp_ext_code_snippets' );
451
+ foreach ( $to_delete as $delete ) {
452
+ delete_option( $delete );
453
+ }
454
+ }
455
+
456
+ }
mainwp-child.php CHANGED
@@ -12,7 +12,7 @@
12
  * Author: MainWP
13
  * Author URI: https://mainwp.com
14
  * Text Domain: mainwp-child
15
- * Version: 4.1.7
16
  * Requires at least: 5.4
17
  * Requires PHP: 7.0
18
  */
12
  * Author: MainWP
13
  * Author URI: https://mainwp.com
14
  * Text Domain: mainwp-child
15
+ * Version: 4.1.7.1
16
  * Requires at least: 5.4
17
  * Requires PHP: 7.0
18
  */
readme.txt CHANGED
@@ -5,9 +5,9 @@ Author: mainwp
5
  Author URI: https://mainwp.com
6
  Plugin URI: https://mainwp.com
7
  Requires at least: 5.4
8
- Tested up to: 5.8
9
  Requires PHP: 7.0
10
- Stable tag: 4.1.7
11
  License: GPLv3 or later
12
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
13
 
@@ -107,6 +107,9 @@ Sure we have a quick FAQ with a lot more questions and answers [here](https://ma
107
 
108
  == Changelog ==
109
 
 
 
 
110
  = 4.1.7 - 6-29-21 =
111
  * Added: Support for the new Vulnerability Checker API
112
 
5
  Author URI: https://mainwp.com
6
  Plugin URI: https://mainwp.com
7
  Requires at least: 5.4
8
+ Tested up to: 5.8.1
9
  Requires PHP: 7.0
10
+ Stable tag: 4.1.7.1
11
  License: GPLv3 or later
12
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
13
 
107
 
108
  == Changelog ==
109
 
110
+ = 4.1.7.1 - 10-1-2021 =
111
+ * Updated: OpenSSL version requirement to 1.1.0 or greater
112
+
113
  = 4.1.7 - 6-29-21 =
114
  * Added: Support for the new Vulnerability Checker API
115