diff --git a/includes/classes/ExternalConnections/WordPressExternalConnection.php b/includes/classes/ExternalConnections/WordPressExternalConnection.php index 7f452d3c7..e95c1fd85 100644 --- a/includes/classes/ExternalConnections/WordPressExternalConnection.php +++ b/includes/classes/ExternalConnections/WordPressExternalConnection.php @@ -912,7 +912,7 @@ private function to_wp_post( $post ) { $obj->ping_status = $post['ping_status']; // Use raw content if both remote and local are using Gutenberg. - $obj->post_content = \Distributor\Utils\is_using_gutenberg( new \WP_Post( $obj ) ) && isset( $post['is_using_gutenberg'] ) ? + $obj->post_content = Utils\is_using_gutenberg( new \WP_Post( $obj ) ) && isset( $post['is_using_gutenberg'] ) ? $post['content']['raw'] : Utils\get_processed_content( $post['content']['raw'] ); diff --git a/includes/utils.php b/includes/utils.php index 7cbc30182..a24c6d4f1 100644 --- a/includes/utils.php +++ b/includes/utils.php @@ -34,11 +34,8 @@ function is_vip_com() { * @return boolean */ function is_using_gutenberg( $post ) { - if ( empty( $post->post_content ) ) { - return false; - } - global $wp_version; + $gutenberg_available = function_exists( 'the_gutenberg_project' ); $version_5_plus = version_compare( $wp_version, '5', '>=' ); @@ -46,12 +43,31 @@ function is_using_gutenberg( $post ) { return false; } - if ( function_exists( 'use_block_editor_for_post' ) ) { - return use_block_editor_for_post( $post ); - } else { + if ( ! empty( $post->post_content ) ) { + if ( function_exists( 'use_block_editor_for_post' ) ) { + return use_block_editor_for_post( $post ); + } + // This duplicates the check from `has_blocks()` as of WP 5.2. return false !== strpos( (string) $post->post_content, '