equal
deleted
inserted
replaced
5 * @package WordPress |
5 * @package WordPress |
6 */ |
6 */ |
7 |
7 |
8 /** |
8 /** |
9 * Renders the `core/post-comments-form` block on the server. |
9 * Renders the `core/post-comments-form` block on the server. |
|
10 * |
|
11 * @since 6.0.0 |
10 * |
12 * |
11 * @param array $attributes Block attributes. |
13 * @param array $attributes Block attributes. |
12 * @param string $content Block default content. |
14 * @param string $content Block default content. |
13 * @param WP_Block $block Block instance. |
15 * @param WP_Block $block Block instance. |
14 * @return string Returns the filtered post comments form for the current post. |
16 * @return string Returns the filtered post comments form for the current post. |
20 |
22 |
21 if ( post_password_required( $block->context['postId'] ) ) { |
23 if ( post_password_required( $block->context['postId'] ) ) { |
22 return; |
24 return; |
23 } |
25 } |
24 |
26 |
25 $classes = 'comment-respond'; // See comment further below. |
27 $classes = array( 'comment-respond' ); // See comment further below. |
26 if ( isset( $attributes['textAlign'] ) ) { |
28 if ( isset( $attributes['textAlign'] ) ) { |
27 $classes .= ' has-text-align-' . $attributes['textAlign']; |
29 $classes[] = 'has-text-align-' . $attributes['textAlign']; |
28 } |
30 } |
29 |
31 if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { |
30 $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); |
32 $classes[] = 'has-link-color'; |
|
33 } |
|
34 $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) ); |
31 |
35 |
32 add_filter( 'comment_form_defaults', 'post_comments_form_block_form_defaults' ); |
36 add_filter( 'comment_form_defaults', 'post_comments_form_block_form_defaults' ); |
33 |
37 |
34 ob_start(); |
38 ob_start(); |
35 comment_form( array(), $block->context['postId'] ); |
39 comment_form( array(), $block->context['postId'] ); |
50 return $form; |
54 return $form; |
51 } |
55 } |
52 |
56 |
53 /** |
57 /** |
54 * Registers the `core/post-comments-form` block on the server. |
58 * Registers the `core/post-comments-form` block on the server. |
|
59 * |
|
60 * @since 6.0.0 |
55 */ |
61 */ |
56 function register_block_core_post_comments_form() { |
62 function register_block_core_post_comments_form() { |
57 register_block_type_from_metadata( |
63 register_block_type_from_metadata( |
58 __DIR__ . '/post-comments-form', |
64 __DIR__ . '/post-comments-form', |
59 array( |
65 array( |
64 add_action( 'init', 'register_block_core_post_comments_form' ); |
70 add_action( 'init', 'register_block_core_post_comments_form' ); |
65 |
71 |
66 /** |
72 /** |
67 * Use the button block classes for the form-submit button. |
73 * Use the button block classes for the form-submit button. |
68 * |
74 * |
|
75 * @since 6.0.0 |
|
76 * |
69 * @param array $fields The default comment form arguments. |
77 * @param array $fields The default comment form arguments. |
70 * |
78 * |
71 * @return array Returns the modified fields. |
79 * @return array Returns the modified fields. |
72 */ |
80 */ |
73 function post_comments_form_block_form_defaults( $fields ) { |
81 function post_comments_form_block_form_defaults( $fields ) { |
74 if ( wp_is_block_theme() ) { |
82 if ( wp_is_block_theme() ) { |
75 $fields['submit_button'] = '<input name="%1$s" type="submit" id="%2$s" class="%3$s wp-block-button__link" value="%4$s" />'; |
83 $fields['submit_button'] = '<input name="%1$s" type="submit" id="%2$s" class="wp-block-button__link ' . wp_theme_get_element_class_name( 'button' ) . '" value="%4$s" />'; |
76 $fields['submit_field'] = '<p class="form-submit wp-block-button">%1$s %2$s</p>'; |
84 $fields['submit_field'] = '<p class="form-submit wp-block-button">%1$s %2$s</p>'; |
77 } |
85 } |
78 |
86 |
79 return $fields; |
87 return $fields; |
80 } |
88 } |