block editor – Unable to remove panels

Question

I’d like to remove the panels that appear on the right of the post/page e.g. categories, featured image and others. I have the function below to register the script.

function remove_block_style() {
    wp_register_script( 'remove-block-style', trailingslashit( get_stylesheet_directory_uri() ) . 'js/remove-block-styles.js', [ 'wp-blocks', 'wp-edit-post' ], '1.0', true );
    register_block_type( 'remove/block-style', [ 'editor_script' => 'remove-block-style'] );
}
add_action( 'enqueue_block_editor_assets', 'remove_block_style' );

It immediately removes the ‘Discussion’ panel without any entries in the remove-block-styles.js file.

When the following entries are added to the remove-block-styles.js file, none of panels are removed (with the exception of the ‘Discussion’ panel which occurs with the function above even when it’s excluded from remove-block-styles.js

wp.data.dispatch('core/edit-post').removeEditorPanel('post-status'); // Status and Visibility
wp.data.dispatch('core/edit-post').removeEditorPanel('taxonomy-panel-category'); // Categories
wp.data.dispatch('core/edit-post').removeEditorPanel('taxonomy-panel-TAXONOMY-NAME'); // custom taxonomy
wp.data.dispatch('core/edit-post').removeEditorPanel('taxonomy-panel-post_tag'); // Tags
wp.data.dispatch('core/edit-post').removeEditorPanel('featured-image'); // Featured Image
wp.data.dispatch('core/edit-post').removeEditorPanel('post-excerpt'); // Excerpt
wp.data.dispatch('core/edit-post').removeEditorPanel('post-link'); // permalink
wp.data.dispatch('core/edit-post').removeEditorPanel('page-attributes'); // page attributes
wp.data.dispatch('core/edit-post').removeEditorPanel('discussion-panel'); // Discussion

What am I doing incorrectly?

0
Ryan 2 months 2023-04-09T19:44:21-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse