MainWP Child - Version 3.5.6

Version Description

  • 3-25-19 =
  • Fixed: an issue with checking Page Speed data
  • Fixed: an issue with empty update data
  • Fixed: an issue with incorrect plugin update data
  • Added: Send From field in the Branding support form
  • Updated: compatibility with the latest Yoast SEO plugin version
Download this release

Release Info

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

Code changes from version 3.5.5 to 3.5.6

class/class-mainwp-child-branding.php CHANGED
@@ -793,13 +793,15 @@ class MainWP_Child_Branding {
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
  $mail = $headers = '';
799
  if ( ! empty( $_POST['mainwp_branding_contact_message_content'] ) && ! empty( $email ) ) {
800
  global $current_user;
801
  $headers .= "Content-Type: text/html;charset=utf-8\r\n";
802
- //$headers .= "From: \"" . $current_user->user_email . "\" <" . $current_user->user_email . ">\r\n";
 
803
  $mail .= "<p>Support Email from: <a href='" . site_url() . "'>" . site_url() . "</a></p>\r\n\r\n";
804
  $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" : "" );
805
  $mail .= "<p>Client Email: " . $current_user->user_email . " </p>\r\n\r\n";
@@ -817,6 +819,7 @@ class MainWP_Child_Branding {
817
  }
818
 
819
  function contact_support() {
 
820
  ?>
821
  <style>
822
  .mainwp_info-box-yellow {
@@ -867,6 +870,7 @@ class MainWP_Child_Branding {
867
 
868
  $support_message = $opts['support_message'];
869
  $support_message = nl2br( stripslashes( $support_message ) );
 
870
  ?>
871
  <form action="" method="post">
872
  <div style="width: 99%;">
@@ -875,7 +879,9 @@ class MainWP_Child_Branding {
875
  <div style="height: auto; margin-bottom: 10px; text-align: left">
876
  <p><?php echo wp_kses_post( $support_message ); ?></p>
877
  <p><label for="mainwp_branding_contact_message_subject"><?php _e('Subject:', 'mainwp-child'); ?></label><br>
878
- <input type="text" name="mainwp_branding_contact_message_subject" style="width: 650px;"></p>
 
 
879
  <div style="max-width: 650px;">
880
  <label for="mainwp_branding_contact_message_content"><?php _e('Your message:', 'mainwp-child'); ?></label><br>
881
  <?php
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
+ $from = trim($_POST['mainwp_branding_contact_send_from']);
797
  $subject = !empty( $sub ) ? $sub : "MainWP - Support Contact";
798
  $content = wp_kses_post( nl2br( stripslashes( $_POST['mainwp_branding_contact_message_content'] ) ) );
799
  $mail = $headers = '';
800
  if ( ! empty( $_POST['mainwp_branding_contact_message_content'] ) && ! empty( $email ) ) {
801
  global $current_user;
802
  $headers .= "Content-Type: text/html;charset=utf-8\r\n";
803
+ if (!empty($from))
804
+ $headers .= "From: \"" . $from . "\" <" . $from . ">\r\n";
805
  $mail .= "<p>Support Email from: <a href='" . site_url() . "'>" . site_url() . "</a></p>\r\n\r\n";
806
  $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" : "" );
807
  $mail .= "<p>Client Email: " . $current_user->user_email . " </p>\r\n\r\n";
819
  }
820
 
821
  function contact_support() {
822
+ global $current_user;
823
  ?>
824
  <style>
825
  .mainwp_info-box-yellow {
870
 
871
  $support_message = $opts['support_message'];
872
  $support_message = nl2br( stripslashes( $support_message ) );
873
+ $from_email = $current_user ? $current_user->user_email : '';
874
  ?>
875
  <form action="" method="post">
876
  <div style="width: 99%;">
879
  <div style="height: auto; margin-bottom: 10px; text-align: left">
880
  <p><?php echo wp_kses_post( $support_message ); ?></p>
881
  <p><label for="mainwp_branding_contact_message_subject"><?php _e('Subject:', 'mainwp-child'); ?></label><br>
882
+ <input type="text" id="mainwp_branding_contact_message_subject" name="mainwp_branding_contact_message_subject" style="width: 650px;"></p>
883
+ <p><label for="mainwp_branding_contact_send_from"><?php _e('From:', 'mainwp-child'); ?></label><br>
884
+ <input type="text" id="mainwp_branding_contact_send_from" name="mainwp_branding_contact_send_from" style="width: 650px;" value="<?php echo esc_html( $from_email ); ?>"></p>
885
  <div style="max-width: 650px;">
886
  <label for="mainwp_branding_contact_message_content"><?php _e('Your message:', 'mainwp-child'); ?></label><br>
887
  <?php
class/class-mainwp-child-pagespeed.php CHANGED
@@ -272,7 +272,8 @@ class MainWP_Child_Pagespeed {
272
  if ( $checkstatus ) {
273
  $information['error'] = __( 'The API is busy checking other pages, please try again later.', 'gpagespeedi' );
274
  } else {
275
- do_action( 'googlepagespeedinsightsworker', array(), $forceRecheck );
 
276
  $information['checked_pages'] = 1;
277
  }
278
  }
272
  if ( $checkstatus ) {
273
  $information['error'] = __( 'The API is busy checking other pages, please try again later.', 'gpagespeedi' );
274
  } else {
275
+ //do_action( 'googlepagespeedinsightsworker', array(), $forceRecheck );
276
+ do_action( 'run_gpi', $forceRecheck ); // to fix
277
  $information['checked_pages'] = 1;
278
  }
279
  }
class/class-mainwp-child-updraft-plus-backups.php CHANGED
@@ -928,7 +928,8 @@ class MainWP_Child_Updraft_Plus_Backups {
928
  );
929
 
930
  // to fix issue for some site
931
- //$this->close_browser_connection( $msg );
 
932
 
933
  $options = array( 'nocloud' => $backupnow_nocloud, 'use_nonce' => $nonce );
934
  if ( ! empty( $_REQUEST['onlythisfileentity'] ) && is_string( $_REQUEST['onlythisfileentity'] ) ) {
928
  );
929
 
930
  // to fix issue for some site
931
+ // unfix for tic#22678
932
+ $this->close_browser_connection( $msg );
933
 
934
  $options = array( 'nocloud' => $backupnow_nocloud, 'use_nonce' => $nonce );
935
  if ( ! empty( $_REQUEST['onlythisfileentity'] ) && is_string( $_REQUEST['onlythisfileentity'] ) ) {
class/class-mainwp-child.php CHANGED
@@ -115,7 +115,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
115
  }
116
 
117
  class MainWP_Child {
118
- public static $version = '3.5.5';
119
  private $update_version = '1.5';
120
 
121
  private $callableFunctions = array(
@@ -3819,6 +3819,11 @@ class MainWP_Child {
3819
  continue;
3820
  }
3821
 
 
 
 
 
 
3822
  $information['plugin_updates'][ $slug ] = $plugin_update;
3823
  }
3824
  }
@@ -3834,6 +3839,10 @@ class MainWP_Child {
3834
  $information['plugin_updates'] = array();
3835
  }
3836
  foreach( $cached_plugins_update as $slug => $plugin_update ) {
 
 
 
 
3837
  if ( !isset( $information['plugin_updates'][ $slug ] ) ) {
3838
  $information['plugin_updates'][ $slug ] = $plugin_update;
3839
  }
@@ -3894,7 +3903,8 @@ class MainWP_Child {
3894
  if ( 'plugin' === $translation_update->type ) {
3895
  $all_plugins = get_plugins();
3896
  foreach ( $all_plugins as $file => $plugin ) {
3897
- if ( stristr( $file, $translation_update->slug ) ) {
 
3898
  $new_translation_update['name'] = $plugin['Name'];
3899
  break;
3900
  }
115
  }
116
 
117
  class MainWP_Child {
118
+ public static $version = '3.5.6';
119
  private $update_version = '1.5';
120
 
121
  private $callableFunctions = array(
3819
  continue;
3820
  }
3821
 
3822
+ // to fix incorrect info
3823
+ if ( !property_exists( $plugin_update, 'update' ) || !property_exists( $plugin_update->update, 'new_version' ) || empty($plugin_update->update->new_version)) {
3824
+ continue;
3825
+ }
3826
+
3827
  $information['plugin_updates'][ $slug ] = $plugin_update;
3828
  }
3829
  }
3839
  $information['plugin_updates'] = array();
3840
  }
3841
  foreach( $cached_plugins_update as $slug => $plugin_update ) {
3842
+ // to fix incorrect info
3843
+ if ( !property_exists( $plugin_update, 'new_version' ) || empty( $plugin_update->new_version ) ) {
3844
+ continue;
3845
+ }
3846
  if ( !isset( $information['plugin_updates'][ $slug ] ) ) {
3847
  $information['plugin_updates'][ $slug ] = $plugin_update;
3848
  }
3903
  if ( 'plugin' === $translation_update->type ) {
3904
  $all_plugins = get_plugins();
3905
  foreach ( $all_plugins as $file => $plugin ) {
3906
+ $path = dirname($file);
3907
+ if ( $path == $translation_update->slug ) {
3908
  $new_translation_update['name'] = $plugin['Name'];
3909
  break;
3910
  }
class/class-mainwp-helper.php CHANGED
@@ -134,17 +134,45 @@ class MainWP_Helper {
134
  if ( is_wp_error( $temporary_file ) ) {
135
  throw new Exception( 'Error: ' . $temporary_file->get_error_message() );
136
  } else {
137
- $local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . basename( $img_url ); //Local name
 
138
  $local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path );
139
 
140
  $gen_unique_fn = true;
141
 
 
142
  if ( $check_file_existed ) {
143
  if ( file_exists( $local_img_path ) ) {
 
144
  if ( filesize( $local_img_path ) == filesize( $temporary_file ) ) { // file exited
145
- $attach_id = attachment_url_to_postid( $local_img_url );
146
- if ( $attach_id ) { // found attachment
147
- return array( 'id' => $attach_id, 'url' => $local_img_url );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  }
149
  }
150
  }
@@ -189,10 +217,17 @@ class MainWP_Helper {
189
  return null;
190
  }
191
 
192
- static function get_image_id($image_url) {
193
- global $wpdb;
194
- $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_url ));
195
- return $attachment[0];
 
 
 
 
 
 
 
196
  }
197
 
198
  static function uploadFile( $file_url, $path, $file_name ) {
134
  if ( is_wp_error( $temporary_file ) ) {
135
  throw new Exception( 'Error: ' . $temporary_file->get_error_message() );
136
  } else {
137
+ $filename = basename( $img_url );
138
+ $local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . $filename; //Local name
139
  $local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path );
140
 
141
  $gen_unique_fn = true;
142
 
143
+ // to fix issue re-create new attachment
144
  if ( $check_file_existed ) {
145
  if ( file_exists( $local_img_path ) ) {
146
+
147
  if ( filesize( $local_img_path ) == filesize( $temporary_file ) ) { // file exited
148
+ $result = self::get_maybe_existed_attached_id( $local_img_url );
149
+ if ( is_array($result) ) { // found attachment
150
+ $attach = current($result);
151
+ if (is_object($attach)) {
152
+ if ( file_exists( $temporary_file ) ) {
153
+ unlink( $temporary_file );
154
+ }
155
+ return array( 'id' => $attach->ID, 'url' => $local_img_url );
156
+ }
157
+ }
158
+ }
159
+
160
+ } else { // find in other path
161
+ $result = self::get_maybe_existed_attached_id( $filename, false );
162
+
163
+ if ( is_array( $result ) ) { // found attachment
164
+ $attach = current($result);
165
+ if (is_object($attach)) {
166
+ $basedir = $upload_dir['basedir'];
167
+ $baseurl = $upload_dir['baseurl'];
168
+ $local_img_path = str_replace( $baseurl, $basedir, $attach->guid );
169
+ if ( file_exists($local_img_path) && (filesize( $local_img_path ) == filesize( $temporary_file )) ) { // file exited
170
+
171
+ if ( file_exists( $temporary_file ) ) {
172
+ unlink( $temporary_file );
173
+ }
174
+ return array( 'id' => $attach->ID, 'url' => $attach->guid );
175
+ }
176
  }
177
  }
178
  }
217
  return null;
218
  }
219
 
220
+ static function get_maybe_existed_attached_id( $filename, $full_guid = true ) {
221
+ global $wpdb;
222
+ if ( $full_guid ) {
223
+ $sql = $wpdb->prepare(
224
+ "SELECT ID,guid FROM $wpdb->posts WHERE post_type = 'attachment' AND guid = %s",
225
+ $filename
226
+ );
227
+ } else {
228
+ $sql = "SELECT ID,guid FROM $wpdb->posts WHERE post_type = 'attachment' AND guid LIKE '%/" . $filename . "'";
229
+ }
230
+ return $wpdb->get_results( $sql );
231
  }
232
 
233
  static function uploadFile( $file_url, $path, $file_name ) {
class/class-mainwp-wordpress-seo.php CHANGED
@@ -53,28 +53,62 @@ class MainWP_Wordpress_SEO {
53
  }
54
 
55
  public function import_settings() {
56
- $file_url = base64_decode( $_POST['file_url'] );
57
- $temporary_file = '';
58
- try {
59
- include_once( ABSPATH . 'wp-admin/includes/file.php' ); //Contains download_url
60
- $temporary_file = download_url( $file_url );
61
-
62
- if ( is_wp_error( $temporary_file ) ) {
63
- throw new Exception( 'Error: ' . $temporary_file->get_error_message() );
64
- } else {
65
- if ( $this->import_seo_settings( $temporary_file ) ) {
66
- $information['success'] = true;
67
- } else {
68
- throw new Exception( __( 'Settings could not be imported.', 'wordpress-seo' ) );
69
- }
70
- }
71
- } catch ( Exception $e ) {
72
- $information['error'] = $e->getMessage();
73
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
 
75
- if ( file_exists( $temporary_file ) ) {
76
- unlink( $temporary_file );
77
- }
78
  MainWP_Helper::write( $information );
79
  }
80
 
53
  }
54
 
55
  public function import_settings() {
56
+ // to compatible
57
+ if ( isset($_POST['file_url']) ) {
58
+ $file_url = base64_decode( $_POST['file_url'] );
59
+ $temporary_file = '';
60
+ try {
61
+ include_once( ABSPATH . 'wp-admin/includes/file.php' ); //Contains download_url
62
+ $temporary_file = download_url( $file_url );
63
+
64
+ if ( is_wp_error( $temporary_file ) ) {
65
+ throw new Exception( 'Error: ' . $temporary_file->get_error_message() );
66
+ } else {
67
+ if ( $this->import_seo_settings( $temporary_file ) ) {
68
+ $information['success'] = true;
69
+ } else {
70
+ throw new Exception( __( 'Settings could not be imported.', 'wordpress-seo' ) );
71
+ }
72
+ }
73
+ } catch ( Exception $e ) {
74
+ $information['error'] = $e->getMessage();
75
+ }
76
+
77
+ if ( file_exists( $temporary_file ) ) {
78
+ unlink( $temporary_file );
79
+ }
80
+
81
+ } else if ( isset( $_POST['settings'] ) ) {
82
+ try {
83
+ $settings = base64_decode( $_POST['settings'] );
84
+ // @codingStandardsIgnoreLine
85
+ $options = parse_ini_string( $settings, true, INI_SCANNER_RAW ); // phpcs:ignore PHPCompatibility.FunctionUse.NewFunctions.parse_ini_stringFound -- We won't get to this function if PHP < 5.3 due to the WPSEO_NAMESPACES check above.
86
+ if ( is_array( $options ) && array() !== $options ) {
87
+
88
+ $old_wpseo_version = null;
89
+ if ( isset( $options['wpseo']['version'] ) && '' !== $options['wpseo']['version'] ) {
90
+ $old_wpseo_version = $options['wpseo']['version'];
91
+ }
92
+ foreach ( $options as $name => $optgroup ) {
93
+ if ( 'wpseo_taxonomy_meta' === $name ) {
94
+ $optgroup = json_decode( urldecode( $optgroup['wpseo_taxonomy_meta'] ), true );
95
+ }
96
+ // Make sure that the imported options are cleaned/converted on import
97
+ $option_instance = WPSEO_Options::get_option_instance( $name );
98
+ if ( is_object( $option_instance ) && method_exists( $option_instance, 'import' ) ) {
99
+ $optgroup = $option_instance->import( $optgroup, $old_wpseo_version, $options );
100
+ }
101
+ }
102
+ $information['success'] = true;
103
+
104
+ } else {
105
+ throw new Exception( __( 'Settings could not be imported:', 'wordpress-seo' ) );
106
+ }
107
+ } catch ( Exception $e ) {
108
+ $information['error'] = $e->getMessage();
109
+ }
110
+ }
111
 
 
 
 
112
  MainWP_Helper::write( $information );
113
  }
114
 
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.5
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.6
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.1
10
- Stable tag: 3.5.5
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
@@ -71,6 +71,13 @@ To see full documentation and FAQs please visit [MainWP Documentation](https://m
71
 
72
  == Changelog ==
73
 
 
 
 
 
 
 
 
74
  = 3.5.5 - 3-6-19 =
75
  * Fixed: an issue with hook for controlling branding options for specific roles
76
  * Fixed: branding issues
6
  Author URI: https://mainwp.com
7
  Plugin URI: https://mainwp.com
8
  Requires at least: 3.6
9
+ Tested up to: 5.1.1
10
+ Stable tag: 3.5.6
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.6 - 3-25-19 =
75
+ * Fixed: an issue with checking Page Speed data
76
+ * Fixed: an issue with empty update data
77
+ * Fixed: an issue with incorrect plugin update data
78
+ * Added: Send From field in the Branding support form
79
+ * Updated: compatibility with the latest Yoast SEO plugin version
80
+
81
  = 3.5.5 - 3-6-19 =
82
  * Fixed: an issue with hook for controlling branding options for specific roles
83
  * Fixed: branding issues