Skip to content

Commit b78d04a

Browse files
jehervesamhotchkiss
authored andcommitted
Comment form: add filter to allow removing the Comment Form title. (Automattic#6347)
The filter can then be used like so: `add_filter( 'jetpack_comment_form_display_greeting', '__return_false' );` This allows removing the title like when using the core comment form and providing empty strings for `title_reply`, `title_reply_before`, and `title_reply_after` as arguments to the `comment_form` function. Unfortunately that is not possible with Jetpack's Comment form since the form lives in an iFrame. Suggested here: https://wordpress.org/support/topic/leave-a-reply-text-and-so-much-vertical-spacing-how-to-remove/
1 parent 436a3ea commit b78d04a

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

‎modules/comments/comments.php‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,24 @@ public function comment_form_after() {
285285
$url .= '&replytocom=' . (int) $_GET['replytocom'];
286286
}
287287

288+
/**
289+
* Filter whether the comment title can be displayed.
290+
*
291+
* @module comments
292+
*
293+
* @since 4.7.0
294+
*
295+
* @param bool $show Can the comment be displayed? Default to true.
296+
*/
297+
$show_greeting = apply_filters( 'jetpack_comment_form_display_greeting', true );
298+
288299
// The actual iframe (loads comment form from Jetpack server)
289300
?>
290301

291302
<div id="respond" class="comment-respond">
292-
<h3 id="reply-title" class="comment-reply-title"><?php comment_form_title( esc_html( $params['greeting'] ), esc_html( $params['greeting_reply'] ) ); ?> <small><?php cancel_comment_reply_link( esc_html__( 'Cancel reply' , 'jetpack') ); ?></small></h3>
303+
<?php if ( true === $show_greeting ) : ?>
304+
<h3 id="reply-title" class="comment-reply-title"><?php comment_form_title( esc_html( $params['greeting'] ), esc_html( $params['greeting_reply'] ) ); ?> <small><?php cancel_comment_reply_link( esc_html__( 'Cancel reply' , 'jetpack') ); ?></small></h3>
305+
<?php endif; ?>
293306
<form id="commentform" class="comment-form">
294307
<iframe src="<?php echo esc_url( $url ); ?>" style="width:100%; height: <?php echo $height; ?>px; border:0;" name="jetpack_remote_comment" class="jetpack_remote_comment" id="jetpack_remote_comment"></iframe>
295308
<!--[if !IE]><!-->

0 commit comments

Comments
 (0)