danielbachhuber / gutenberg-migration-guide

Documents WordPress Classic Editor integration points and their Gutenberg equivalents
183 stars 14 forks source link

remove_meta_box #4

Open braders opened 6 years ago

braders commented 6 years ago

In the current editor it is possible to suppress also every part of the interface through the use of remove_metabox(). In the new editor, metaboxes are a legacy concept, and document settings are implemented in alternative ways.

Specific examples

  1. Suppressing post-specific content from admin-only custom post types (e.g. a redirect CPT, which does not require an author, page attributes etc.)

  2. In the current editor, it is possible to remove a core metabox, and replace it with a custom implementation. For example, a common use-case it to remove taxonomy metaboxes in order to provide a new interface which uses radio buttons (instead of checkboxes). e.g. https://plugins.trac.wordpress.org/browser/radio-buttons-for-taxonomies

Gutenburg alternative

There appears to be no ideal alternative in Gutenburg. I have seen it suggested that non-content posts, (such as the redirect CPT example) should continue to use the old editor, but this does seem to be limiting the usefulness of the new editor.

It may be possible to hide Document sidebar sections with CSS, but this is going to be a brittle solution unsuited to most use-cases.

danielbachhuber commented 6 years ago
  1. Suppressing post-specific content from admin-only custom post types (e.g. a redirect CPT, which does not require an author, page attributes etc.)

To speak to these points specifically:

  1. The author select UI only appears when post_type_supports( $post_type, 'author' ).
  2. Similarly, page attributes are only displayed if the post type supports page-attributes.

You can remove the UI for either from Gutenberg by removing post type support for that feature.

  1. In the current editor, it is possible to remove a core metabox, and replace it with a custom implementation. For example, a common use-case it to remove taxonomy metaboxes in order to provide a new interface which uses radio buttons (instead of checkboxes). e.g.

Correct, there's no direct equivalent here.

Related https://github.com/WordPress/gutenberg/issues/6694#issuecomment-390421485

danielbachhuber commented 6 years ago

Related https://github.com/WordPress/gutenberg/issues/6912

abursill commented 5 years ago

This totally sucks I have sspent hours trying to remove the

function my_remove_meta_boxes() { remove_meta_box('postimagediv', 'brand', 'side'); } add_action( 'do_meta_boxes', 'my_remove_meta_boxes' );

I need to move it into the content below which I managed to do but it now conflicts with the original one I can not move. I do not want to have to write some hacky javascript to remove it.

You need to make some kind of simple rest function an array of items to not show in the rest ui. When you make one please put a full working example of it. 90% of the things here on github are badly documented also.

I am no Wordpress expert. I actually hate it and find it much harder to work with than writing my own code.