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

Conversation

anton-vlasenko
Copy link

@anton-vlasenko anton-vlasenko commented Jun 3, 2024

This PR is a backport of WordPress/gutenberg#60642 to WordPress Core.

Trac ticket: https://core.trac.wordpress.org/ticket/61360

This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Copy link

github-actions bot commented Jun 3, 2024

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@anton-vlasenko anton-vlasenko marked this pull request as ready for review June 3, 2024 22:34
Copy link

github-actions bot commented Jun 3, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @anton@antons-mac-mini.local.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

Core Committers: Use this line as a base for the props when committing in SVN:

Props antonvlasenko, timothyblynjacobs, ellatrix, oandregal.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

$schema['properties']['class_list'] = array(
'description' => __( 'An array of the class names for the post container element.' ),
'type' => 'array',
'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.

@@ -2353,6 +2357,15 @@ public function get_item_schema() {
'context' => array( 'edit' ),
'readonly' => true,
);

$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.

}

if ( 1 === preg_match( '/^post-\d+$/', $value ) ) {
$data[ $key ] = 'post-1073';
Copy link
Member

Choose a reason for hiding this comment

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

What is this? Why is this hardcoded? Is it for test stability? Might be good to comment.

Copy link
Author

@anton-vlasenko anton-vlasenko Jun 4, 2024

Choose a reason for hiding this comment

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

Yes, it's to ensure test stability. Fixed in d24ee39.
P.S. I'll quckly check if hardcoding the value can be avoided. For now, let's just add the comment.

Copy link
Author

@anton-vlasenko anton-vlasenko Jun 4, 2024

Choose a reason for hiding this comment

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

I've discovered an improved method for adding these fixture replacements. While the current implementation works, the approach detailed here offers a better solution: WordPress Core Ticket #61369.

This isn't urgent since the current setup functions adequately for mocking the REST API. However, it would be great if someone could review the new approach when they have time.

@oandregal oandregal changed the title Templates: only resolve patterns for REST API endpoints Jun 4, 2024
@ellatrix
Copy link
Member

ellatrix commented Jun 4, 2024

Looks good to me to and works.

pento pushed a commit that referenced this pull request Jun 4, 2024
See WordPress/gutenberg#60642.
See #6716.

Fixes #61360.

Props antonvlasenko, timothyblynjacobs, ellatrix, oandregal.



git-svn-id: https://develop.svn.wordpress.org/trunk@58326 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Jun 4, 2024
See WordPress/gutenberg#60642.
See WordPress/wordpress-develop#6716.

Fixes #61360.

Props antonvlasenko, timothyblynjacobs, ellatrix, oandregal.


Built from https://develop.svn.wordpress.org/trunk@58326


git-svn-id: http://core.svn.wordpress.org/trunk@57783 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@ellatrix ellatrix closed this Jun 4, 2024
github-actions bot pushed a commit to gilzow/wordpress-performance that referenced this pull request Jun 4, 2024
See WordPress/gutenberg#60642.
See WordPress/wordpress-develop#6716.

Fixes #61360.

Props antonvlasenko, timothyblynjacobs, ellatrix, oandregal.


Built from https://develop.svn.wordpress.org/trunk@58326


git-svn-id: https://core.svn.wordpress.org/trunk@57783 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants