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

Try: bundle WP_REST_Global_Styles_Controller class instead of inheriting per WordPress version #53618

Merged
merged 5 commits into from
Aug 14, 2023

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented Aug 14, 2023

What?

Similar to:

This PR bundles rest global styles controller code into one class WP_REST_Global_Styles_Controller to avoid conflicts, and to make sure the response always reflects changes from WP_Theme_JSON_Gutenberg.

The WP_REST_Global_Styles_Controller is the endpoint that fetches the contents of the theme global styles custom post from the database.

Why?

Context for change: https://github.com/WordPress/gutenberg/pull/53451/files#r1289969201

For many of the reasons cited in #46579, but also because the underlying response is directly affected by changes to WP_Theme_JSON_Gutenberg.

How?

Removing all extensions in lib/compat and creating an "evergreen" file under /lib.

Testing Instructions

Check that all tests pass on CI.

Ensure both classic (TwentyTwenty) and block themes (TwentyTwentyThree) load properly and that any presets are loaded and work correctly.

For block themes, perform some common global styles-related functions, e.g.,

In the site editor, check that the endpoint returns the current merged theme.json. Run this command in the browser console:

await wp.apiFetch( { url: `/index.php?rest_route=%2Fwp%2Fv2%2Fglobal-styles%2F${ wp.data.select('core').__experimentalGetCurrentGlobalStylesId() }&_locale=user` } );

In the site editor, make some changes to the global styles (e.g.,: select a different style variation, add a custom color palette). Refresh the page and verify they are applied everywhere (editor, front-end).

Check that the revisions count in the global styles revisions drop down is accurate

@ramonjd ramonjd added [Type] Code Quality Issues or PRs that relate to code quality Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Aug 14, 2023
@ramonjd ramonjd self-assigned this Aug 14, 2023
@github-actions
Copy link

github-actions bot commented Aug 14, 2023

This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.

If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged.

If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack.

Thank you! ❤️

View changed files
❔ lib/class-wp-rest-global-styles-controller-gutenberg.php
❔ lib/rest-api.php
❔ lib/compat/wordpress-6.4/rest-api.php
❔ lib/load.php
❔ phpunit/class-wp-rest-global-styles-controller-gutenberg-test.php

@github-actions
Copy link

github-actions bot commented Aug 14, 2023

Flaky tests detected in c8f3f3e213fff1c7e47756d5321139a88ddf9284.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5852630758
📝 Reported issues:

@ramonjd
Copy link
Member Author

ramonjd commented Aug 14, 2023

@michalczaplinski Sorry, I think I missed something in relation to 'behaviors'. The E2E tests are failing.

Trying to find it, but am code blind. 😅

@ramonjd
Copy link
Member Author

ramonjd commented Aug 14, 2023

@michalczaplinski Sorry, I think I missed something in relation to 'behaviors'. The E2E tests are failing.

Never mind. User error. Forgot to import a file and got too excited 🤦🏻 All is well.

…s and ensure the response always reflects changes from WP_Theme_JSON_Gutenberg
… block comment" and "Empty lines are not allowed in multi-line function calls" rules.

Which one will prevail?

For now just use single line comments to shut them both up.
@ramonjd ramonjd force-pushed the try/bundle-global-styles-controller branch from c8f3f3e to 111c7e0 Compare August 14, 2023 07:09
@ramonjd ramonjd merged commit c4ff7b1 into trunk Aug 14, 2023
50 checks passed
@ramonjd ramonjd deleted the try/bundle-global-styles-controller branch August 14, 2023 23:34
@github-actions github-actions bot added this to the Gutenberg 16.5 milestone Aug 14, 2023
@mikachan mikachan added the Needs PHP backport Needs PHP backport to Core label Sep 5, 2023
ramonjd added a commit to ramonjd/wordpress-develop that referenced this pull request Sep 6, 2023
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] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants