Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#45112 closed task (blessed) (fixed)

Integrate meta box support for the new editor

Reported by: desrosj's profile desrosj Owned by:
Milestone: 5.0 Priority: normal
Severity: normal Version:
Component: Options, Meta APIs Keywords: has-patch fixed-5.0
Focuses: Cc:

Description

Meta box functionality for the new editor exists in gutenberg/lib/meta-box-partial-page.php. This should exist in WordPress Core.

Attachments (4)

45112.diff (14.5 KB) - added by pento 6 years ago.
45112.2.diff (14.4 KB) - added by ocean90 6 years ago.
45112.3.diff (614 bytes) - added by Nikschavan 6 years ago.
advanced-panels.png (74.2 KB) - added by ocean90 6 years ago.

Download all attachments as: .zip

Change History (40)

#1 @desrosj
6 years ago

  • Type changed from defect (bug) to task (blessed)

#2 @andizer
6 years ago

I have one question about the approach. Do you want this as a class to contain all functionality? Or should it be done the same way it has been done in gutenberg/lib/meta-box-partial-page.php?

#3 @youknowriad
6 years ago

Just a notice that we're doing small tweaks in this PR https://github.com/WordPress/gutenberg/pull/10676
In case anyone already started doing a patch.

@pento
6 years ago

#4 @pento
6 years ago

  • Keywords has-patch added; needs-patch removed

45112.diff is a first pass at adding meta box support. It needs unit tests added, and testing in conjunction with the patch on #45037.

@ocean90
6 years ago

#6 @pento
6 years ago

In 43778:

Block Editor: Add helper functions to collect meta box information.

To allow the block editor to render meta boxes, it needs to collect information about how those meta boxes are registered, and format it for the block editor to make use of.

See #45112.

#7 @pento
6 years ago

In 43779:

Meta Boxes: Add __back_compat_meta_box and __block_editor_compatible_meta_box flags to meta boxes.

When meta boxes are registered, they can use the __back_compat_meta_box and __block_editor_compatible_meta_box flags, to show whether this registration just exists for if the classic editor is loaded, and whether this meta box is compatible with the block editor.

When a meta box marks itself as incompatible with the block editor, and WP_DEBUG is enabled, a warning will show inside that meta box in the classic editor.

As all core meta boxes have been recreated in the block editor, they can be marked with the __back_compat_meta_box flag.

See #45112.

#8 @pento
6 years ago

  • Keywords fixed-5.0 added; needs-unit-tests removed

Meta box support has been ported.

#9 @ocean90
6 years ago

@pento Was there a reason for not using 45112.2.diff?

#10 @pento
6 years ago

Only that I missed that you'd added the patch, sorry about that. 🙂

#11 @ocean90
6 years ago

In 43792:

Meta Boxes: Sync checks for valid meta boxes from do_meta_boxes() to the_block_editor_meta_boxes().

See #45112.

#12 @afercia
6 years ago

While the notice appears only when define( 'WP_DEBUG', true ), ideally it shouldn't appear at all for meta boxes widgets exclusively meant to be used in the Dashboard. Right now, any dashboard widget added by plugins gets the notice:

http://cldup.com/a8gMker8wI.png

http://cldup.com/5qibqfoS1Z.png

http://cldup.com/8Yn9hEW1-q.png

#13 @afercia
6 years ago

For completeness, in the Gutenberg screen:

http://cldup.com/FQZ0O4rK6d.png

This ticket was mentioned in Slack in #core by timothybjacobs. View the logs.


6 years ago

#15 follow-up: @TimothyBlynJacobs
6 years ago

Adding to this, I think it should really only run on post type screens as opposed to whitelisting the dashboard. I know I've used the meta box API for completely custom admin pages, I'm sure others have as well.

#16 in reply to: ↑ 15 @nerrad
6 years ago

Replying to TimothyBlynJacobs:

Adding to this, I think it should really only run on post type screens as opposed to whitelisting the dashboard. I know I've used the meta box API for completely custom admin pages, I'm sure others have as well.

+1 to this. We also use the metabox API on custom admin pages.

This ticket was mentioned in Slack in #core-editor by youknowriad. View the logs.


6 years ago

#18 @zodiac1978
6 years ago

#45173 was marked as a duplicate.

#19 @SergeyBiryukov
6 years ago

  • Component changed from General to Options, Meta APIs

#20 @Nikschavan
6 years ago

In the 5.0 beta.1, the meta boxes registered from the theme are not displayed, It works correctly when Gutenberg plugin is activated.

To reproduce

  1. install WP 5.0 beta.1 on a fresh site and install any theme that registers a meta box (example - Astra)

The meta box will not be displayed in the block editor.

  1. Install and activate Gutenberg from the plugin repository and the meta boxes will be displayed now.
Last edited 6 years ago by Nikschavan (previous) (diff)

#21 @Nikschavan
6 years ago

Upon some debugging it seems action do_action( 'add_meta_boxes', $post_type, $post ); is not fired inside the block editor.

Whe gutenberg is activated it gets fired from gutenberg_collect_meta_box_data() - https://github.com/WordPress/gutenberg/blob/master/lib/register.php#L172

@Nikschavan
6 years ago

#23 @Nikschavan
6 years ago

45112.3.diff fires the action add_meta_boxes before the the_block_editor_meta_boxes() is called in /src/wp-admin/edit-form-blocks.php.

#24 @DrewAPicture
6 years ago

Looks like [43779] introduced a problem with static meta box display callbacks expressed as 'Class::method'. Patch on #45192 should take care of it.

#25 @swissspidy
6 years ago

#45195 was marked as a duplicate.

#26 @swissspidy
6 years ago

#45200 was marked as a duplicate.

#27 follow-up: @jeherve
6 years ago

The error message appears to be triggered on dashboard widgets as well, as reported above and here:

[43830] does not solve the problem.

Since wp_add_dashboard_widget uses add_meta_box here, should __block_editor_compatible_meta_box be set to false in that meta box's $callback_args to solve the issue for all dashboard widgets? I don't believe any dashboard widget is meant to support the block editor yet.

Last edited 6 years ago by jeherve (previous) (diff)

#28 follow-up: @ocean90
6 years ago

Without Gutenberg activated, I'm seeing all the default meta boxes in the Advanced Panels section, see advanced-panels.png. Can someone confirm?

This ticket was mentioned in Slack in #core-editor by ocean90. View the logs.


6 years ago

#30 @websupporter
6 years ago

Without Gutenberg activated, I'm seeing all the default meta boxes in the Advanced Panels section, see advanced-panels.png​. Can someone confirm?

I can reproduce it with the current beta2.

#31 in reply to: ↑ 28 @noisysocks
6 years ago

Replying to ocean90:

Without Gutenberg activated, I'm seeing all the default meta boxes in the Advanced Panels section, see advanced-panels.png. Can someone confirm?

Yes, that looks like a bug. I've created #45249 to track it. Thanks!

#32 in reply to: ↑ 27 @jeherve
6 years ago

Replying to jeherve:

The error message appears to be triggered on dashboard widgets as well, as reported above and here:

[43830] does not solve the problem.

Since wp_add_dashboard_widget uses add_meta_box here, should __block_editor_compatible_meta_box be set to false in that meta box's $callback_args to solve the issue for all dashboard widgets? I don't believe any dashboard widget is meant to support the block editor yet.

To close the loop, it seems that this was fixed in [43856].

#33 @pento
6 years ago

In 44131:

Block Editor: Add helper functions to collect meta box information.

To allow the block editor to render meta boxes, it needs to collect information about how those meta boxes are registered, and format it for the block editor to make use of.

Merges [43778] from the 5.0 branch to trunk.

See #45112.

#34 @pento
6 years ago

In 44132:

Meta Boxes: Add __back_compat_meta_box and __block_editor_compatible_meta_box flags to meta boxes.

When meta boxes are registered, they can use the __back_compat_meta_box and __block_editor_compatible_meta_box flags, to show whether this registration just exists for if the classic editor is loaded, and whether this meta box is compatible with the block editor.

When a meta box marks itself as incompatible with the block editor, and WP_DEBUG is enabled, a warning will show inside that meta box in the classic editor.

As all core meta boxes have been recreated in the block editor, they can be marked with the __back_compat_meta_box flag.

Merges [43779] from the 5.0 branch to trunk.

See #45112.

#35 @jeremyfelt
6 years ago

In 44141:

Meta Boxes: Sync checks for valid meta boxes from do_meta_boxes() to the_block_editor_meta_boxes().

Merges [43792] from the 5.0 branch to trunk.

Props ocean90.
See #45112.

#36 @SergeyBiryukov
6 years ago

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.