Skip to content

Instantly share code, notes, and snippets.

@Mamaduka
Created May 19, 2022 16:54
Show Gist options
  • Save Mamaduka/cb6215937ae10ecf43f21d7911dfcec7 to your computer and use it in GitHub Desktop.
Save Mamaduka/cb6215937ae10ecf43f21d7911dfcec7 to your computer and use it in GitHub Desktop.
<?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