Skip to content
Merged
Next Next commit
Block Commenting: Add block-comments as a new post type support
  • Loading branch information
t-hamano committed Sep 16, 2025
commit 42bd1d978c462f1969cd2499773daf6b03983a52
14 changes: 14 additions & 0 deletions lib/experimental/block-comments.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
<?php

/**
* Adds support for block comments to the built-in post types.
*
* @return void
*/
if ( ! function_exists( 'gutenberg_block_comment_add_post_type_support' ) ) {
function gutenberg_block_comment_add_post_type_support() {
add_post_type_support( 'post', 'block-comments' );
add_post_type_support( 'page', 'block-comments' );
}
add_action( 'init', 'gutenberg_block_comment_add_post_type_support' );
}

/**
* Updates the comment type in the REST API.
*
Expand Down
5 changes: 0 additions & 5 deletions packages/editor/src/components/collab-sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,6 @@ export default function CollabSidebar() {
? resultComments.find( ( thread ) => thread.id === blockCommentId )
: null;

// If postId is not a valid number, do not render the comment sidebar.
if ( ! ( !! postId && typeof postId === 'number' ) ) {
return null;
}

return (
<>
<AddCommentComponent
Expand Down
5 changes: 4 additions & 1 deletion packages/editor/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import MoreMenu from '../more-menu';
import PostPreviewButton from '../post-preview-button';
import PostPublishButtonOrToggle from '../post-publish-button/post-publish-button-or-toggle';
import PostSavedState from '../post-saved-state';
import PostTypeSupportCheck from '../post-type-support-check';
import PostViewLink from '../post-view-link';
import PreviewDropdown from '../preview-dropdown';
import ZoomOutToggle from '../zoom-out-toggle';
Expand Down Expand Up @@ -197,7 +198,9 @@ function Header( {
) }

{ isBlockCommentExperimentEnabled ? (
<CollabSidebar />
<PostTypeSupportCheck supportKeys="block-comments">
<CollabSidebar />
</PostTypeSupportCheck>
) : undefined }

{ customSaveButton }
Expand Down
Loading