-
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
Fix duotone theme cache #36236
Fix duotone theme cache #36236
Conversation
Thank you for this, so quick! This seems to fix the cache issues I was seeing on Skatepark myself |
Hey, thanks for creating the PR. This looks a bit involved and I have my brain cycles focused on today's freeze. Would you mind if I come back to this on Monday? It's a bug that we need to fix so we have more leeway than for features. |
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.
Added a few comments to help with reviewing
lib/block-supports/duotone.php
Outdated
@@ -451,6 +486,8 @@ function gutenberg_render_duotone_support( $block_content, $block ) { | |||
wp_add_inline_style( $filter_id, $filter_style ); | |||
wp_enqueue_style( $filter_id ); | |||
|
|||
gutenberg_render_duotone_filter( $filter_preset ); |
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.
Previously this was handled by gutenberg_render_duotone_filter_preset
(above), but now has to be its own separate call.
*/ | ||
function gutenberg_register_duotone_support( $block_type ) { |
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.
This whole function was just moved below without modification.
*/ | ||
function gutenberg_render_duotone_filter_preset( $preset ) { |
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.
Split this into a few functions
gutenberg_get_duotone_filter_property
for generating the filterurl()
propertygutenberg_get_duotone_filter_svg
for creating SVGgutenberg_render_duotone_filter
for rendering the SVG in the appropriate place
This way the SVG can be generated and saved in get_svg_filters
below which can be cached.
The old gutenberg_render_duotone_filter_preset
still exists below for value_func
and for backwards compatibility.
Hey, I wasn't able to look at this yet for reasons. I hope to be able to look at this when the beta1 is in a better place (probably next week?). One overall comment I'd like to share is that we need to be careful with changes to code that landed in WordPress. For example, changes to code in |
No worries, there is a lot going on for the beta release and this is just a bug fix that can go in any time. Feel free to add me on any reviews for things, especially around the color palette work, if you need some help with reviews.
Yep, all functions that existed before still exist with the same signature. I noticed a documentation problem with one of them that I fixed, and I updated some of my review comments to help point to where they all moved since it isn't obvious from the diff. |
Hey, I've been looking at this during the morning and I have a couple of minor details that I'll push shortly if you don't mind (where code lives and function names to make sure backporting is easy). I need to review the duotone block supports a bit more and understand what's new in 5.9 and what existed in 5.8. My current understanding of how duotone works and how this PR changes it:
Is this correct? If so, I've got a couple of questions:
|
@ajlende got to test this a bit and this is what I ran into. Env: WordPress 5.8, so I could test this PR. I've used the TwentyTwentyTwo theme and put this bit under "core/image": {
"filter": {
"duotone": "var(--wp--preset--duotone--foreground-and-background)"
}
} It worked for the front & post editor (reloading the page still showed me the images and they used that filter). The images in the site editor didn't get the filter, though. Then I've tried with a duotone coming from core: "core/image": {
"filter": {
"duotone": "var(--wp--preset--duotone--blue-red)"
}
} and I ran into the same issue as in |
I've tested on |
a05b51d
to
2109308
Compare
Removed at 2109308 We still need to use |
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.
I've tested this in the following scenarios:
- custom filter added by the user
- default filter used by the theme through theme.json
- theme filter used by the theme through theme.json
And it works well in the post and frontend. There's some issue in the site editor but it exists in trunk
already, so can be looked up separately.
I've pushed some code changes here, so I'll let @ajlende merge this one when he feels is right, in case some of what I've done has caused havoc somewhere.
fa40cfc
to
43167b0
Compare
43167b0
to
fa1c821
Compare
Yeah, this was a know issue I'm taking another look at now. #35331 |
We discussed these a bit on Slack, but I'll summarize here for future reference.
One of the places we render duotone filters is for the user-defined custom per-block filters and the other is for the filters defined in theme.json. If we can somehow register the custom filters into some global store and access them from |
Rendering in I updated the footer rendering to be in |
Thanks for merging this! |
Cherry-picked for 5.9.1. |
Co-authored-by: André <583546+oandregal@users.noreply.github.com>
This changeset is a backport for the following Gutenberg PRs: - Fix duotone theme cache: WordPress/gutenberg#36236 - Fix duotone render in non-fse themes gutenberg: WordPress/gutenberg#37954 - Duotone: Allow users to specify custom filters gutenberg: WordPress/gutenberg#38442 Props oandregal, scruffian, Mamaduka. Merges [52757] to the 5.9 branch. See #55179. git-svn-id: https://develop.svn.wordpress.org/branches/5.9@52759 602fd350-edb4-49c9-b593-d223f7449a82
This changeset is a backport for the following Gutenberg PRs: - Fix duotone theme cache: WordPress/gutenberg#36236 - Fix duotone render in non-fse themes gutenberg: WordPress/gutenberg#37954 - Duotone: Allow users to specify custom filters gutenberg: WordPress/gutenberg#38442 Props oandregal, scruffian, Mamaduka. Merges [52757] to the 5.9 branch. See #55179. Built from https://develop.svn.wordpress.org/branches/5.9@52759 git-svn-id: http://core.svn.wordpress.org/branches/5.9@52348 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset is a backport for the following Gutenberg PRs: - Fix duotone theme cache: WordPress/gutenberg#36236 - Fix duotone render in non-fse themes gutenberg: WordPress/gutenberg#37954 - Duotone: Allow users to specify custom filters gutenberg: WordPress/gutenberg#38442 Props oandregal, scruffian, Mamaduka. Merges [52757] to the 5.9 branch. See #55179. Built from https://develop.svn.wordpress.org/branches/5.9@52759 git-svn-id: https://core.svn.wordpress.org/branches/5.9@52348 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset is a backport for the following Gutenberg PRs: - Fix duotone theme cache: WordPress/gutenberg#36236 - Fix duotone render in non-fse themes gutenberg: WordPress/gutenberg#37954 - Duotone: Allow users to specify custom filters gutenberg: WordPress/gutenberg#38442 Props oandregal, scruffian, Mamaduka. Merges [52757] to the 5.9 branch. See #55179. Built from https://develop.svn.wordpress.org/branches/5.9@52759
This changeset is a backport for the following Gutenberg PRs: - Fix duotone theme cache: WordPress/gutenberg#36236 - Fix duotone render in non-fse themes gutenberg: WordPress/gutenberg#37954 - Duotone: Allow users to specify custom filters gutenberg: WordPress/gutenberg#38442 Props oandregal, scruffian, Mamaduka. Merges [52757] to the 5.9 branch. See #55179. Built from https://develop.svn.wordpress.org/branches/5.9@52759 git-svn-id: http://core.svn.wordpress.org/branches/5.9@52348 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Description
Fix #36208
Duotone filters were getting rendered via a side-effect of the global stylesheet generation. Because the stylesheets were cached, the duotone filter rendering wasn't called when the cache hit.
This adds a separate cache for the SVG filters which have to be rendered in the footer of the document, separate from the stylesheet.
How has this been tested?
gutenberg/lib/compat/wordpress-5.9/get-global-styles-and-settings.php
Lines 79 to 85 in 3e84b56
Types of changes
Bug fix
Checklist:
*.native.js
files for terms that need renaming or removal).