comments.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /**
  3. * Comments template
  4. *
  5. * @package vamtam/consulting
  6. */
  7. if ( is_page_template( 'page-blank.php' ) ) {
  8. return;
  9. }
  10. wp_reset_postdata();
  11. if ( ! defined( 'ABSPATH' ) ) {
  12. die( 'Please do not load this page directly. Thanks!' );
  13. }
  14. $req = get_option( 'require_name_email' ); // Checks if fields are required.
  15. // do not display anything if the post is protected or the comments are closed and there is no comment history
  16. if (
  17. ( ! empty( $post->post_password ) && post_password_required() ) ||
  18. ( ! comments_open() && ! have_comments() ) ||
  19. ! post_type_supports( get_post_type(), 'comments' ) ) {
  20. return;
  21. }
  22. ?>
  23. <div class="limit-wrapper clearboth">
  24. <div id="comments" class="comments-wrapper">
  25. <?php if ( have_comments() ) : ?>
  26. <?php // numbers of pings and comments
  27. $ping_count = $comment_count = 0;
  28. foreach ( $comments as $comment ) {
  29. get_comment_type() == 'comment' ? ++$comment_count : ++$ping_count;
  30. }
  31. ?>
  32. <div class="sep-text centered keep-always">
  33. <div class="content">
  34. <?php comments_popup_link( esc_html__( '0 Comments:', 'vamtam-consulting' ), esc_html__( '1 Comment', 'vamtam-consulting' ), esc_html__( '% Comments:', 'vamtam-consulting' ) ); ?>
  35. </div>
  36. </div>
  37. <?php if ( $comment_count ) : ?>
  38. <div id="comments-list" class="comments">
  39. <?php wp_list_comments( array(
  40. 'type' => 'comment',
  41. 'callback' => array( 'VamtamTemplates', 'comments' ),
  42. 'style' => 'div',
  43. ) ); ?>
  44. </div>
  45. <?php endif; ?>
  46. <?php if ( $ping_count ) : ?>
  47. <div class="sep-text centered keep-always">
  48. <div class="content">
  49. <?php echo sprintf( $ping_count > 1 ? esc_html__( '%d Trackbacks:', 'vamtam-consulting' ) : esc_html__( 'One Trackback:', 'vamtam-consulting' ), (int) (int) $ping_count ); // xss ok ?>
  50. </div>
  51. </div>
  52. <div id="trackbacks-list" class="comments">
  53. <?php wp_list_comments( array(
  54. 'type' => 'pings',
  55. 'callback' => array( 'VamtamTemplates', 'comments' ),
  56. 'style' => 'div',
  57. 'short_ping' => true,
  58. ) ); ?>
  59. </div>
  60. <?php endif ?>
  61. <?php endif ?>
  62. <?php
  63. $comment_pages = paginate_comments_links( array(
  64. 'echo' => false,
  65. ) );
  66. if ( ! empty( $comment_pages ) ) :
  67. ?>
  68. <div class="wp-pagenavi comment-paging"><?php echo $comment_pages // xss ok ?></div>
  69. <?php endif ?>
  70. <div class="respond-box">
  71. <?php if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) : ?>
  72. <p class="no-comments"><?php esc_html_e( 'Comments are closed.', 'vamtam-consulting' ); ?></p>
  73. <?php endif; ?>
  74. <?php if ( get_option( 'comment_registration' ) && ! $user_ID ) : ?>
  75. <p id="login-req"><?php printf( wp_kses_post( __( 'You must be <a href="%s" title="Log in">logged in</a> to post a comment.', 'vamtam-consulting' ) ), esc_url( get_option( 'siteurl' ) . '/wp-login.php?redirect_to=' . get_permalink() ) ) ?></p>
  76. <?php else : ?>
  77. <?php
  78. comment_form( array(
  79. 'title_reply_before' => '<h5 id="reply-title" class="comment-reply-title respond-box-title grid-1-1">',
  80. 'title_reply_after' => '</h5>',
  81. 'title_reply' => esc_html__( 'Write a comment:', 'vamtam-consulting' ),
  82. 'fields' => array(
  83. 'author' => '<div class="comment-form-author form-input grid-1-1"><label for="author" >' . esc_html__( 'Name', 'vamtam-consulting' ) . '</label>' . ( $req ? ' <span class="required">*</span>' : '' ) .
  84. '<input id="author" autocomplete="name" name="author" type="text" ' . ( $req ? 'required="required"' : '' ) . ' value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" placeholder="' . esc_attr__( 'John Doe', 'vamtam-consulting' ) . '" /></div>',
  85. 'email' => '<div class="comment-form-email form-input grid-1-1"><label for="email" >' . esc_html__( 'Email', 'vamtam-consulting' ) . '</label> ' . ( $req ? ' <span class="required">*</span>' : '' ) .
  86. '<input id="email" autocomplete="email" name="email" type="email" ' . ( $req ? 'required="required"' : '' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" placeholder="email@example.com" /></div> <p class="comment-notes grid-1-1">' . esc_html__( 'Your email address will not be published.', 'vamtam-consulting' ) . '</p>',
  87. ),
  88. 'comment_field' => '<div class="comment-form-comment grid-1-1"><label for="comment" class="visuallyhidden">' . esc_html_x( 'Message', 'noun', 'vamtam-consulting' ) . '</label><textarea id="comment" name="comment" required placeholder="' . esc_attr__( 'Write us something nice or just a funny joke...', 'vamtam-consulting' ) . '" rows="2"></textarea></div>',
  89. 'comment_notes_before' => '',
  90. 'comment_notes_after' => '',
  91. 'format' => 'xhtml', // otherwise we get novalidate on the form
  92. ) );
  93. ?>
  94. <?php endif /* if ( get_option( 'comment_registration' ) && !$user_ID ) */ ?>
  95. </div><!-- .respond-box -->
  96. </div><!-- #comments -->
  97. </div>