MainWP Child - Version 4.2.4

Version Description

  • 7-14-2022 =
  • Fixed: An issue with falling back to the Filesystem API in chrooted configurations
  • Fixed: Compatibility issues with the new version of the WP Staging plugin
  • Fixed: A problem with overwriting page attributes
Download this release

Release Info

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

Code changes from version 4.2.3 to 4.2.4

class/class-mainwp-child-posts.php CHANGED
@@ -746,8 +746,12 @@ class MainWP_Child_Posts {
746
  }
747
  $new_post['post_status'] = $post_status; // child reports: to logging as update post.
748
  }
749
- $wp_error = null;
750
- $new_post_id = wp_insert_post( $new_post, $wp_error ); // insert post.
 
 
 
 
751
  // Show errors if something went wrong.
752
  if ( is_wp_error( $wp_error ) ) {
753
  return $wp_error->get_error_message();
@@ -1328,6 +1332,12 @@ class MainWP_Child_Posts {
1328
  '_mainwp_replace_advance_img',
1329
  );
1330
 
 
 
 
 
 
 
1331
  if ( is_array( $post_custom ) ) {
1332
  foreach ( $post_custom as $meta_key => $meta_values ) {
1333
  if ( ! in_array( $meta_key, $not_allowed ) ) {
@@ -1396,6 +1406,7 @@ class MainWP_Child_Posts {
1396
  $upload = MainWP_Utility::upload_image( $_seo_opengraph_image ); // Upload image to WP.
1397
  if ( null !== $upload ) {
1398
  update_post_meta( $new_post_id, \WPSEO_Meta::$meta_prefix . 'opengraph-image', $upload['url'] ); // Add the image to the post!
 
1399
  }
1400
  } catch ( \Exception $e ) {
1401
  // ok!
746
  }
747
  $new_post['post_status'] = $post_status; // child reports: to logging as update post.
748
  }
749
+ $wp_error = false;
750
+ if ( $edit_post_id ) {
751
+ $new_post_id = wp_update_post( $new_post, $wp_error ); // to fix: update post.
752
+ } else {
753
+ $new_post_id = wp_insert_post( $new_post, $wp_error ); // insert post.
754
+ }
755
  // Show errors if something went wrong.
756
  if ( is_wp_error( $wp_error ) ) {
757
  return $wp_error->get_error_message();
1332
  '_mainwp_replace_advance_img',
1333
  );
1334
 
1335
+ if ( $seo_ext_activated ) {
1336
+ // update those custom fields later.
1337
+ $not_allowed[] = \WPSEO_Meta::$meta_prefix . 'opengraph-image-id';
1338
+ $not_allowed[] = \WPSEO_Meta::$meta_prefix . 'opengraph-image';
1339
+ }
1340
+
1341
  if ( is_array( $post_custom ) ) {
1342
  foreach ( $post_custom as $meta_key => $meta_values ) {
1343
  if ( ! in_array( $meta_key, $not_allowed ) ) {
1406
  $upload = MainWP_Utility::upload_image( $_seo_opengraph_image ); // Upload image to WP.
1407
  if ( null !== $upload ) {
1408
  update_post_meta( $new_post_id, \WPSEO_Meta::$meta_prefix . 'opengraph-image', $upload['url'] ); // Add the image to the post!
1409
+ update_post_meta( $new_post_id, \WPSEO_Meta::$meta_prefix . 'opengraph-image-id', $upload['id'] ); // Add the id image to the post!
1410
  }
1411
  } catch ( \Exception $e ) {
1412
  // ok!
class/class-mainwp-child-staging.php CHANGED
@@ -385,7 +385,36 @@ class MainWP_Child_Staging {
385
  }
386
  } else {
387
  $this->url = '';
388
- $cloning = new \WPStaging\Backend\Modules\Jobs\Cloning();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
389
 
390
  if ( ! $cloning->save() ) {
391
  return;
385
  }
386
  } else {
387
  $this->url = '';
388
+
389
+ // to compatible with new version.
390
+ if ( class_exists( '\WPStaging\Framework\Database\SelectedTables' ) ) {
391
+
392
+ if ( isset( $_POST['includedTables'] ) && is_array( $_POST['includedTables'] ) ) {
393
+ $_POST['includedTables'] = implode( \WPStaging\Framework\Filesystem\Scanning\ScanConst::DIRECTORIES_SEPARATOR, $_POST['includedTables'] );
394
+ }
395
+
396
+ if ( isset( $_POST['excludedTables'] ) && is_array( $_POST['excludedTables'] ) ) {
397
+ $_POST['excludedTables'] = implode( \WPStaging\Framework\Filesystem\Scanning\ScanConst::DIRECTORIES_SEPARATOR, $_POST['excludedTables'] );
398
+ }
399
+
400
+ if ( isset( $_POST['selectedTablesWithoutPrefix'] ) && is_array( $_POST['selectedTablesWithoutPrefix'] ) ) {
401
+ $_POST['selectedTablesWithoutPrefix'] = implode( \WPStaging\Framework\Filesystem\Scanning\ScanConst::DIRECTORIES_SEPARATOR, $_POST['selectedTablesWithoutPrefix'] );
402
+ }
403
+
404
+ if ( isset( $_POST['includedDirectories'] ) && is_array( $_POST['includedDirectories'] ) ) {
405
+ $_POST['includedDirectories'] = implode( \WPStaging\Framework\Filesystem\Scanning\ScanConst::DIRECTORIES_SEPARATOR, $_POST['includedDirectories'] );
406
+ }
407
+
408
+ if ( isset( $_POST['excludedDirectories'] ) && is_array( $_POST['excludedDirectories'] ) ) {
409
+ $_POST['excludedDirectories'] = implode( \WPStaging\Framework\Filesystem\Scanning\ScanConst::DIRECTORIES_SEPARATOR, $_POST['excludedDirectories'] );
410
+ }
411
+
412
+ if ( isset( $_POST['extraDirectories'] ) && is_array( $_POST['extraDirectories'] ) ) {
413
+ $_POST['extraDirectories'] = implode( \WPStaging\Framework\Filesystem\Scanning\ScanConst::DIRECTORIES_SEPARATOR, $_POST['extraDirectories'] );
414
+ }
415
+ }
416
+
417
+ $cloning = new \WPStaging\Backend\Modules\Jobs\Cloning();
418
 
419
  if ( ! $cloning->save() ) {
420
  return;
class/class-mainwp-child.php CHANGED
@@ -33,7 +33,7 @@ class MainWP_Child {
33
  *
34
  * @var string MainWP Child plugin version.
35
  */
36
- public static $version = '4.2.3';
37
 
38
  /**
39
  * Private variable containing the latest MainWP Child update version.
33
  *
34
  * @var string MainWP Child plugin version.
35
  */
36
+ public static $version = '4.2.4';
37
 
38
  /**
39
  * Private variable containing the latest MainWP Child update version.
class/class-mainwp-custom-post-type.php CHANGED
@@ -203,7 +203,7 @@ class MainWP_Custom_Post_Type {
203
  *
204
  * @return array|bool|string[] Response array, true|false, Error message.
205
  */
206
- private function insert_post( $data, $edit_id, $parent_id = 0 ) {
207
  $data_insert = array();
208
  $data_post = $data['post'];
209
  $data_insert['post_author'] = get_current_user_id();
@@ -280,7 +280,13 @@ class MainWP_Custom_Post_Type {
280
  if ( ! empty( $parent_id ) ) {
281
  $data_insert['post_parent'] = $parent_id;
282
  }
283
- $post_id = wp_insert_post( $data_insert, true );
 
 
 
 
 
 
284
  if ( is_wp_error( $post_id ) ) {
285
  return array( 'error' => __( 'Error when insert new post:', $this->plugin_translate ) . ' ' . $post_id->get_error_message() );
286
  }
203
  *
204
  * @return array|bool|string[] Response array, true|false, Error message.
205
  */
206
+ private function insert_post( $data, $edit_id, $parent_id = 0 ) { // phpcs:ignore -- required to achieve desired results, pull request solutions appreciated.
207
  $data_insert = array();
208
  $data_post = $data['post'];
209
  $data_insert['post_author'] = get_current_user_id();
280
  if ( ! empty( $parent_id ) ) {
281
  $data_insert['post_parent'] = $parent_id;
282
  }
283
+
284
+ if ( ! empty( $edit_id ) ) {
285
+ $post_id = wp_update_post( $data_insert, true );
286
+ } else {
287
+ $post_id = wp_insert_post( $data_insert, true );
288
+ }
289
+
290
  if ( is_wp_error( $post_id ) ) {
291
  return array( 'error' => __( 'Error when insert new post:', $this->plugin_translate ) . ' ' . $post_id->get_error_message() );
292
  }
class/class-mainwp-security.php CHANGED
@@ -336,11 +336,12 @@ class MainWP_Security {
336
  */
337
  global $wp_filesystem;
338
 
 
339
  if ( $force || self::get_security_option( 'readme' ) ) {
340
- if ( $wp_filesystem->exists( ABSPATH . 'readme.html' ) ) {
341
  if ( ! unlink( ABSPATH . 'readme.html' ) ) {
342
- $wp_filesystem->delete( ABSPATH . 'readme.html' );
343
- if ( $wp_filesystem->exists( ABSPATH . 'readme.html' ) ) {
344
  // prevent repeat delete.
345
  self::update_security_option( 'readme', false );
346
  }
336
  */
337
  global $wp_filesystem;
338
 
339
+ $abs_path = $wp_filesystem->abspath();
340
  if ( $force || self::get_security_option( 'readme' ) ) {
341
+ if ( $wp_filesystem->exists( $abs_path . 'readme.html' ) ) {
342
  if ( ! unlink( ABSPATH . 'readme.html' ) ) {
343
+ $wp_filesystem->delete( $abs_path . 'readme.html' );
344
+ if ( $wp_filesystem->exists( $abs_path . 'readme.html' ) ) {
345
  // prevent repeat delete.
346
  self::update_security_option( 'readme', false );
347
  }
class/class-mainwp-utility.php CHANGED
@@ -458,7 +458,8 @@ class MainWP_Utility {
458
  }
459
 
460
  $allowed_files = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico' );
461
- $file_ext = strtolower( end( explode( '.', $filename ) ) );
 
462
  if ( ! in_array( $file_ext, $allowed_files ) ) {
463
  return false;
464
  }
458
  }
459
 
460
  $allowed_files = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico' );
461
+ $names = explode( '.', $filename );
462
+ $file_ext = strtolower( end( $names ) );
463
  if ( ! in_array( $file_ext, $allowed_files ) ) {
464
  return false;
465
  }
mainwp-child.php CHANGED
@@ -12,7 +12,7 @@
12
  * Author: MainWP
13
  * Author URI: https://mainwp.com
14
  * Text Domain: mainwp-child
15
- * Version: 4.2.3
16
  * Requires at least: 5.4
17
  * Requires PHP: 7.0
18
  */
@@ -25,7 +25,9 @@ require_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'version.php'; // V
25
  * @const ( bool ) Whether or not MainWP Child is in debug mode. Default: false.
26
  * @source https://code-reference.mainwp.com/classes/MainWP.Child.MainWP_Child.html
27
  */
28
- define( 'MAINWP_CHILD_DEBUG', false );
 
 
29
 
30
  if ( ! defined( 'MAINWP_CHILD_FILE' ) ) {
31
 
12
  * Author: MainWP
13
  * Author URI: https://mainwp.com
14
  * Text Domain: mainwp-child
15
+ * Version: 4.2.4
16
  * Requires at least: 5.4
17
  * Requires PHP: 7.0
18
  */
25
  * @const ( bool ) Whether or not MainWP Child is in debug mode. Default: false.
26
  * @source https://code-reference.mainwp.com/classes/MainWP.Child.MainWP_Child.html
27
  */
28
+ if ( ! defined( 'MAINWP_CHILD_DEBUG' ) ) {
29
+ define( 'MAINWP_CHILD_DEBUG', false );
30
+ }
31
 
32
  if ( ! defined( 'MAINWP_CHILD_FILE' ) ) {
33
 
readme.txt CHANGED
@@ -5,9 +5,9 @@ Author: mainwp
5
  Author URI: https://mainwp.com
6
  Plugin URI: https://mainwp.com
7
  Requires at least: 5.4
8
- Tested up to: 6.0
9
  Requires PHP: 7.0
10
- Stable tag: 4.2.3
11
  License: GPLv3 or later
12
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
13
 
@@ -111,6 +111,11 @@ Sure we have a quick FAQ with a lot more questions and answers [here](https://ma
111
 
112
  == Changelog ==
113
 
 
 
 
 
 
114
  = 4.2.3 - 5-16-2022 =
115
  Added: Swift Performance Pro to the Purge Cache system
116
 
5
  Author URI: https://mainwp.com
6
  Plugin URI: https://mainwp.com
7
  Requires at least: 5.4
8
+ Tested up to: 6.0.1
9
  Requires PHP: 7.0
10
+ Stable tag: 4.2.4
11
  License: GPLv3 or later
12
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
13
 
111
 
112
  == Changelog ==
113
 
114
+ = 4.2.4 - 7-14-2022 =
115
+ * Fixed: An issue with falling back to the Filesystem API in chrooted configurations
116
+ * Fixed: Compatibility issues with the new version of the WP Staging plugin
117
+ * Fixed: A problem with overwriting page attributes
118
+
119
  = 4.2.3 - 5-16-2022 =
120
  Added: Swift Performance Pro to the Purge Cache system
121