Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Gutenberg Whitelist
<?php
/**
* Plugin Name: Control Gutenberg blocks.
* Description:
* Plugin URI: https://bueltge.de
* Version: 1.0.0
* Author:
* Author URI:
* Licence: GPLv2+
*/
// Visible only the listet blocks.
add_filter( 'allowed_block_types', function($allowed_block_types, $post) {
if ($post->post_type !== 'post') {
return $allowed_block_types;
}
return [
'core/heading',
'core/paragraph',
'core/image'
];
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment