Skip to content

Commit

Permalink
Experimental: Fix TinyMCE removal for heartbeat requests (#52935)
Browse files Browse the repository at this point in the history
* Experimental: Fix TinyMCE removal for heartbeat requests

* intval => absint

Post IDs are supposed to be non-negative integers.

Co-authored-by: George Mamadashvili <georgemamadashvili@gmail.com>

* get_post() cannot return a WP_Error

---------

Co-authored-by: George Mamadashvili <georgemamadashvili@gmail.com>
  • Loading branch information
tyxla and Mamaduka committed Jul 26, 2023
1 parent 6b1e937 commit a78a632
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/experimental/disable-tinymce.php
Original file line number Diff line number Diff line change
Expand Up @@ -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( absint( $_GET['post'] ) );
if ( ! $current_post ) {
return false;
}

// Check if block editor is disabled by "Classic Editor" or another plugin.
Expand All @@ -79,6 +80,7 @@ function_exists( 'use_block_editor_for_post_type' ) &&
return true;
}

$content = $current_post->post_content;
if ( empty( $content ) ) {
return false;
}
Expand Down

1 comment on commit a78a632

@github-actions
Copy link

@github-actions github-actions bot commented on a78a632 Jul 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in a78a632.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5666495798
📝 Reported issues:

Please sign in to comment.