Skip to content

Remove a panel from the settings? #6225

Closed

Description

@Soean

A Question from camthor in the support forum:

Hi,

For the previous editor we had the possibility to remove a default meta box with remove_meta_box. That was useful if, for example, you wanted to create an alternative box for tags.

Is there anything equivalent for Gutenberg, i.e. to remove a panel from the settings on the right side? I was checking if you could simply hide the element, but all divs seem to have the class “components-panel__body” and no id. So there doesn’t seem to be a way how to select a particular panel. I would prefer, however, to remove the element already before rendering the page if that’s possible, not just with jQuery.

Thanks!

Source: https://wordpress.org/support/topic/how-to-programatically-remove-a-panel-from-the-settings/

Activity

  1. added
    [Type] Help Request
    on Apr 17, 2018
  2. youknowriad commented on Jun 28, 2018

    @youknowriad
    Contributor

    Let's consolidate in #6533

  3. genseirin commented on Nov 12, 2018

    @genseirin

    This has been closed, so is there any solution how to remove the panel of the post tags?

  4. reopened this on Nov 12, 2018
  5. added this to the WordPress 5.0 milestone on Nov 12, 2018
  6. gziolo commented on Nov 12, 2018

    @gziolo
    Member

    is there any solution how to remove the panel of the post tags?

    You can do the following as of today:

    var el = wp.element.createElement;
    
    function removeCategoryPanel( OriginalComponent ) {
    	return function( props ) {
    		if ( props.slug === 'category' ) {
    			return null
    		} else {
    			return el(
    				OriginalComponent,
    				props
    			);
    		}
    	}
    };
    
    wp.hooks.addFilter(
    	'editor.PostTaxonomyType',
    	'my-custom-plugin',
    	removeCategoryPanel
    );

    Howeve it won't remove the panel's title. I will have a look tomorrow and find out if that is easy to do.

  7. added
    [Feature] Extensibility
    on Nov 12, 2018
  8. youknowriad commented on Nov 13, 2018

    @youknowriad
    Contributor

    There's an API used in the options panel to hide these panels, I think we can just use it here?

  9. gziolo commented on Nov 13, 2018

    @gziolo
    Member

    There's an API used in the options panel to hide these panels, I think we can just use it here?

    I have PR almost ready which adds another flag. The issue with the existing action is that you still would be able to enable it back using Options modal. My change will put the editor in the following state:

    screen shot 2018-11-13 at 09 41 43

  10. added
    Backwards Compatibility
    on Nov 13, 2018
  11. added
    [Status] In Progress
    and removed
    [Type] Help Request
    on Nov 14, 2018
  12. removed
    [Status] In Progress
    on Jan 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Backwards Compatibility[Feature] Extensibility

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions