Skip to content

Instantly share code, notes, and snippets.

@agrogeek
Created April 29, 2020 14:52
Show Gist options
  • Save agrogeek/7c8ec5fae6514f6da85b85c43c0eec16 to your computer and use it in GitHub Desktop.
Save agrogeek/7c8ec5fae6514f6da85b85c43c0eec16 to your computer and use it in GitHub Desktop.
Deshabilitar paneles del editor de WP desde código
// remove excerpt panel
wp.data.dispatch( 'core/edit-post').removeEditorPanel( 'post-excerpt' );
Here is an (incomplete) list of panel IDs:
taxonomy-panel-category - Category panel.
taxonomy-panel-CUSTOM-TAXONOMY-NAME - Custom taxonomy panel. If your taxonomy is topic, then taxonomy-panel-topic works.
taxonomy-panel-post_tag - Tags panel
featured-image - Featured image panel.
post-link - Permalink panel.
page-attributes - Page attributes panel.
post-excerpt - Post excerpt panel.
discussion-panel - Discussions panel.
The full code
PHP (in your functions.php or custom plugin):
function cc_gutenberg_register_files() {
// script file
wp_register_script(
'cc-block-script',
get_stylesheet_directory_uri() .'/js/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' );
@artmaug
Copy link

artmaug commented Sep 1, 2020

Thank you for this, works like a charm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment