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.
Related Posts:
- Deactivate Gutenberg tips forever – not Gutenberg
- How do I register multiple blocks with block.json and register_block_type_from_metadata?
- Disable Gutenberg text-Settings in all blocks
- gutenberg block – how to force update after attribute changed?
- How can I add a custom attribute to Gutenberg core blocks?
- Add additional classes to gutenberg .editor-styles-wrapper
- How to use the WordPress < LinkControl /> Component
- Remove border radius setting from the Gutenberg button block?
- Add PHP block template to content using wp_insert_post
- Gutenberg reusable blocks – is it possible to customise an instance?
- Dynamic gutenberg block with react instead of php
- File structure and react setup when creating multiple Gutenberg blocks
- Gutenberg block get categories in SelectControl
- How to access “default” property of attribute in Gutenberg
- Gutenberg Block manipulation: Undo parse_blocks() with serialize_blocks() results in unicode issues
- How to use “getEntityRecords” for user data?
- Gutenberg: Restrict Top Level Blocks, But Not Child Blocks
- Gutenberg default value not saved in json
- Gutenberg default initial values for FocalPointPicker
- Pre-set CSS class into custom block/template
- How to check whether Gutenberg editor is installed or not [duplicate]
- How to align a single Gutenberg block button in WP 5.5.3?
- Is it possible to print the output of a Gunteberg block with no classes?
- How can you reset InnerBlock content to base template?
- Gutenberg Multiple InnerBlocks
- How can we mimic the columns block in Gutenberg to instead be a list?
- How to set Gutenberg preferences programmatically with wp.data.dispatch?
- Dynamic Gutenburg block output echoes in WP Dashboard
- Are gutenberg blocks ideally supposed to look the same in both back-end and front-end?
- How to output child block attributes on a parent block
- How can I center Gutenberg buttons on mobile?
- Extend the “core/link” Block Format
- Passing settings from Reusable Block to it’s children
- Gutenberg element: How to usw Rangecontrol with two values to imitate a rangeslider?
- Is there any simple way to remove Gutenberg editor H1 H5 H6 and change the label for the rest H2 H3 H4?
- Deprecated for blocks.getSaveElement
- WordPress filter post content with PHP before editing it in Gutenberg
- Pass PHP vars to gutenberg sidebar
- Suggested image dimensions Gutenberg Hook
- How Add New Button to Gutenberg Editing Toolbar
- How to force gutenberg to reload blocks after saving
- How can I programaticly open Gutenberg
- Update a block template and apply those changes to an existing post/page
- How do you manage the Gutenberg block previews in the admin area?
- Custom block save does not match due to stripped slashes from br tag and added figure tag around images
- How to disable align-wide for specified blocks in Gutenberg
- Deprecated function not working in Gutenberg
- WordPress npm run build and start only outputs wp-scripts start but does nothing
- Gutenberg get index of gutenberg innerblock
- Custom Endpoint API based on attribute gutenberg block
- Gutenberg : how can I get the title of the current block within its ‘edit’ function?
- Gutenberg – Remove add block button
- how can default_content filter tell if content will load in block editor or classic editor?
- Gutenberg programmatically move block to position
- Gutenberg somehow not loading in WP 5
- Gutenberg block – remove setting for core/file
- Gutenberg JavaScript error
- Gutenberg selecting child blocks directly from appender
- WordPress Gutenberg – Open the “Block Pattern Explorer” programmatically
- Modify src attribute on image block
- Two text color palettes are appearing in Gutenberg
- WordPress Gutenberg – Sidebar get posts list based on selected category
- Gutenberg button removed on save if its empty
- Gutenberg build error: You may need an appropriate loader to handle this file type SCSS
- Quasy – modal component does not hide itself
- Table block – Wrap table
- ResizableBox component is not selectable in block editor
- Whitelist a single SVG for use in post_content
- Gutenberg block previews suddenly not working
- WordPress Gutenberg Signal on Block Alignment Change
- When to use block patterns over nested blocks?
- How to convert block to a list block in WordPress gutenberg editor?
- How to do store, retrieve and write attributes in the registerFormatType method in Guttenberg?
- How can I create more advanced layouts in Gutenberg block editor?
- How to replace the Gutenberg default block with a custom block?
- how to disable a button added by a plugin in gutenberg toolbar?
- Images are not shown in the post editor
- Updating failed message when a wp_insert_post function is hooked to save_post hook
- Get post ancestors in the Block Editor
- How to disable blocks in Gutenberg editor for specific post type
- Possible to make the link autocompleter prioritize Tags before Posts?
- Prevent FormTokenField component to accept random entries
- How to move the customizations done in the Editor to my child theme?
- Unable to see the attributes for the custom block created
- Block Theme Template parts – Why saving a part updates the other ones?
- No inline css, simple css file?
- How can I reset/remove background colour from a block
- Possible to use a block filter (blocks.getSaveContent.extraProps) with dynamic blocks?
- Elements positioning in a custom block
- In Full-Site-Editing, edits made to the code in a template part are not showing
- How to get appender icon to appear more often for innerblock usage
- Create a block variation of list elements
- Remove ‘default’ font option from Gutenberg typography settings
- Globally update pattern styles
- Block-based navigation and multi-language plugins
- Custom Gallery Block – Uncaught TypeError: setAttributes is not a function
- how to display gutenberg editor in a view
- Gutenberg list items nesting and creating invalid content errors
- Trying to understand block alignment
- Custom Link Block with own background color