[wp-trac] [WordPress Trac] #65335: Show a warning message about a commented-out Gutenberg block in the Classic Editor.

WordPress Trac noreply at wordpress.org
Mon May 25 09:00:50 UTC 2026


#65335: Show a warning message about a commented-out Gutenberg block in the Classic
Editor.
-----------------------------+------------------------------
 Reporter:  blackstar1991    |       Owner:  (none)
     Type:  feature request  |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Editor           |     Version:
 Severity:  normal           |  Resolution:
 Keywords:  has-patch        |     Focuses:  ui, ui-copy
-----------------------------+------------------------------

Comment (by dhrumilk):

 {{{
 <?php
 if (
         isset( $post->post_content ) &&
         str_contains( (string) $post->post_content, '<!-- wp:' )
 ) {
         wp_admin_notice(
                         __(
                         'This content includes blocks, and some of the
 block content might not display in the Visual editor. Please review the
 content carefully before overwriting or deleting it.',
                         'your-text-domain'
                 ),
                 array(
                         'type'        => 'warning',
                         'dismissible' => true,
                 )
         );
 }
 ?>
 }}}

 This code follows WordPress best practices by safely checking if block
 content exists before running the logic, which prevents PHP warnings and
 improves stability. It also uses proper escaping and translation functions
 to keep the admin notice secure, maintainable, and translation-ready.

 This is my suggestion for improving the code by following WordPress coding
 standards, adding safer checks, and improving maintainability.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/65335#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list