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

Output post classes in the editor #6716

Closed
wants to merge 17 commits into from
Prev Previous commit
Next Next commit
Don't add to embed context.
  • Loading branch information
anton-vlasenko authored and Anton Vlasenko committed Jun 4, 2024
commit 4b07732b3b6c802880ae7e7423f888f1f0caddcc
Original file line number Diff line number Diff line change
Expand Up @@ -2359,9 +2359,9 @@ public function get_item_schema() {
);

$schema['properties']['class_list'] = array(
Copy link
Member

Choose a reason for hiding this comment

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

We should add a readonly keyword.

Copy link
Author

Choose a reason for hiding this comment

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

Good catch. Fixed in e4c1641
Thanks.

'description' => __( 'An array of the class names for the post container element.' ),
'description' => __( 'An array of the CSS class names for the post container element.' ),
'type' => 'array',
'context' => array( 'view', 'edit', 'embed' ),
'context' => array( 'view', 'edit' ),
Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure about the context.
It seems that 'view' and 'edit' would be appropriate for this field, but I could use some help here. I'd be happy to update the PR if these contexts are not correct for the given field.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah view and edit looks correc to me. Basically everything should have edit, and view should be used if it's a non-privileged field.

The embed context is a bit of a bar to meet. It should be used when developers would often need this information when including the resource as an embed. That doesn't seem the case to me here, since the class list would most often be used when looping over the list of posts as a main query.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for the information. It's indeed very helpful in understanding when to use the embed context.

'items' => array(
'type' => 'string',
),
Expand Down