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

Update function names for the public global styles API functions #36907

Merged
merged 2 commits into from
Nov 26, 2021

Conversation

oandregal
Copy link
Member

@oandregal oandregal commented Nov 26, 2021

Follow-up to #34843 and #36610

This PR updates the names of the public functions to access global styles data. It substitutes the gutenberg_* prefix with the wp_* one.

Changes

Before, we had:

  • in Gutenberg we used gutenberg_get_global_settings, gutenberg_get_global_styles and gutenberg_get_global_stylesheet.
  • in WordPress 5.9 we used wp_get_global_settings, wp_get_global_styles, wp_get_global_stylesheet.

After, we have:

  • only wp_get_global_settings, wp_get_global_styles, wp_get_global_stylesheet, both in Gutenberg and WordPress 5.9.

Why we need to do this

By doing this, we fix two issues:

  • We make the wp_* functions available in all WordPress versions supported by the plugin (e.g. WordPress 5.8). These are expected to be used by 3rd parties and we can't have them to change between gutenberg_* or wp_* depending on the environment.

  • We align these with the rationale laid out for how the lib/compat/wordpress-X.X code should work. This is meant to minimize the backport efforts by having in this folder code with the same name as core and checking for function_exist. This way, once the minimum version of the plugin is updated, we just can remove the folder completely and Gutenberg will work nicely, without any other change.

By doing this, we offer a stable way for plugins to get access
to global styles data, no matter the WordPress version they're using
(e.g. WordPress 5.8) or whether the plugin is active or not.
@oandregal oandregal self-assigned this Nov 26, 2021
@oandregal oandregal added Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Nov 26, 2021
Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense.

Makes me wonder what Global Styles and FSE code is remaining outside compat/wordpress-5.9 folder that we should move.

@oandregal
Copy link
Member Author

Created #36913 to do the same for a couple of other functions.

@noisysocks noisysocks removed the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Nov 29, 2021
noisysocks pushed a commit that referenced this pull request Nov 29, 2021
)

* Use wp_* prefix in functions

By doing this, we offer a stable way for plugins to get access
to global styles data, no matter the WordPress version they're using
(e.g. WordPress 5.8) or whether the plugin is active or not.

* Update usage of functions
oandregal added a commit that referenced this pull request Nov 29, 2021
getdave pushed a commit that referenced this pull request Nov 29, 2021
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants