-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add filter for duotone to account for gutenberg_restore_image_outer_container in classic themes #59764
Conversation
…ontainer in classic themes. Fixes #54121
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Looking at the way that |
The wrapper With the gutenberg plugin, the core version of the layout filter is replaced with the identical gutenberg version ( gutenberg/lib/block-supports/layout.php Lines 1071 to 1074 in 3561d77
So with the plugin active, both Gutenberg layout hook and the new duotone hook should be running. The duotone one runs after the layout one because of the order they're defined in Line 210 in d7e80e6
When this gets backported to core, the same should happen with the core version of the functions. Although, it looks like the imports will have to be reordered during the core backport (https://github.com/WordPress/wordpress-develop/blob/9a616a573434b432a5efd4de21039250658371fe/src/wp-settings.php#L371). In my opinion, with the way WordPress code is written with side effects in many files, the way that we mostly centralize imports, the size of the codebase, and the number of contributors, it makes more sense for use to just preserve the order of imports when backporting things to not have to worry so much about priority levels. It seems better to me to maintain that order than force extenders to use extra high priorities to override core behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok I get it now thanks. It's working as expected.
…ontainer in classic themes (WordPress#59764) Co-authored-by: ajlende <ajlende@git.wordpress.org> Co-authored-by: scruffian <scruffian@git.wordpress.org> Co-authored-by: bph <bph@git.wordpress.org> Co-authored-by: ndiego <ndiego@git.wordpress.org> Co-authored-by: annezazu <annezazu@git.wordpress.org> Co-authored-by: sabernhardt <sabernhardt@git.wordpress.org> * Add filter for duotone to account for gutenberg_restore_image_outer_container in classic themes. Fixes WordPress#54121 * Try making things a bit more efficient * Fix phpcs * Fix phpcs * Reuse if class_exists block * Fix phpcs
What?
Fixes an issue with duotone filters not working in aligned images in classic themes.
Why?
Fixes #54121
How?
Adds a filter to restore the generated duotone class name for blocks that get a wrapping
div
due togutenberg_restore_image_outer_container
.It isn't the most elegant solution, but it works. I'm open to other suggestions.
Unfortunately we can't just change the priority on the layout core/image filter since the block filters run after all the general filters where duotone is added.
And I didn't see a filter to update the block metadata at render time.
So I ended up with a filter that moves the class after the fact.
Testing Instructions
Here's the example HTML post content from the screenshots using Twenty Twenty.
Testing Instructions for Keyboard
N/A
Screenshots or screencast
Showing images with duotone in multiple contexts in Twenty Twenty. As you can see, before the aligned images didn't get the duotone filters while the unaligned ones did.
Before
After