MainWP Child - Version 3.5.4

Version Description

  • 2-14-19 =
  • Fixed: issues with displaying broken links data for specific setups
  • Fixed: compatibility issues with the latest PageSpeed Insights plugin version
  • Fixed: an issue with publishing "future" posts
  • Fixed: an issue with sending email alerts in specific setups
  • Fixed: an issue with saving code snippets in wp-config.php when the file is in a custom location
  • Fixed: an issue with clearing unused scheduled cron jobs
  • Added: support for the new PageSpeed Insights plugin options
  • Updated: disabled the "Remove readme.html" security check feature for WPEngine hosted child sites
  • Updated: support for detecting premium themes updates
Download this release

Release Info

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

Code changes from version 3.5.3 to 3.5.4

class/class-mainwp-child-branding.php CHANGED
@@ -2,14 +2,14 @@
2
 
3
  class MainWP_Child_Branding {
4
  public static $instance = null;
5
- protected $child_plugin_dir;
6
- protected $settings = null;
 
7
 
8
  static function Instance() {
9
  if ( null === MainWP_Child_Branding::$instance ) {
10
  MainWP_Child_Branding::$instance = new MainWP_Child_Branding();
11
  }
12
-
13
  return MainWP_Child_Branding::$instance;
14
  }
15
 
@@ -17,25 +17,65 @@ class MainWP_Child_Branding {
17
  $this->child_plugin_dir = dirname( dirname( __FILE__ ) );
18
  add_action( 'mainwp_child_deactivation', array( $this, 'child_deactivation' ) );
19
  add_filter( 'mainwp_child_plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 3 );
 
 
20
 
21
- $label = get_option( 'mainwp_branding_button_contact_label' );
22
- if ( ! empty( $label ) ) {
23
- $label = stripslashes( $label );
24
- } else {
25
- $label = 'Contact Support';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  }
 
 
27
 
28
- $this->settings['contact_support_label'] = $label;
29
- $this->settings['extra_settings'] = get_option( 'mainwp_branding_extra_settings' );
30
- }
 
 
 
 
31
 
 
 
32
 
33
  public function plugin_row_meta( $plugin_meta, $plugin_file, $child_plugin_slug ) {
34
  if ( $child_plugin_slug !== $plugin_file ) {
35
  return $plugin_meta;
36
  }
37
 
38
- if ( ! self::is_branding() ) {
39
  return $plugin_meta;
40
  }
41
  // hide View details links
@@ -52,6 +92,7 @@ class MainWP_Child_Branding {
52
  }
53
 
54
  public function child_deactivation() {
 
55
  $dell_all = array(
56
  'mainwp_branding_disable_change',
57
  'mainwp_branding_disable_switching_theme',
@@ -73,9 +114,40 @@ class MainWP_Child_Branding {
73
  'mainwp_branding_extra_settings',
74
  'mainwp_branding_ext_enabled',
75
  );
 
76
  foreach ( $dell_all as $opt ) {
77
  delete_option( $opt );
78
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
80
 
81
 
@@ -95,8 +167,13 @@ class MainWP_Child_Branding {
95
  if ( ! is_array( $settings ) ) {
96
  return $information;
97
  }
98
- $current_extra_setting = $this->settings['extra_settings'];
99
- MainWP_Helper::update_option( 'mainwp_branding_ext_enabled', 'Y', 'yes' );
 
 
 
 
 
100
  $header = array(
101
  'name' => $settings['child_plugin_name'],
102
  'description' => $settings['child_plugin_desc'],
@@ -104,23 +181,44 @@ class MainWP_Child_Branding {
104
  'authoruri' => $settings['child_plugin_author_uri'],
105
  'pluginuri' => isset($settings['child_plugin_uri']) ? $settings['child_plugin_uri'] : '',
106
  );
107
- MainWP_Helper::update_option( 'mainwp_branding_preserve_branding', $settings['child_preserve_branding'], 'yes' );
108
- MainWP_Helper::update_option( 'mainwp_branding_plugin_header', $header, 'yes' );
109
- MainWP_Helper::update_option( 'mainwp_branding_support_email', $settings['child_support_email'] );
110
- MainWP_Helper::update_option( 'mainwp_branding_support_message', $settings['child_support_message'] );
111
- MainWP_Helper::update_option( 'mainwp_branding_remove_restore', $settings['child_remove_restore'] );
112
- MainWP_Helper::update_option( 'mainwp_branding_remove_setting', $settings['child_remove_setting'], 'yes' );
113
- MainWP_Helper::update_option( 'mainwp_branding_remove_server_info', $settings['child_remove_server_info'] );
114
- MainWP_Helper::update_option( 'mainwp_branding_remove_connection_detail', (isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0) );
115
- MainWP_Helper::update_option( 'mainwp_branding_remove_wp_tools', $settings['child_remove_wp_tools'], 'yes' );
116
- MainWP_Helper::update_option( 'mainwp_branding_remove_wp_setting', $settings['child_remove_wp_setting'], 'yes' );
117
- MainWP_Helper::update_option( 'mainwp_branding_remove_permalink', $settings['child_remove_permalink'], 'yes' );
118
- MainWP_Helper::update_option( 'mainwp_branding_button_contact_label', $settings['child_button_contact_label'], 'yes' );
119
- MainWP_Helper::update_option( 'mainwp_branding_send_email_message', $settings['child_send_email_message'] );
120
- MainWP_Helper::update_option( 'mainwp_branding_message_return_sender', $settings['child_message_return_sender'] );
121
- MainWP_Helper::update_option( 'mainwp_branding_submit_button_title', $settings['child_submit_button_title'] );
122
- if ( isset( $settings['child_disable_wp_branding'] ) && ( 'Y' === $settings['child_disable_wp_branding'] || 'N' === $settings['child_disable_wp_branding'] ) ) {
123
- MainWP_Helper::update_option( 'mainwp_branding_disable_wp_branding', $settings['child_disable_wp_branding'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  }
125
 
126
  $extra_setting = array(
@@ -206,31 +304,40 @@ class MainWP_Child_Branding {
206
  $extra_setting['favico_image'] = $current_extra_setting['favico_image'];
207
  }
208
 
209
- MainWP_Helper::update_option( 'mainwp_branding_extra_settings', $extra_setting, 'yes' );
 
210
 
 
211
  if ( $settings['child_plugin_hide'] ) {
212
  MainWP_Helper::update_option( 'mainwp_branding_child_hide', 'T', 'yes' );
213
  } else {
214
  MainWP_Helper::update_option( 'mainwp_branding_child_hide', '' );
215
  }
 
 
 
 
 
 
216
 
217
- if ( $settings['child_show_support_button'] && ! empty( $settings['child_support_email'] ) ) {
218
- MainWP_Helper::update_option( 'mainwp_branding_show_support', 'T' );
219
- } else {
220
- MainWP_Helper::update_option( 'mainwp_branding_show_support', '' );
221
- }
222
 
223
- if ( $settings['child_disable_change'] ) {
224
- MainWP_Helper::update_option( 'mainwp_branding_disable_change', 'T' );
225
- } else {
226
- MainWP_Helper::update_option( 'mainwp_branding_disable_change', '' );
227
- }
228
 
229
- if ( $settings['child_disable_switching_theme'] ) {
230
- MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', 'T' );
231
- } else {
232
- MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', '' );
233
- }
 
234
 
235
  $information['result'] = 'SUCCESS';
236
 
@@ -266,10 +373,8 @@ class MainWP_Child_Branding {
266
 
267
 
268
  public function branding_init() {
269
- $extra_setting = $this->settings['extra_settings'];
270
- if ( ! is_array( $extra_setting ) ) {
271
- $extra_setting = array();
272
- }
273
 
274
  // to hide updates notice
275
  if (is_admin()) {
@@ -279,27 +384,28 @@ class MainWP_Child_Branding {
279
  // front end
280
  add_action( 'add_admin_bar_menus', array( $this, 'add_admin_bar_menus' ));
281
  }
 
282
 
283
-
284
- $cancelled_branding = ( get_option( 'mainwp_child_branding_disconnected' ) === 'yes' ) && ! get_option( 'mainwp_branding_preserve_branding' );
285
  if ( $cancelled_branding ) {
286
  return;
287
  }
288
- // enable branding in case child plugin is deactive
289
- add_filter( 'all_plugins', array( $this, 'branding_child_plugin' ) );
290
 
291
- if ( self::is_branding() ) {
 
 
 
292
  add_filter( 'site_transient_update_plugins', array( &$this, 'remove_update_nag' ) );
293
  add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) );
294
  }
295
 
296
- if ( get_option( 'mainwp_branding_ext_enabled' ) !== 'Y' ) {
297
  return;
298
  }
299
 
300
  add_filter( 'map_meta_cap', array( $this, 'branding_map_meta_cap' ), 10, 5 );
301
 
302
- if ( 'T' === get_option( 'mainwp_branding_disable_change' ) ) {
303
 
304
  // Disable the wordpress plugin update notifications
305
  remove_action('load-update-core.php', 'wp_update_plugins');
@@ -323,7 +429,7 @@ class MainWP_Child_Branding {
323
 
324
  // to fix
325
  add_action( 'admin_menu', array( &$this, 'admin_menu' ) );//
326
- if ( get_option( 'mainwp_branding_disable_wp_branding' ) !== 'Y' ) {
327
  add_filter( 'wp_footer', array( &$this, 'branding_global_footer' ), 15 );
328
  add_action( 'wp_dashboard_setup', array( &$this, 'custom_dashboard_widgets' ), 999 );
329
  // branding site generator
@@ -366,14 +472,17 @@ class MainWP_Child_Branding {
366
  } else if ( !current_user_can( 'administrator' ) ) {
367
  return false;
368
  }
369
- $extra_setting = $this->settings['extra_settings'];
370
- if ( ! is_array( $extra_setting ) ) {
371
- $extra_setting = array();
 
372
  }
373
- if ( 'T' === get_option( 'mainwp_branding_show_support' ) ) {
374
- $title = $this->settings['contact_support_label'];
 
 
375
  if ( isset( $extra_setting['show_button_in'] ) && ( 2 === (int) $extra_setting['show_button_in'] || 3 === (int) $extra_setting['show_button_in'] ) ) {
376
- $title = $this->settings['contact_support_label'];
377
  add_menu_page( $title, $title, 'read', 'ContactSupport2', array(
378
  $this,
379
  'contact_support',
@@ -381,7 +490,7 @@ class MainWP_Child_Branding {
381
  }
382
 
383
  if ( isset( $extra_setting['show_button_in'] ) && ( 1 === $extra_setting['show_button_in'] || 3 === $extra_setting['show_button_in'] ) ) {
384
- add_submenu_page( null, $title, $this->settings['contact_support_label'], 'read', 'ContactSupport', array(
385
  $this,
386
  'contact_support',
387
  ) );
@@ -392,10 +501,7 @@ class MainWP_Child_Branding {
392
  }
393
 
394
  function remove_default_post_metaboxes() {
395
- $extra_setting = $this->settings['extra_settings'];
396
- if ( ! is_array( $extra_setting ) ) {
397
- $extra_setting = array();
398
- }
399
 
400
  add_filter( 'manage_posts_columns', array( &$this, 'custom_post_columns' ) );
401
  add_filter( 'manage_edit-post_tag_columns', array( &$this, 'manage_my_category_columns' ) );
@@ -435,10 +541,7 @@ class MainWP_Child_Branding {
435
 
436
 
437
  function custom_post_columns( $defaults ) {
438
- $extra_setting = $this->settings['extra_settings'];
439
- if ( ! is_array( $extra_setting ) ) {
440
- $extra_setting = array();
441
- }
442
 
443
  if ( isset( $extra_setting['hide_metabox_post_comments'] ) && $extra_setting['hide_metabox_post_comments'] ) {
444
  unset( $defaults['comments'] );
@@ -454,10 +557,7 @@ class MainWP_Child_Branding {
454
  }
455
 
456
  function manage_my_category_columns( $defaults ) {
457
- $extra_setting = $this->settings['extra_settings'];
458
- if ( ! is_array( $extra_setting ) ) {
459
- $extra_setting = array();
460
- }
461
 
462
  if ( isset( $extra_setting['hide_metabox_post_slug'] ) && $extra_setting['hide_metabox_post_slug'] ) {
463
  unset( $defaults['slug'] );
@@ -467,10 +567,7 @@ class MainWP_Child_Branding {
467
  }
468
 
469
  function remove_default_page_metaboxes() {
470
- $extra_setting = $this->settings['extra_settings'];
471
- if ( ! is_array( $extra_setting ) ) {
472
- $extra_setting = array();
473
- }
474
 
475
  add_filter( 'manage_pages_columns', array( &$this, 'custom_pages_columns' ) );
476
 
@@ -498,10 +595,7 @@ class MainWP_Child_Branding {
498
  }
499
 
500
  function custom_pages_columns( $defaults ) {
501
- $extra_setting = $this->settings['extra_settings'];
502
- if ( ! is_array( $extra_setting ) ) {
503
- $extra_setting = array();
504
- }
505
 
506
  if ( isset( $extra_setting['hide_metabox_page_comments'] ) && $extra_setting['hide_metabox_page_comments'] ) {
507
  unset( $defaults['comments'] );
@@ -541,14 +635,14 @@ class MainWP_Child_Branding {
541
  }
542
 
543
  function admin_footer_text() {
544
- $extra_setting = $this->settings['extra_settings'];
545
  if ( isset( $extra_setting['dashboard_footer'] ) && ! empty( $extra_setting['dashboard_footer'] ) ) {
546
  echo wp_kses_post( nl2br( stripslashes( $extra_setting['dashboard_footer'] ) ) );
547
  }
548
  }
549
 
550
  function custom_favicon_frontend() {
551
- $extra_setting = $this->settings['extra_settings'];
552
  if ( isset( $extra_setting['favico_image']['url'] ) && ! empty( $extra_setting['favico_image']['url'] ) ) {
553
  $favico = $extra_setting['favico_image']['url'];
554
  echo '<link rel="shortcut icon" href="' . esc_url( $favico ) . '"/>' . "\n";
@@ -556,7 +650,7 @@ class MainWP_Child_Branding {
556
  }
557
 
558
  function custom_login_logo() {
559
- $extra_setting = $this->settings['extra_settings'];
560
  if ( isset( $extra_setting['login_image']['url'] ) && ! empty( $extra_setting['login_image']['url'] ) ) {
561
  $login_logo = $extra_setting['login_image']['url'];
562
  echo '<style type="text/css">
@@ -567,7 +661,7 @@ class MainWP_Child_Branding {
567
 
568
  function custom_login_headerurl( $value ) {
569
 
570
- $extra_setting = $this->settings['extra_settings'];
571
  if ( isset( $extra_setting['login_image_link'] ) && ! empty( $extra_setting['login_image_link'] ) ) {
572
  return $extra_setting['login_image_link'];
573
  }
@@ -577,7 +671,7 @@ class MainWP_Child_Branding {
577
 
578
  function custom_login_headertitle( $value ) {
579
 
580
- $extra_setting = $this->settings['extra_settings'];
581
  if ( isset( $extra_setting['login_image_title'] ) && ! empty( $extra_setting['login_image_title'] ) ) {
582
  return $extra_setting['login_image_title'];
583
  }
@@ -586,7 +680,7 @@ class MainWP_Child_Branding {
586
  }
587
 
588
  function custom_gettext( $translations, $text, $domain = 'default' ) {
589
- $extra_setting = $this->settings['extra_settings'];
590
  $texts_replace = $extra_setting['texts_replace'];
591
  if ( is_array( $texts_replace ) && count( $texts_replace ) > 0 ) {
592
  foreach ( $texts_replace as $text => $replace ) {
@@ -601,9 +695,9 @@ class MainWP_Child_Branding {
601
 
602
  function custom_admin_css() {
603
  $header_css = '';
604
- $extra_setting = $this->settings['extra_settings'];
605
 
606
- if ( is_array( $extra_setting ) && isset( $extra_setting['admin_css'] ) && ! empty( $extra_setting['admin_css'] ) ) {
607
  $header_css .= $extra_setting['admin_css'];
608
  }
609
 
@@ -622,14 +716,14 @@ class MainWP_Child_Branding {
622
  }
623
 
624
  function custom_login_css() {
625
- $extra_setting = $this->settings['extra_settings'];
626
- if ( is_array( $extra_setting ) && isset( $extra_setting['login_css'] ) && ! empty( $extra_setting['login_css'] ) ) {
627
  echo '<style>' . MainWP_Helper::parse_css( $extra_setting['login_css'] ) . '</style>';
628
  }
629
  }
630
 
631
  function custom_the_generator( $generator, $type = '' ) {
632
- $extra_setting = $this->settings['extra_settings'];
633
  if ( isset( $extra_setting['site_generator'] ) ) {
634
  if ( ! empty( $extra_setting['site_generator'] ) ) {
635
  switch ( $type ) :
@@ -671,7 +765,7 @@ class MainWP_Child_Branding {
671
 
672
  function custom_dashboard_widgets() {
673
  global $wp_meta_boxes;
674
- $extra_setting = $this->settings['extra_settings'];
675
  if ( isset( $extra_setting['remove_widget_welcome'] ) && $extra_setting['remove_widget_welcome'] ) {
676
  remove_action( 'welcome_panel', 'wp_welcome_panel' );
677
  }
@@ -690,28 +784,28 @@ class MainWP_Child_Branding {
690
  }
691
 
692
  public function branding_global_footer() {
693
- $extra_setting = $this->settings['extra_settings'];
694
  if ( isset( $extra_setting['global_footer'] ) && ! empty( $extra_setting['global_footer'] ) ) {
695
  echo wp_kses_post( nl2br( stripslashes( $extra_setting['global_footer'] ) ) );
696
  }
697
  }
698
 
699
  public function send_support_mail() {
700
- $email = get_option( 'mainwp_branding_support_email' );
701
  $sub = wp_kses_post( nl2br( stripslashes( $_POST['mainwp_branding_contact_message_subject'] ) ) );
702
  $subject = !empty( $sub ) ? $sub : "MainWP - Support Contact";
703
  $content = wp_kses_post( nl2br( stripslashes( $_POST['mainwp_branding_contact_message_content'] ) ) );
704
  if ( ! empty( $_POST['mainwp_branding_contact_message_content'] ) && ! empty( $email ) ) {
705
  global $current_user;
706
  $headers .= "Content-Type: text/html;charset=utf-8\r\n";
707
- $headers .= "From: \"" . $current_user->user_email . "\" <" . $current_user->user_email . ">\r\n";
708
  $mail .= "<p>Support Email from: <a href='" . site_url() . "'>" . site_url() . "</a></p>\r\n\r\n";
709
  $mail .= "<p>Sent from WordPress page: " . ( ! empty( $_POST["mainwp_branding_send_from_page"] ) ? "<a href='" . esc_url( $_POST["mainwp_branding_send_from_page"] ) . "'>" . esc_url( $_POST["mainwp_branding_send_from_page"] ) . "</a></p>\r\n\r\n" : "" );
710
  $mail .= "<p>Client Email: " . $current_user->user_email . " </p>\r\n\r\n";
711
  $mail .= "<p>Support Text:</p>\r\n\r\n";
712
  $mail .= "<p>" . $content . "</p>\r\n\r\n";
713
 
714
- if ( wp_mail( $email, $subject, $mail, $headers ) ) {
715
  ;
716
  }
717
 
@@ -736,17 +830,19 @@ class MainWP_Child_Branding {
736
  }
737
  </style>
738
  <?php
 
 
739
  if ( isset( $_POST['submit'] ) ) {
740
  if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], '_contactNonce' ) ) {
741
  return false;
742
  }
743
  $from_page = $_POST['mainwp_branding_send_from_page'];
744
- $back_link = get_option( 'mainwp_branding_message_return_sender' );
745
  $back_link = ! empty( $back_link ) ? $back_link : 'Go Back';
746
  $back_link = ! empty( $from_page ) ? '<a href="' . esc_url( $from_page ) . '" title="' . esc_attr( $back_link ) . '">' . esc_html( $back_link ) . '</a>' : '';
747
 
748
  if ( $this->send_support_mail() ) {
749
- $send_email_message = get_option( 'mainwp_branding_send_email_message' );
750
  if ( ! empty( $send_email_message ) ) {
751
  $send_email_message = stripslashes( $send_email_message );
752
  } else {
@@ -768,12 +864,12 @@ class MainWP_Child_Branding {
768
  $from_page = urldecode( $fullurl );
769
  }
770
 
771
- $support_message = get_option( 'mainwp_branding_support_message' );
772
  $support_message = nl2br( stripslashes( $support_message ) );
773
  ?>
774
  <form action="" method="post">
775
  <div style="width: 99%;">
776
- <h2><?php echo esc_html( $this->settings['contact_support_label'] ); ?></h2>
777
 
778
  <div style="height: auto; margin-bottom: 10px; text-align: left">
779
  <p><?php echo wp_kses_post( $support_message ); ?></p>
@@ -796,7 +892,7 @@ class MainWP_Child_Branding {
796
  </div>
797
  <br/>
798
  <?php
799
- $button_title = get_option( 'mainwp_branding_submit_button_title' );
800
  $button_title = ! empty( $button_title ) ? $button_title : __( 'Submit' );
801
  ?>
802
  <input id="mainwp-branding-contact-support-submit" type="submit" name="submit"
@@ -827,47 +923,59 @@ class MainWP_Child_Branding {
827
  }
828
  $args = array(
829
  'id' => 999,
830
- 'title' => $this->settings['contact_support_label'],
831
  'parent' => 'top-secondary',
832
  'href' => $href,
833
  'meta' => array(
834
  'class' => 'mainwp_branding_support_top_bar_button',
835
- 'title' => $this->settings['contact_support_label'],
836
  ),
837
  );
838
 
839
  $wp_admin_bar->add_node( $args );
840
  }
841
 
842
- public static function is_branding() {
843
- $cancelled_branding = ( get_option( 'mainwp_child_branding_disconnected' ) === 'yes' ) && ! get_option( 'mainwp_branding_preserve_branding' );
844
- if ( $cancelled_branding ) {
845
- return false;
846
- }
847
 
848
- // hide
849
- if ( 'T' === get_option( 'mainwp_branding_child_hide' ) ) {
850
- return true;
851
- }
852
- // branding
853
- $header = get_option( 'mainwp_branding_plugin_header' );
854
- if ( is_array( $header ) && ! empty( $header['name'] ) ) {
855
- return true;
856
- }
857
 
858
- return false;
859
- }
 
860
 
861
- public static function get_branding() {
862
- if ( self::is_branding() ) {
863
- $header = get_option( 'mainwp_branding_plugin_header' );
 
 
 
 
 
 
 
 
 
864
 
865
- return $header['name'];
 
 
 
866
  }
867
-
868
- return 'MainWP';
869
  }
870
 
 
 
 
 
 
 
 
 
 
871
  public function add_admin_bar_menus() {
872
 
873
  $hide_slugs = apply_filters('mainwp_child_hide_update_notice' , array());
@@ -998,15 +1106,7 @@ class MainWP_Child_Branding {
998
  }
999
 
1000
  public function branding_map_meta_cap( $caps, $cap, $user_id, $args ) {
1001
-
1002
- // this is causing of some plugin's menu not added
1003
- // if ( 'T' === get_option( 'mainwp_branding_disable_change' ) ) {
1004
- // // disable: edit, update, install, active themes and plugins
1005
- // if ( false !== strpos( $cap, 'plugins' ) || false !== strpos( $cap, 'themes' ) || 'edit_theme_options' === $cap ) {
1006
- // $caps[0] = 'do_not_allow';
1007
- // }
1008
- // }
1009
- if ( 'T' === get_option( 'mainwp_branding_disable_switching_theme' ) ) {
1010
  // disable: theme switching
1011
  if ( 'switch_themes' === $cap ) {
1012
  $caps[0] = 'do_not_allow';
@@ -1015,24 +1115,35 @@ class MainWP_Child_Branding {
1015
  return $caps;
1016
  }
1017
 
1018
- public function branding_child_plugin( $plugins ) {
1019
- if ( 'T' === get_option( 'mainwp_branding_child_hide' ) ) {
1020
- foreach ( $plugins as $key => $value ) {
1021
- $plugin_slug = basename( $key, '.php' );
1022
- if ( 'mainwp-child' === $plugin_slug ) {
1023
- unset( $plugins[ $key ] );
1024
- }
1025
- }
1026
 
1027
- return $plugins;
1028
- }
 
1029
 
1030
- $header = get_option( 'mainwp_branding_plugin_header' );
1031
- if ( is_array( $header ) && ! empty( $header['name'] ) ) {
1032
- return $this->update_child_header( $plugins, $header );
1033
- } else {
1034
- return $plugins;
1035
- }
 
 
 
 
 
 
 
 
 
 
 
 
1036
  }
1037
 
1038
  function hide_update_notice( $slugs ) {
@@ -1056,7 +1167,7 @@ class MainWP_Child_Branding {
1056
  return $value;
1057
  }
1058
 
1059
- public function update_child_header( $plugins, $header ) {
1060
  $plugin_key = '';
1061
  foreach ( $plugins as $key => $value ) {
1062
  $plugin_slug = basename( $key, '.php' );
2
 
3
  class MainWP_Child_Branding {
4
  public static $instance = null;
5
+
6
+ public $child_plugin_dir;
7
+ public $child_branding_options = null;
8
 
9
  static function Instance() {
10
  if ( null === MainWP_Child_Branding::$instance ) {
11
  MainWP_Child_Branding::$instance = new MainWP_Child_Branding();
12
  }
 
13
  return MainWP_Child_Branding::$instance;
14
  }
15
 
17
  $this->child_plugin_dir = dirname( dirname( __FILE__ ) );
18
  add_action( 'mainwp_child_deactivation', array( $this, 'child_deactivation' ) );
19
  add_filter( 'mainwp_child_plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 3 );
20
+ $this->child_branding_options = $this->init_options();
21
+ }
22
 
23
+ function init_options(){
24
+
25
+ $opts = get_option( 'mainwp_child_branding_settings' );
26
+
27
+ if ( !is_array( $opts ) ) {
28
+ // compatible with old code
29
+ $opts = array();
30
+
31
+ $label = get_option( 'mainwp_branding_button_contact_label' );
32
+ if ( ! empty( $label ) ) {
33
+ $label = stripslashes( $label );
34
+ }
35
+
36
+ $opts['contact_label'] = $label;
37
+ $opts['extra_settings'] = get_option( 'mainwp_branding_extra_settings' );
38
+ }
39
+
40
+ if ( !isset($opts['contact_label']) || empty($opts['contact_label']) ) {
41
+ $opts['contact_label'] = 'Contact Support';
42
+ }
43
+
44
+ $disconnected = isset( $opts['branding_disconnected'] ) ? $opts['branding_disconnected'] : '';
45
+ $preserve_branding = isset( $opts['preserve_branding'] ) ? $opts['preserve_branding'] : '';
46
+ $cancelled_branding = ( $disconnected === 'yes' ) && ! $preserve_branding;
47
+
48
+ $opts['cancelled_branding'] = $cancelled_branding;
49
+ $opts['branding_preserve_title'] = '';
50
+
51
+ if ( ! $cancelled_branding ) {
52
+ if (isset($opts['branding_header'])) {
53
+ $branding_header = $opts['branding_header'];
54
+ if ( is_array( $branding_header ) && isset( $branding_header['name'] ) && ! empty( $branding_header['name'] ) ) {
55
+ $opts['branding_preserve_title'] = stripslashes( $branding_header['name'] );
56
+ }
57
+ }
58
  }
59
+ return $opts;
60
+ }
61
 
62
+ function get_extra_options() {
63
+ $extra = array();
64
+ if (is_array($this->child_branding_options) && isset($this->child_branding_options['extra_settings'])) {
65
+ $extra = $this->child_branding_options['extra_settings'];
66
+ if (!is_array($extra))
67
+ $extra = array();
68
+ }
69
 
70
+ return $extra;
71
+ }
72
 
73
  public function plugin_row_meta( $plugin_meta, $plugin_file, $child_plugin_slug ) {
74
  if ( $child_plugin_slug !== $plugin_file ) {
75
  return $plugin_meta;
76
  }
77
 
78
+ if ( ! $this->is_branding() ) {
79
  return $plugin_meta;
80
  }
81
  // hide View details links
92
  }
93
 
94
  public function child_deactivation() {
95
+ // will remove later
96
  $dell_all = array(
97
  'mainwp_branding_disable_change',
98
  'mainwp_branding_disable_switching_theme',
114
  'mainwp_branding_extra_settings',
115
  'mainwp_branding_ext_enabled',
116
  );
117
+
118
  foreach ( $dell_all as $opt ) {
119
  delete_option( $opt );
120
  }
121
+
122
+ $brandingOptions_empty = array(
123
+ 'hide',
124
+ 'disable_change',
125
+ 'disable_switching_theme',
126
+ 'show_support',
127
+ 'support_email',
128
+ 'support_message',
129
+ 'remove_restore',
130
+ 'remove_setting',
131
+ 'remove_server_info',
132
+ 'remove_wp_tools',
133
+ 'remove_wp_setting',
134
+ 'remove_permalink',
135
+ //'branding_header', // don't remove header
136
+ 'contact_label',
137
+ 'email_message',
138
+ 'message_return_sender',
139
+ 'submit_button_title',
140
+ 'extra_settings',
141
+ 'branding_ext_enabled',
142
+ );
143
+
144
+ foreach($brandingOptions_empty as $opt) {
145
+ if (isset($this->child_branding_options[$opt])) {
146
+ $this->child_branding_options[$opt] = '';
147
+ }
148
+ }
149
+ MainWP_Helper::update_option( 'mainwp_child_branding_settings', $this->child_branding_options );
150
+
151
  }
152
 
153
 
167
  if ( ! is_array( $settings ) ) {
168
  return $information;
169
  }
170
+
171
+ $current_settings = $this->child_branding_options;
172
+ $current_extra_setting = $this->child_branding_options['extra_settings'];
173
+
174
+ //MainWP_Helper::update_option( 'mainwp_branding_ext_enabled', 'Y' );
175
+ $current_settings['branding_ext_enabled'] = 'Y';
176
+
177
  $header = array(
178
  'name' => $settings['child_plugin_name'],
179
  'description' => $settings['child_plugin_desc'],
181
  'authoruri' => $settings['child_plugin_author_uri'],
182
  'pluginuri' => isset($settings['child_plugin_uri']) ? $settings['child_plugin_uri'] : '',
183
  );
184
+
185
+ MainWP_Helper::update_option( 'mainwp_branding_preserve_branding', $settings['child_preserve_branding'], 'yes' ); // to compatible with old version of child report plugin
186
+ MainWP_Helper::update_option( 'mainwp_branding_plugin_header', $header, 'yes' ); // to compatible
187
+ // MainWP_Helper::update_option( 'mainwp_branding_support_email', $settings['child_support_email'] );
188
+ // MainWP_Helper::update_option( 'mainwp_branding_support_message', $settings['child_support_message'] );
189
+ // MainWP_Helper::update_option( 'mainwp_branding_remove_restore', $settings['child_remove_restore'] );
190
+ // MainWP_Helper::update_option( 'mainwp_branding_remove_setting', $settings['child_remove_setting'], 'yes' );
191
+ // MainWP_Helper::update_option( 'mainwp_branding_remove_server_info', $settings['child_remove_server_info'] );
192
+ // MainWP_Helper::update_option( 'mainwp_branding_remove_connection_detail', (isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0) );
193
+ // MainWP_Helper::update_option( 'mainwp_branding_remove_wp_tools', $settings['child_remove_wp_tools'], 'yes' );
194
+ // MainWP_Helper::update_option( 'mainwp_branding_remove_wp_setting', $settings['child_remove_wp_setting'], 'yes' );
195
+ // MainWP_Helper::update_option( 'mainwp_branding_remove_permalink', $settings['child_remove_permalink'], 'yes' );
196
+ // MainWP_Helper::update_option( 'mainwp_branding_button_contact_label', $settings['child_button_contact_label'], 'yes' );
197
+ // MainWP_Helper::update_option( 'mainwp_branding_send_email_message', $settings['child_send_email_message'] );
198
+ // MainWP_Helper::update_option( 'mainwp_branding_message_return_sender', $settings['child_message_return_sender'] );
199
+ // MainWP_Helper::update_option( 'mainwp_branding_submit_button_title', $settings['child_submit_button_title'] );
200
+ // if ( isset( $settings['child_disable_wp_branding'] ) && ( 'Y' === $settings['child_disable_wp_branding'] || 'N' === $settings['child_disable_wp_branding'] ) ) {
201
+ // MainWP_Helper::update_option( 'mainwp_branding_disable_wp_branding', $settings['child_disable_wp_branding'] );
202
+ // }
203
+
204
+ $current_settings['preserve_branding'] = $settings['child_preserve_branding'];
205
+ $current_settings['branding_header'] = $header;
206
+ $current_settings['support_email'] = $settings['child_support_email'];
207
+ $current_settings['support_message'] = $settings['child_support_message'];
208
+ $current_settings['remove_restore'] = $settings['child_remove_restore'];
209
+ $current_settings['remove_setting'] = $settings['child_remove_setting'];
210
+ $current_settings['remove_server_info'] = $settings['child_remove_server_info'];
211
+ $current_settings['remove_connection_detail'] = isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0 ;
212
+ $current_settings['remove_wp_tools'] = $settings['child_remove_wp_tools'];
213
+ $current_settings['remove_wp_setting'] = $settings['child_remove_wp_setting'];
214
+ $current_settings['remove_permalink'] = $settings['child_remove_permalink'];
215
+ $current_settings['contact_label'] = $settings['child_button_contact_label'];
216
+ $current_settings['email_message'] = $settings['child_send_email_message'];
217
+ $current_settings['return_sender'] = $settings['child_message_return_sender'];
218
+ $current_settings['submit_button_title'] = $settings['child_submit_button_title'];
219
+
220
+ if ( isset( $settings['child_disable_wp_branding'] ) && ( 'Y' === $settings['child_disable_wp_branding'] || 'N' === $settings['child_disable_wp_branding'] ) ) {
221
+ $current_settings['disable_wp_branding'] = $settings['child_disable_wp_branding'];
222
  }
223
 
224
  $extra_setting = array(
304
  $extra_setting['favico_image'] = $current_extra_setting['favico_image'];
305
  }
306
 
307
+ //MainWP_Helper::update_option( 'mainwp_branding_extra_settings', $extra_setting, 'yes' );
308
+ $current_settings['extra_settings'] = $extra_setting;
309
 
310
+ // keep it to compatible with old version of child reports plugin
311
  if ( $settings['child_plugin_hide'] ) {
312
  MainWP_Helper::update_option( 'mainwp_branding_child_hide', 'T', 'yes' );
313
  } else {
314
  MainWP_Helper::update_option( 'mainwp_branding_child_hide', '' );
315
  }
316
+ //
317
+ // if ( $settings['child_show_support_button'] && ! empty( $settings['child_support_email'] ) ) {
318
+ // MainWP_Helper::update_option( 'mainwp_branding_show_support', 'T' );
319
+ // } else {
320
+ // MainWP_Helper::update_option( 'mainwp_branding_show_support', '' );
321
+ // }
322
 
323
+ // if ( $settings['child_disable_change'] ) {
324
+ // MainWP_Helper::update_option( 'mainwp_branding_disable_change', 'T' );
325
+ // } else {
326
+ // MainWP_Helper::update_option( 'mainwp_branding_disable_change', '' );
327
+ // }
328
 
329
+ // if ( $settings['child_disable_switching_theme'] ) {
330
+ // MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', 'T' );
331
+ // } else {
332
+ // MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', '' );
333
+ // }
334
 
335
+ $current_settings['hide'] = $settings['child_plugin_hide'] ? 'T' : '';
336
+ $current_settings['show_support'] = ( $settings['child_show_support_button'] && !empty($settings['child_support_email']) ) ? 'T' : '';
337
+ $current_settings['disable_change'] = $settings['child_disable_change'] ? 'T' : '';
338
+ $current_settings['disable_switching_theme'] = $settings['child_disable_switching_theme'] ? 'T' : '';
339
+
340
+ MainWP_Helper::update_option( 'mainwp_child_branding_settings', $current_settings );
341
 
342
  $information['result'] = 'SUCCESS';
343
 
373
 
374
 
375
  public function branding_init() {
376
+
377
+ $extra_setting = $this->get_extra_options();
 
 
378
 
379
  // to hide updates notice
380
  if (is_admin()) {
384
  // front end
385
  add_action( 'add_admin_bar_menus', array( $this, 'add_admin_bar_menus' ));
386
  }
387
+ $opts = $this->child_branding_options;
388
 
389
+ $cancelled_branding = $opts['cancelled_branding'];
 
390
  if ( $cancelled_branding ) {
391
  return;
392
  }
 
 
393
 
394
+ // enable branding in case child plugin deactive and re-activated
395
+ add_filter( 'all_plugins', array( $this, 'modify_plugin_header' ) );
396
+
397
+ if ( $this->is_branding() ) {
398
  add_filter( 'site_transient_update_plugins', array( &$this, 'remove_update_nag' ) );
399
  add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) );
400
  }
401
 
402
+ if ( !isset($opts['branding_ext_enabled']) || $opts['branding_ext_enabled'] !== 'Y' ) {
403
  return;
404
  }
405
 
406
  add_filter( 'map_meta_cap', array( $this, 'branding_map_meta_cap' ), 10, 5 );
407
 
408
+ if ( 'T' === $opts['disable_change']) {
409
 
410
  // Disable the wordpress plugin update notifications
411
  remove_action('load-update-core.php', 'wp_update_plugins');
429
 
430
  // to fix
431
  add_action( 'admin_menu', array( &$this, 'admin_menu' ) );//
432
+ if ( $opts['disable_wp_branding'] !== 'Y' ) {
433
  add_filter( 'wp_footer', array( &$this, 'branding_global_footer' ), 15 );
434
  add_action( 'wp_dashboard_setup', array( &$this, 'custom_dashboard_widgets' ), 999 );
435
  // branding site generator
472
  } else if ( !current_user_can( 'administrator' ) ) {
473
  return false;
474
  }
475
+
476
+ $extra_setting = $this->get_extra_options();
477
+ if ( empty ( $extra_setting ) ) {
478
+ return false;
479
  }
480
+ $opts = $this->child_branding_options;
481
+
482
+ if ( 'T' === $opts['show_support'] ) {
483
+ $title = $opts['contact_label'];
484
  if ( isset( $extra_setting['show_button_in'] ) && ( 2 === (int) $extra_setting['show_button_in'] || 3 === (int) $extra_setting['show_button_in'] ) ) {
485
+ $title = $opts['contact_label'];
486
  add_menu_page( $title, $title, 'read', 'ContactSupport2', array(
487
  $this,
488
  'contact_support',
490
  }
491
 
492
  if ( isset( $extra_setting['show_button_in'] ) && ( 1 === $extra_setting['show_button_in'] || 3 === $extra_setting['show_button_in'] ) ) {
493
+ add_submenu_page( null, $title, $opts['contact_label'], 'read', 'ContactSupport', array(
494
  $this,
495
  'contact_support',
496
  ) );
501
  }
502
 
503
  function remove_default_post_metaboxes() {
504
+ $extra_setting = $this->get_extra_options();
 
 
 
505
 
506
  add_filter( 'manage_posts_columns', array( &$this, 'custom_post_columns' ) );
507
  add_filter( 'manage_edit-post_tag_columns', array( &$this, 'manage_my_category_columns' ) );
541
 
542
 
543
  function custom_post_columns( $defaults ) {
544
+ $extra_setting = $this->get_extra_options();
 
 
 
545
 
546
  if ( isset( $extra_setting['hide_metabox_post_comments'] ) && $extra_setting['hide_metabox_post_comments'] ) {
547
  unset( $defaults['comments'] );
557
  }
558
 
559
  function manage_my_category_columns( $defaults ) {
560
+ $extra_setting = $this->get_extra_options();
 
 
 
561
 
562
  if ( isset( $extra_setting['hide_metabox_post_slug'] ) && $extra_setting['hide_metabox_post_slug'] ) {
563
  unset( $defaults['slug'] );
567
  }
568
 
569
  function remove_default_page_metaboxes() {
570
+ $extra_setting = $this->get_extra_options();
 
 
 
571
 
572
  add_filter( 'manage_pages_columns', array( &$this, 'custom_pages_columns' ) );
573
 
595
  }
596
 
597
  function custom_pages_columns( $defaults ) {
598
+ $extra_setting = $this->get_extra_options();
 
 
 
599
 
600
  if ( isset( $extra_setting['hide_metabox_page_comments'] ) && $extra_setting['hide_metabox_page_comments'] ) {
601
  unset( $defaults['comments'] );
635
  }
636
 
637
  function admin_footer_text() {
638
+ $extra_setting = $this->get_extra_options();
639
  if ( isset( $extra_setting['dashboard_footer'] ) && ! empty( $extra_setting['dashboard_footer'] ) ) {
640
  echo wp_kses_post( nl2br( stripslashes( $extra_setting['dashboard_footer'] ) ) );
641
  }
642
  }
643
 
644
  function custom_favicon_frontend() {
645
+ $extra_setting = $this->get_extra_options();
646
  if ( isset( $extra_setting['favico_image']['url'] ) && ! empty( $extra_setting['favico_image']['url'] ) ) {
647
  $favico = $extra_setting['favico_image']['url'];
648
  echo '<link rel="shortcut icon" href="' . esc_url( $favico ) . '"/>' . "\n";
650
  }
651
 
652
  function custom_login_logo() {
653
+ $extra_setting = $this->get_extra_options();
654
  if ( isset( $extra_setting['login_image']['url'] ) && ! empty( $extra_setting['login_image']['url'] ) ) {
655
  $login_logo = $extra_setting['login_image']['url'];
656
  echo '<style type="text/css">
661
 
662
  function custom_login_headerurl( $value ) {
663
 
664
+ $extra_setting = $this->get_extra_options();
665
  if ( isset( $extra_setting['login_image_link'] ) && ! empty( $extra_setting['login_image_link'] ) ) {
666
  return $extra_setting['login_image_link'];
667
  }
671
 
672
  function custom_login_headertitle( $value ) {
673
 
674
+ $extra_setting = $this->get_extra_options();
675
  if ( isset( $extra_setting['login_image_title'] ) && ! empty( $extra_setting['login_image_title'] ) ) {
676
  return $extra_setting['login_image_title'];
677
  }
680
  }
681
 
682
  function custom_gettext( $translations, $text, $domain = 'default' ) {
683
+ $extra_setting = $this->get_extra_options();
684
  $texts_replace = $extra_setting['texts_replace'];
685
  if ( is_array( $texts_replace ) && count( $texts_replace ) > 0 ) {
686
  foreach ( $texts_replace as $text => $replace ) {
695
 
696
  function custom_admin_css() {
697
  $header_css = '';
698
+ $extra_setting = $this->get_extra_options();
699
 
700
+ if ( isset( $extra_setting['admin_css'] ) && ! empty( $extra_setting['admin_css'] ) ) {
701
  $header_css .= $extra_setting['admin_css'];
702
  }
703
 
716
  }
717
 
718
  function custom_login_css() {
719
+ $extra_setting = $this->get_extra_options();
720
+ if ( isset( $extra_setting['login_css'] ) && ! empty( $extra_setting['login_css'] ) ) {
721
  echo '<style>' . MainWP_Helper::parse_css( $extra_setting['login_css'] ) . '</style>';
722
  }
723
  }
724
 
725
  function custom_the_generator( $generator, $type = '' ) {
726
+ $extra_setting = $this->get_extra_options();
727
  if ( isset( $extra_setting['site_generator'] ) ) {
728
  if ( ! empty( $extra_setting['site_generator'] ) ) {
729
  switch ( $type ) :
765
 
766
  function custom_dashboard_widgets() {
767
  global $wp_meta_boxes;
768
+ $extra_setting = $this->get_extra_options();
769
  if ( isset( $extra_setting['remove_widget_welcome'] ) && $extra_setting['remove_widget_welcome'] ) {
770
  remove_action( 'welcome_panel', 'wp_welcome_panel' );
771
  }
784
  }
785
 
786
  public function branding_global_footer() {
787
+ $extra_setting = $this->get_extra_options();
788
  if ( isset( $extra_setting['global_footer'] ) && ! empty( $extra_setting['global_footer'] ) ) {
789
  echo wp_kses_post( nl2br( stripslashes( $extra_setting['global_footer'] ) ) );
790
  }
791
  }
792
 
793
  public function send_support_mail() {
794
+ $email = $this->child_branding_options['support_email'];
795
  $sub = wp_kses_post( nl2br( stripslashes( $_POST['mainwp_branding_contact_message_subject'] ) ) );
796
  $subject = !empty( $sub ) ? $sub : "MainWP - Support Contact";
797
  $content = wp_kses_post( nl2br( stripslashes( $_POST['mainwp_branding_contact_message_content'] ) ) );
798
  if ( ! empty( $_POST['mainwp_branding_contact_message_content'] ) && ! empty( $email ) ) {
799
  global $current_user;
800
  $headers .= "Content-Type: text/html;charset=utf-8\r\n";
801
+ //$headers .= "From: \"" . $current_user->user_email . "\" <" . $current_user->user_email . ">\r\n";
802
  $mail .= "<p>Support Email from: <a href='" . site_url() . "'>" . site_url() . "</a></p>\r\n\r\n";
803
  $mail .= "<p>Sent from WordPress page: " . ( ! empty( $_POST["mainwp_branding_send_from_page"] ) ? "<a href='" . esc_url( $_POST["mainwp_branding_send_from_page"] ) . "'>" . esc_url( $_POST["mainwp_branding_send_from_page"] ) . "</a></p>\r\n\r\n" : "" );
804
  $mail .= "<p>Client Email: " . $current_user->user_email . " </p>\r\n\r\n";
805
  $mail .= "<p>Support Text:</p>\r\n\r\n";
806
  $mail .= "<p>" . $content . "</p>\r\n\r\n";
807
 
808
+ if ( @wp_mail( $email, $subject, $mail, $headers ) ) {
809
  ;
810
  }
811
 
830
  }
831
  </style>
832
  <?php
833
+ $opts = $this->child_branding_options;
834
+
835
  if ( isset( $_POST['submit'] ) ) {
836
  if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], '_contactNonce' ) ) {
837
  return false;
838
  }
839
  $from_page = $_POST['mainwp_branding_send_from_page'];
840
+ $back_link = $opts['message_return_sender'];
841
  $back_link = ! empty( $back_link ) ? $back_link : 'Go Back';
842
  $back_link = ! empty( $from_page ) ? '<a href="' . esc_url( $from_page ) . '" title="' . esc_attr( $back_link ) . '">' . esc_html( $back_link ) . '</a>' : '';
843
 
844
  if ( $this->send_support_mail() ) {
845
+ $send_email_message = $opts['send_email_message'];
846
  if ( ! empty( $send_email_message ) ) {
847
  $send_email_message = stripslashes( $send_email_message );
848
  } else {
864
  $from_page = urldecode( $fullurl );
865
  }
866
 
867
+ $support_message = $opts['support_message'];
868
  $support_message = nl2br( stripslashes( $support_message ) );
869
  ?>
870
  <form action="" method="post">
871
  <div style="width: 99%;">
872
+ <h2><?php echo esc_html( $opts['contact_label'] ); ?></h2>
873
 
874
  <div style="height: auto; margin-bottom: 10px; text-align: left">
875
  <p><?php echo wp_kses_post( $support_message ); ?></p>
892
  </div>
893
  <br/>
894
  <?php
895
+ $button_title = $opts['submit_button_title'];
896
  $button_title = ! empty( $button_title ) ? $button_title : __( 'Submit' );
897
  ?>
898
  <input id="mainwp-branding-contact-support-submit" type="submit" name="submit"
923
  }
924
  $args = array(
925
  'id' => 999,
926
+ 'title' => $this->child_branding_options['contact_label'],
927
  'parent' => 'top-secondary',
928
  'href' => $href,
929
  'meta' => array(
930
  'class' => 'mainwp_branding_support_top_bar_button',
931
+ 'title' => $this->child_branding_options['contact_label'],
932
  ),
933
  );
934
 
935
  $wp_admin_bar->add_node( $args );
936
  }
937
 
938
+ public function is_branding() {
939
+ $opts = $this->child_branding_options;
 
 
 
940
 
941
+ if (!isset($opts['branding_ext_enabled']) || $opts['branding_ext_enabled'] !== 'Y') {
942
+ return false;
943
+ }
 
 
 
 
 
 
944
 
945
+ $is_hide = isset( $opts['hide'] ) ? $opts['hide'] : '';
946
+ $cancelled_branding = $opts['cancelled_branding'];
947
+ $branding_header = isset( $opts['branding_header'] ) ? $opts['branding_header'] : '';
948
 
949
+ if ( $cancelled_branding ) {
950
+ return false;
951
+ }
952
+ // hide
953
+ if ( 'T' === $is_hide ) {
954
+ return true;
955
+ }
956
+ if ( is_array( $branding_header ) && !empty( $branding_header['name'] ) ) {
957
+ return true;
958
+ }
959
+ return false;
960
+ }
961
 
962
+ public function get_branding_title() {
963
+ if ( $this->is_branding() ) {
964
+ $branding_header = $this->child_branding_options['branding_header'];
965
+ return $branding_header['name'];
966
  }
967
+ return '';
 
968
  }
969
 
970
+ public function get_branding_options() {
971
+ return $this->child_branding_options;
972
+ }
973
+
974
+ public function save_branding_options( $name, $val ) {
975
+ $this->child_branding_options[$name] = $val;
976
+ MainWP_Helper::update_option( 'mainwp_child_branding_settings', $this->child_branding_options );
977
+ }
978
+
979
  public function add_admin_bar_menus() {
980
 
981
  $hide_slugs = apply_filters('mainwp_child_hide_update_notice' , array());
1106
  }
1107
 
1108
  public function branding_map_meta_cap( $caps, $cap, $user_id, $args ) {
1109
+ if ( isset($this->child_branding_options['disable_switching_theme']) && 'T' === $this->child_branding_options['disable_switching_theme'] ) {
 
 
 
 
 
 
 
 
1110
  // disable: theme switching
1111
  if ( 'switch_themes' === $cap ) {
1112
  $caps[0] = 'do_not_allow';
1115
  return $caps;
1116
  }
1117
 
1118
+ public function modify_plugin_header( $plugins ) {
1119
+ $opts = $this->child_branding_options;
1120
+ if ( is_array($opts) ) {
1121
+ $is_hide = isset( $opts['hide'] ) ? $opts['hide'] : '';
1122
+ $cancelled_branding = $opts['cancelled_branding'];
1123
+ $branding_header = isset( $opts['branding_header'] ) ? $opts['branding_header'] : '';
 
 
1124
 
1125
+ if ( $cancelled_branding ) {
1126
+ return $plugins;
1127
+ }
1128
 
1129
+ if ( $is_hide === 'T' ) {
1130
+ foreach ( $plugins as $key => $value ) {
1131
+ $plugin_slug = basename( $key, '.php' );
1132
+ if ( 'mainwp-child-reports' === $plugin_slug ) {
1133
+ unset( $plugins[ $key ] );
1134
+ }
1135
+ }
1136
+ return $plugins;
1137
+ }
1138
+
1139
+ if ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) {
1140
+ return $this->update_plugin_header( $plugins, $branding_header );
1141
+ } else {
1142
+ return $plugins;
1143
+ }
1144
+ }
1145
+
1146
+ return $plugins;
1147
  }
1148
 
1149
  function hide_update_notice( $slugs ) {
1167
  return $value;
1168
  }
1169
 
1170
+ public function update_plugin_header( $plugins, $header ) {
1171
  $plugin_key = '';
1172
  foreach ( $plugins as $key => $value ) {
1173
  $plugin_slug = basename( $key, '.php' );
class/class-mainwp-child-links-checker.php CHANGED
@@ -18,12 +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
  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,7 +33,8 @@ class MainWP_Child_Links_Checker {
33
  MainWP_Helper::write( $information );
34
  }
35
  blc_init();
36
-
 
37
  // need this try()
38
  try {
39
  if ( isset( $_POST['mwp_action'] ) ) {
@@ -100,7 +101,7 @@ class MainWP_Child_Links_Checker {
100
  }
101
 
102
  function save_settings() {
103
- $information = array();
104
  $check_threshold = intval( $_POST['check_threshold'] );
105
  if ( $check_threshold > 0 ) {
106
  $conf = blc_get_configuration();
@@ -186,7 +187,6 @@ class MainWP_Child_Links_Checker {
186
 
187
 
188
  function set_showhide() {
189
- MainWP_Helper::update_option( 'mainwp_linkschecker_ext_enabled', 'Y', 'yes' );
190
  $hide = isset( $_POST['showhide'] ) && ( 'hide' === $_POST['showhide'] ) ? 'hide' : '';
191
  MainWP_Helper::update_option( 'mainwp_linkschecker_hide_plugin', $hide );
192
  $information['result'] = 'SUCCESS';
@@ -195,106 +195,106 @@ class MainWP_Child_Links_Checker {
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))
214
  $information['data'] = $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
-
239
- $max_results = isset($_POST['max_results']) ? intval($_POST['max_results']) : 50;
240
  $offset = isset($_POST['offset']) ? intval($_POST['offset']) : 0;
241
-
242
- $params = array(
243
  array( 'load_instances' => true ),
244
  'max_results' => $max_results
245
- );
246
-
247
  if (empty($offset)) {
248
- $first_sync = true;
249
  } else {
250
  $params['offset'] = $offset;
251
  }
252
-
253
- $link_data = $this->links_checker_data($params);
254
-
255
  $total_sync = 0;
256
  if ($offset){
257
  $total_sync = $offset;
258
  }
259
  $total_sync += (is_array($link_data) ? count($link_data) : 0);
260
-
261
  $information = array('links_data' => $link_data);
262
-
263
  if ($first_sync) {
264
  $information['data'] = $this->get_count_links();
265
  }
266
-
267
  if ($total > $offset + $max_results ) {
268
  $information['sync_offset'] = $offset + $max_results;
269
  } else {
270
  $information['last_sync'] = 1;
271
  $information['total_sync'] = $total_sync;
272
  $information['data'] = $this->get_count_links();
273
- }
274
-
275
  $information['result'] = 'success';
276
- return $information;
277
  }
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 ) );
@@ -302,14 +302,14 @@ class MainWP_Child_Links_Checker {
302
  $data['all'] = $blc_link_query->get_filter_links( 'all', 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(
314
  'link_id',
315
  'url',
@@ -332,10 +332,10 @@ class MainWP_Child_Links_Checker {
332
  'dismissed',
333
  'status_text',
334
  'status_code',
335
- 'log'
336
  );
337
  $return = array();
338
-
339
  $blc_option = get_option( 'wsblc_options' );
340
 
341
  if ( is_string( $blc_option ) && ! empty( $blc_option ) ) {
@@ -348,47 +348,47 @@ class MainWP_Child_Links_Checker {
348
  foreach ( $filter_fields as $field ) {
349
  $new_link->$field = $link->$field;
350
  }
351
-
352
  $extra_info = array();
353
-
354
- if ( ! empty( $link->post_date ) ) {
355
  $extra_info['post_date'] = $link->post_date;
356
  }
357
-
358
  $days_broken = 0;
359
  if ( $link->broken ) {
360
  //Add a highlight to broken links that appear to be permanently broken
361
  $days_broken = intval( ( time() - $link->first_failure ) / ( 3600 * 24 ) );
362
  if ( $days_broken >= $blc_option['failure_duration_threshold'] ) {
363
- $extra_info['permanently_broken'] = 1;
364
- if ( $blc_option['highlight_permanent_failures'] ) {
365
  $extra_info['permanently_broken_highlight'] = 1;
366
  }
367
  }
368
- }
369
  $extra_info['days_broken'] = $days_broken;
370
  $instances = false;
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 );
@@ -422,8 +422,8 @@ class MainWP_Child_Links_Checker {
422
  }
423
  $extra_info['data_link_text'] = $data_link_text;
424
  $extra_info['can_edit_url'] = $can_edit_url;
425
- $extra_info['can_edit_text'] = $can_edit_text;
426
- } else {
427
  $new_link->link_text = '';
428
  $extra_info['count_instance'] = 0;
429
  }
@@ -642,10 +642,10 @@ class MainWP_Child_Links_Checker {
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
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
+ MainWP_Helper::update_option( 'mainwp_linkschecker_ext_enabled', 'Y', 'yes' );
38
  // need this try()
39
  try {
40
  if ( isset( $_POST['mwp_action'] ) ) {
101
  }
102
 
103
  function save_settings() {
104
+ $information = array();
105
  $check_threshold = intval( $_POST['check_threshold'] );
106
  if ( $check_threshold > 0 ) {
107
  $conf = blc_get_configuration();
187
 
188
 
189
  function set_showhide() {
 
190
  $hide = isset( $_POST['showhide'] ) && ( 'hide' === $_POST['showhide'] ) ? 'hide' : '';
191
  MainWP_Helper::update_option( 'mainwp_linkschecker_hide_plugin', $hide );
192
  $information['result'] = 'SUCCESS';
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))
214
  $information['data'] = $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
+
239
+ $max_results = isset($_POST['max_results']) ? intval($_POST['max_results']) : 50;
240
  $offset = isset($_POST['offset']) ? intval($_POST['offset']) : 0;
241
+
242
+ $params = array(
243
  array( 'load_instances' => true ),
244
  'max_results' => $max_results
245
+ );
246
+
247
  if (empty($offset)) {
248
+ $first_sync = true;
249
  } else {
250
  $params['offset'] = $offset;
251
  }
252
+
253
+ $link_data = $this->links_checker_data($params);
254
+
255
  $total_sync = 0;
256
  if ($offset){
257
  $total_sync = $offset;
258
  }
259
  $total_sync += (is_array($link_data) ? count($link_data) : 0);
260
+
261
  $information = array('links_data' => $link_data);
262
+
263
  if ($first_sync) {
264
  $information['data'] = $this->get_count_links();
265
  }
266
+
267
  if ($total > $offset + $max_results ) {
268
  $information['sync_offset'] = $offset + $max_results;
269
  } else {
270
  $information['last_sync'] = 1;
271
  $information['total_sync'] = $total_sync;
272
  $information['data'] = $this->get_count_links();
273
+ }
274
+
275
  $information['result'] = 'success';
276
+ return $information;
277
  }
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 ) );
302
  $data['all'] = $blc_link_query->get_filter_links( 'all', 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(
314
  'link_id',
315
  'url',
332
  'dismissed',
333
  'status_text',
334
  'status_code',
335
+ 'log'
336
  );
337
  $return = array();
338
+
339
  $blc_option = get_option( 'wsblc_options' );
340
 
341
  if ( is_string( $blc_option ) && ! empty( $blc_option ) ) {
348
  foreach ( $filter_fields as $field ) {
349
  $new_link->$field = $link->$field;
350
  }
351
+
352
  $extra_info = array();
353
+
354
+ if ( ! empty( $link->post_date ) ) {
355
  $extra_info['post_date'] = $link->post_date;
356
  }
357
+
358
  $days_broken = 0;
359
  if ( $link->broken ) {
360
  //Add a highlight to broken links that appear to be permanently broken
361
  $days_broken = intval( ( time() - $link->first_failure ) / ( 3600 * 24 ) );
362
  if ( $days_broken >= $blc_option['failure_duration_threshold'] ) {
363
+ $extra_info['permanently_broken'] = 1;
364
+ if ( $blc_option['highlight_permanent_failures'] ) {
365
  $extra_info['permanently_broken_highlight'] = 1;
366
  }
367
  }
368
+ }
369
  $extra_info['days_broken'] = $days_broken;
370
  $instances = false;
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 );
422
  }
423
  $extra_info['data_link_text'] = $data_link_text;
424
  $extra_info['can_edit_url'] = $can_edit_url;
425
+ $extra_info['can_edit_text'] = $can_edit_text;
426
+ } else {
427
  $new_link->link_text = '';
428
  $extra_info['count_instance'] = 0;
429
  }
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
class/class-mainwp-child-pagespeed.php CHANGED
@@ -62,7 +62,7 @@ class MainWP_Child_Pagespeed {
62
  public function init() {
63
  if (!$this->is_plugin_installed)
64
  return;
65
-
66
  if ( get_option( 'mainwp_pagespeed_hide_plugin' ) === 'hide' ) {
67
  add_filter( 'all_plugins', array( $this, 'hide_plugin' ) );
68
  add_action('admin_menu', array($this, 'hide_menu'), 999);
@@ -164,6 +164,13 @@ class MainWP_Child_Pagespeed {
164
  $current_values['strategy'] = $_POST['strategy'];
165
  }
166
 
 
 
 
 
 
 
 
167
  if ( isset( $settings['max_execution_time'] ) ) {
168
  $current_values['max_execution_time'] = $settings['max_execution_time'];
169
  }
@@ -184,10 +191,6 @@ class MainWP_Child_Pagespeed {
184
  $current_values['log_api_errors'] = ( $settings['log_exception'] ) ? true : false;
185
  }
186
 
187
- if ( isset( $settings['scan_technical'] ) ) {
188
- $current_values['scan_method'] = $settings['scan_technical'];
189
- }
190
-
191
  if ( isset( $settings['report_expiration'] ) ) {
192
  $current_values['recheck_interval'] = $settings['report_expiration'];
193
  }
@@ -197,8 +200,9 @@ class MainWP_Child_Pagespeed {
197
  $current_values['check_pages'] = in_array( 'page', $settings['check_report'] ) ? true : false;
198
  $current_values['check_posts'] = in_array( 'post', $settings['check_report'] ) ? true : false;
199
  $current_values['check_categories'] = in_array( 'category', $settings['check_report'] ) ? true : false;
 
200
  } else {
201
- $current_values['check_pages'] = $current_values['check_posts'] = $current_values['check_categories'] = false;
202
  }
203
  }
204
 
@@ -253,7 +257,7 @@ class MainWP_Child_Pagespeed {
253
  if ( $checkstatus ) {
254
  $information['error'] = __( 'The API is busy checking other pages, please try again later.', 'gpagespeedi' );
255
  } else {
256
- do_action( 'googlepagespeedinsightsworker', array(), true );
257
  $information['checked_pages'] = 1;
258
  }
259
  }
@@ -288,15 +292,19 @@ class MainWP_Child_Pagespeed {
288
 
289
  if ( 'both' === $strategy || 'desktop' === $strategy ) {
290
  $result = self::cal_pagespeed_data( 'desktop' );
291
- $data['desktop_score'] = $result['average_score'];
292
- $data['desktop_total_pages'] = $result['total_pages'];
293
- $data['desktop_last_modified'] = $result['last_modified'];
 
 
294
  }
295
  if ( 'both' === $strategy || 'mobile' === $strategy ) {
296
  $result = self::cal_pagespeed_data( 'mobile' );
297
- $data['mobile_score'] = $result['average_score'];
298
- $data['mobile_total_pages'] = $result['total_pages'];
299
- $data['mobile_last_modified'] = $result['last_modified'];
 
 
300
  }
301
 
302
  $information['data'] = $data;
@@ -307,15 +315,15 @@ class MainWP_Child_Pagespeed {
307
  static function cal_pagespeed_data( $strategy ) {
308
  global $wpdb;
309
  if ( ! defined( 'GPI_DIRECTORY' ) ) {
310
- return 0;
311
  }
312
 
313
  if ( 'desktop' !== $strategy && 'mobile' !== $strategy ) {
314
- return 0;
315
  }
316
 
317
  $score_column = $strategy . '_score';
318
- $page_stats_column = $strategy . '_page_stats';
319
 
320
 
321
  $data_typestocheck = self::getTypesToCheck( 'all' );
@@ -325,7 +333,7 @@ class MainWP_Child_Pagespeed {
325
 
326
  $allpagedata = $wpdb->get_results(
327
  $wpdb->prepare(
328
- "SELECT ID, URL, $score_column, $page_stats_column
329
  FROM $gpi_page_stats
330
  WHERE ($data_typestocheck[0])",
331
  $data_typestocheck[1]
@@ -343,11 +351,10 @@ class MainWP_Child_Pagespeed {
343
 
344
  $allpagereports = $wpdb->get_results(
345
  $wpdb->prepare(
346
- "SELECT r.rule_key, r.rule_name, r.rule_impact
347
  FROM $gpi_page_stats d
348
  INNER JOIN $gpi_page_reports r
349
  ON r.page_id = d.ID
350
- AND r.rule_impact > 0
351
  AND r.strategy = '$strategy'
352
  WHERE ($reports_typestocheck[0])",
353
  $reports_typestocheck[1]
62
  public function init() {
63
  if (!$this->is_plugin_installed)
64
  return;
65
+
66
  if ( get_option( 'mainwp_pagespeed_hide_plugin' ) === 'hide' ) {
67
  add_filter( 'all_plugins', array( $this, 'hide_plugin' ) );
68
  add_action('admin_menu', array($this, 'hide_menu'), 999);
164
  $current_values['strategy'] = $_POST['strategy'];
165
  }
166
 
167
+ if ( isset( $settings['store_screenshots'] ) ) {
168
+ $current_values['store_screenshots'] = $settings['store_screenshots'];
169
+ }
170
+ if ( isset( $settings['use_schedule'] ) ) {
171
+ $current_values['use_schedule'] = $settings['use_schedule'];
172
+ }
173
+
174
  if ( isset( $settings['max_execution_time'] ) ) {
175
  $current_values['max_execution_time'] = $settings['max_execution_time'];
176
  }
191
  $current_values['log_api_errors'] = ( $settings['log_exception'] ) ? true : false;
192
  }
193
 
 
 
 
 
194
  if ( isset( $settings['report_expiration'] ) ) {
195
  $current_values['recheck_interval'] = $settings['report_expiration'];
196
  }
200
  $current_values['check_pages'] = in_array( 'page', $settings['check_report'] ) ? true : false;
201
  $current_values['check_posts'] = in_array( 'post', $settings['check_report'] ) ? true : false;
202
  $current_values['check_categories'] = in_array( 'category', $settings['check_report'] ) ? true : false;
203
+ $current_values['check_custom_urls'] = in_array( 'custom_urls', $settings['check_report'] ) ? true : false;
204
  } else {
205
+ $current_values['check_pages'] = $current_values['check_posts'] = $current_values['check_categories'] = $current_values['check_custom_urls'] = false;
206
  }
207
  }
208
 
257
  if ( $checkstatus ) {
258
  $information['error'] = __( 'The API is busy checking other pages, please try again later.', 'gpagespeedi' );
259
  } else {
260
+ do_action( 'googlepagespeedinsightsworker', array(), $forceRecheck );
261
  $information['checked_pages'] = 1;
262
  }
263
  }
292
 
293
  if ( 'both' === $strategy || 'desktop' === $strategy ) {
294
  $result = self::cal_pagespeed_data( 'desktop' );
295
+ if ( !empty($result) && is_array($result) ) {
296
+ $data['desktop_score'] = $result['average_score'];
297
+ $data['desktop_total_pages'] = $result['total_pages'];
298
+ $data['desktop_last_modified'] = $result['last_modified'];
299
+ }
300
  }
301
  if ( 'both' === $strategy || 'mobile' === $strategy ) {
302
  $result = self::cal_pagespeed_data( 'mobile' );
303
+ if ( !empty($result) && is_array($result) ) {
304
+ $data['mobile_score'] = $result['average_score'];
305
+ $data['mobile_total_pages'] = $result['total_pages'];
306
+ $data['mobile_last_modified'] = $result['last_modified'];
307
+ }
308
  }
309
 
310
  $information['data'] = $data;
315
  static function cal_pagespeed_data( $strategy ) {
316
  global $wpdb;
317
  if ( ! defined( 'GPI_DIRECTORY' ) ) {
318
+ return false;
319
  }
320
 
321
  if ( 'desktop' !== $strategy && 'mobile' !== $strategy ) {
322
+ return false;
323
  }
324
 
325
  $score_column = $strategy . '_score';
326
+ //$page_stats_column = $strategy . '_page_stats';
327
 
328
 
329
  $data_typestocheck = self::getTypesToCheck( 'all' );
333
 
334
  $allpagedata = $wpdb->get_results(
335
  $wpdb->prepare(
336
+ "SELECT ID, URL, $score_column
337
  FROM $gpi_page_stats
338
  WHERE ($data_typestocheck[0])",
339
  $data_typestocheck[1]
351
 
352
  $allpagereports = $wpdb->get_results(
353
  $wpdb->prepare(
354
+ "SELECT r.rule_key, r.rule_name
355
  FROM $gpi_page_stats d
356
  INNER JOIN $gpi_page_reports r
357
  ON r.page_id = d.ID
 
358
  AND r.strategy = '$strategy'
359
  WHERE ($reports_typestocheck[0])",
360
  $reports_typestocheck[1]
class/class-mainwp-child-plugins-check.php CHANGED
@@ -33,19 +33,20 @@ class MainWP_Child_Plugins_Check {
33
  }
34
 
35
  public function __construct() {
36
- $this->schedule_watchdog();
 
37
 
38
- add_action( $this->cron_name_batching, array( $this, 'run_check' ) );
39
- add_action( $this->cron_name_daily, array( $this, 'run_check' ) );
40
 
41
- add_action( $this->cron_name_watcher, array( $this, 'perform_watchdog' ) );
42
 
43
- //add_filter( 'plugin_row_meta', array( $this, 'change_plugin_row_meta' ), 10, 4 );
44
 
45
- add_filter( 'plugins_api_args', array( $this, 'modify_plugin_api_search_query' ), 10, 2 );
46
-
47
- add_action( 'mainwp_child_deactivation', array( $this, 'cleanup_deactivation' ) );
48
 
 
 
49
  }
50
 
51
  private function cleanup_basic() {
33
  }
34
 
35
  public function __construct() {
36
+ if ( get_option('mainwp_child_plugintheme_days_outdate') ) {
37
+ $this->schedule_watchdog();
38
 
39
+ add_action( $this->cron_name_batching, array( $this, 'run_check' ) );
40
+ add_action( $this->cron_name_daily, array( $this, 'run_check' ) );
41
 
42
+ add_action( $this->cron_name_watcher, array( $this, 'perform_watchdog' ) );
43
 
44
+ //add_filter( 'plugin_row_meta', array( $this, 'change_plugin_row_meta' ), 10, 4 );
45
 
46
+ add_filter( 'plugins_api_args', array( $this, 'modify_plugin_api_search_query' ), 10, 2 );
 
 
47
 
48
+ add_action( 'mainwp_child_deactivation', array( $this, 'cleanup_deactivation' ) );
49
+ }
50
  }
51
 
52
  private function cleanup_basic() {
class/class-mainwp-child-server-information.php CHANGED
@@ -66,7 +66,7 @@ class MainWP_Child_Server_Information {
66
  var data = {
67
  action: 'mainwp-child_dismiss_warnings',
68
  what: pAction,
69
- warnings: <?php echo intval($warnings); ?>
70
  };
71
 
72
  jQuery.ajax( {
@@ -537,11 +537,11 @@ class MainWP_Child_Server_Information {
537
  }
538
 
539
  public static function render() {
540
- $branding_title = 'MainWP Child';
541
- $isBranding = false;
542
- if ( MainWP_Child_Branding::is_branding() ) {
543
- $branding_title = MainWP_Child_Branding::get_branding();
544
- $isBranding = true;
545
  }
546
 
547
  ?>
@@ -956,10 +956,10 @@ class MainWP_Child_Server_Information {
956
  }
957
 
958
  protected static function checkDirectoryMainWPDirectory( $write = true ) {
959
- $branding_title = 'MainWP';
960
- if ( MainWP_Child_Branding::is_branding() ) {
961
- $branding_title = MainWP_Child_Branding::get_branding();
962
- }
963
  $branding_title .= ' Upload Directory';
964
 
965
  try {
@@ -1009,7 +1009,7 @@ class MainWP_Child_Server_Information {
1009
  ?>
1010
  <tr class="mwp-not-generate-row">
1011
  <td></td>
1012
- <td><?php echo esc_html( stripslashes( $pName ) ); ?><br/><?php echo esc_html( ( MainWP_Child_Branding::is_branding() ) ? '' : $pDirectory ); ?>
1013
  </td>
1014
  <td><?php echo esc_html( $pCheck ); ?></td>
1015
  <td><?php echo esc_html( $pResult ); ?></td>
@@ -1467,14 +1467,12 @@ class MainWP_Child_Server_Information {
1467
  $lines = array_filter( $lines );
1468
 
1469
  if ( empty( $lines ) ) {
1470
- if ( MainWP_Child_Branding::is_branding() ) {
1471
- $branding_title = MainWP_Child_Branding::get_branding();
1472
- $msg = esc_html( stripslashes( $branding_title ) ) . ' is unable to find your error logs, please contact your host for server error logs.';
1473
- } else {
1474
- $msg = esc_html__( 'MainWP is unable to find your error logs, please contact your host for server error logs.', 'mainwp-child' );
1475
  }
 
1476
  echo '<tr><td colspan="2">' . $msg . '</td></tr>';
1477
-
1478
  return;
1479
  }
1480
 
@@ -1621,10 +1619,9 @@ class MainWP_Child_Server_Information {
1621
  }
1622
 
1623
  public static function renderConnectionDetails() {
1624
- $branding_title = 'MainWP';
1625
- if ( MainWP_Child_Branding::is_branding() ) {
1626
- $branding_title = MainWP_Child_Branding::get_branding();
1627
- }
1628
 
1629
  global $current_user;
1630
  $uniqueId = get_option('mainwp_child_uniqueId');
66
  var data = {
67
  action: 'mainwp-child_dismiss_warnings',
68
  what: pAction,
69
+ warnings: <?php echo intval($warnings); ?>
70
  };
71
 
72
  jQuery.ajax( {
537
  }
538
 
539
  public static function render() {
540
+ $branding_title = MainWP_Child_Branding::Instance()->get_branding_title();
541
+ $isBranding = true;
542
+ if ( $branding_title == '' ) {
543
+ $branding_title = 'MainWP Child';
544
+ $isBranding = false;
545
  }
546
 
547
  ?>
956
  }
957
 
958
  protected static function checkDirectoryMainWPDirectory( $write = true ) {
959
+ $branding_title = MainWP_Child_Branding::Instance()->get_branding_title();
960
+ if ($branding_title == '')
961
+ $branding_title = 'MainWP';
962
+
963
  $branding_title .= ' Upload Directory';
964
 
965
  try {
1009
  ?>
1010
  <tr class="mwp-not-generate-row">
1011
  <td></td>
1012
+ <td><?php echo esc_html( stripslashes( $pName ) ); ?><br/><?php echo esc_html( ( MainWP_Child_Branding::Instance()->is_branding() ) ? '' : $pDirectory ); ?>
1013
  </td>
1014
  <td><?php echo esc_html( $pCheck ); ?></td>
1015
  <td><?php echo esc_html( $pResult ); ?></td>
1467
  $lines = array_filter( $lines );
1468
 
1469
  if ( empty( $lines ) ) {
1470
+ $branding_title = MainWP_Child_Branding::Instance()->get_branding_title();
1471
+ if ($branding_title == '') {
1472
+ $branding_title = 'MainWP';
 
 
1473
  }
1474
+ $msg = esc_html( stripslashes( $branding_title ) ) . ' is unable to find your error logs, please contact your host for server error logs.';
1475
  echo '<tr><td colspan="2">' . $msg . '</td></tr>';
 
1476
  return;
1477
  }
1478
 
1619
  }
1620
 
1621
  public static function renderConnectionDetails() {
1622
+ $branding_title = MainWP_Child_Branding::Instance()->get_branding_title();
1623
+ if ($branding_title == '')
1624
+ $branding_title = 'MainWP';
 
1625
 
1626
  global $current_user;
1627
  $uniqueId = get_option('mainwp_child_uniqueId');
class/class-mainwp-child-themes-check.php CHANGED
@@ -33,15 +33,19 @@ class MainWP_Child_Themes_Check {
33
  }
34
 
35
  public function __construct() {
36
- $this->schedule_watchdog();
37
- add_action( $this->cron_name_batching, array( $this, 'run_check' ) );
38
- add_action( $this->cron_name_daily, array( $this, 'run_check' ) );
39
 
40
- add_action( $this->cron_name_watcher, array( $this, 'perform_watchdog' ) );
 
 
 
41
 
42
- add_filter( 'themes_api_args', array( $this, 'modify_theme_api_search_query' ), 10, 2 );
43
 
44
- add_action( 'mainwp_child_deactivation', array( $this, 'cleanup_deactivation' ) );
 
 
 
 
45
  }
46
 
47
  private function cleanup_basic() {
33
  }
34
 
35
  public function __construct() {
 
 
 
36
 
37
+ if ( get_option('mainwp_child_plugintheme_days_outdate') ) {
38
+ $this->schedule_watchdog();
39
+ add_action( $this->cron_name_batching, array( $this, 'run_check' ) );
40
+ add_action( $this->cron_name_daily, array( $this, 'run_check' ) );
41
 
42
+ add_action( $this->cron_name_watcher, array( $this, 'perform_watchdog' ) );
43
 
44
+ add_filter( 'themes_api_args', array( $this, 'modify_theme_api_search_query' ), 10, 2 );
45
+
46
+ add_action( 'mainwp_child_deactivation', array( $this, 'cleanup_deactivation' ) );
47
+ }
48
+
49
  }
50
 
51
  private function cleanup_basic() {
class/class-mainwp-child.php CHANGED
@@ -115,8 +115,8 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
115
  }
116
 
117
  class MainWP_Child {
118
- public static $version = '3.5.3';
119
- private $update_version = '1.3';
120
 
121
  private $callableFunctions = array(
122
  'stats' => 'getSiteStats',
@@ -185,7 +185,7 @@ class MainWP_Child {
185
  'disconnect' => 'disconnect',
186
  'time_capsule' => 'time_capsule',
187
  'extra_excution' => 'extra_execution', // deprecated
188
- 'extra_execution' => 'extra_execution',
189
  );
190
 
191
  private $FTP_ERROR = 'Failed! Please, add FTP details for automatic updates.';
@@ -203,7 +203,6 @@ class MainWP_Child {
203
 
204
  private $filterFunction = null;
205
  public static $brandingTitle = null;
206
- private $branding_robust = 'MainWP';
207
 
208
  public static $subPages;
209
  public static $subPagesLoaded = false;
@@ -231,7 +230,9 @@ class MainWP_Child {
231
  add_action( 'admin_init', array( &$this, 'admin_init' ) );
232
  add_action( 'admin_head', array( &$this, 'admin_head' ) );
233
  add_action( 'init', array( &$this, 'localization' ), 33 );
234
- add_action( 'pre_current_active_plugins', array( &$this, 'pre_current_active_plugins' ) );
 
 
235
 
236
  if ( is_admin() ) {
237
  MainWP_Helper::update_option( 'mainwp_child_plugin_version', self::$version, 'yes' );
@@ -242,22 +243,16 @@ class MainWP_Child {
242
  MainWP_Clone::get()->init();
243
  MainWP_Child_Server_Information::init();
244
  MainWP_Client_Report::Instance()->init();
245
- MainWP_Child_Plugins_Check::Instance();
246
- MainWP_Child_Themes_Check::Instance();
247
 
248
  $this->run_saved_snippets();
249
 
250
  if ( ! get_option( 'mainwp_child_pubkey' ) ) {
251
- MainWP_Helper::update_option( 'mainwp_child_branding_disconnected', 'yes', 'yes' );
 
252
  }
253
 
254
- $cancelled_branding = ( get_option( 'mainwp_child_branding_disconnected' ) === 'yes' ) && ! get_option( 'mainwp_branding_preserve_branding' );
255
- if ( ! $cancelled_branding ) {
256
- $branding_header = get_option( 'mainwp_branding_plugin_header' );
257
- if ( is_array( $branding_header ) && isset( $branding_header['name'] ) && ! empty( $branding_header['name'] ) ) {
258
- $this->branding_robust = stripslashes( $branding_header['name'] );
259
- }
260
- }
261
  add_action( 'admin_notices', array( &$this, 'admin_notice' ) );
262
  add_filter( 'plugin_row_meta', array( &$this, 'plugin_row_meta' ), 10, 2 );
263
 
@@ -310,15 +305,17 @@ class MainWP_Child {
310
  'mainwp_security',
311
  'mainwp_backupwordpress_ext_enabled',
312
  'mainwp_wprocket_ext_enabled',
313
- 'mainwp_wordfence_ext_enabled',
314
  'mainwp_branding_button_contact_label',
315
  'mainwp_branding_extra_settings',
316
  'mainwp_branding_child_hide',
317
  'mainwp_branding_ext_enabled',
318
- 'mainwp_creport_ext_branding_enabled',
319
  'mainwp_pagespeed_ext_enabled',
320
  'mainwp_linkschecker_ext_enabled',
321
- 'mainwp_ithemes_ext_enabled',
 
 
322
  );
323
  $query = "SELECT option_name, option_value FROM $wpdb->options WHERE option_name in (";
324
  foreach ($options as $option) {
@@ -360,7 +357,6 @@ class MainWP_Child {
360
  $options = array(
361
  'mainwp_child_legacy',
362
  'mainwp_child_auth',
363
- 'mainwp_branding_ext_enabled',
364
  'mainwp_child_uniqueId',
365
  'mainwp_child_htaccess_set',
366
  'mainwp_child_fix_htaccess',
@@ -401,33 +397,33 @@ class MainWP_Child {
401
  'mainwp_kwl_statistic_data_',
402
  'mainwp_kwl_enable_statistic',
403
  'mainwpKeywordLinks',
404
- 'mainwp_branding_ext_enabled',
405
- 'mainwp_branding_plugin_header',
406
- 'mainwp_branding_support_email',
407
- 'mainwp_branding_support_message',
408
- 'mainwp_branding_remove_restore',
409
- 'mainwp_branding_remove_setting',
410
- 'mainwp_branding_remove_wp_tools',
411
- 'mainwp_branding_remove_wp_setting',
412
- 'mainwp_branding_remove_permalink',
413
- 'mainwp_branding_button_contact_label',
414
- 'mainwp_branding_send_email_message',
415
- 'mainwp_branding_message_return_sender',
416
- 'mainwp_branding_submit_button_title',
417
- 'mainwp_branding_disable_wp_branding',
418
- 'mainwp_branding_extra_settings',
419
- 'mainwp_branding_child_hide',
420
- 'mainwp_branding_show_support',
421
- 'mainwp_branding_disable_change',
422
  );
423
  foreach ( $options as $option ) {
424
  MainWP_Helper::fix_option( $option );
425
  }
426
- } else if ( ( false === $update_version ) || ( '1.0' === $update_version ) || ( '1.1' === $update_version ) ) {
427
  $options = array(
428
  'mainwp_child_pubkey',
429
- 'mainwp_child_branding_disconnected',
430
- 'mainwp_branding_plugin_header',
431
  'mainwp_child_update_version',
432
  'mainwp_child_auth',
433
  'mainwp_child_clone_permalink',
@@ -444,14 +440,14 @@ class MainWP_Child {
444
  'mainwp_updraftplus_ext_enabled',
445
  'mainwpKeywordLinks',
446
  'mainwp_keyword_links_htaccess_set',
447
- 'mainwp_branding_button_contact_label',
448
- 'mainwp_branding_extra_settings',
449
- 'mainwp_branding_ext_enabled',
450
- 'mainwp_creport_ext_branding_enabled',
451
  'mainwp_pagespeed_ext_enabled',
452
  'mainwp_linkschecker_ext_enabled',
453
- 'mainwp_wordfence_ext_enabled',
454
- 'mainwp_ithemes_ext_enabled',
455
  'mainwp_maintenance_opt_alert_404',
456
  );
457
  foreach ( $options as $option ) {
@@ -479,9 +475,46 @@ class MainWP_Child {
479
  }
480
  MainWP_Helper::update_option( 'mainwp_security', $security, 'yes' );
481
  }
482
- } else if ($update_version == '1.2') {
483
- MainWP_Child_Plugins_Check::Instance()->cleanup_deactivation(false);
484
- MainWP_Child_Themes_Check::Instance()->cleanup_deactivation(false);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
485
  }
486
 
487
  MainWP_Helper::update_option( 'mainwp_child_update_version', $this->update_version, 'yes' );
@@ -507,27 +540,27 @@ class MainWP_Child {
507
 
508
  public function admin_notice() {
509
  //Admin Notice...
510
- if ( is_plugin_active( 'mainwp-child/mainwp-child.php' ) ) {
511
- if ( ! get_option( 'mainwp_child_pubkey' ) && MainWP_Helper::isAdmin() && is_admin() ) {
512
- $child_name = ( $this->branding_robust === 'MainWP' ) ? 'MainWP Child' : $this->branding_robust;
513
- $msg = '<div class="wrap"><div class="postbox" style="margin-top: 4em;"><p style="background: #a00; color: #fff; font-size: 22px; font-weight: bold; margin: 0; padding: .3em;">';
514
- $msg .= __( 'Attention!', 'mainwp-child' );
515
- $msg .= '</p><div style="padding-left: 1em; padding-right: 1em;"><p style="font-size: 16px;">';
516
- $msg .= __( 'Please add this site to your ', 'mainwp-child' ) . $this->branding_robust . __( ' Dashboard <b>NOW</b> or deactivate the ', 'mainwp-child' ) . $child_name . __( ' plugin until you are ready to connect this site to your Dashboard in order to avoid unexpected security issues.','mainwp-child' );
517
- $msg .= '</p>';
518
- $msg .= '<p style="font-size: 16px;">';
519
- $msg .= __( 'If you are not sure how to add this site to your Dashboard, <a href="https://mainwp.com/help/docs/set-up-the-mainwp-plugin/add-site-to-your-dashboard/" target="_blank">please review these instructions</a>.', 'mainwp-child' );
520
- $msg .= '</p>';
521
- if ( ! MainWP_Child_Branding::is_branding() ) {
522
- $msg .= '<p>';
523
- $msg .= __( 'You can also turn on the unique security ID option in <a href="admin.php?page=mainwp_child_tab">', 'mainwp-child' ) . $this->branding_robust . __( ' settings</a> if you would like extra security and additional time to add this site to your Dashboard. <br/>Find out more in this help document <a href="https://mainwp.com/help/docs/set-up-the-mainwp-plugin/set-unique-security-id/" target="_blank">How do I use the child unique security ID?</a>', 'mainwp-child' );
524
- $msg .= '</p>';
525
- }
526
- $msg .= '</div></div></div>';
527
- echo wp_kses_post( $msg );
528
- }
529
- }
530
-
531
  MainWP_Child_Server_Information::showWarnings();
532
  }
533
 
@@ -535,14 +568,28 @@ class MainWP_Child {
535
  load_plugin_textdomain( 'mainwp-child', false, dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' );
536
  }
537
 
538
- public function pre_current_active_plugins() {
539
  if (isset($_GET['_detect_plugins_updates']) && $_GET['_detect_plugins_updates'] == 'yes') {
540
  // to fix some premium plugins update notification
541
  $current = get_site_transient( 'update_plugins' );
542
  set_site_transient( 'update_plugins', $current );
543
 
544
- $plugin_updates = get_plugin_updates();
545
- set_site_transient( 'mainwp_update_plugins_cached', $plugin_updates, DAY_IN_SECONDS);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
546
  }
547
  }
548
 
@@ -600,9 +647,11 @@ class MainWP_Child {
600
  }
601
 
602
  function admin_menu() {
603
- $cancelled_branding = ( get_option( 'mainwp_child_branding_disconnected' ) === 'yes' ) && ! get_option( 'mainwp_branding_preserve_branding' );
 
 
604
 
605
- if ( get_option( 'mainwp_branding_remove_wp_tools' ) && ! $cancelled_branding ) {
606
  remove_menu_page( 'tools.php' );
607
  $pos = stripos( $_SERVER['REQUEST_URI'], 'tools.php' ) ||
608
  stripos( $_SERVER['REQUEST_URI'], 'import.php' ) ||
@@ -612,7 +661,7 @@ class MainWP_Child {
612
  }
613
  }
614
  // if preserve branding do not remove menus
615
- if ( get_option( 'mainwp_branding_remove_wp_setting' ) && ! $cancelled_branding ) {
616
  remove_menu_page( 'options-general.php' );
617
  $pos = stripos( $_SERVER['REQUEST_URI'], 'options-general.php' ) ||
618
  stripos( $_SERVER['REQUEST_URI'], 'options-writing.php' ) ||
@@ -626,7 +675,7 @@ class MainWP_Child {
626
  }
627
  }
628
 
629
- if ( get_option( 'mainwp_branding_remove_permalink' ) && ! $cancelled_branding ) {
630
  remove_submenu_page( 'options-general.php', 'options-permalink.php' );
631
  $pos = stripos( $_SERVER['REQUEST_URI'], 'options-permalink.php' );
632
  if ( false !== $pos ) {
@@ -636,13 +685,13 @@ class MainWP_Child {
636
  }
637
 
638
  $remove_all_child_menu = false;
639
- if ( get_option( 'mainwp_branding_remove_setting' ) && get_option( 'mainwp_branding_remove_restore' ) && get_option( 'mainwp_branding_remove_server_info' ) ) {
640
  $remove_all_child_menu = true;
641
  }
642
 
643
  // if preserve branding do not hide menus
644
- if ( ( ! $remove_all_child_menu && get_option( 'mainwp_branding_child_hide' ) !== 'T' ) || $cancelled_branding ) {
645
- $branding_header = get_option( 'mainwp_branding_plugin_header' );
646
  if ( ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) && ! $cancelled_branding ) {
647
  self::$brandingTitle = $child_menu_title = stripslashes( $branding_header['name'] );
648
  $child_page_title = $child_menu_title . ' Settings';
@@ -662,6 +711,7 @@ class MainWP_Child {
662
  do_action( 'mainwp-child-subpages', $subpageargs ); // to compatible
663
 
664
  $sub_pages = array();
 
665
  $all_subpages = apply_filters( 'mainwp-child-init-subpages', array() );
666
 
667
  if ( !is_array( $all_subpages ) )
@@ -709,11 +759,13 @@ class MainWP_Child {
709
  if ( isset($_GET['tab']) ) {
710
  $shownPage = $_GET['tab'];
711
  }
 
 
 
 
 
 
712
 
713
- $hide_settings = get_option( 'mainwp_branding_remove_setting' ) ? true : false;
714
- $hide_restore = get_option( 'mainwp_branding_remove_restore' ) ? true : false;
715
- $hide_server_info = get_option( 'mainwp_branding_remove_server_info' ) ? true : false;
716
- $hide_connection_detail = get_option( 'mainwp_branding_remove_connection_detail' ) ? true : false;
717
  $hide_style = 'style="display:none"';
718
 
719
  if ($shownPage == '') {
@@ -783,10 +835,13 @@ class MainWP_Child {
783
  if (empty($shownPage))
784
  $shownPage = 'settings';
785
 
786
- $hide_settings = get_option( 'mainwp_branding_remove_setting' ) ? true : false;
787
- $hide_restore = get_option( 'mainwp_branding_remove_restore' ) ? true : false;
788
- $hide_server_info = get_option( 'mainwp_branding_remove_server_info' ) ? true : false;
789
- $hide_connection_detail = get_option( 'mainwp_branding_remove_connection_detail' ) ? true : false;
 
 
 
790
  $sitesToClone = get_option( 'mainwp_child_clone_sites' );
791
 
792
  ?>
@@ -1064,7 +1119,7 @@ class MainWP_Child {
1064
  }
1065
  }
1066
 
1067
- function check_login() {
1068
  $file = '';
1069
  if ( isset( $_REQUEST['f'] ) ) {
1070
  $file = $_REQUEST['f'];
@@ -1084,13 +1139,30 @@ class MainWP_Child {
1084
  MainWP_Helper::error( __( 'Authentication failed! Please deactivate and re-activate the MainWP Child plugin on this site.', 'mainwp-child' ) );
1085
  }
1086
 
 
1087
  if ( $auth ) {
1088
  //disable duo auth for mainwp
1089
  remove_action('init', 'duo_verify_auth', 10);
1090
 
1091
  //Check if the user exists & is an administrator
1092
  if ( isset( $_POST['function'] ) && isset( $_POST['user'] ) ) {
1093
- $user = get_user_by( 'login', $_POST['user'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1094
  if ( ! $user ) {
1095
  MainWP_Helper::error( __( 'That administrator username was not found on this child site. Please verify that it is an existing administrator.', 'mainwp-child' ) );
1096
  }
@@ -1099,11 +1171,16 @@ class MainWP_Child {
1099
  MainWP_Helper::error( __( 'That user is not an administrator. Please use an administrator user to establish the connection.', 'mainwp-child' ) );
1100
  }
1101
 
1102
- $this->login( $_REQUEST['user'] );
1103
  }
1104
 
1105
  if ( isset( $_POST['function'] ) && 'visitPermalink' === $_POST['function'] ) {
1106
- if ( $this->login( $_POST['user'], true ) ) {
 
 
 
 
 
1107
  return;
1108
  } else {
1109
  exit();
@@ -1261,7 +1338,17 @@ class MainWP_Child {
1261
  global $current_user; //wp variable
1262
  //Login the user
1263
  if ( isset( $_REQUEST['login_required'] ) && ( '1' === $_REQUEST['login_required'] ) && isset( $_REQUEST['user'] ) ) {
1264
- $username = rawurldecode( $_REQUEST['user'] );
 
 
 
 
 
 
 
 
 
 
1265
  if ( is_user_logged_in() ) {
1266
  global $current_user;
1267
  if ( 10 !== $current_user->wp_user_level && ( ! isset( $current_user->user_level ) || 10 !== $current_user->user_level ) && ! current_user_can( 'level_10' ) ) {
@@ -1291,9 +1378,14 @@ class MainWP_Child {
1291
 
1292
  global $current_user;
1293
  if ( 10 !== $current_user->wp_user_level && ( ! isset( $current_user->user_level ) || 10 !== $current_user->user_level ) && ! current_user_can( 'level_10' ) ) {
1294
- do_action( 'wp_logout' );
 
 
 
 
1295
 
1296
- return;
 
1297
  }
1298
  }
1299
 
@@ -1323,6 +1415,7 @@ class MainWP_Child {
1323
  $_SESSION['size'] = $_POST['size'];
1324
  }
1325
 
 
1326
  $open_location = isset( $_REQUEST['open_location'] ) ? $_REQUEST['open_location'] : '';
1327
  if ( ! empty( $open_location ) ) {
1328
  $open_location = base64_decode( $open_location );
@@ -1347,7 +1440,6 @@ class MainWP_Child {
1347
  exit();
1348
  }
1349
 
1350
- add_filter( 'the_content', array( MainWP_Keyword_Links::Instance(), 'filter_content' ), 100, 2 );
1351
  wp_redirect( admin_url( $where ) );
1352
  exit();
1353
  }
@@ -1387,10 +1479,26 @@ class MainWP_Child {
1387
  MainWP_Helper::error( __( 'Authentication failed! Please deactivate and re-activate the MainWP Child plugin on this site.', 'mainwp-child' ) );
1388
  }
1389
 
 
1390
  if ( $auth ) {
1391
  //Check if the user exists & is an administrator
1392
  if ( isset( $_POST['function'] ) && isset( $_POST['user'] ) ) {
1393
- $user = get_user_by( 'login', $_POST['user'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1394
  if ( ! $user ) {
1395
  MainWP_Helper::error( __( 'That administrator username was not found on this child site. Please verify that it is an existing administrator.', 'mainwp-child' ) );
1396
  }
@@ -1399,11 +1507,16 @@ class MainWP_Child {
1399
  MainWP_Helper::error( __( 'That user is not an administrator. Please use an administrator user to establish the connection.', 'mainwp-child' ) );
1400
  }
1401
 
1402
- $this->login( $_REQUEST['user'] );
1403
  }
1404
 
1405
  if ( isset( $_POST['function'] ) && 'visitPermalink' === $_POST['function'] ) {
1406
- if ( $this->login( $_POST['user'], true ) ) {
 
 
 
 
 
1407
  return;
1408
  } else {
1409
  exit();
@@ -1470,6 +1583,31 @@ class MainWP_Child {
1470
 
1471
  }
1472
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1473
  function default_option_active_plugins( $default ) {
1474
  if ( ! is_array( $default ) ) {
1475
  $default = array();
@@ -1508,10 +1646,16 @@ class MainWP_Child {
1508
  //Logout if required
1509
  if ( isset( $current_user->user_login ) ) {
1510
  if ( $current_user->user_login === $username ) {
 
 
 
 
 
 
 
1511
  wp_set_auth_cookie( $current_user->ID );
1512
  return true;
1513
  }
1514
-
1515
  do_action( 'wp_logout' );
1516
  }
1517
 
@@ -1521,7 +1665,7 @@ class MainWP_Child {
1521
  // wp_set_auth_cookie($user->ID);
1522
 
1523
  wp_set_current_user( $user->ID );
1524
- wp_set_auth_cookie( $user->ID );
1525
  if ( $doAction ) {
1526
  do_action( 'wp_login', $user->user_login );
1527
  }
@@ -1899,11 +2043,11 @@ class MainWP_Child {
1899
  // trick to prevent some premium plugins re-create update info
1900
  remove_all_filters('pre_set_site_transient_update_plugins');
1901
 
1902
- $information['plugin_updates'] = get_plugin_updates();
1903
-
1904
- // to support cached premium plugins update info, hooking in the bulk_upgrade()
1905
  add_filter( 'pre_site_transient_update_plugins', array( $this, 'set_cached_update_plugins' ) );
1906
 
 
 
1907
  $plugins = explode( ',', urldecode( $_POST['list'] ) );
1908
  $premiumPlugins = array();
1909
  $premiumUpdates = get_option( 'mainwp_premium_updates' );
@@ -2011,6 +2155,10 @@ class MainWP_Child {
2011
 
2012
  @wp_update_themes();
2013
  include_once( ABSPATH . '/wp-admin/includes/theme.php' );
 
 
 
 
2014
  $information['theme_updates'] = $this->upgrade_get_theme_updates();
2015
  $themes = explode( ',', $_POST['list'] );
2016
  $premiumThemes = array();
@@ -2094,6 +2242,10 @@ class MainWP_Child {
2094
 
2095
  }
2096
 
 
 
 
 
2097
  // $last_update = get_site_transient( 'update_themes' );
2098
  // if ( !empty( $last_update ) && property_exists( $last_update, 'last_checked' ) ) {
2099
  // $last_update->last_checked = $originalLastChecked;
@@ -2197,9 +2349,32 @@ class MainWP_Child {
2197
  $pre = false;
2198
  $cached_update_info = get_site_transient( 'mainwp_update_plugins_cached' );
2199
  if ( is_array($cached_update_info) && count($cached_update_info) > 0 ) {
2200
- foreach( $cached_update_info as $slug => $plugin_update ) {
2201
- if ( !isset( $_transient_data->response[ $slug ] ) && isset($plugin_update->update) ) {
2202
- $_transient_data->response[ $slug ] = $plugin_update->update;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2203
  $pre = true;
2204
  }
2205
  }
@@ -2253,11 +2428,13 @@ class MainWP_Child {
2253
  MainWP_Helper::error( __( 'Invalid request!', 'mainwp-child' ) );
2254
  }
2255
 
2256
- MainWP_Helper::update_option( 'mainwp_child_branding_disconnected', 'yes', 'yes' );
2257
-
2258
  //Already added - can't readd. Deactivate plugin..
2259
  if ( get_option( 'mainwp_child_pubkey' ) ) {
 
 
 
2260
  MainWP_Helper::error( __( 'Public key already set. Please reset the MainWP Child plugin on the child site and try again.', 'mainwp-child' ) );
 
2261
  }
2262
 
2263
  if ( '' != get_option( 'mainwp_child_uniqueId' ) ) {
@@ -2294,7 +2471,6 @@ class MainWP_Child {
2294
  $nossl_key = uniqid( '', true );
2295
  MainWP_Helper::update_option( 'mainwp_child_nossl_key', $nossl_key, 'yes' );
2296
  $information['nosslkey'] = $nossl_key;
2297
- MainWP_Helper::update_option( 'mainwp_child_branding_disconnected', '', 'yes' );
2298
 
2299
  $information['register'] = 'OK';
2300
  $information['uniqueId'] = get_option( 'mainwp_child_uniqueId', '' );
@@ -2348,9 +2524,21 @@ class MainWP_Child {
2348
  $my_post = array();
2349
 
2350
  if ( 'publish' === $action ) {
2351
- // to fix error post slug
2352
- //wp_publish_post( $postId );
2353
- wp_update_post(array('ID' => $postId, 'post_status' => 'publish' ));
 
 
 
 
 
 
 
 
 
 
 
 
2354
  } else if ( 'update' === $action ) {
2355
  $postData = $_POST['post_data'];
2356
  $my_post = is_array( $postData ) ? $postData : array();
@@ -2897,7 +3085,7 @@ class MainWP_Child {
2897
  $message .= sprintf( __( 'Password: %s' ), $new_user['user_pass'] ) . "\r\n";
2898
  $message .= wp_login_url() . "\r\n";
2899
 
2900
- wp_mail( $user_email, sprintf( __( '[%s] Your username and password' ), $blogname ), $message );
2901
  }
2902
  $information['added'] = true;
2903
  MainWP_Helper::write( $information );
@@ -3461,15 +3649,16 @@ class MainWP_Child {
3461
  $this->updateExternalSettings();
3462
  }
3463
 
 
3464
  MainWP_Helper::update_option( 'mainwp_child_branding_disconnected', '', 'yes' );
3465
  if ( isset( $_POST['server'] ) ) {
3466
  MainWP_Helper::update_option( 'mainwp_child_server', $_POST['server'] );
3467
  }
3468
 
3469
- if ( isset( $_POST['numberdaysOutdatePluginTheme'] ) && ! empty( $_POST['numberdaysOutdatePluginTheme'] ) ) {
3470
  $days_outdate = get_option( 'mainwp_child_plugintheme_days_outdate', 365 );
3471
- if ( $days_outdate !== $_POST['numberdaysOutdatePluginTheme'] ) {
3472
- $days_outdate = $_POST['numberdaysOutdatePluginTheme'];
3473
  MainWP_Helper::update_option( 'mainwp_child_plugintheme_days_outdate', $days_outdate );
3474
  MainWP_Child_Plugins_Check::Instance()->cleanup_deactivation( false );
3475
  MainWP_Child_Themes_Check::Instance()->cleanup_deactivation( false );
@@ -3479,7 +3668,7 @@ class MainWP_Child {
3479
  $information['version'] = self::$version;
3480
  $information['wpversion'] = $wp_version;
3481
  $information['siteurl'] = get_option( 'siteurl' );
3482
- $information['wpe'] = function_exists( 'is_wpe' ) ? 1 : 0;
3483
 
3484
  $information['site_info'] = array(
3485
  'wpversion' => $wp_version,
@@ -3614,23 +3803,23 @@ class MainWP_Child {
3614
  }
3615
  }
3616
 
3617
- // to fix bug
3618
- $info_update_plugins_cached = get_site_transient( 'mainwp_update_plugins_cached' );
3619
- if ( is_array( $info_update_plugins_cached ) && ( count( $info_update_plugins_cached ) > 0 ) ) {
 
 
 
 
3620
  if (!isset($information['plugin_updates'])) {
3621
  $information['plugin_updates'] = array();
3622
  }
3623
- foreach( $info_update_plugins_cached as $slug => $plugin_update ) {
3624
  if ( !isset( $information['plugin_updates'][ $slug ] ) ) {
3625
  $information['plugin_updates'][ $slug ] = $plugin_update;
3626
  }
3627
  }
3628
  }
3629
- // end fix
3630
 
3631
- if ( null !== $this->filterFunction ) {
3632
- remove_filter( 'pre_site_transient_update_plugins', $this->filterFunction, 99 );
3633
- }
3634
  if ( null !== $this->filterFunction ) {
3635
  add_filter( 'pre_site_transient_update_themes', $this->filterFunction, 99 );
3636
  }
@@ -3653,6 +3842,26 @@ class MainWP_Child {
3653
  remove_filter( 'pre_site_transient_update_themes', $this->filterFunction, 99 );
3654
  }
3655
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3656
  $translation_updates = wp_get_translation_updates();
3657
  if ( !empty( $translation_updates ) ) {
3658
  $information['translation_updates'] = array();
@@ -4773,7 +4982,7 @@ class MainWP_Child {
4773
  global $wp_version;
4774
  $information['version'] = self::$version;
4775
  $information['wpversion'] = $wp_version;
4776
- $information['wpe'] = function_exists( 'is_wpe' ) ? 1 : 0;
4777
  MainWP_Helper::write( $information );
4778
  }
4779
 
@@ -5226,8 +5435,8 @@ class MainWP_Child {
5226
  '<div>' . 'USER AGENT: ' . $agent . '</div>';
5227
  $mail = '<div>404 alert</div>
5228
  <div></div>' . $mail;
5229
- wp_mail( $email, 'MainWP - 404 Alert: ' . $blog, MainWP_Helper::formatEmail( $email, $mail ), array(
5230
- 'From: "' . $from_email . '" <' . $from_email . '>',
5231
  'content-type: text/html',
5232
  ) );
5233
 
@@ -5299,13 +5508,33 @@ class MainWP_Child {
5299
  }
5300
 
5301
  public function snippetUpdateWPConfig( $action, $slug, $code = '' ) {
5302
- $wpConfig = file_get_contents( ABSPATH . 'wp-config.php' );
5303
- if ( 'delete' === $action ) {
5304
- $wpConfig = preg_replace( '/' . PHP_EOL . '{1,2}\/\*\*\*snippet_' . $slug . '\*\*\*\/(.*)\/\*\*\*end_' . $slug . '\*\*\*\/' . PHP_EOL . '/is', '', $wpConfig );
5305
- } else if ( 'save' === $action ) {
5306
- $wpConfig = preg_replace( '/(\$table_prefix *= *[\'"][^\'|^"]*[\'"] *;)/is', '${1}' . PHP_EOL . PHP_EOL . '/***snippet_' . $slug . '***/' . PHP_EOL . $code . PHP_EOL . '/***end_' . $slug . '***/' . PHP_EOL, $wpConfig );
5307
- }
5308
- file_put_contents( ABSPATH . 'wp-config.php', $wpConfig );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5309
  }
5310
 
5311
  function run_saved_snippets() {
@@ -5564,7 +5793,7 @@ class MainWP_Child {
5564
  MainWP_Helper::write( $information );
5565
  }
5566
 
5567
- function disconnect() {
5568
  $this->deactivation(false);
5569
  MainWP_Helper::write( array( 'result' => 'success' ) );
5570
  }
115
  }
116
 
117
  class MainWP_Child {
118
+ public static $version = '3.5.4';
119
+ private $update_version = '1.5';
120
 
121
  private $callableFunctions = array(
122
  'stats' => 'getSiteStats',
185
  'disconnect' => 'disconnect',
186
  'time_capsule' => 'time_capsule',
187
  'extra_excution' => 'extra_execution', // deprecated
188
+ 'extra_execution' => 'extra_execution'
189
  );
190
 
191
  private $FTP_ERROR = 'Failed! Please, add FTP details for automatic updates.';
203
 
204
  private $filterFunction = null;
205
  public static $brandingTitle = null;
 
206
 
207
  public static $subPages;
208
  public static $subPagesLoaded = false;
230
  add_action( 'admin_init', array( &$this, 'admin_init' ) );
231
  add_action( 'admin_head', array( &$this, 'admin_head' ) );
232
  add_action( 'init', array( &$this, 'localization' ), 33 );
233
+ add_action( 'pre_current_active_plugins', array( &$this, 'detect_premium_themesplugins_updates' ) ); // to support detect premium themes/plugins update
234
+ add_action( 'core_upgrade_preamble', array( &$this, 'detect_premium_themesplugins_updates' ) );
235
+
236
 
237
  if ( is_admin() ) {
238
  MainWP_Helper::update_option( 'mainwp_child_plugin_version', self::$version, 'yes' );
243
  MainWP_Clone::get()->init();
244
  MainWP_Child_Server_Information::init();
245
  MainWP_Client_Report::Instance()->init();
246
+ MainWP_Child_Plugins_Check::Instance();
247
+ MainWP_Child_Themes_Check::Instance();
248
 
249
  $this->run_saved_snippets();
250
 
251
  if ( ! get_option( 'mainwp_child_pubkey' ) ) {
252
+ MainWP_Child_Branding::Instance()->save_branding_options('branding_disconnected', 'yes');
253
+ MainWP_Helper::update_option( 'mainwp_child_branding_disconnected', 'yes', 'yes' ); // to compatible
254
  }
255
 
 
 
 
 
 
 
 
256
  add_action( 'admin_notices', array( &$this, 'admin_notice' ) );
257
  add_filter( 'plugin_row_meta', array( &$this, 'plugin_row_meta' ), 10, 2 );
258
 
305
  'mainwp_security',
306
  'mainwp_backupwordpress_ext_enabled',
307
  'mainwp_wprocket_ext_enabled',
308
+ //'mainwp_wordfence_ext_enabled',
309
  'mainwp_branding_button_contact_label',
310
  'mainwp_branding_extra_settings',
311
  'mainwp_branding_child_hide',
312
  'mainwp_branding_ext_enabled',
313
+ //'mainwp_creport_ext_branding_enabled',
314
  'mainwp_pagespeed_ext_enabled',
315
  'mainwp_linkschecker_ext_enabled',
316
+ //'mainwp_ithemes_ext_enabled',
317
+ 'mainwp_child_branding_settings',
318
+ 'mainwp_child_plugintheme_days_outdate'
319
  );
320
  $query = "SELECT option_name, option_value FROM $wpdb->options WHERE option_name in (";
321
  foreach ($options as $option) {
357
  $options = array(
358
  'mainwp_child_legacy',
359
  'mainwp_child_auth',
 
360
  'mainwp_child_uniqueId',
361
  'mainwp_child_htaccess_set',
362
  'mainwp_child_fix_htaccess',
397
  'mainwp_kwl_statistic_data_',
398
  'mainwp_kwl_enable_statistic',
399
  'mainwpKeywordLinks',
400
+ // 'mainwp_branding_ext_enabled',
401
+ // 'mainwp_branding_plugin_header',
402
+ // 'mainwp_branding_support_email',
403
+ // 'mainwp_branding_support_message',
404
+ // 'mainwp_branding_remove_restore',
405
+ // 'mainwp_branding_remove_setting',
406
+ // 'mainwp_branding_remove_wp_tools',
407
+ // 'mainwp_branding_remove_wp_setting',
408
+ // 'mainwp_branding_remove_permalink',
409
+ // 'mainwp_branding_button_contact_label',
410
+ // 'mainwp_branding_send_email_message',
411
+ // 'mainwp_branding_message_return_sender',
412
+ // 'mainwp_branding_submit_button_title',
413
+ // 'mainwp_branding_disable_wp_branding',
414
+ // 'mainwp_branding_extra_settings',
415
+ // 'mainwp_branding_child_hide',
416
+ // 'mainwp_branding_show_support',
417
+ // 'mainwp_branding_disable_change',
418
  );
419
  foreach ( $options as $option ) {
420
  MainWP_Helper::fix_option( $option );
421
  }
422
+ } else if ( ( '1.0' === $update_version ) || ( '1.1' === $update_version ) ) {
423
  $options = array(
424
  'mainwp_child_pubkey',
425
+ //'mainwp_child_branding_disconnected',
426
+ //'mainwp_branding_plugin_header',
427
  'mainwp_child_update_version',
428
  'mainwp_child_auth',
429
  'mainwp_child_clone_permalink',
440
  'mainwp_updraftplus_ext_enabled',
441
  'mainwpKeywordLinks',
442
  'mainwp_keyword_links_htaccess_set',
443
+ //'mainwp_branding_button_contact_label',
444
+ //'mainwp_branding_extra_settings',
445
+ //'mainwp_branding_ext_enabled',
446
+ //'mainwp_creport_ext_branding_enabled',
447
  'mainwp_pagespeed_ext_enabled',
448
  'mainwp_linkschecker_ext_enabled',
449
+ //'mainwp_wordfence_ext_enabled',
450
+ //'mainwp_ithemes_ext_enabled',
451
  'mainwp_maintenance_opt_alert_404',
452
  );
453
  foreach ( $options as $option ) {
475
  }
476
  MainWP_Helper::update_option( 'mainwp_security', $security, 'yes' );
477
  }
478
+ }
479
+
480
+ if ( !empty($update_version) && version_compare($update_version, '1.4', '<=' ) ) { // 3.5.4
481
+ if ( ! is_array( get_option( 'mainwp_child_branding_settings' ) ) ) {
482
+ // to fix: reduce number of options
483
+ $brandingOptions = array(
484
+ 'hide' => 'mainwp_branding_child_hide',
485
+ 'extra_settings' => 'mainwp_branding_extra_settings',
486
+ 'branding_disconnected' => 'mainwp_child_branding_disconnected',
487
+ 'preserve_branding' => 'mainwp_branding_preserve_branding',
488
+ 'branding_header' => 'mainwp_branding_plugin_header',
489
+ 'support_email' => 'mainwp_branding_support_email',
490
+ 'support_message' => 'mainwp_branding_support_message',
491
+ 'remove_restore' => 'mainwp_branding_remove_restore',
492
+ 'remove_setting' => 'mainwp_branding_remove_setting',
493
+ 'remove_server_info' => 'mainwp_branding_remove_server_info',
494
+ 'remove_connection_detail' => 'mainwp_branding_remove_connection_detail',
495
+ 'remove_wp_tools' => 'mainwp_branding_remove_wp_tools',
496
+ 'remove_wp_setting' => 'mainwp_branding_remove_wp_setting',
497
+ 'remove_permalink' => 'mainwp_branding_remove_permalink',
498
+ 'contact_label' => 'mainwp_branding_button_contact_label',
499
+ 'email_message' => 'mainwp_branding_send_email_message',
500
+ 'message_return_sender' => 'mainwp_branding_message_return_sender',
501
+ 'submit_button_title' => 'mainwp_branding_submit_button_title',
502
+ 'disable_wp_branding' => 'mainwp_branding_disable_wp_branding',
503
+ 'show_support' => 'mainwp_branding_show_support',
504
+ 'disable_change' => 'mainwp_branding_disable_change',
505
+ 'disable_switching_theme' => 'mainwp_branding_disable_switching_theme',
506
+ 'hide_child_reports' => 'mainwp_creport_branding_stream_hide',
507
+ 'branding_ext_enabled' => 'mainwp_branding_ext_enabled'
508
+ );
509
+
510
+ $convertBranding = array();
511
+ foreach ( $brandingOptions as $option => $old ) {
512
+ $value = get_option( $old );
513
+ $convertBranding[ $option ] = $value;
514
+ }
515
+ MainWP_Helper::update_option( 'mainwp_child_branding_settings', $convertBranding );
516
+ }
517
+
518
  }
519
 
520
  MainWP_Helper::update_option( 'mainwp_child_update_version', $this->update_version, 'yes' );
540
 
541
  public function admin_notice() {
542
  //Admin Notice...
543
+ if ( ! get_option( 'mainwp_child_pubkey' ) && MainWP_Helper::isAdmin() && is_admin() ) {
544
+ $branding_opts = MainWP_Child_Branding::Instance()->get_branding_options();
545
+ $child_name = ( $branding_opts['branding_preserve_title'] === '' ) ? 'MainWP Child' : $branding_opts['branding_preserve_title'];
546
+ $dashboard_name = ( $branding_opts['branding_preserve_title'] === '' ) ? 'MainWP Dashboard' : $branding_opts['branding_preserve_title'] . ' Dashboard';
547
+
548
+ $msg = '<div class="wrap"><div class="postbox" style="margin-top: 4em;"><p style="background: #a00; color: #fff; font-size: 22px; font-weight: bold; margin: 0; padding: .3em;">';
549
+ $msg .= __( 'Attention!', 'mainwp-child' );
550
+ $msg .= '</p><div style="padding-left: 1em; padding-right: 1em;"><p style="font-size: 16px;">';
551
+ $msg .= __( 'Please add this site to your ', 'mainwp-child' ) . $dashboard_name . ' ' . __( '<b>NOW</b> or deactivate the ', 'mainwp-child' ) . $child_name . __( ' plugin until you are ready to connect this site to your Dashboard in order to avoid unexpected security issues.','mainwp-child' );
552
+ $msg .= '</p>';
553
+ $msg .= '<p style="font-size: 16px;">';
554
+ $msg .= __( 'If you are not sure how to add this site to your Dashboard, <a href="https://mainwp.com/help/docs/set-up-the-mainwp-plugin/add-site-to-your-dashboard/" target="_blank">please review these instructions</a>.', 'mainwp-child' );
555
+ $msg .= '</p>';
556
+ if ( ! MainWP_Child_Branding::Instance()->is_branding() ) {
557
+ $msg .= '<p>';
558
+ $msg .= __( 'You can also turn on the unique security ID option in <a href="admin.php?page=mainwp_child_tab">', 'mainwp-child' ) . $child_name . __( ' settings</a> if you would like extra security and additional time to add this site to your Dashboard. <br/>Find out more in this help document <a href="https://mainwp.com/help/docs/set-up-the-mainwp-plugin/set-unique-security-id/" target="_blank">How do I use the child unique security ID?</a>', 'mainwp-child' );
559
+ $msg .= '</p>';
560
+ }
561
+ $msg .= '</div></div></div>';
562
+ echo wp_kses_post( $msg );
563
+ }
564
  MainWP_Child_Server_Information::showWarnings();
565
  }
566
 
568
  load_plugin_textdomain( 'mainwp-child', false, dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' );
569
  }
570
 
571
+ public function detect_premium_themesplugins_updates() {
572
  if (isset($_GET['_detect_plugins_updates']) && $_GET['_detect_plugins_updates'] == 'yes') {
573
  // to fix some premium plugins update notification
574
  $current = get_site_transient( 'update_plugins' );
575
  set_site_transient( 'update_plugins', $current );
576
 
577
+ add_filter( 'pre_site_transient_update_plugins', $this->filterFunction, 99 );
578
+ $plugins = get_plugin_updates();
579
+ remove_filter( 'pre_site_transient_update_plugins', $this->filterFunction, 99 );
580
+
581
+ set_site_transient( 'mainwp_update_plugins_cached', $plugins, DAY_IN_SECONDS);
582
+ wp_destroy_current_session(); // to fix issue multi user session
583
+
584
+ }
585
+
586
+ if (isset($_GET['_detect_themes_updates']) && $_GET['_detect_themes_updates'] == 'yes') {
587
+ add_filter( 'pre_site_transient_update_themes', $this->filterFunction, 99 );
588
+ $themes = get_theme_updates();
589
+ remove_filter( 'pre_site_transient_update_themes', $this->filterFunction, 99 );
590
+
591
+ set_site_transient( 'mainwp_update_themes_cached', $themes, DAY_IN_SECONDS);
592
+ wp_destroy_current_session(); // to fix issue multi user session
593
  }
594
  }
595
 
647
  }
648
 
649
  function admin_menu() {
650
+ $branding_opts = MainWP_Child_Branding::Instance()->get_branding_options();
651
+ $is_hide = isset( $branding_opts['hide'] ) ? $branding_opts['hide'] : '';
652
+ $cancelled_branding = $branding_opts['cancelled_branding'];
653
 
654
+ if ( isset($branding_opts['remove_wp_tools']) && $branding_opts['remove_wp_tools'] && ! $cancelled_branding ) {
655
  remove_menu_page( 'tools.php' );
656
  $pos = stripos( $_SERVER['REQUEST_URI'], 'tools.php' ) ||
657
  stripos( $_SERVER['REQUEST_URI'], 'import.php' ) ||
661
  }
662
  }
663
  // if preserve branding do not remove menus
664
+ if ( isset($branding_opts['remove_wp_setting']) && $branding_opts['remove_wp_setting'] && ! $cancelled_branding ) {
665
  remove_menu_page( 'options-general.php' );
666
  $pos = stripos( $_SERVER['REQUEST_URI'], 'options-general.php' ) ||
667
  stripos( $_SERVER['REQUEST_URI'], 'options-writing.php' ) ||
675
  }
676
  }
677
 
678
+ if ( isset($branding_opts['remove_permalink']) && $branding_opts['remove_permalink'] && ! $cancelled_branding ) {
679
  remove_submenu_page( 'options-general.php', 'options-permalink.php' );
680
  $pos = stripos( $_SERVER['REQUEST_URI'], 'options-permalink.php' );
681
  if ( false !== $pos ) {
685
  }
686
 
687
  $remove_all_child_menu = false;
688
+ if ( isset($branding_opts['remove_setting']) && isset($branding_opts['remove_restore']) && isset($branding_opts['remove_server_info']) && $branding_opts['remove_setting'] && $branding_opts['remove_restore'] && $branding_opts['remove_server_info'] ) {
689
  $remove_all_child_menu = true;
690
  }
691
 
692
  // if preserve branding do not hide menus
693
+ if ( ( ! $remove_all_child_menu && $is_hide !== 'T' ) || $cancelled_branding ) {
694
+ $branding_header = isset( $branding_opts['branding_header'] ) ? $branding_opts['branding_header'] : array();
695
  if ( ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) && ! $cancelled_branding ) {
696
  self::$brandingTitle = $child_menu_title = stripslashes( $branding_header['name'] );
697
  $child_page_title = $child_menu_title . ' Settings';
711
  do_action( 'mainwp-child-subpages', $subpageargs ); // to compatible
712
 
713
  $sub_pages = array();
714
+
715
  $all_subpages = apply_filters( 'mainwp-child-init-subpages', array() );
716
 
717
  if ( !is_array( $all_subpages ) )
759
  if ( isset($_GET['tab']) ) {
760
  $shownPage = $_GET['tab'];
761
  }
762
+ $branding_opts = MainWP_Child_Branding::Instance()->get_branding_options();
763
+
764
+ $hide_settings = $branding_opts['remove_setting'] ? true : false;
765
+ $hide_restore = $branding_opts['remove_restore'] ? true : false;
766
+ $hide_server_info = $branding_opts['remove_server_info'] ? true : false;
767
+ $hide_connection_detail = $branding_opts['remove_connection_detail'] ? true : false;
768
 
 
 
 
 
769
  $hide_style = 'style="display:none"';
770
 
771
  if ($shownPage == '') {
835
  if (empty($shownPage))
836
  $shownPage = 'settings';
837
 
838
+ $branding_opts = MainWP_Child_Branding::Instance()->get_branding_options();
839
+
840
+ $hide_settings = $branding_opts['remove_setting'] ? true : false;
841
+ $hide_restore = $branding_opts['remove_restore'] ? true : false;
842
+ $hide_server_info = $branding_opts['remove_server_info'] ? true : false;
843
+ $hide_connection_detail = $branding_opts['remove_connection_detail'] ? true : false;
844
+
845
  $sitesToClone = get_option( 'mainwp_child_clone_sites' );
846
 
847
  ?>
1119
  }
1120
  }
1121
 
1122
+ function check_login() {
1123
  $file = '';
1124
  if ( isset( $_REQUEST['f'] ) ) {
1125
  $file = $_REQUEST['f'];
1139
  MainWP_Helper::error( __( 'Authentication failed! Please deactivate and re-activate the MainWP Child plugin on this site.', 'mainwp-child' ) );
1140
  }
1141
 
1142
+ $auth_user = false;
1143
  if ( $auth ) {
1144
  //disable duo auth for mainwp
1145
  remove_action('init', 'duo_verify_auth', 10);
1146
 
1147
  //Check if the user exists & is an administrator
1148
  if ( isset( $_POST['function'] ) && isset( $_POST['user'] ) ) {
1149
+
1150
+ $user = null;
1151
+
1152
+ if ( isset( $_POST['alt_user'] ) && !empty( $_POST['alt_user'] ) ) {
1153
+ if ( $this->check_login_as( $_POST['alt_user'] ) ) {
1154
+ $auth_user = $_POST['alt_user'];
1155
+ $user = get_user_by( 'login', $auth_user );
1156
+ }
1157
+ }
1158
+
1159
+ // if not valid alternative admin
1160
+ if ( ! $user ) {
1161
+ // check connected admin existed
1162
+ $user = get_user_by( 'login', $_POST['user'] );
1163
+ $auth_user = $_POST['user'];
1164
+ }
1165
+
1166
  if ( ! $user ) {
1167
  MainWP_Helper::error( __( 'That administrator username was not found on this child site. Please verify that it is an existing administrator.', 'mainwp-child' ) );
1168
  }
1171
  MainWP_Helper::error( __( 'That user is not an administrator. Please use an administrator user to establish the connection.', 'mainwp-child' ) );
1172
  }
1173
 
1174
+ $this->login( $auth_user );
1175
  }
1176
 
1177
  if ( isset( $_POST['function'] ) && 'visitPermalink' === $_POST['function'] ) {
1178
+
1179
+ if (empty($auth_user)) {
1180
+ $auth_user = $_POST['user'];
1181
+ }
1182
+
1183
+ if ( $this->login( $auth_user, true ) ) {
1184
  return;
1185
  } else {
1186
  exit();
1338
  global $current_user; //wp variable
1339
  //Login the user
1340
  if ( isset( $_REQUEST['login_required'] ) && ( '1' === $_REQUEST['login_required'] ) && isset( $_REQUEST['user'] ) ) {
1341
+ $alter_login_required = false;
1342
+ $username = rawurldecode( $_REQUEST['user'] );
1343
+
1344
+ if ( isset( $_REQUEST['alt_user'] ) && !empty( $_REQUEST['alt_user'] ) ) {
1345
+ $alter_login_required = $this->check_login_as( $_REQUEST['alt_user'] );
1346
+
1347
+ if ( $alter_login_required ) {
1348
+ $username = rawurldecode( $_REQUEST['alt_user'] );
1349
+ }
1350
+ }
1351
+
1352
  if ( is_user_logged_in() ) {
1353
  global $current_user;
1354
  if ( 10 !== $current_user->wp_user_level && ( ! isset( $current_user->user_level ) || 10 !== $current_user->user_level ) && ! current_user_can( 'level_10' ) ) {
1378
 
1379
  global $current_user;
1380
  if ( 10 !== $current_user->wp_user_level && ( ! isset( $current_user->user_level ) || 10 !== $current_user->user_level ) && ! current_user_can( 'level_10' ) ) {
1381
+ // if is not alternative admin login
1382
+ // it is connected admin login
1383
+ if ( ! $alter_login_required ) {
1384
+ // log out if connected admin is not admin level 10
1385
+ do_action( 'wp_logout' );
1386
 
1387
+ return;
1388
+ }
1389
  }
1390
  }
1391
 
1415
  $_SESSION['size'] = $_POST['size'];
1416
  }
1417
 
1418
+ // to support open not wp-admin url
1419
  $open_location = isset( $_REQUEST['open_location'] ) ? $_REQUEST['open_location'] : '';
1420
  if ( ! empty( $open_location ) ) {
1421
  $open_location = base64_decode( $open_location );
1440
  exit();
1441
  }
1442
 
 
1443
  wp_redirect( admin_url( $where ) );
1444
  exit();
1445
  }
1479
  MainWP_Helper::error( __( 'Authentication failed! Please deactivate and re-activate the MainWP Child plugin on this site.', 'mainwp-child' ) );
1480
  }
1481
 
1482
+ $auth_user = false;
1483
  if ( $auth ) {
1484
  //Check if the user exists & is an administrator
1485
  if ( isset( $_POST['function'] ) && isset( $_POST['user'] ) ) {
1486
+
1487
+ $user = null;
1488
+ if ( isset( $_POST['alt_user'] ) && !empty( $_POST['alt_user'] ) ) {
1489
+ if ( $this->check_login_as( $_POST['alt_user'] ) ) {
1490
+ $auth_user = $_POST['alt_user'];
1491
+ $user = get_user_by( 'login', $auth_user );
1492
+ }
1493
+ }
1494
+
1495
+ // if alternative admin not existed
1496
+ if ( ! $user ) {
1497
+ // check connected admin existed
1498
+ $user = get_user_by( 'login', $_POST['user'] );
1499
+ $auth_user = $_POST['user'];
1500
+ }
1501
+
1502
  if ( ! $user ) {
1503
  MainWP_Helper::error( __( 'That administrator username was not found on this child site. Please verify that it is an existing administrator.', 'mainwp-child' ) );
1504
  }
1507
  MainWP_Helper::error( __( 'That user is not an administrator. Please use an administrator user to establish the connection.', 'mainwp-child' ) );
1508
  }
1509
 
1510
+ $this->login( $auth_user );
1511
  }
1512
 
1513
  if ( isset( $_POST['function'] ) && 'visitPermalink' === $_POST['function'] ) {
1514
+
1515
+ if (empty($auth_user)) {
1516
+ $auth_user = $_POST['user'];
1517
+ }
1518
+
1519
+ if ( $this->login( $auth_user, true ) ) {
1520
  return;
1521
  } else {
1522
  exit();
1583
 
1584
  }
1585
 
1586
+ // Check to support login by alternative admin
1587
+ // return false will login by connected admin user
1588
+ // return true will try to login as alternative user
1589
+ function check_login_as( $alter_login ) {
1590
+
1591
+ if ( !empty( $alter_login ) ) {
1592
+ // check alternative admin existed
1593
+ $user = get_user_by( 'login', $alter_login );
1594
+
1595
+ if ( ! $user ) {
1596
+ //That administrator username was not found on this child site
1597
+ return false;
1598
+ }
1599
+
1600
+ if ( 10 != $user->wp_user_level && ( ! isset( $user->user_level ) || 10 != $user->user_level ) && ! $user->has_cap( 'level_10' ) ) {
1601
+ // That user is not an administrator
1602
+ return false;
1603
+ }
1604
+
1605
+ return true; // ok, will try to login by alternative user
1606
+ }
1607
+
1608
+ return false;
1609
+ }
1610
+
1611
  function default_option_active_plugins( $default ) {
1612
  if ( ! is_array( $default ) ) {
1613
  $default = array();
1646
  //Logout if required
1647
  if ( isset( $current_user->user_login ) ) {
1648
  if ( $current_user->user_login === $username ) {
1649
+
1650
+ // to fix issue multi user session
1651
+ $user_id = wp_validate_auth_cookie();
1652
+ if ( $user_id && $user_id === $current_user->ID ) {
1653
+ return true;
1654
+ }
1655
+
1656
  wp_set_auth_cookie( $current_user->ID );
1657
  return true;
1658
  }
 
1659
  do_action( 'wp_logout' );
1660
  }
1661
 
1665
  // wp_set_auth_cookie($user->ID);
1666
 
1667
  wp_set_current_user( $user->ID );
1668
+ wp_set_auth_cookie( $user->ID );
1669
  if ( $doAction ) {
1670
  do_action( 'wp_login', $user->user_login );
1671
  }
2043
  // trick to prevent some premium plugins re-create update info
2044
  remove_all_filters('pre_set_site_transient_update_plugins');
2045
 
2046
+ // to support cached premium plugins update info, hooking in the bulk_upgrade()
 
 
2047
  add_filter( 'pre_site_transient_update_plugins', array( $this, 'set_cached_update_plugins' ) );
2048
 
2049
+ $information['plugin_updates'] = get_plugin_updates();
2050
+
2051
  $plugins = explode( ',', urldecode( $_POST['list'] ) );
2052
  $premiumPlugins = array();
2053
  $premiumUpdates = get_option( 'mainwp_premium_updates' );
2155
 
2156
  @wp_update_themes();
2157
  include_once( ABSPATH . '/wp-admin/includes/theme.php' );
2158
+
2159
+ // to support cached premium themes update info, hooking in the bulk_upgrade()
2160
+ add_filter( 'pre_site_transient_update_themes', array( $this, 'set_cached_update_themes' ) );
2161
+
2162
  $information['theme_updates'] = $this->upgrade_get_theme_updates();
2163
  $themes = explode( ',', $_POST['list'] );
2164
  $premiumThemes = array();
2242
 
2243
  }
2244
 
2245
+ remove_filter( 'pre_site_transient_update_themes', array( $this, 'set_cached_update_themes' ), 10 );
2246
+ delete_site_transient( 'mainwp_update_themes_cached' ); // to fix cached update info
2247
+
2248
+
2249
  // $last_update = get_site_transient( 'update_themes' );
2250
  // if ( !empty( $last_update ) && property_exists( $last_update, 'last_checked' ) ) {
2251
  // $last_update->last_checked = $originalLastChecked;
2349
  $pre = false;
2350
  $cached_update_info = get_site_transient( 'mainwp_update_plugins_cached' );
2351
  if ( is_array($cached_update_info) && count($cached_update_info) > 0 ) {
2352
+ foreach( $cached_update_info as $slug => $info ) {
2353
+ if ( !isset( $_transient_data->response[ $slug ] ) && isset($info->update) ) {
2354
+ $_transient_data->response[ $slug ] = $info->update;
2355
+ $pre = true;
2356
+ }
2357
+ }
2358
+ }
2359
+
2360
+ if ($pre == false)
2361
+ return $false;
2362
+
2363
+ return $_transient_data;
2364
+ }
2365
+
2366
+ public function set_cached_update_themes( $false = false, $_transient_data = null ) {
2367
+
2368
+ if ( ! is_object( $_transient_data ) ) {
2369
+ $_transient_data = new stdClass;
2370
+ }
2371
+
2372
+ $pre = false;
2373
+ $cached_update_info = get_site_transient( 'mainwp_update_themes_cached' );
2374
+ if ( is_array($cached_update_info) && count($cached_update_info) > 0 ) {
2375
+ foreach( $cached_update_info as $slug => $info ) {
2376
+ if ( !isset( $_transient_data->response[ $slug ] ) && isset($info->update) ) {
2377
+ $_transient_data->response[ $slug ] = $info->update;
2378
  $pre = true;
2379
  }
2380
  }
2428
  MainWP_Helper::error( __( 'Invalid request!', 'mainwp-child' ) );
2429
  }
2430
 
 
 
2431
  //Already added - can't readd. Deactivate plugin..
2432
  if ( get_option( 'mainwp_child_pubkey' ) ) {
2433
+ // set disconnect status to yes here, it will empty after reconnected
2434
+ MainWP_Child_Branding::Instance()->save_branding_options('branding_disconnected', 'yes');
2435
+ MainWP_Helper::update_option( 'mainwp_child_branding_disconnected', 'yes', 'yes' ); // to compatible with old client reports
2436
  MainWP_Helper::error( __( 'Public key already set. Please reset the MainWP Child plugin on the child site and try again.', 'mainwp-child' ) );
2437
+
2438
  }
2439
 
2440
  if ( '' != get_option( 'mainwp_child_uniqueId' ) ) {
2471
  $nossl_key = uniqid( '', true );
2472
  MainWP_Helper::update_option( 'mainwp_child_nossl_key', $nossl_key, 'yes' );
2473
  $information['nosslkey'] = $nossl_key;
 
2474
 
2475
  $information['register'] = 'OK';
2476
  $information['uniqueId'] = get_option( 'mainwp_child_uniqueId', '' );
2524
  $my_post = array();
2525
 
2526
  if ( 'publish' === $action ) {
2527
+ $post_current = get_post( $postId );
2528
+ if ( empty($post_current) ) {
2529
+ $information['status'] = 'FAIL';
2530
+ } else {
2531
+ if ( 'future' == $post_current->post_status ) {
2532
+ wp_publish_post( $postId ); // to fix: fail when publish future page
2533
+ wp_update_post(array('ID' => $postId,
2534
+ 'post_date' => current_time( 'mysql', false ),
2535
+ 'post_date_gmt' => current_time( 'mysql', true )
2536
+ ));
2537
+ } else {
2538
+ // to fix error post slug
2539
+ wp_update_post(array('ID' => $postId,'post_status' => 'publish' ));
2540
+ }
2541
+ }
2542
  } else if ( 'update' === $action ) {
2543
  $postData = $_POST['post_data'];
2544
  $my_post = is_array( $postData ) ? $postData : array();
3085
  $message .= sprintf( __( 'Password: %s' ), $new_user['user_pass'] ) . "\r\n";
3086
  $message .= wp_login_url() . "\r\n";
3087
 
3088
+ @wp_mail( $user_email, sprintf( __( '[%s] Your username and password' ), $blogname ), $message, '' );
3089
  }
3090
  $information['added'] = true;
3091
  MainWP_Helper::write( $information );
3649
  $this->updateExternalSettings();
3650
  }
3651
 
3652
+ MainWP_Child_Branding::Instance()->save_branding_options('branding_disconnected', '');
3653
  MainWP_Helper::update_option( 'mainwp_child_branding_disconnected', '', 'yes' );
3654
  if ( isset( $_POST['server'] ) ) {
3655
  MainWP_Helper::update_option( 'mainwp_child_server', $_POST['server'] );
3656
  }
3657
 
3658
+ if ( isset( $_POST['numberdaysOutdatePluginTheme'] ) ) {
3659
  $days_outdate = get_option( 'mainwp_child_plugintheme_days_outdate', 365 );
3660
+ if ( $days_outdate != $_POST['numberdaysOutdatePluginTheme'] ) {
3661
+ $days_outdate = intval($_POST['numberdaysOutdatePluginTheme']);
3662
  MainWP_Helper::update_option( 'mainwp_child_plugintheme_days_outdate', $days_outdate );
3663
  MainWP_Child_Plugins_Check::Instance()->cleanup_deactivation( false );
3664
  MainWP_Child_Themes_Check::Instance()->cleanup_deactivation( false );
3668
  $information['version'] = self::$version;
3669
  $information['wpversion'] = $wp_version;
3670
  $information['siteurl'] = get_option( 'siteurl' );
3671
+ $information['wpe'] = MainWP_Helper::is_wp_engine() ? 1 : 0;
3672
 
3673
  $information['site_info'] = array(
3674
  'wpversion' => $wp_version,
3803
  }
3804
  }
3805
 
3806
+ if ( null !== $this->filterFunction ) {
3807
+ remove_filter( 'pre_site_transient_update_plugins', $this->filterFunction, 99 );
3808
+ }
3809
+
3810
+ // to fix premium plugs update
3811
+ $cached_plugins_update = get_site_transient( 'mainwp_update_plugins_cached' );
3812
+ if ( is_array( $cached_plugins_update ) && ( count( $cached_plugins_update ) > 0 ) ) {
3813
  if (!isset($information['plugin_updates'])) {
3814
  $information['plugin_updates'] = array();
3815
  }
3816
+ foreach( $cached_plugins_update as $slug => $plugin_update ) {
3817
  if ( !isset( $information['plugin_updates'][ $slug ] ) ) {
3818
  $information['plugin_updates'][ $slug ] = $plugin_update;
3819
  }
3820
  }
3821
  }
 
3822
 
 
 
 
3823
  if ( null !== $this->filterFunction ) {
3824
  add_filter( 'pre_site_transient_update_themes', $this->filterFunction, 99 );
3825
  }
3842
  remove_filter( 'pre_site_transient_update_themes', $this->filterFunction, 99 );
3843
  }
3844
 
3845
+ // to fix premium themes update
3846
+ $cached_themes_update = get_site_transient( 'mainwp_update_themes_cached' );
3847
+ if ( is_array( $cached_themes_update ) && ( count( $cached_themes_update ) > 0 ) ) {
3848
+ if (!isset($information['theme_updates'])) {
3849
+ $information['theme_updates'] = array();
3850
+ }
3851
+
3852
+ foreach ( $cached_themes_update as $slug => $theme_update ) {
3853
+ $name = ( is_array( $theme_update ) ? $theme_update['Name'] : $theme_update->Name );
3854
+ if ( in_array( $name, $premiumThemes ) ) {
3855
+ continue;
3856
+ }
3857
+ if ( isset( $information['theme_updates'][ $slug ] ) ) {
3858
+ continue;
3859
+ }
3860
+ $information['theme_updates'][ $slug ] = $theme_update;
3861
+ }
3862
+ }
3863
+
3864
+
3865
  $translation_updates = wp_get_translation_updates();
3866
  if ( !empty( $translation_updates ) ) {
3867
  $information['translation_updates'] = array();
4982
  global $wp_version;
4983
  $information['version'] = self::$version;
4984
  $information['wpversion'] = $wp_version;
4985
+ $information['wpe'] = MainWP_Helper::is_wp_engine() ? 1 : 0;
4986
  MainWP_Helper::write( $information );
4987
  }
4988
 
5435
  '<div>' . 'USER AGENT: ' . $agent . '</div>';
5436
  $mail = '<div>404 alert</div>
5437
  <div></div>' . $mail;
5438
+ @wp_mail( $email, 'MainWP - 404 Alert: ' . $blog, MainWP_Helper::formatEmail( $email, $mail ), array(
5439
+ //'From: "' . $from_email . '" <' . $from_email . '>',
5440
  'content-type: text/html',
5441
  ) );
5442
 
5508
  }
5509
 
5510
  public function snippetUpdateWPConfig( $action, $slug, $code = '' ) {
5511
+
5512
+ $config_file = '';
5513
+ if ( file_exists( ABSPATH . 'wp-config.php') ) {
5514
+
5515
+ /** The config file resides in ABSPATH */
5516
+ $config_file = ABSPATH . 'wp-config.php';
5517
+
5518
+ } elseif ( @file_exists( dirname( ABSPATH ) . '/wp-config.php' ) && ! @file_exists( dirname( ABSPATH ) . '/wp-settings.php' ) ) {
5519
+
5520
+ /** The config file resides one level above ABSPATH but is not part of another install */
5521
+ $config_file = dirname( ABSPATH ) . '/wp-config.php';
5522
+
5523
+ }
5524
+
5525
+ if ( !empty($config_file) ) {
5526
+ $wpConfig = file_get_contents( $config_file );
5527
+
5528
+ if ( 'delete' === $action ) {
5529
+ $wpConfig = preg_replace( '/' . PHP_EOL . '{1,2}\/\*\*\*snippet_' . $slug . '\*\*\*\/(.*)\/\*\*\*end_' . $slug . '\*\*\*\/' . PHP_EOL . '/is', '', $wpConfig );
5530
+ } else if ( 'save' === $action ) {
5531
+ $wpConfig = preg_replace( '/(\$table_prefix *= *[\'"][^\'|^"]*[\'"] *;)/is', '${1}' . PHP_EOL . PHP_EOL . '/***snippet_' . $slug . '***/' . PHP_EOL . $code . PHP_EOL . '/***end_' . $slug . '***/' . PHP_EOL, $wpConfig );
5532
+ }
5533
+ file_put_contents( $config_file, $wpConfig );
5534
+
5535
+ return true;
5536
+ }
5537
+ return false;
5538
  }
5539
 
5540
  function run_saved_snippets() {
5793
  MainWP_Helper::write( $information );
5794
  }
5795
 
5796
+ function disconnect() {
5797
  $this->deactivation(false);
5798
  MainWP_Helper::write( array( 'result' => 'success' ) );
5799
  }
class/class-mainwp-client-report.php CHANGED
@@ -256,7 +256,7 @@ class MainWP_Client_Report {
256
  $args['date_to'] = date( 'Y-m-d H:i:s', $args['date_to'] );
257
  }
258
 
259
- if ( MainWP_Child_Branding::is_branding() ) {
260
  $args['hide_child_reports'] = 1;
261
  }
262
 
@@ -316,6 +316,8 @@ class MainWP_Client_Report {
316
 
317
  function get_other_tokens_data( $records, $tokens, &$skip_records ) {
318
 
 
 
319
  $convert_context_name = array(
320
  'comment' => 'comments',
321
  'plugin' => 'plugins',
@@ -489,19 +491,19 @@ class MainWP_Client_Report {
489
  'backup' => 'mainwp_backup',
490
  );
491
 
492
- $some_allowed_data = array(
493
- 'ID',
494
- 'name',
495
- 'title',
496
- 'oldversion',
497
- 'currentversion',
498
- 'date',
499
- 'time',
500
- 'count',
501
- 'author',
502
- 'old.version',
503
- 'current.version',
504
- );
505
 
506
  $context = $action = '';
507
  $str_tmp = str_replace( array( '[', ']' ), '', $section );
@@ -807,30 +809,33 @@ class MainWP_Client_Report {
807
  }
808
 
809
  function set_showhide() {
810
- // MainWP_Helper::update_option( 'mainwp_creport_ext_branding_enabled', 'Y', 'yes' );
811
- $hide = isset( $_POST['showhide'] ) && ( 'hide' === $_POST['showhide'] ) ? 'hide' : '';
812
- MainWP_Helper::update_option( 'mainwp_creport_branding_stream_hide', $hide, 'yes' );
813
  $information['result'] = 'SUCCESS';
814
 
815
- return $information;
816
  }
817
 
818
  public function creport_init() {
819
- // if ( get_option( 'mainwp_creport_ext_branding_enabled' ) !== 'Y' ) {
820
- // return;
821
- // }
822
 
 
823
  $hide_nag = false;
824
- if ( get_option( 'mainwp_creport_branding_stream_hide' ) === 'hide' ) {
825
- add_filter( 'all_plugins', array( $this, 'creport_branding_plugin' ) );
826
- add_action( 'admin_menu', array( $this, 'creport_remove_menu' ) );
827
- $hide_nag = true;
828
- }
829
 
830
- if ( MainWP_Child_Branding::is_branding() ) {
 
 
 
831
  $hide_nag = true;
832
  }
833
 
 
 
 
 
 
 
 
834
  if ($hide_nag) {
835
  add_filter( 'site_transient_update_plugins', array( &$this, 'remove_update_nag' ) );
836
  add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) );
256
  $args['date_to'] = date( 'Y-m-d H:i:s', $args['date_to'] );
257
  }
258
 
259
+ if ( MainWP_Child_Branding::Instance()->is_branding() ) {
260
  $args['hide_child_reports'] = 1;
261
  }
262
 
316
 
317
  function get_other_tokens_data( $records, $tokens, &$skip_records ) {
318
 
319
+ // convert context name of tokens to context name saved in child report
320
+ // some context are not difference
321
  $convert_context_name = array(
322
  'comment' => 'comments',
323
  'plugin' => 'plugins',
491
  'backup' => 'mainwp_backup',
492
  );
493
 
494
+ // $some_allowed_data = array(
495
+ // 'ID',
496
+ // 'name',
497
+ // 'title',
498
+ // 'oldversion',
499
+ // 'currentversion',
500
+ // 'date',
501
+ // 'time',
502
+ // 'count',
503
+ // 'author',
504
+ // 'old.version',
505
+ // 'current.version',
506
+ // );
507
 
508
  $context = $action = '';
509
  $str_tmp = str_replace( array( '[', ']' ), '', $section );
809
  }
810
 
811
  function set_showhide() {
812
+ $hide = isset( $_POST['showhide'] ) && ( 'hide' === $_POST['showhide'] ) ? 'hide' : '';
813
+ MainWP_Child_Branding::Instance()->save_branding_options('hide_child_reports', $hide);
814
+ MainWP_Helper::update_option( 'mainwp_creport_branding_stream_hide', $hide, 'yes' ); // to compatible with old child reports
815
  $information['result'] = 'SUCCESS';
816
 
817
+ return $information;
818
  }
819
 
820
  public function creport_init() {
 
 
 
821
 
822
+ $branding_opts = MainWP_Child_Branding::Instance()->get_branding_options();
823
  $hide_nag = false;
 
 
 
 
 
824
 
825
+ // check setting of 'hide_child_reports'
826
+ if ( isset($branding_opts['hide_child_reports']) && $branding_opts['hide_child_reports'] == 'hide' ) {
827
+ add_filter( 'all_plugins', array( $this, 'creport_branding_plugin' ) );
828
+ add_action( 'admin_menu', array( $this, 'creport_remove_menu' ) );
829
  $hide_nag = true;
830
  }
831
 
832
+ if ( ! $hide_nag ) {
833
+ // check child branding settings
834
+ if ( MainWP_Child_Branding::Instance()->is_branding() ) {
835
+ $hide_nag = true;
836
+ }
837
+ }
838
+
839
  if ($hide_nag) {
840
  add_filter( 'site_transient_update_plugins', array( &$this, 'remove_update_nag' ) );
841
  add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) );
class/class-mainwp-clone.php CHANGED
@@ -198,7 +198,7 @@ class MainWP_Clone {
198
  </div>
199
  <p><?php _e("The site selected above will replace this site's files and database", 'mainwp-child'); ?></p>
200
  </div>
201
- <div class="mainwp-child_clonebutton_container"><?php if ( ! $error ) { ?>
202
  <a href="#"
203
  id="mainwp-child_clonebutton"
204
  class="button-primary"><?php esc_html_e( 'Clone website', 'mainwp-child' ); ?></a><?php } ?>
@@ -223,12 +223,12 @@ class MainWP_Clone {
223
  <br/>
224
  <form
225
  action="<?php echo esc_attr( admin_url( 'options-general.php?page=mainwp_child_tab&tab=restore-clone&upload=yes' ) ); ?>"
226
- method="post"
227
  enctype="multipart/form-data">
228
- <input type="file" name="file" id="file"/>
229
- <input type="submit"
230
- name="submit"
231
- id="filesubmit"
232
  class="button button-primary"
233
  disabled="disabled"
234
  value="<?php esc_attr_e( 'Clone/Restore Website', 'mainwp-child' ); ?>"/>
@@ -287,7 +287,7 @@ class MainWP_Clone {
287
  </div>
288
  <?php
289
  if ( $uploadFile ) {
290
- esc_html_e( 'Upload successful.', 'mainwp-child' ); ?> <a href="#"
291
  id="mainwp-child_uploadclonebutton"
292
  class="button-primary"
293
  file="<?php echo esc_attr( $uploadFile ); ?>"><?php esc_html_e( 'Restore Website', 'mainwp-child' ); ?></a><?php
@@ -300,26 +300,19 @@ class MainWP_Clone {
300
  ?>
301
  <p><?php esc_html_e( 'Upload backup in .zip format (Maximum filesize for your server settings: ', 'mainwp-child' ); ?><?php echo esc_html( $uploadSize ); ?>)</p>
302
  <?php
303
- $branding_msg = '';
304
- if ( MainWP_Child_Branding::is_branding() ) {
305
- $branding_title = MainWP_Child_Branding::get_branding();
306
- $branding_msg = 'If you have a FULL backup created by basic ' . esc_html( stripslashes( $branding_title ) ) . ' Backup system you may restore it by uploading here. Backups created by 3rd party plugins will not work.';
 
307
  }
308
  ?>
309
- <em>
310
- <?php
311
- if ($branding_msg != '') {
312
- echo $branding_msg ;
313
- } else {
314
- esc_html_e( 'If you have a FULL backup created by basic MainWP Backup system you may restore it by uploading here. Backups created by 3rd party plugins will not work.', 'mainwp-child' );
315
- }
316
- ?>
317
- <br/>
318
  <?php esc_html_e( 'A database only backup will not work.', 'mainwp-child' ); ?></em><br/><br/>
319
- <form action="<?php echo esc_attr( admin_url( 'options-general.php?page=mainwp_child_tab&tab=restore-clone&upload=yes' ) ); ?>"
320
  method="post"
321
  enctype="multipart/form-data">
322
- <input type="file" name="file" id="file"/>
323
  <input type="submit"
324
  name="submit"
325
  class="button button-primary"
@@ -332,7 +325,7 @@ class MainWP_Clone {
332
  </div>
333
  </div>
334
  <?php
335
-
336
  self::renderCloneFromServer();
337
  self::renderJavaScript();
338
  }
@@ -350,7 +343,7 @@ class MainWP_Clone {
350
 
351
  $page = $_REQUEST['page'];
352
 
353
- $sitesToClone = get_option( 'mainwp_child_clone_sites' );
354
  $url = admin_url( 'options-general.php?page=mainwp_child_tab&tab=restore-clone#title_03' );
355
 
356
  $dirs = MainWP_Helper::getMainWPDir( 'backup', false );
@@ -895,7 +888,7 @@ class MainWP_Clone {
895
  } );
896
 
897
  </script>
898
- <?php
899
  }
900
 
901
  public static function renderStyle() {
198
  </div>
199
  <p><?php _e("The site selected above will replace this site's files and database", 'mainwp-child'); ?></p>
200
  </div>
201
+ <div class="mainwp-child_clonebutton_container"><?php if ( ! $error ) { ?>
202
  <a href="#"
203
  id="mainwp-child_clonebutton"
204
  class="button-primary"><?php esc_html_e( 'Clone website', 'mainwp-child' ); ?></a><?php } ?>
223
  <br/>
224
  <form
225
  action="<?php echo esc_attr( admin_url( 'options-general.php?page=mainwp_child_tab&tab=restore-clone&upload=yes' ) ); ?>"
226
+ method="post"
227
  enctype="multipart/form-data">
228
+ <input type="file" name="file" id="file"/>
229
+ <input type="submit"
230
+ name="submit"
231
+ id="filesubmit"
232
  class="button button-primary"
233
  disabled="disabled"
234
  value="<?php esc_attr_e( 'Clone/Restore Website', 'mainwp-child' ); ?>"/>
287
  </div>
288
  <?php
289
  if ( $uploadFile ) {
290
+ esc_html_e( 'Upload successful.', 'mainwp-child' ); ?> <a href="#"
291
  id="mainwp-child_uploadclonebutton"
292
  class="button-primary"
293
  file="<?php echo esc_attr( $uploadFile ); ?>"><?php esc_html_e( 'Restore Website', 'mainwp-child' ); ?></a><?php
300
  ?>
301
  <p><?php esc_html_e( 'Upload backup in .zip format (Maximum filesize for your server settings: ', 'mainwp-child' ); ?><?php echo esc_html( $uploadSize ); ?>)</p>
302
  <?php
303
+ $branding_title = MainWP_Child_Branding::Instance()->get_branding_title();
304
+ if ( $branding_title != '' ) {
305
+ $branding_msg = 'If you have a FULL backup created by basic ' . esc_html( stripslashes( $branding_title ) ) . ' Backup system you may restore it by uploading here. Backups created by 3rd party plugins will not work.';
306
+ } else {
307
+ $branding_msg = esc_html__( 'If you have a FULL backup created by basic MainWP Backup system you may restore it by uploading here. Backups created by 3rd party plugins will not work.', 'mainwp-child' );
308
  }
309
  ?>
310
+ <em> <?php echo $branding_msg ; ?> <br/>
 
 
 
 
 
 
 
 
311
  <?php esc_html_e( 'A database only backup will not work.', 'mainwp-child' ); ?></em><br/><br/>
312
+ <form action="<?php echo esc_attr( admin_url( 'options-general.php?page=mainwp_child_tab&tab=restore-clone&upload=yes' ) ); ?>"
313
  method="post"
314
  enctype="multipart/form-data">
315
+ <input type="file" name="file" id="file"/>
316
  <input type="submit"
317
  name="submit"
318
  class="button button-primary"
325
  </div>
326
  </div>
327
  <?php
328
+
329
  self::renderCloneFromServer();
330
  self::renderJavaScript();
331
  }
343
 
344
  $page = $_REQUEST['page'];
345
 
346
+ $sitesToClone = get_option( 'mainwp_child_clone_sites' );
347
  $url = admin_url( 'options-general.php?page=mainwp_child_tab&tab=restore-clone#title_03' );
348
 
349
  $dirs = MainWP_Helper::getMainWPDir( 'backup', false );
888
  } );
889
 
890
  </script>
891
+ <?php
892
  }
893
 
894
  public static function renderStyle() {
class/class-mainwp-helper.php CHANGED
@@ -263,18 +263,21 @@ class MainWP_Helper {
263
  }
264
  }
265
 
 
 
266
  //Set up a new post (adding addition information)
267
- $usr = get_user_by( 'login', $_POST['user'] );
268
  //$new_post['post_author'] = $current_user->ID;
269
- $is_robot_post = false;
 
270
  if ( isset( $_POST['isMainWPRobot'] ) && ! empty( $_POST['isMainWPRobot'] ) ) {
271
  $is_robot_post = true;
272
  }
273
 
274
- $post_author = isset( $new_post['post_author'] ) ? $new_post['post_author'] : $usr->ID;
275
- if ( $is_robot_post ) {
276
  if ( 1 === $post_author ) {
277
- $new_post['post_author'] = $usr->ID;
278
  } else if ( ! is_numeric( $post_author ) ) {
279
  $user_author = get_user_by( 'login', $post_author );
280
  if ( $user_author ) {
@@ -289,12 +292,12 @@ class MainWP_Helper {
289
  if ( ! empty( $_author ) ) {
290
  $new_post['post_author'] = $_author->ID;
291
  } else {
292
- $new_post['post_author'] = $usr->ID;
293
  }
294
  unset( $new_post['custom_post_author'] );
295
  }
296
 
297
- $post_author = ! empty( $post_author ) ? $post_author : $usr->ID;
298
  $new_post['post_author'] = $post_author;
299
 
300
  $is_ezine_post = ! empty( $post_custom['_ezine_post_article_source'] ) ? true : false;
@@ -1433,6 +1436,10 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name =
1433
  return false;
1434
  }
1435
 
 
 
 
 
1436
  public static function check_files_exists( $files = array(), $return = false ) {
1437
  $missing = array();
1438
  if (is_array($files)) {
263
  }
264
  }
265
 
266
+ // current user may be connected admin or alternative admin
267
+ $current_uid = $current_user->ID;
268
  //Set up a new post (adding addition information)
269
+ //$usr = get_user_by( 'login', $_POST['user'] );
270
  //$new_post['post_author'] = $current_user->ID;
271
+
272
+ $is_robot_post = false; // retirement soon
273
  if ( isset( $_POST['isMainWPRobot'] ) && ! empty( $_POST['isMainWPRobot'] ) ) {
274
  $is_robot_post = true;
275
  }
276
 
277
+ $post_author = isset( $new_post['post_author'] ) ? $new_post['post_author'] : $current_uid;
278
+ if ( $is_robot_post ) { // retirement soon
279
  if ( 1 === $post_author ) {
280
+ $new_post['post_author'] = $current_uid;
281
  } else if ( ! is_numeric( $post_author ) ) {
282
  $user_author = get_user_by( 'login', $post_author );
283
  if ( $user_author ) {
292
  if ( ! empty( $_author ) ) {
293
  $new_post['post_author'] = $_author->ID;
294
  } else {
295
+ $new_post['post_author'] = $current_uid;
296
  }
297
  unset( $new_post['custom_post_author'] );
298
  }
299
 
300
+ $post_author = ! empty( $post_author ) ? $post_author : $current_uid;
301
  $new_post['post_author'] = $post_author;
302
 
303
  $is_ezine_post = ! empty( $post_custom['_ezine_post_article_source'] ) ? true : false;
1436
  return false;
1437
  }
1438
 
1439
+ public static function is_wp_engine() {
1440
+ return function_exists( 'is_wpe' ) && is_wpe();
1441
+ }
1442
+
1443
  public static function check_files_exists( $files = array(), $return = false ) {
1444
  $missing = array();
1445
  if (is_array($files)) {
class/class-mainwp-security.php CHANGED
@@ -318,6 +318,11 @@ class MainWP_Security {
318
  }
319
 
320
  public static function remove_readme( $force = false ) {
 
 
 
 
 
321
  if ( $force || self::get_security_option( 'readme' ) ) {
322
  if ( @file_exists( ABSPATH . 'readme.html' ) ) {
323
  if ( ! @unlink( ABSPATH . 'readme.html' ) ) {
318
  }
319
 
320
  public static function remove_readme( $force = false ) {
321
+
322
+ // to prevent remove readme.html file on WPE hosts
323
+ if ( MainWP_Helper::is_wp_engine() )
324
+ return true;
325
+
326
  if ( $force || self::get_security_option( 'readme' ) ) {
327
  if ( @file_exists( ABSPATH . 'readme.html' ) ) {
328
  if ( ! @unlink( ABSPATH . 'readme.html' ) ) {
class/class-mainwp-wordpress-seo.php CHANGED
@@ -50,7 +50,7 @@ class MainWP_Wordpress_SEO {
50
  if ( $this->import_seo_settings( $temporary_file ) ) {
51
  $information['success'] = true;
52
  } else {
53
- throw new Exception( __( 'Settings could not be imported:', 'wordpress-seo' ) );
54
  }
55
  }
56
  } catch ( Exception $e ) {
50
  if ( $this->import_seo_settings( $temporary_file ) ) {
51
  $information['success'] = true;
52
  } else {
53
+ throw new Exception( __( 'Settings could not be imported.', 'wordpress-seo' ) );
54
  }
55
  }
56
  } catch ( Exception $e ) {
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.5.3
10
  */
11
  //if ( ( isset( $_REQUEST['heatmap'] ) && '1' === $_REQUEST['heatmap'] ) || ( isset( $_REQUEST['mainwpsignature'] ) && ( ! empty( $_REQUEST['mainwpsignature'] ) ) ) ) {
12
  // header( 'X-Frame-Options: ALLOWALL' );
6
  Author: MainWP
7
  Author URI: https://mainwp.com
8
  Text Domain: mainwp-child
9
+ Version: 3.5.4
10
  */
11
  //if ( ( isset( $_REQUEST['heatmap'] ) && '1' === $_REQUEST['heatmap'] ) || ( isset( $_REQUEST['mainwpsignature'] ) && ( ! empty( $_REQUEST['mainwpsignature'] ) ) ) ) {
12
  // header( 'X-Frame-Options: ALLOWALL' );
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: 5.0.1
10
- Stable tag: 3.5.3
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
@@ -71,6 +71,17 @@ To see full documentation and FAQs please visit [MainWP Documentation](https://m
71
 
72
  == Changelog ==
73
 
 
 
 
 
 
 
 
 
 
 
 
74
  = 3.5.3 - 12-19-18 =
75
  * Fixed: an issue with the X-Frame-Options configuration
76
  * Fixed: an issue with clearing WP Rocket cache
6
  Author URI: https://mainwp.com
7
  Plugin URI: https://mainwp.com
8
  Requires at least: 3.6
9
+ Tested up to: 5.0.3
10
+ Stable tag: 3.5.4
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
71
 
72
  == Changelog ==
73
 
74
+ = 3.5.4 - 2-14-19 =
75
+ * Fixed: issues with displaying broken links data for specific setups
76
+ * Fixed: compatibility issues with the latest PageSpeed Insights plugin version
77
+ * Fixed: an issue with publishing "future" posts
78
+ * Fixed: an issue with sending email alerts in specific setups
79
+ * Fixed: an issue with saving code snippets in wp-config.php when the file is in a custom location
80
+ * Fixed: an issue with clearing unused scheduled cron jobs
81
+ * Added: support for the new PageSpeed Insights plugin options
82
+ * Updated: disabled the "Remove readme.html" security check feature for WPEngine hosted child sites
83
+ * Updated: support for detecting premium themes updates
84
+
85
  = 3.5.3 - 12-19-18 =
86
  * Fixed: an issue with the X-Frame-Options configuration
87
  * Fixed: an issue with clearing WP Rocket cache