block editor – Unable to remove panels


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'core/edit-post').removeEditorPanel('post-status'); // Status and Visibility'core/edit-post').removeEditorPanel('taxonomy-panel-category'); // Categories'core/edit-post').removeEditorPanel('taxonomy-panel-TAXONOMY-NAME'); // custom taxonomy'core/edit-post').removeEditorPanel('taxonomy-panel-post_tag'); // Tags'core/edit-post').removeEditorPanel('featured-image'); // Featured Image'core/edit-post').removeEditorPanel('post-excerpt'); // Excerpt'core/edit-post').removeEditorPanel('post-link'); // permalink'core/edit-post').removeEditorPanel('page-attributes'); // page attributes'core/edit-post').removeEditorPanel('discussion-panel'); // Discussion

What am I doing incorrectly?

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

Leave an answer