This question already has an answer here:

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?

marked as duplicate by shanebp, Jacob Peattie, fuxia Jan 4 at 22:39

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • please try this code but i am not confirm – vikrant zilpe Dec 8 '18 at 7:35
  • global $current_screen; $current_screen = get_current_screen(); if ( ( method_exists($current_screen, 'is_block_editor') && $current_screen->is_block_editor() ) || ( function_exists('is_gutenberg_page')) && is_gutenberg_page() ) ) { // DO SOMETHING } – vikrant zilpe Dec 8 '18 at 7:35

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() ) {

You can also add to this condition

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

to be compatible with older versions.

Not the answer you're looking for? Browse other questions tagged or ask your own question.