Skip to content

Instantly share code, notes, and snippets.

@bueltge
Created December 4, 2019 12:10
Show Gist options
  • Save bueltge/8668dbe30565bb26f709eedccb518cbc to your computer and use it in GitHub Desktop.
Save bueltge/8668dbe30565bb26f709eedccb518cbc to your computer and use it in GitHub Desktop.
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