-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Typography: theme.json "layout" settings cannot be custom css variables or references, must be explicit values #55070
Comments
Hi @ouw-jvt, This issue does not seem to reproduce in WordPress 6.4 Beta, and with the latest Gutenberg plugin.
Is it possible to use something like the Beta Tester plugin to check if this problem occurs even with the latest WordPress core? |
Thanks for creating this issue. What I think is happening is, since Wordpress 6.3.x, specifically #53551, the typography block supports will fallback to The fallback value is set as The workaround for now could be to hardcode your values into "typography": {
"fluid": {
"maxViewportWidth": "1980px",
},
} This was introduced in Wordpress 6.4 in #53081 (it's been in the plugin since 16.5) So CSS vars are not resolved. This is equally true of Another idea might be to introduce filters so theme developers could use their own
This is a very good suggestion, thank you! I can update the docs with the current reality as well as pragmatic workaround. |
Actually I don't have access :) It looks like the docs are getting an overhaul anyway: https://github.com/WordPress/Documentation-Issue-Tracker/issues?q=is%3Aissue+is%3Aopen+theme.json In the meantime, the most trustworthy reference is the living theme.json schema, which should always reflect the latest changes in Gutenberg: gutenberg/schemas/json/theme.json Line 286 in 8ef6e40
|
@ramonjd I'll see if I can get involved in that documentation rewrite! |
Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks. |
Description
If you attempt to set the
contentSize
orwideSize
property ofsettings.layout
to a custom variable defined insettings.custom
, the PHP portion of the style generation does not properly interpret the variable and map it to the real value. This causes some features to stop working, such as fluid typography.In order to fix this,
wp_get_typography_value_and_unit()
from typography.php (or the methods calling it) would need to detect the presence of and interpolate the variable to its value by fetching it fromwp_get_global_settings()
(in the case of the below example's suggested fix, that would be$global_settings['custom'][layout][wideSize]
).While this may not be intended functionality, every other theme.json setting (that I have tried) seems to work when set to a variable. It's also useful for child theme inheritance and SASS workflows. Additional use cases are mentioned in #53525. However, if this will not be supported, a note in documentation demonstrating the formatting requirements of this particular setting would suffice.
Step-by-step reproduction instructions
In a block theme, using this example theme.json causes the fluid type (expected on the h1 style) to fail and revert to the
size
key. Key lines are"contentSize": "var(--wp--custom--layout--content-size)",
and"wideSize": "var(--wp--custom--layout--wide-size)"
.By switching back to a pixel value, things work as expected
Potential solutions
theme.json variable detection and lookup
In
typography.php
wp_get_typography_value_and_unit()
after theis_numeric()
check (link to source here):$raw_value
) for the text "var(--wp--)"wp_get_global_settings()
array.A similar method could be used to handle
ref
entries, as well (mentioned in #53525)Pitfalls
Could be expensive, performance-wise, to traverse the entire theme.json checking for a match (possibly multiple times)
Documentation and/or json schema update
If we can't implement this, we should note it in the layout setting's documentation and the schema description for the field. It may be appropriate to do this anywhere in which a value is expected in a specific format literally/directly by the style engine PHP.
Environment info and related issues
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
Related issue
Suggested tags
The text was updated successfully, but these errors were encountered: