-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugin: Deprecate metabox supports, fall back to core #13449
Conversation
'post' => $post->ID, | ||
'action' => 'edit', | ||
'meta-box-loader' => true, | ||
'_wpnonce' => wp_create_nonce( 'meta-box-loader' ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this to match the URL used in Core?
Do you think we could remove bootstraping Gutenberg entirely in the plugin (and just upgrade the scripts)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we could remove bootstraping Gutenberg entirely in the plugin (and just upgrade the scripts)
Yes, in fact, what I've done here is simply to align the bootstrapping to exactly what core does, in order to facilitate it being dropped altogether.
@@ -210,6 +210,8 @@ function gutenberg_init( $return, $post ) { | |||
return false; | |||
} | |||
|
|||
get_current_screen()->is_block_editor( true ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw a comment on the description, but still having hard time understanding this :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw a comment on the description, but still having hard time understanding this :)
It mimics similar to what's done here:
It's important because there are conditions in core's handling of meta boxes which key off this value:
- https://github.com/WordPress/wordpress-develop/blob/8b4330bb6ea196005b5f0f84070b64c139f39b37/src/wp-admin/includes/template.php#L1242
- https://github.com/WordPress/wordpress-develop/blob/8b4330bb6ea196005b5f0f84070b64c139f39b37/src/wp-admin/includes/template.php#L1252
- https://github.com/WordPress/wordpress-develop/blob/8b4330bb6ea196005b5f0f84070b64c139f39b37/src/wp-admin/includes/template.php#L1265
- https://github.com/WordPress/wordpress-develop/blob/8b4330bb6ea196005b5f0f84070b64c139f39b37/src/wp-admin/includes/template.php#L1290
Without this, the the value of is_block_editor
is false on the Gutenberg screen, which is clearly problematic irrespective of the specific meta box integration. For example, it forces plugin authors to do funny things to check whether the current screen is the block editor, regardless of whether that's the one in core or the one in the Gutenberg plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a clarifying comment in the rebased 4f62c93.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to work as intended but given the fragility of meta boxes, I'd like a second review. Maybe @noisysocks
abe9b04
to
22f8939
Compare
22f8939
to
be024b0
Compare
* Plugin: Emulate is_block_editor for Gutenberg screen * Plugin: Deprecate metabox supports, fall back to core
* Plugin: Emulate is_block_editor for Gutenberg screen * Plugin: Deprecate metabox supports, fall back to core
Related: #11015
This pull request seeks to remove the Gutenberg-specific meta box compatibility functions, instead deferring to those shipped with WordPress 5.0.
Implementation notes:
The most tricky bit here is that we need the Gutenberg editor screen to claim itself as being the block editor, i.e.
get_current_screen()->is_block_editor()
. This should be the case anyways, but since core uses this function as a condition to perform some additional logic, it requires that those equivalent bits be disabled from Gutenberg as well.From what I can gather, outside meta boxes, this impacts:
gutenberg_common_scripts_and_styles
(reference)gutenberg_enqueue_registered_block_scripts_and_styles
(reference)Testing instructions:
Verify that there are no regressions in the display and saving of meta boxes.