-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathindex.php
39 lines (35 loc) · 1005 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/**
* Server-side rendering of the `core/post-comments-form` block.
*
* @package WordPress
*/
/**
* Renders the `core/post-comments-form` block on the server.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
* @return string Returns the filtered post comments form for the current post.
*/
function render_block_core_post_comments_form( $attributes, $content, $block ) {
if ( ! isset( $block->context['postId'] ) ) {
return '';
}
ob_start();
comment_form( array(), $block->context['postId'] );
$form = ob_get_clean();
return $form;
}
/**
* Registers the `core/post-comments-form` block on the server.
*/
function register_block_core_post_comments_form() {
register_block_type_from_metadata(
__DIR__ . '/post-comments-form',
array(
'render_callback' => 'render_block_core_post_comments_form',
)
);
}
add_action( 'init', 'register_block_core_post_comments_form' );