Archived topic
Remove "Active elements" panel in the Block Editor
5 replies · Started by Jose Salgado on September 29, 2021
I was trying to remove some gutenberg panels in the block editor to make much cleaner look of gutenberg editor and less confusing for clients.
I already removed some of them following this guide:
https://wordpress.stackexchange.com/questions/339436/removing-panels-meta-boxes-in-the-block-editor/339437#339437
I already remove "Generatepress Layout panel" but i cant make the same with "Active Elements" and "Revisions" panel.
In order to do this, i downloaded generatepress child theme and installed. Then i create a Js document (called "block-script.js") into the child theme carpet in Cpanel. And also modify the child theme "functions.php"
...........
block-script.js has this code:
//Hiding Gutenberg Editor panels
// page attributes
wp.data.dispatch( 'core/edit-post').removeEditorPanel( 'page-attributes' );
// Comments Panel
wp.data.dispatch( 'core/edit-post').removeEditorPanel( 'discussion-panel' );
// Comments Panel
wp.data.dispatch( 'core/edit-post').removeEditorPanel( 'editor-post-last-revision__panel' );
//Remove panels from certain plugins
// Remove Generatepress Layout Panel:
var boxId = 'generate_layout_options_meta_box';
wp.data.dispatch( 'core/edit-post').removeEditorPanel( 'meta-box-' + boxId );
......
functions.php has this code:
//Remove Panels From Gutenberg Editor
function cc_gutenberg_register_files() {
// script file
wp_register_script(
'cc-block-script',
get_stylesheet_directory_uri() .'/block-script.js', // adjust the path to the JS file
array( 'wp-blocks', 'wp-edit-post' )
);
// register block editor script
register_block_type( 'cc/ma-block-files', array(
'editor_script' => 'cc-block-script'
) );
}
add_action( 'init', 'cc_gutenberg_register_files' );
//Add excerpt on pages
add_post_type_support( 'page', 'excerpt' );
.......
So i need your help to know what is the "Active Elements" PANEL-ID in order to try if my code can remove it from editor. or if you can give me some code in order to complete this.
and if posible, can you help me to algo remove "revisions" panel?
Thanks for your help and waiting for you reply.
Hi there,
Our Elements section is a "plugin", so you'd do this:
var unregisterPlugin = wp.plugins.unregisterPlugin;
unregisterPlugin( 'generatepress-elements-info-panel' );
Let me know if you need more info :)
Hi Tom,
Unfortunately not worked :c
Maybe i dont explain correct. i send and image hoping it illustrate better my problem.
https://drive.google.com/file/d/1ed9Y4bIcVTdHPPkgtTQm_hjMDpRK8vTi/view?usp=sharing
......
I tried that code into "Generatepress child theme folder > "block-script.js"
if this location its wrong?, what whould be the correct file where i have to put the code
If that script is enqueued correctly it should work.
You can try using domReady():
wp.domReady( function() {
var unregisterPlugin = wp.plugins.unregisterPlugin;
unregisterPlugin( 'generatepress-elements-info-panel' );
} );
Thanks Tom, That last one worked like a charm.
Appreciate your support :D
Glad I could help :)