Created
March 9, 2023 01:14
-
-
Save bacoords/498cfe55d059166dd47cf5b5749dc042 to your computer and use it in GitHub Desktop.
Remove core blocks from WordPress block editor
This file contains hidden or 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
wp.domReady( () => { | |
let blocks = wp.blocks.getBlockTypes().map( ( block ) => block.name ); | |
blocks.forEach( ( block ) => { | |
if ( block.indexOf( 'core/' ) === 0 ) { | |
wp.blocks.unregisterBlockType( block ); | |
} | |
}); | |
} ); |
This file contains hidden or 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 | |
/** | |
* 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