Skip to content

Conversation

@mkaz
Copy link
Member

@mkaz mkaz commented Dec 10, 2018

Description

The documentation has an example of the parameter to pass in to add_meta_box to disable once the meta box has been converted to a block. This value should be true, not false.

__back_compat_meta_box => true

You can confirm this by looking at the code which is looking for the value to be true, and if so will unset from the list of meta boxes to be shown.

if ( isset( $data['args']['__back_compat_meta_box'] ) && $data['args']['__back_compat_meta_box'] ) {
    unset( $meta_boxes[ $page ][ $context ][ $priority ][ $name ] );
}

From: https://github.com/WordPress/gutenberg/blob/master/lib/meta-box-partial-page.php#L149

How has this been tested?

Use an older WordPress plugin that has a metabox, and update with the parameter __back_compat_meta_box set to false and true to the add_meta_box()

It should not show in Gutenberg when set to true.

Types of changes

Documentation update.

@mkaz mkaz force-pushed the docs/fix-meta-box branch from 61fe985 to 69c6851 Compare December 10, 2018 22:55
@mkaz mkaz added the [Type] Developer Documentation Documentation for developers label Dec 10, 2018
@chrisvanpatten chrisvanpatten requested a review from pento December 11, 2018 18:23
@chrisvanpatten
Copy link
Contributor

Here's an excerpt of @pento's original post on the flag:

__back_compat_meta_box

This flag lets you set whether the meta box is intended to be used in the block editor, or if it has been replaced by block-based functionality. Setting it to true signifies that this meta box should only be loaded in the classic editor interface, and the block editor should not display it. Setting it to false signifies that this meta box is intended to be loaded in the block editor. If the flag isn’t set, then WordPress 5.0 will assume that the meta box is intended to be loaded in the block editor.

To be honest I'm not sure I understand it better after reading this but maybe the extra context will be helpful 😂

@mkaz
Copy link
Member Author

mkaz commented Dec 11, 2018

Thanks @chrisvanpatten that does help clarify for me, and reassures me the PR is needed.

From @pento's explanation:

Setting it to true signifies that this meta box should only be loaded in the classic editor interface, and the block editor should not display it.

And the docs say below the example code:

When Gutenberg is used, this meta box will no longer be displayed in the meta box area, as it now only exists for backward compatibility purposes. It will continue to display correctly in the Classic editor, should some other meta box cause a fallback.

So, it seems like it true is the value the example should be in the docs.

Copy link
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks a "bug" in the documentation, and the value should be true.

@gziolo gziolo added this to the 4.8 milestone Dec 14, 2018
@gziolo gziolo merged commit a617aee into master Dec 14, 2018
@gziolo gziolo deleted the docs/fix-meta-box branch December 14, 2018 09:18
@gziolo gziolo modified the milestones: 4.8, Documentation & Handbook Dec 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Developer Documentation Documentation for developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants