Gutenberg Whitelist
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 | |
/** | |
* 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