-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Block Commenting: Add block-comments as a new post type support #71682
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
Conversation
7882ad3 to
42bd1d9
Compare
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: +15 B (0%) Total Size: 1.95 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in f64cfef. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/17763784020
|
Mamaduka
left a comment
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.
Thanks, @t-hamano!
I like the opt-in nature of this new support feature, and block-comments seems to be a good name.
Cc @swissspidy, you've worked on some recent post-type supports. Did we miss anything?
|
Why is this a top level support and not a property of the editor support? That would make way more sense to me at first glance. Can't have block-comments without editor support. |
|
That's a good point, @swissspidy! The block comments don't work without the block editor. @t-hamano, I think we also will need to update |
I would like to confirm under what conditions the block comment support is considered enabled. My understanding is as follows, but is it correct? ✅Block Comment is enabled: register_post_type(
'post',
array(
// ...
'supports' => array(
'title',
'editor' => array(
'block-comments' => true,
),
),
)
);❌ Block Comment is disabled: register_post_type(
'post',
array(
// ...
'supports' => array( 'title', 'editor' ),
)
);
register_post_type(
'post',
array(
// ...
'supports' => array( 'title' ),
)
);
register_post_type(
'post',
array(
// ...
'supports' => array(
'title',
'editor' => array(
'block-comments' => false,
),
),
)
); |
|
We could also say it's implicitly enabled unless explicitly disabled. So |
|
@swissspidy, I think we want to make this feature opt-in and enable it only for Posts and Pages by default. The |
|
I just realized that This could be problematic for our use cases, as the editor is beginning to manage some of its features through sub-property flags. add_action( 'init', function() {
add_post_type_support( 'page', 'editor', array(
'default-mode' => 'template-locked',
) );
// This second call will overwrite the first sub-support property instead of merging.
add_post_type_support( 'page', 'editor', array(
'block-comments' => true,
) );
} ); |
adamsilverstein
left a comment
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.
Nice!
Ideally, we may need to update the add_post_type_support() function so that the third argument (sub-properties) is automatically merged. However, for now, we may need to incorporate the subproperty merging logic ourselves into this PR, and I plan to work on that before merging this PR. |
2ba0670 to
4894b77
Compare
4894b77 to
42025a0
Compare
|
In 42025a0, I made sure to explicitly merge the subproperties so that even if the consumer had predefined editor support subproperties, they wouldn't be overwritten. |
Co-authored-by: George Mamadashvili <georgemamadashvili@gmail.com>
|
@t-hamano, are there any blockers here? |
|
@Mamaduka I think there are no blockers. Are we good to merge this PR? |
|
@t-hamano, yes. Let's merge this. |
block-commentas a new post type support #71642What?
This PR adds a new
'block-comments'post type support to Page and Post.Why?
In #71643, we disabled the block commenting when postId is not a number, because the block commenting functionality doesn't work in the template or template part, which has a string value post id, such as 'twentytwentyfive//home'.
That said, ideally, enabling block commenting should depend on whether the post type supports it, rather than on whether the post ID is an integer.
How?
Adds a new
'block-comments'post type support. I'm not sure which is better,block-commentsorblock-comment..P.S. If the Block Commenting is stabilized and shipped into core, I plan to add new block support here directly.
https://github.com/WordPress/wordpress-develop/blob/da61a89ddebabc030db6a218ccac6d6a85f91fc3/src/wp-includes/post.php#L40
Testing Instructions
Confirm that you can comment on a block in the post or page editor.
Confirm that you can NOT comment on a block in the template or template part, or pattern editor.