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

Backport the global styles variations changes from Gutenberg #2503

Conversation

youknowriad
Copy link
Contributor

This PR backports the global styles variations endpoint changes from the Gutenberg plugin.

Trac ticket: https://core.trac.wordpress.org/ticket/55505

@youknowriad youknowriad self-assigned this Apr 4, 2022
@gziolo
Copy link
Member

gziolo commented Apr 4, 2022

@oandregal and @jorgefilipecosta, we would appreciate your help here.

@youknowriad
Copy link
Contributor Author

I think I managed to fix the tests, let's see what CI says.

@youknowriad youknowriad force-pushed the backport/global-styles-variations-changes branch from 8640d53 to 176009e Compare April 4, 2022 12:57
gziolo added 2 commits April 4, 2022 15:46
GitHub UI isn't perfect for that 😅
@oandregal
Copy link
Member

@youknowriad it looks like the only failing test is WP_Test_REST_Schema_Initialization::test_expected_routes_in_schema, which is missing one of the global styles routes.

@youknowriad
Copy link
Contributor Author

I guess we need to regenerate that REST API fixtures file, I forgot how to do that. I can the entry manually though.

@oandregal
Copy link
Member

This is working as expected for me.

This is what I've done to test:

Created a styles folder within src/wp-content/themes/twentytwentytwo with two files.

bluish.json whose content was:

{
  "version": 2,
  "title": "Blue style",
  "styles": {
    "color": {
      "background": "blue",
      "text": "white"
    }
  },
  "settings": {
    "color": {
      "palette": [
        { "slug": "blue", "name": "Blue", "color": "blue" }
      ]
    }
  }
}

redish.json whose content was:

{
  "version": 2,
  "title": "Red style",
  "styles": {
    "color": {
      "background": "red",
      "text": "white"
    }
  },
  "settings": {
    "color": {
      "palette": [
        { "slug": "red", "name": "Red", "color": "red" }
      ]
    }
  }
}

Then, I opened the site editor and, in the console, executed this command: wp.apiFetch({path: '/wp/v2/global-styles/themes/twentytwentytwo/variations', method: 'GET'}). Once the request is resolved I saw the content of the style variations.

I've also tested with the existing TwentyTwentyTwo theme with no styles folder and also works fine (the endpoint returns 0 style variations).

@youknowriad
Copy link
Contributor Author

@gziolo Should I go ahead and commit this one?

@gziolo
Copy link
Member

gziolo commented Apr 5, 2022

@gziolo Should I go ahead and commit this one?

That would be fantastic, thank you 🙇🏻

@youknowriad
Copy link
Contributor Author

committed in https://core.trac.wordpress.org/changeset/53072

@youknowriad youknowriad closed this Apr 5, 2022
@youknowriad youknowriad deleted the backport/global-styles-variations-changes branch April 5, 2022 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants