Skip to content

Commit

Permalink
Comment form: add filter to allow removing the Comment Form title. (#…
Browse files Browse the repository at this point in the history
…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/
  • Loading branch information
jeherve authored and samhotchkiss committed Feb 10, 2017
1 parent 436a3ea commit b78d04a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion modules/comments/comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,24 @@ public function comment_form_after() {
$url .= '&replytocom=' . (int) $_GET['replytocom'];
}

/**
* Filter whether the comment title can be displayed.
*
* @module comments
*
* @since 4.7.0
*
* @param bool $show Can the comment be displayed? Default to true.
*/
$show_greeting = apply_filters( 'jetpack_comment_form_display_greeting', true );

// The actual iframe (loads comment form from Jetpack server)
?>

<div id="respond" class="comment-respond">
<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>
<?php if ( true === $show_greeting ) : ?>
<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>
<?php endif; ?>
<form id="commentform" class="comment-form">
<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>
<!--[if !IE]><!-->
Expand Down

0 comments on commit b78d04a

Please sign in to comment.