From d330218e99421ad9af9be3a9c1eecd857d7020c3 Mon Sep 17 00:00:00 2001 From: Dreb Bits Date: Fri, 15 Mar 2019 03:34:04 +0800 Subject: [PATCH 1/4] Bypass check_admin_referrer call in the use_block_editor_for_post Since WordPress 5.1 will do a check_admin_referrer() inside the use_block_editor_for_posts(), and this call would fail and returns a 404 if there's custom meta box. Unsetting the 'meta-box-loader' in the global request would bypass that check. --- includes/utils.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/includes/utils.php b/includes/utils.php index 24b3631b2..5b804b592 100644 --- a/includes/utils.php +++ b/includes/utils.php @@ -55,6 +55,27 @@ function is_using_gutenberg( $post ) { return false; } + /** + * WordPress 5.1 will do a check_admin_referrer() inside the use_block_editor_for_posts(), + * and this call would fail and returns a 404 if there's custom meta box. + * + * Unsetting the 'meta-box-loader' in the global request would bypass that check. + */ + if ( isset( $_GET['meta-box-loader'] ) ) { + $meta_box_loader = $_GET['meta-box-loader']; + unset( $_GET['meta-box-loader'] ); + } + + $use_block_editor = use_block_editor_for_post( $post ); + + /** + * Set the $meta_box_loader back to the request, if it exists + * so other areas that rely on it would still work. + */ + if ( isset( $meta_box_loader ) ) { + $_GET['meta-box-loader'] = $meta_box_loader; + } + return use_block_editor_for_post( $post ); } From 19dd599231a1fd1d0239b2596018d1e7949d8844 Mon Sep 17 00:00:00 2001 From: Dreb Bits Date: Fri, 15 Mar 2019 21:13:32 +0800 Subject: [PATCH 2/4] Update the correct WP core version, and the return data --- includes/utils.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/utils.php b/includes/utils.php index 5b804b592..e656617a4 100644 --- a/includes/utils.php +++ b/includes/utils.php @@ -56,8 +56,8 @@ function is_using_gutenberg( $post ) { } /** - * WordPress 5.1 will do a check_admin_referrer() inside the use_block_editor_for_posts(), - * and this call would fail and returns a 404 if there's custom meta box. + * WordPress 5.0 will do a check_admin_referrer() inside the use_block_editor_for_posts(), + * and this call would fail, returns a 404 if there's custom meta box, and kills the request. * * Unsetting the 'meta-box-loader' in the global request would bypass that check. */ @@ -76,7 +76,7 @@ function is_using_gutenberg( $post ) { $_GET['meta-box-loader'] = $meta_box_loader; } - return use_block_editor_for_post( $post ); + return $use_block_editor; } From 07e0053a0c067c6a881fa97d29f7a19c01323f70 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Fri, 15 Mar 2019 11:48:25 -0600 Subject: [PATCH 3/4] bump version to 1.4.1 --- distributor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/distributor.php b/distributor.php index 72af073dc..77dc18194 100644 --- a/distributor.php +++ b/distributor.php @@ -2,7 +2,7 @@ /** * Plugin Name: Distributor * Description: Makes it easy to syndicate and reuse content across your websites, whether inside of a multisite or across the web. - * Version: 1.4.0 + * Version: 1.4.1 * Author: 10up Inc. * Author URI: https://distributorplugin.com * License: GPLv2 or later @@ -17,7 +17,7 @@ exit; // Exit if accessed directly. } -define( 'DT_VERSION', '1.4.0-dev' ); +define( 'DT_VERSION', '1.4.1-dev' ); define( 'DT_PLUGIN_FILE', preg_replace( '#^.*plugins/(.*)$#i', '$1', __FILE__ ) ); // Define a constant if we're network activated to allow plugin to respond accordingly. From b8ef4b3420041c53d7517c493a9f5adf1e314612 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Fri, 15 Mar 2019 11:55:41 -0600 Subject: [PATCH 4/4] update changelog for 1.4.1 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index be1ee710e..2c3f534f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file, per [the Keep a Changelog standard](http://keepachangelog.com/). +## [ 1.4.1 ] - 2019-03-15 +### Fixed +* Improve block editor detection, correcting an issue with post saving. + ## [ 1.4.0 ] - 2019-03-07 ### Added * Clearer instructions and help text when adding an external connection.