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

Background image support: Fix duplicate output of styling rules #56997

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

andrewserong
Copy link
Contributor

What?

Part of #54336

Fix duplicate output of background image styling rules for the Group block.

Why?

As of WP 6.4, the background image block support exists in core as well as in the Gutenberg plugin. Unlike the other block supports, in Gutenberg, we were missing the remove_filter line to switch off the core behaviour if present, to prioritise the Gutenberg behaviour and allow further development of the block support within the plugin.

How?

  • Add a remove_filter line to disable core's callback for the background support if present

Testing Instructions

Test with WP 6.4+

Prior to applying this PR, add a post or page with a Group block and set a background image for it. Save and view the site frontend, and inspect the generated markup — notice that the background-image and background-size:cover rules are duplicated.

With this PR applied, there should only be one background-image and background-size:cover rule in the generated markup.

Screenshots or screencast

Before

image

After

image

@andrewserong andrewserong added [Type] Bug An existing feature does not function as intended [Type] Code Quality Issues or PRs that relate to code quality labels Dec 13, 2023
@andrewserong andrewserong self-assigned this Dec 13, 2023
@andrewserong andrewserong added [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi and removed [Type] Code Quality Issues or PRs that relate to code quality labels Dec 13, 2023
Copy link

This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.

If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged.

If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack.

Thank you! ❤️

View changed files
❔ lib/block-supports/background.php

Copy link

Flaky tests detected in 783771e.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7189603410
📝 Reported issues:

Copy link
Member

@ramonjd ramonjd left a comment

Choose a reason for hiding this comment

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

A cunning plan!

Before

Screenshot 2023-12-13 at 1 33 27 pm

After

Screenshot 2023-12-13 at 1 32 01 pm

lib/block-supports/background.php Show resolved Hide resolved
@andrewserong
Copy link
Contributor Author

Thanks for the quick review!

@andrewserong andrewserong merged commit 9855f16 into trunk Dec 13, 2023
54 of 60 checks passed
@andrewserong andrewserong deleted the fix/double-output-of-background-image-styles branch December 13, 2023 03:11
@github-actions github-actions bot added this to the Gutenberg 17.3 milestone Dec 13, 2023
@getdave getdave added Needs PHP backport Needs PHP backport to Core Backported to WP Core Pull request that has been successfully merged into WP Core and removed Needs PHP backport Needs PHP backport to Core labels Jan 22, 2024
@getdave
Copy link
Contributor

getdave commented Jan 22, 2024

✅ I updated this PR with the Backported to Core label to indicate that the backport has successfully merged into WP Core. I also updated the PHP Sync Tracking Issue for WP 6.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backported to WP Core Pull request that has been successfully merged into WP Core [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants