-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Respect fields param for global styles REST API requests. #36206
Conversation
Fixes originally from #36076 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Supporting the _fields
might be good here, we don't need it ourselves but it doesn't hurt I guess.
I'll defer to you all REST API folks.
$data['id'] = $post->ID; | ||
} | ||
|
||
if ( rest_is_field_included( 'title', $fields ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we include both raw and rendered here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is what is happening in the line below 😄
$data['title']['raw'] = $post->post_title; | ||
} | ||
if ( rest_is_field_included( 'title.rendered', $fields ) ) { | ||
add_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected style variations is not something that is meaningful for the global styles IMO, so I'd rather remove all these "protected" handling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how core handles protected titles. We can't do much about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Global styles posts won't be password protected, so I'm not sure we need to handle it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better safe than sorry?
* Respect fields param for REST API requests. * Fix lint
* Respect fields param for REST API requests. * Fix lint
Cherry picked into the Gutenberg 11.9 release in: b147195 |
Description
The global styles endpoint, does not respect fields param passed a query string.
This fix, addresses that issue.
This PR also fixes protected titles.
How has this been tested?
Screenshots
Types of changes
Checklist:
*.native.js
files for terms that need renaming or removal).