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

Mobile - Add new endpoint to get global styles settings through the REST API #29063

Closed
geriux opened this issue Feb 17, 2021 · 3 comments · Fixed by #29969
Closed

Mobile - Add new endpoint to get global styles settings through the REST API #29063

geriux opened this issue Feb 17, 2021 · 3 comments · Fixed by #29969
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) REST API Interaction Related to REST API

Comments

@geriux
Copy link
Member

geriux commented Feb 17, 2021

What problem does this address?

In order to add support for Global Styles on the mobile editor, there should be an endpoint to be able to fetch this data through the REST API.

What is your proposed solution?

There's an opened PR with an exploration of this so we'd need to either continue that effort to use it as a reference.

@geriux geriux added the Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) label Feb 17, 2021
@TimothyBJacobs TimothyBJacobs added the REST API Interaction Related to REST API label Feb 17, 2021
@chipsnyder
Copy link
Contributor

@geriux It looks like we might already have these values in the endpoint /wp/v2/themes?status=active Can we leverage this existing endpoint? Would that endpoint be missing any data that we might need?

https://github.com/WordPress/WordPress/blob/019bc2d244c4d536338d2c634419583e928143df/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php#L17

@oandregal oandregal added the Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json label Feb 23, 2021
@geriux
Copy link
Member Author

geriux commented Feb 23, 2021

@geriux It looks like we might already have these values in the endpoint /wp/v2/themes?status=active Can we leverage this existing endpoint? Would that endpoint be missing any data that we might need?

https://github.com/WordPress/WordPress/blob/019bc2d244c4d536338d2c634419583e928143df/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php#L17

Hey @chipsnyder 👋

Unfortunately, that endpoint doesn't return the values that we need (contents of theme.json). I guess we could add the theme.json values but there are other things like __experimentalGlobalStylesUserEntityId logic which we'll need to bring any changes of the Global styles settings from the user.

So I think we should create a new endpoint that pulls the data from lib/global-styles.php, my only concern now is that it is filtering to only work if you're editing a site page so we'd need to figure out a way to make it work for both cases, on the web when you're editing your site (as it is now) and returning these settings without any gutenberg_is_edit_site_page checks through the REST API.

@chipsnyder
Copy link
Contributor

Thanks @geriux for confirming. Diving in more I realized I was confusing theme_support with theme.json

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 Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) REST API Interaction Related to REST API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants