From 2931e45363998c4fc88262b342e30fe816a53431 Mon Sep 17 00:00:00 2001 From: Marin Atanasov Date: Tue, 25 Jul 2023 14:19:49 +0300 Subject: [PATCH] Experimental: Fix TinyMCE removal for heartbeat requests --- lib/experimental/disable-tinymce.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/experimental/disable-tinymce.php b/lib/experimental/disable-tinymce.php index 824f1ab9a73ae..72a39cbcb204d 100644 --- a/lib/experimental/disable-tinymce.php +++ b/lib/experimental/disable-tinymce.php @@ -61,14 +61,15 @@ function gutenberg_post_being_edited_requires_classic_block() { return false; } - // Handle the post editor. - if ( ! empty( $_GET['post'] ) && ! empty( $_GET['action'] ) && 'edit' === $_GET['action'] ) { - $current_post = get_post( intval( $_GET['post'] ) ); - if ( ! $current_post || is_wp_error( $current_post ) ) { - return false; - } + // Continue only if we're in the post editor. + if ( empty( $_GET['post'] ) || empty( $_GET['action'] ) || 'edit' !== $_GET['action'] ) { + return false; + } - $content = $current_post->post_content; + // Bail if for some reason the post isn't found. + $current_post = get_post( intval( $_GET['post'] ) ); + if ( ! $current_post || is_wp_error( $current_post ) ) { + return false; } // Check if block editor is disabled by "Classic Editor" or another plugin. @@ -79,6 +80,7 @@ function_exists( 'use_block_editor_for_post_type' ) && return true; } + $content = $current_post->post_content; if ( empty( $content ) ) { return false; }