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

Font Library: font families endpoints context default to 'edit'. #58281

Closed
matiasbenedetto opened this issue Jan 25, 2024 · 2 comments · Fixed by #58287
Closed

Font Library: font families endpoints context default to 'edit'. #58281

matiasbenedetto opened this issue Jan 25, 2024 · 2 comments · Fixed by #58287
Labels
[Feature] Font Library [Type] Code Quality Issues or PRs that relate to code quality

Comments

@matiasbenedetto
Copy link
Contributor

matiasbenedetto commented Jan 25, 2024

Description

/font-families/ endpoints default context patameter to edit instead of view. But amost all the core endpoints set the default thecontext parameter to view. Let's change it to default to view.

/**
* Retrieves the query params for the font family collection, defaulting to the 'edit' context.
*
* @since 6.5.0
*
* @param array $args Optional. Additional arguments for context parameter. Default empty array.
* @return array Context parameter details.
*/
public function get_context_param( $args = array() ) {
if ( isset( $args['default'] ) ) {
$args['default'] = 'edit';
}
return parent::get_context_param( $args );
}

Why?

It seems like we misinterpreted the meaning of the context parameter, and we used view because the font families are used by default in the editor, but that seems to be unrelated.

I didn't find the docs in the rest API handbook about it, but this reading is useful: https://make.xwp.co/2017/07/25/defining-context-in-the-wp-rest-api/

Step-by-step reproduction instructions

  • check the context default in lib/experimental/fonts/font-library/class-wp-rest-font-families-controller.php and compare it with most core endpoints.

Screenshots, screen recording, code snippet

Screenshot of a search in core codebase:
image

Environment info

  • Gutenberg trunk

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@matiasbenedetto matiasbenedetto added [Type] Bug An existing feature does not function as intended [Type] Code Quality Issues or PRs that relate to code quality [Feature] Font Library and removed [Type] Bug An existing feature does not function as intended labels Jan 25, 2024
@creativecoder
Copy link
Contributor

Thanks for taking a closer look at this, the linked article was very informative. I've opened a PR to update font-families and font-faces endpoints here: #58287

@matiasbenedetto
Copy link
Contributor Author

fixed by: #58287

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Font Library [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants