Skip to content

Commit

Permalink
Merge pull request #157 from WordPress/tt1-comments
Browse files Browse the repository at this point in the history
TT1 Blocks: Add comments.php
  • Loading branch information
kjellr authored Jan 11, 2021
2 parents e755034 + 00c9148 commit d33eeeb
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions tt1-blocks/block-templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@

<!-- wp:post-content /-->
<!-- wp:post-comments /-->
<!-- wp:post-comments-form /-->

<!-- wp:template-part {"slug":"footer","theme":"tt1-blocks","align":"full","tagName":"footer","className":"site-footer"} /-->
1 change: 1 addition & 0 deletions tt1-blocks/block-templates/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@
<div style="height:70px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->
<!-- wp:post-comments /-->
<!-- wp:post-comments-form /-->

<!-- wp:template-part {"slug":"footer","theme":"tt1-blocks","align":"full","tagName":"footer","className":"site-footer"} /-->
69 changes: 69 additions & 0 deletions tt1-blocks/comments.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php
/**
* The template for displaying comments
*
* This is the template that displays the area of the page that contains both the current comments
* and the comment form. This can be deleted from TT1 Blocks once this Gutenberg issue has been resolved:
* https://github.com/WordPress/gutenberg/issues/28045
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package WordPress
* @subpackage TT1_Blocks
* @since 0.1
*/

/*
* If the current post is protected by a password and
* the visitor has not yet entered the password,
* return early without loading the comments.
*/
if ( post_password_required() ) {
return;
}

$tt1_blocks_comment_count = get_comments_number();
?>

<div id="comments" class="comments-area <?php echo get_option( 'show_avatars' ) ? 'show-avatars' : ''; ?>">

<?php
if ( have_comments() ) :
;
?>
<h2 class="comments-title">
<?php if ( '1' === $tt1_blocks_comment_count ) : ?>
<?php esc_html_e( '1 comment', 'tt1-blocks' ); ?>
<?php else : ?>
<?php
printf(
/* translators: %s: comment count number. */
esc_html( _nx( '%s comment', '%s comments', $tt1_blocks_comment_count, 'Comments title', 'tt1-blocks' ) ),
esc_html( number_format_i18n( $tt1_blocks_comment_count ) )
);
?>
<?php endif; ?>
</h2><!-- .comments-title -->

<ol class="comment-list">
<?php
wp_list_comments(
array(
'avatar_size' => 60,
'style' => 'ol',
'short_ping' => true,
)
);
?>
</ol><!-- .comment-list -->

<?php
the_comments_pagination();
?>

<?php if ( ! comments_open() ) : ?>
<p class="no-comments"><?php esc_html_e( 'Comments are closed.', 'tt1-blocks' ); ?></p>
<?php endif; ?>
<?php endif; ?>

</div><!-- #comments -->

0 comments on commit d33eeeb

Please sign in to comment.