-
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
Duotone: Output duotone presets per block #48374
Conversation
Flaky tests detected in 50a9763fe0b5a7ec1bea88dd3950cd2d6c6c3dd8. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4284866549
|
lib/block-supports/duotone.php
Outdated
*/ | ||
printf( | ||
'<script>( function() { var el = document.querySelector( %s ); var display = el.style.display; el.style.display = "none"; el.offsetHeight; el.style.display = display; } )();</script>', | ||
wp_json_encode( $selector ) |
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.
$selector
isn't defined in this function. Not sure what it's needed for, but it appears to already run through the footer action above even if it's a global style, so maybe this Safari stuff isn't needed here?
I've tested this on TT3 with the Sherbert theme on a single post template with these images:
It's working in all these cases and only the duotones used on that post are being output in the |
I think there must be something wrong with your testing setup - it shouldn't be working for all these cases yet! |
lib/block-supports/duotone.php
Outdated
} | ||
); | ||
|
||
function gutenberg_save_duotone_preset_svgs( $block_content, $block ) { |
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 runs for every block we render. That might be inefficient...
$styles_variables = ''; | ||
if ( in_array( 'variables', $types, true ) ) { | ||
|
||
// We need to do this first for duotone. |
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.
Elucidate this!
@scruffian - I branched off of this since I was doing one gigantic refactor and couldn't split it into smaller commits. It is working though (I think)! 🎉 #48436 If you think it's a good approach, feel free to merge it into this branch and keep going with it. |
'unset' is a valid attribute to pass, but we don't want to output any svg definition for it. Checking for unset makes sure we're dealing with a valid slug that should output a corresponding svg definition.
…red blocks I'm sorry this is in one giant commit. The general idea is: - On wp_loaded - save all duotone presets defined in merged global styles - save all block names and their corresponding duotone slug info - on block render, check if the block: - is one of the blocks using duotone via global styles - has any defined duotone styles - if so, add it to the duotone_output array to have its duotone info output
50a9763
to
00d3dac
Compare
Duotone received a large refactor and has changed too much. Closing in favor of #48995 |
haha - yes! Good catch! |
What?
This is another angle on #48291.
If we remove the code that outputs the presets, how can we still use presets? This PR suggests saving the presets to an array and then outputting them in the footer. We do this for both block supports, and filters that are defined in the theme.json.
Why?
Outputting unused presets creates extra output that we don't need.
How?
Testing Instructions
Notes
Still to do: