How to check if current admin page is Gutenberg editor? [duplicate]

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 … Read more

How to Disable Gutenberg & Return to the Classic WordPress Editor Without any Plugins

Simply add the following to functions.php file of your current theme. <?php /** * Disable Gutenberg for supported posts. */ add_filter( ‘use_block_editor_for_post_type’, ‘__return_false’, 100 ); /** * Disable Gutenberg action and filter hooks. */ function df_disable_gutenberg_hooks() { remove_action( ‘admin_menu’, ‘gutenberg_menu’ ); remove_action( ‘admin_init’, ‘gutenberg_redirect_demo’ ); remove_filter( ‘wp_refresh_nonces’, ‘gutenberg_add_rest_nonce_to_heartbeat_response_headers’ ); remove_filter( ‘get_edit_post_link’, ‘gutenberg_revisions_link_to_editor’ ); remove_filter( ‘wp_prepare_revision_for_js’, … Read more

Gutenberg: Restrict Top Level Blocks, But Not Child Blocks

The short answer is you can’t. But you can accomplish this by using a block template that only contains your block and is locked. If your block has an InnerBlocks instance, you can add any of the registered blocks to it. add_action( ‘init’, ‘insert_template’ ); function insert_template() { $post_type_object = get_post_type_object( ‘post’ ); $post_type_object->template =[ … Read more

How to enable Gutenberg Block Editor on taxonomy term pages?

As mentioned in the comments, it isn’t currently supported, although there is an open issue for exactly this feature: https://github.com/WordPress/gutenberg/issues/17099 Meanwhile, I can think of a couple of ways to achieve the same effect: 1) Pages + custom rewrites As you suggested in your question, you could create a set of parallel pages with the … Read more

How does the Gutenberg mobile/tablet/desktop preview work with media queries?

I investigated the states set using React Dev Tools and found the preview modes are set under the deviceType key. Went through the Gutenberg source and came across the __experimentalGetPreviewDeviceType function. /** * Returns the current deviceType. */ const { deviceType } = useSelect( select => { const { __experimentalGetPreviewDeviceType } = select( ‘core/edit-post’ ); … Read more

How to define a Block Style in an Innerblocks template

I can’t determine the syntax to use (or if it is even supported) to define the blocks’ style. For example, I would like the Button to use the “Outline” style instead of its default “Fill” style. Yes it’s supported and the syntax is quite easy. Excerpt from the block styles documentation: Block Styles allow alternative … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)