-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Fix WP_Block_Supports class compatibility with Gutenberg-provided class #640
Fix WP_Block_Supports class compatibility with Gutenberg-provided class #640
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
I won't be able to test this today but it's looking good to me if anyone wants to ship it :) |
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). |
…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>
Thanks for fixing this ❤️ |
…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>
Merged with changeset https://core.trac.wordpress.org/changeset/49310 and https://core.trac.wordpress.org/changeset/49312 |
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: