diff --git a/docs/reference-guides/core-blocks.md b/docs/reference-guides/core-blocks.md
index a27de8211c824a..caf6e86fc061f9 100644
--- a/docs/reference-guides/core-blocks.md
+++ b/docs/reference-guides/core-blocks.md
@@ -187,7 +187,7 @@ An advanced block that allows displaying post comments using different visual co
- **Name:** core/comments
- **Category:** theme
- **Supports:** align (full, wide), color (background, gradients, heading, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~
-- **Attributes:** legacy, tagName
+- **Attributes:** enhancedSubmission, legacy, tagName
## Comments Pagination
diff --git a/packages/block-library/package.json b/packages/block-library/package.json
index b196e53e5cd0f9..f07662650b8feb 100644
--- a/packages/block-library/package.json
+++ b/packages/block-library/package.json
@@ -30,6 +30,7 @@
"./file/view": "./build-module/file/view.js",
"./image/view": "./build-module/image/view.js",
"./navigation/view": "./build-module/navigation/view.js",
+ "./post-comments-form/view": "./build-module/post-comments-form/view.js",
"./query/view": "./build-module/query/view.js",
"./search/view": "./build-module/search/view.js"
},
diff --git a/packages/block-library/src/comment-reply-link/block.json b/packages/block-library/src/comment-reply-link/block.json
index 68aa93c3c1526a..24c5ef162392d5 100644
--- a/packages/block-library/src/comment-reply-link/block.json
+++ b/packages/block-library/src/comment-reply-link/block.json
@@ -7,7 +7,7 @@
"ancestor": [ "core/comment-template" ],
"description": "Displays a link to reply to a comment.",
"textdomain": "default",
- "usesContext": [ "commentId" ],
+ "usesContext": [ "commentId", "enhancedSubmission" ],
"attributes": {
"textAlign": {
"type": "string"
diff --git a/packages/block-library/src/comment-reply-link/index.php b/packages/block-library/src/comment-reply-link/index.php
index 7121b6f25a195e..8eb997c310b513 100644
--- a/packages/block-library/src/comment-reply-link/index.php
+++ b/packages/block-library/src/comment-reply-link/index.php
@@ -63,6 +63,17 @@ function render_block_core_comment_reply_link( $attributes, $content, $block ) {
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
+ $p = new WP_HTML_Tag_Processor( $comment_reply_link );
+ if ( $p->next_tag(
+ array(
+ 'tag_name' => 'A',
+ 'class_name' => 'comment-reply-link',
+ )
+ ) ) {
+ $p->set_attribute( 'data-wp-on--click', 'actions.changeReplyTo' );
+ }
+ $comment_reply_link = $p->get_updated_html();
+
return sprintf(
'
%2$s
',
$wrapper_attributes,
diff --git a/packages/block-library/src/comment-template/block.json b/packages/block-library/src/comment-template/block.json
index 08fd591b42409b..abea94d7f8c776 100644
--- a/packages/block-library/src/comment-template/block.json
+++ b/packages/block-library/src/comment-template/block.json
@@ -7,7 +7,7 @@
"parent": [ "core/comments" ],
"description": "Contains the block elements used to display a comment, like the title, date, author, avatar and more.",
"textdomain": "default",
- "usesContext": [ "postId" ],
+ "usesContext": [ "postId", "enhancedSubmission" ],
"supports": {
"align": true,
"html": false,
diff --git a/packages/block-library/src/comment-template/index.php b/packages/block-library/src/comment-template/index.php
index ec462e6a050de2..5c430148767dca 100644
--- a/packages/block-library/src/comment-template/index.php
+++ b/packages/block-library/src/comment-template/index.php
@@ -20,6 +20,7 @@ function block_core_comment_template_render_comments( $comments, $block ) {
global $comment_depth;
$thread_comments = get_option( 'thread_comments' );
$thread_comments_depth = get_option( 'thread_comments_depth' );
+ $enhanced_submission = isset( $block->context['enhancedSubmission'] ) && $block->context['enhancedSubmission'];
if ( empty( $comment_depth ) ) {
$comment_depth = 1;
@@ -83,7 +84,15 @@ function block_core_comment_template_render_comments( $comments, $block ) {
}
}
- $content .= sprintf( '', $comment->comment_ID, $comment_classes, $block_content );
+ $comment_directives = $enhanced_submission ? ' data-wp-key="comment-' . $comment->comment_ID . '" data-wp-slot=\'{"name":"comment-' . $comment->comment_ID . '","position":"after"}\'' : '';
+
+ $content .= sprintf(
+ '',
+ $comment->comment_ID,
+ $comment_classes,
+ $comment_directives,
+ $block_content
+ );
}
return $content;
diff --git a/packages/block-library/src/comments/block.json b/packages/block-library/src/comments/block.json
index ceb8f750c3472d..a5a25fec702314 100644
--- a/packages/block-library/src/comments/block.json
+++ b/packages/block-library/src/comments/block.json
@@ -14,6 +14,10 @@
"legacy": {
"type": "boolean",
"default": false
+ },
+ "enhancedSubmission": {
+ "type": "boolean",
+ "default": false
}
},
"supports": {
@@ -60,5 +64,8 @@
}
},
"editorStyle": "wp-block-comments-editor",
- "usesContext": [ "postId", "postType" ]
+ "usesContext": [ "postId", "postType" ],
+ "providesContext": {
+ "enhancedSubmission": "enhancedSubmission"
+ }
}
diff --git a/packages/block-library/src/comments/edit/comments-inspector-controls.js b/packages/block-library/src/comments/edit/comments-inspector-controls.js
index 1a33cb68ea38a6..d50a3cca3cccaf 100644
--- a/packages/block-library/src/comments/edit/comments-inspector-controls.js
+++ b/packages/block-library/src/comments/edit/comments-inspector-controls.js
@@ -1,12 +1,19 @@
/**
* WordPress dependencies
*/
-import { SelectControl } from '@wordpress/components';
+import {
+ SelectControl,
+ PanelBody,
+ ToggleControl,
+ Notice,
+} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { InspectorControls } from '@wordpress/block-editor';
+import { useEffect, useRef } from '@wordpress/element';
+import { speak } from '@wordpress/a11y';
export default function CommentsInspectorControls( {
- attributes: { tagName },
+ attributes: { tagName, enhancedSubmission },
setAttributes,
} ) {
const htmlElementMessages = {
@@ -17,8 +24,21 @@ export default function CommentsInspectorControls( {
"The