The function is_gutenberg_page
is from the Gutenberg plugin, while the is_block_editor
method is available from 5.0. This function below combines both into a single checking function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | function is_gutenberg_page() { if ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) { // The Gutenberg plugin is on. return true; } $current_screen = get_current_screen(); if ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) { // Gutenberg page on 5+. return true; } return false; } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.