Skip to content
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: Ensure that PHP code for blocks is correctly assigned to WP releases #40179

Merged
merged 1 commit into from
Apr 8, 2022

Conversation

gziolo
Copy link
Member

@gziolo gziolo commented Apr 8, 2022

What?

Follow-up for #36176.
Part of #39889.

As part of this PR, I remove the usage of:

  • gutenberg_block_has_support
  • gutenberg_migrate_old_typography_shape filter's callback

They were added in WordPress 5.8.

I also moved block-related functionality to the appropriate compat layer files.

Why?

To ensure that compatibility layer functionality gets removed whenever we bump the minimum version of WordPress supported in the Gutenberg plugin.

How?

WordPres 5.9 compat:

  • _wp_normalize_relative_css_links function
  • wp_enqueue_block_style function
  • gutenberg_multiple_block_styles filter's callback

WordPres 6.0 compat (needs to be backported to WP core):

  • wp_enqueue_block_view_script function
  • gutenberg_block_type_metadata_multiple_view_scripts filter's callback

Testing Instructions

No functional changes. The plugin should still work as before.

@gziolo gziolo added [Feature] Blocks Overall functionality of blocks Gutenberg Plugin Issues or PRs related to Gutenberg Plugin management related efforts [Type] Code Quality Issues or PRs that relate to code quality labels Apr 8, 2022
@gziolo gziolo requested review from adamziel and aristath April 8, 2022 07:13
@gziolo gziolo self-assigned this Apr 8, 2022
@gziolo gziolo requested a review from youknowriad April 8, 2022 07:14
* @param array $metadata Metadata for registering a block type.
* @return array Metadata for registering a block type with the supports shape updated.
*/
function gutenberg_migrate_old_typography_shape( $metadata ) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*
* @return boolean Whether or not the feature is supported.
*/
function gutenberg_block_has_support( $block_type, $feature, $default = false ) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://developer.wordpress.org/reference/functions/block_has_support/ was introduced in WordPress 5.8 and that is the minimum supported version for the plugin.

Copy link
Member

@aristath aristath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! LGTM 👍

@gziolo gziolo merged commit 5933364 into trunk Apr 8, 2022
@gziolo gziolo deleted the update/lib-blocks-compat branch April 8, 2022 11:02
@github-actions github-actions bot added this to the Gutenberg 13.0 milestone Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks Gutenberg Plugin Issues or PRs related to Gutenberg Plugin management related efforts [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants