Previously I could use is_gutenberg_page(), but this function seems to be gone after 5.0 release.

Any tips on how to check if current admin page is gutenberg editor?

1 Answer
1

In 5.0 new function was introduced (docs):

WP_Screen::is_block_editor( bool $set = null )

which sets or returns whether the block editor is loading on the current screen.

So you can do that check using this code:

global $current_screen;
$current_screen = get_current_screen();
if ( method_exists($current_screen, 'is_block_editor') && $current_screen->is_block_editor() ) {
    // DO SOMETHING
}

You can also add to this condition

|| ( function_exists('is_gutenberg_page')) && is_gutenberg_page() )

to be compatible with older versions.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *