Edit File by line
/home/zeestwma/ceyloniy.../wp-inclu.../blocks
File: post-comments-form.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Server-side rendering of the `core/post-comments-form` block.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Renders the `core/post-comments-form` block on the server.
[8] Fix | Delete
*
[9] Fix | Delete
* @since 6.0.0
[10] Fix | Delete
*
[11] Fix | Delete
* @param array $attributes Block attributes.
[12] Fix | Delete
* @param string $content Block default content.
[13] Fix | Delete
* @param WP_Block $block Block instance.
[14] Fix | Delete
* @return string Returns the filtered post comments form for the current post.
[15] Fix | Delete
*/
[16] Fix | Delete
function render_block_core_post_comments_form( $attributes, $content, $block ) {
[17] Fix | Delete
if ( ! isset( $block->context['postId'] ) ) {
[18] Fix | Delete
return '';
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
if ( post_password_required( $block->context['postId'] ) ) {
[22] Fix | Delete
return;
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
$classes = array( 'comment-respond' ); // See comment further below.
[26] Fix | Delete
if ( isset( $attributes['textAlign'] ) ) {
[27] Fix | Delete
$classes[] = 'has-text-align-' . $attributes['textAlign'];
[28] Fix | Delete
}
[29] Fix | Delete
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
[30] Fix | Delete
$classes[] = 'has-link-color';
[31] Fix | Delete
}
[32] Fix | Delete
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
[33] Fix | Delete
[34] Fix | Delete
add_filter( 'comment_form_defaults', 'post_comments_form_block_form_defaults' );
[35] Fix | Delete
[36] Fix | Delete
ob_start();
[37] Fix | Delete
comment_form( array(), $block->context['postId'] );
[38] Fix | Delete
$form = ob_get_clean();
[39] Fix | Delete
[40] Fix | Delete
remove_filter( 'comment_form_defaults', 'post_comments_form_block_form_defaults' );
[41] Fix | Delete
[42] Fix | Delete
// We use the outermost wrapping `<div />` returned by `comment_form()`
[43] Fix | Delete
// which is identified by its default classname `comment-respond` to inject
[44] Fix | Delete
// our wrapper attributes. This way, it is guaranteed that all styling applied
[45] Fix | Delete
// to the block is carried along when the comment form is moved to the location
[46] Fix | Delete
// of the 'Reply' link that the user clicked by Core's `comment-reply.js` script.
[47] Fix | Delete
$form = str_replace( 'class="comment-respond"', $wrapper_attributes, $form );
[48] Fix | Delete
[49] Fix | Delete
// Enqueue the comment-reply script.
[50] Fix | Delete
wp_enqueue_script( 'comment-reply' );
[51] Fix | Delete
[52] Fix | Delete
return $form;
[53] Fix | Delete
}
[54] Fix | Delete
[55] Fix | Delete
/**
[56] Fix | Delete
* Registers the `core/post-comments-form` block on the server.
[57] Fix | Delete
*
[58] Fix | Delete
* @since 6.0.0
[59] Fix | Delete
*/
[60] Fix | Delete
function register_block_core_post_comments_form() {
[61] Fix | Delete
register_block_type_from_metadata(
[62] Fix | Delete
__DIR__ . '/post-comments-form',
[63] Fix | Delete
array(
[64] Fix | Delete
'render_callback' => 'render_block_core_post_comments_form',
[65] Fix | Delete
)
[66] Fix | Delete
);
[67] Fix | Delete
}
[68] Fix | Delete
add_action( 'init', 'register_block_core_post_comments_form' );
[69] Fix | Delete
[70] Fix | Delete
/**
[71] Fix | Delete
* Use the button block classes for the form-submit button.
[72] Fix | Delete
*
[73] Fix | Delete
* @since 6.0.0
[74] Fix | Delete
*
[75] Fix | Delete
* @param array $fields The default comment form arguments.
[76] Fix | Delete
*
[77] Fix | Delete
* @return array Returns the modified fields.
[78] Fix | Delete
*/
[79] Fix | Delete
function post_comments_form_block_form_defaults( $fields ) {
[80] Fix | Delete
if ( wp_is_block_theme() ) {
[81] Fix | Delete
$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" />';
[82] Fix | Delete
$fields['submit_field'] = '<p class="form-submit wp-block-button">%1$s %2$s</p>';
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
return $fields;
[86] Fix | Delete
}
[87] Fix | Delete
[88] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function