Skip to content

Instantly share code, notes, and snippets.

@bacoords
Created March 9, 2023 01:14
Show Gist options
  • Save bacoords/498cfe55d059166dd47cf5b5749dc042 to your computer and use it in GitHub Desktop.
Save bacoords/498cfe55d059166dd47cf5b5749dc042 to your computer and use it in GitHub Desktop.
Remove core blocks from WordPress block editor
wp.domReady( () => {
let blocks = wp.blocks.getBlockTypes().map( ( block ) => block.name );
blocks.forEach( ( block ) => {
if ( block.indexOf( 'core/' ) === 0 ) {
wp.blocks.unregisterBlockType( block );
}
});
} );
<?php
/**
* Enqueue block editor assets.
*
* @return void
*/
function understrap_enqueue_block_editor_assets() {
wp_enqueue_script( 'remove-blocks', get_stylesheet_directory_uri() . '/js/editor.js', array( 'wp-blocks', 'wp-dom', 'wp-edit-post' ), filemtime( get_stylesheet_directory() . '/js/editor.js' ), true );
}
add_action( 'enqueue_block_editor_assets', 'understrap_enqueue_block_editor_assets' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment