Created
April 29, 2020 14:52
-
-
Save agrogeek/7c8ec5fae6514f6da85b85c43c0eec16 to your computer and use it in GitHub Desktop.
Deshabilitar paneles del editor de WP desde código
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
// 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' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for this, works like a charm!