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

Merged
merged 2 commits into from Jan 28, 2019

Conversation

@aduth
Copy link
Member

aduth commented Jan 23, 2019

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.

'post' => $post->ID,
'action' => 'edit',
'meta-box-loader' => true,
'_wpnonce' => wp_create_nonce( 'meta-box-loader' ),

This comment has been minimized.

@youknowriad

youknowriad Jan 25, 2019

Contributor

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)

This comment has been minimized.

@aduth

aduth Jan 25, 2019

Author Member

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.

https://github.com/WordPress/wordpress-develop/blob/8b4330bb6ea196005b5f0f84070b64c139f39b37/src/wp-admin/edit-form-blocks.php#L115-L126

@@ -210,6 +210,8 @@ function gutenberg_init( $return, $post ) {
return false;
}
get_current_screen()->is_block_editor( true );

This comment has been minimized.

@youknowriad

youknowriad Jan 25, 2019

Contributor

I saw a comment on the description, but still having hard time understanding this :)

This comment has been minimized.

@aduth

aduth Jan 25, 2019

Author Member

I saw a comment on the description, but still having hard time understanding this :)

It mimics similar to what's done here:

https://github.com/WordPress/wordpress-develop/blob/8b4330bb6ea196005b5f0f84070b64c139f39b37/src/wp-admin/edit-form-blocks.php#L26-L28

It's important because there are conditions in core's handling of meta boxes which key off this value:

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.

https://github.com/aduth/g-debugger/blob/522d88a56f7e389f741edc48220a9750d78b80fd/g-debugger.php#L13-L32

This comment has been minimized.

@aduth

aduth Jan 25, 2019

Author Member

I added a clarifying comment in the rebased 4f62c93.

@youknowriad
Copy link
Contributor

youknowriad left a comment

Seems to work as intended but given the fragility of meta boxes, I'd like a second review. Maybe @noisysocks

@youknowriad youknowriad added this to the 5.0 (Gutenberg) milestone Jan 25, 2019

@aduth aduth force-pushed the remove/metaboxes-supports branch 2 times, most recently from abe9b04 to 22f8939 Jan 25, 2019

@aduth aduth force-pushed the remove/metaboxes-supports branch from 22f8939 to be024b0 Jan 28, 2019

@youknowriad youknowriad merged commit cfb269d into master Jan 28, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

Remove PHP automation moved this from In Progress to Done Jan 28, 2019

@youknowriad youknowriad deleted the remove/metaboxes-supports branch Jan 28, 2019

daniloercoli added a commit that referenced this pull request Jan 28, 2019

Merge branch 'master' of https://github.com/WordPress/gutenberg into …
…rnmobile/372-move-title-to-rich-text

* 'master' of https://github.com/WordPress/gutenberg:
  Adds undo/redo support for the title. (#13514)
  Fix typo (#13524)
  RichText: List: Fix indent/outdent (#12667)
  Fixes tense on verb “assign” to correct tense (#13541)
  Plugin: Deprecate metabox supports, fall back to core (#13449)
  Rnmobile/upload media file (#13128)
  Plugin: Remove redundant core compatibility from plugin (#13442)
  Testing: Remove PHPUnit tests covering core functions (#13513)
  Plugin: Deprecate gutenberg_add_gutenberg_post_state (#13471)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment