114 lines
5.7 KiB
PHP
114 lines
5.7 KiB
PHP
<?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.
|
|
*
|
|
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
|
|
*
|
|
* @package CyyWordpress
|
|
*/
|
|
|
|
/*
|
|
* If the current post is protected by a password and
|
|
* the visitor has not yet entered the password we will
|
|
* return early without loading the comments.
|
|
*/
|
|
if ( post_password_required() ) {
|
|
return;
|
|
}
|
|
?>
|
|
|
|
<div id="comments" class="comments-area" style=" margin-top: 15px;">
|
|
<!-- <div class="container is-narrow">-->
|
|
|
|
<?php
|
|
// You can start editing here -- including this comment!
|
|
if ( have_comments() ) :
|
|
?>
|
|
<div class="content">
|
|
<div class="header">
|
|
<h2 class="title is-3"><?php esc_html_e('评论区', 'cyywordpress'); ?></h2>
|
|
<p class="subtitle">
|
|
<?php
|
|
$cyywordpress_comment_count = get_comments_number();
|
|
if ( '1' === $cyywordpress_comment_count ) {
|
|
printf(
|
|
/* translators: 1: title. */
|
|
esc_html__( 'One thought on “%1$s”', 'cyywordpress' ),
|
|
'<span>' . wp_kses_post( get_the_title() ) . '</span>'
|
|
);
|
|
} else {
|
|
printf(
|
|
/* translators: 1: comment count number, 2: title. */
|
|
esc_html( _nx( '%1$s thought on “%2$s”', '%1$s thoughts on “%2$s”', $cyywordpress_comment_count, 'comments title', 'cyywordpress' ) ),
|
|
number_format_i18n( $cyywordpress_comment_count ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
|
'<span>' . wp_kses_post( get_the_title() ) . '</span>'
|
|
);
|
|
}
|
|
?>
|
|
</p><!-- .comments-title -->
|
|
</div>
|
|
|
|
|
|
<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
|
|
<nav id="comment-nav-above" class="navigation comment-navigation" role="navigation">
|
|
<h2 class="screen-reader-text"><?php esc_html_e( 'Comment navigation', 'cyywordpress' ); ?></h2>
|
|
<div class="nav-links level">
|
|
<div class="nav-next"><?php next_comments_link( esc_html__( 'Newer Comments', 'cyywordpress' ) ); ?></div>
|
|
<div class="nav-previous"><?php previous_comments_link( esc_html__( 'Older Comments', 'cyywordpress' ) ); ?></div>
|
|
</div><!-- .nav-links -->
|
|
</nav><!-- #comment-nav-above -->
|
|
<?php endif; // Check for comment navigation. ?>
|
|
|
|
|
|
<ul class="comment-list ">
|
|
<?php
|
|
wp_list_comments( array(
|
|
'style' => 'ul',
|
|
'short_ping' => true,
|
|
'avatar_size' => 50
|
|
) );
|
|
?>
|
|
</ul><!-- .comment-list -->
|
|
<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
|
|
<nav id="comment-nav-below" class="navigation comment-navigation" role="navigation">
|
|
<h2 class="screen-reader-text"><?php esc_html_e( 'Comment navigation', 'cyywordpress' ); ?></h2>
|
|
<div class="nav-links level">
|
|
<div class="nav-next"><?php next_comments_link( esc_html__( 'Newer Comments', 'cyywordpress' ) ); ?></div>
|
|
<div class="nav-previous"><?php previous_comments_link( esc_html__( 'Older Comments', 'cyywordpress' ) ); ?></div>
|
|
</div><!-- .nav-links -->
|
|
</nav><!-- #comment-nav-below -->
|
|
<?php
|
|
endif; // Check for comment navigation.
|
|
?>
|
|
</div>
|
|
|
|
<?php
|
|
endif; // Check for have_comments().
|
|
?>
|
|
|
|
<?php
|
|
// If comments are closed and there are comments, let's leave a little note, shall we?
|
|
if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) : ?>
|
|
<div class="content">
|
|
<p class="no-comments"><?php esc_html_e( 'Comments are closed.', 'cyywordpress' ); ?></p>
|
|
</div>
|
|
<?php
|
|
endif;
|
|
?>
|
|
<?php $comment_args = array(
|
|
'title_reply'=>'<h3 class="title is-3">有什么要说的吗?</h3>',
|
|
'comment_field' => '<div class="columns is-multiline"><div class="column '. (is_user_logged_in() ? 'is-full' : 'is-half') .'"><label class="label" for="comment">' . __( '您的评论' ) . '</label>' . '<p class="control">' . '<textarea class="textarea" id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea>' . '</p></div>',
|
|
'fields' => apply_filters( 'comment_form_default_fields', array(
|
|
'author' => '<div class="column is-half"><label class="label" for="author">' . __( '昵称' ) . ( $req ? '<span>*</span>' : '' ) .'</label> ' . '<p class="control">' . '<input class="input" id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
|
|
'email' => '<label class="label" for="email">' . __( '邮箱' ) . ( $req ? '<span>*</span>' : '' ) . '</label> ' . '<p class="control">' . '<input class="input" id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' />'.'</p>',
|
|
'url' => '</div>' ) ),
|
|
'comment_notes_after' => '',
|
|
'submit_button' => '<div class="column is-full"><div class="control"><input name="submit" type="submit" id="submit" class="button is-info is-outlined post-comment-button" value="提交评论" /></div></div></div>'
|
|
);
|
|
comment_form($comment_args); ?>
|
|
<!-- </div>-->
|
|
</div><!-- #comments -->
|