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

Updates Font Families and Font Faces endpoints context param #58287

Merged
merged 2 commits into from Jan 26, 2024

Conversation

creativecoder
Copy link
Contributor

@creativecoder creativecoder commented Jan 25, 2024

What?

Updates the wp/v2/font-families and wp/v2/font-families/<id>/font-faces endpoints context param

  • Default context to view, to be consistent with other Core endpoints
  • Accept view, edit, and embed, since viewing, editing, and embedding are valid contexts for both objects

Why?

As pointed out by @matiasbenedetto here, the context param seems to be not about where the request is being called from (front-end vs. editor), but about what information is needed to take a specific action on the object.

How?

Updates the endpoint schema and defaults.

Testing Instructions

  • Make requests to the following endpoints using view, edit, embed and no value for ?context=
    • GET wp/v2/font-families
    • GET wp/v2/font-families
    • GET wp/v2/font-families/<id>/font-faces
    • GET wp/v2/font-families/<id>/font-faces/<id>
  • See that all fields are returned for all contexts
  • You can also check OPTIONS requests to see that the context param correctly defaults to view and accepts any of those three contexts as valid

@creativecoder creativecoder added [Type] Bug An existing feature does not function as intended REST API Interaction Related to REST API [Feature] Font Library labels Jan 25, 2024
@creativecoder creativecoder self-assigned this Jan 25, 2024
Copy link

github-actions bot commented Jan 25, 2024

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/experimental/fonts/font-library/class-wp-rest-font-faces-controller.php
❔ lib/experimental/fonts/font-library/class-wp-rest-font-families-controller.php
❔ phpunit/tests/fonts/font-library/wpRestFontFacesController.php
❔ phpunit/tests/fonts/font-library/wpRestFontFamiliesController.php

@creativecoder creativecoder added [Type] Enhancement A suggestion for improvement. and removed [Type] Bug An existing feature does not function as intended labels Jan 25, 2024
Copy link
Contributor

@matiasbenedetto matiasbenedetto left a comment

Choose a reason for hiding this comment

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

  • Defaulting the context to view seems in line with most of WordPress core controllers.

  • Having the 3 context view, edit and embed in most of the properties seems correct as we don't have reasons to 'hide' those properties in those contexts.

Looks good to me.

@creativecoder creativecoder changed the title Updates Font Families and Font Faces endpoint context param Updates Font Families and Font Faces endpoints context param Jan 26, 2024
@creativecoder creativecoder merged commit 113eb47 into trunk Jan 26, 2024
57 checks passed
@creativecoder creativecoder deleted the update/font-family-face-controllers-context branch January 26, 2024 18:41
@github-actions github-actions bot added this to the Gutenberg 17.7 milestone Jan 26, 2024
@creativecoder creativecoder added the Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) label Jan 26, 2024
@cbravobernal
Copy link
Contributor

I just cherry-picked this PR to the release/17.6 branch to get it included in the next release: 7529726

@cbravobernal cbravobernal removed the Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) label Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Font Library REST API Interaction Related to REST API [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Font Library: font families endpoints context default to 'edit'.
3 participants