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

wp_get_global_styles: return values instead of CSS Custom Properties #49712

Closed
oandregal opened this issue Apr 11, 2023 · 3 comments
Closed

wp_get_global_styles: return values instead of CSS Custom Properties #49712

oandregal opened this issue Apr 11, 2023 · 3 comments
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Enhancement A suggestion for improvement.

Comments

@oandregal
Copy link
Member

Related #49693 #45171

What problem does this address?

The wp_get_global_styles function returns the content in the theme.json.

For example, for a content such as:

"core/post-terms": {
    "typography": { "fontSize": "var(--wp--preset--font-size--small)" }
}

The expected result is:

(
    [typography] => Array( [fontSize] => var(--wp--preset--font-size--small) )
)

Some environments don't have support for CSS Custom Properties. For example, mobile or email templates. They have to parse the content to understand it and convert it to a value they can use.

What is your proposed solution?

There are two alternatives we could explore to help them use theme.json provided values:

  • Add some new parameter to wp_get_global_styles that tells the function to resolve the CSS Custom Properties to the value they reference.
  • Create a new function, for example wp_get_global_styles_values, that does the same.
@oandregal oandregal added the Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json label Apr 11, 2023
@kathrynwp kathrynwp added the [Type] Enhancement A suggestion for improvement. label Apr 11, 2023
@samnajian
Copy link
Contributor

@oandregal I'd rather go with your second proposal since:

  1. The use case is pretty limited for now, so it's better to not adjust the main, more multi-purpose function to do even more
  2. wp_get_global_styles is already receiving 2 parameters in the form of arrays, which in the absence of proper typing on the language level are confusing enough, so refraining from adding a new parameter to the same rather complex input parameters would keep the complexity the same and not add to it.

So basically by introducing a new function, we can keep the complexity to the underlying classes and not push it to the user side.

@oandregal
Copy link
Member Author

Relevant thread for this conversation, so we can see everything together https://github.com/WordPress/gutenberg/pull/50484/files#r1192502874

@oandregal
Copy link
Member Author

This has been fixed by #50484

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

3 participants