Created
May 19, 2022 16:54
-
-
Save Mamaduka/cb6215937ae10ecf43f21d7911dfcec7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// See: https://developer.wordpress.org/reference/classes/wp_block_editor_context/. | |
add_filter( 'block_editor_settings_all', function( $settings, $context ) { | |
// Curated blocks for the Widgets Editor. | |
if ( isset( $context->name ) && 'core/edit-widgets' === $context->name ) { | |
$settings['allowedBlockTypes'] = [ 'core/cover', 'core/heading', 'core/image', 'core/paragraph' ]; | |
} | |
// Disable block locking controls in Site Editor. | |
if ( isset( $context->name ) && 'core/edit-site' === $context->name ) { | |
$settings['canLockBlocks'] = false; | |
} | |
if ( isset( $context->name ) && 'core/edit-post' === $context->name ) { | |
/** Post editor setting overrides... */ | |
} | |
return $settings; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment