Fix WP_Block_Supports class compatibility with Gutenberg-provided class #640
Closed
oandregal wants to merge 14 commits intoWordPress:masterfrom
oandregal:remove/global-current-parsed-block
Closed
Fix WP_Block_Supports class compatibility with Gutenberg-provided class #640oandregal wants to merge 14 commits intoWordPress:masterfrom oandregal:remove/global-current-parsed-block
oandregal wants to merge 14 commits intoWordPress:masterfrom
oandregal:remove/global-current-parsed-block
Conversation
…urrent code
Since:
https://core.trac.wordpress.org/ticket/49927
Commit 910de8f at wordpress-develop
we no longer use the render method of WP_Block_Type,
but its equivalent at WP_Block.
There's still some tests that use that old path that were failing
because the render_callback was called with only 2 arguments
instead of the three that WP_Block uses.
This commit:
- Signals WP_Block_Type->render as deprecated.
- Patch it to pass a null value as the third argument
(it represents an instance of WP_Block).
Because the render_callback is now wrapped by a function at src/wp-includes/class-wp-block-supports.php it'll be callable. So we pass null as the callback and the wrapper won't be attached.
By using is_callable we make sure that we don't change any callback behavior: - if the original callback is callable => attach the wrapper - if the original callback is not callable => no wrapper
youknowriad
reviewed
Oct 23, 2020
youknowriad
reviewed
Oct 23, 2020
Contributor
|
I won't be able to test this today but it's looking good to me if anyone wants to ship it :) |
Member
Author
|
Some testing Instructions:
I've reproduced these instructions with WordPress 5.6 beta1 with and without this patch in the following scenarios: no Gutenberg plugin installed, with gutenberg 9.2.1, with Gutenberg master. In Gutenberg master without this patch, the class isn't attached and there are some PHP errors. I think this is ready to go. Anyone to review? Was hoping to land this before next Tuesday (beta 2). |
6 tasks
oandregal
pushed a commit
to WordPress/gutenberg
that referenced
this pull request
Oct 26, 2020
…ss (#26417) This PR ports the changes from the core PR at WordPress/wordpress-develop#640 Co-authored-by: Jon Surrell <jon.surrell@automattic.com> Co-authored-by: Miguel Fonseca <miguelcsf@gmail.com>
Contributor
|
Thanks for fixing this ❤️ |
oandregal
pushed a commit
to WordPress/gutenberg
that referenced
this pull request
Oct 26, 2020
…ss (#26417) This PR ports the changes from the core PR at WordPress/wordpress-develop#640 Co-authored-by: Jon Surrell <jon.surrell@automattic.com> Co-authored-by: Miguel Fonseca <miguelcsf@gmail.com>
Contributor
|
Merged with changeset https://core.trac.wordpress.org/changeset/49310 and https://core.trac.wordpress.org/changeset/49312 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related:
The WP_Block_Supports class is a new addition that will come with 5.6 and acts as a register of the kind of features a block supports. It's already on WordPress 5.6 beta1 and we need to fix how core and the plugin play together in a number of situations: