comments.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * The template for displaying comments
  4. *
  5. * This is the template that displays the area of the page that contains both the current comments
  6. * and the comment form.
  7. *
  8. * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
  9. *
  10. * @package spice-software
  11. */
  12. /*
  13. * If the current post is protected by a password and
  14. * the visitor has not yet entered the password we will
  15. * return early without loading the comments.
  16. */
  17. if (post_password_required()) {
  18. return;
  19. }
  20. if (have_comments()) : ?>
  21. <article class="comment-section">
  22. <div class="comment-title">
  23. <h3>
  24. <?php
  25. $spice_software_comment_count = get_comments_number();
  26. if ('1' === $spice_software_comment_count) {
  27. printf(
  28. /* translators: 1: title. */
  29. esc_html__('1 comment', 'spice-software' ),
  30. '<span>' . esc_html(get_the_title()) . '</span>'
  31. );
  32. } else {
  33. printf(
  34. /* translators: 1: comment count number, 2: title. */
  35. esc_html(_nx('%1$s comment', '%1$s comments', $spice_software_comment_count, 'comments title', 'spice-software' )),
  36. esc_html(number_format_i18n($spice_software_comment_count)),
  37. '<span>' . esc_html(get_the_title()) . '</span>'
  38. );
  39. }
  40. ?>
  41. </h3>
  42. </div>
  43. <?php
  44. the_comments_navigation();
  45. wp_list_comments('type=comment&callback=spice_software_comment');
  46. the_comments_navigation();
  47. // If comments are closed and there are comments, let's leave a little note, shall we?
  48. if (!comments_open()) :
  49. ?>
  50. <p class="no-comments"><?php esc_html_e('Comments are closed.', 'spice-software' ); ?></p>
  51. <?php endif; ?>
  52. </article>
  53. <?php endif;
  54. echo '<article class="comment-form">';
  55. $fields=array(
  56. 'author' => '<p><span class="blog-form-group your-name">
  57. <input type="text" name="author" value="" size="40" class="blog-form-control" placeholder="'.__('Your Name','spice-software' ).'" aria-required="true" arai-invalid="false">
  58. </span></p>',
  59. 'email' => '<p><span class="blog-form-group your-email">
  60. <input type="email" name="email" value="" size="40" class="blog-form-control" placeholder="'.__('Your Email','spice-software' ).'" aria-required="true" arai-invalid="false">
  61. </span></p>',
  62. 'url' => '<p>
  63. <span class="blog-form-group your-subject">
  64. <input type="text" name="url" value="" size="40" class="blog-form-control" placeholder="'.__('Website','spice-software' ).'" aria-required="true" arai-invalid="false">
  65. </span>
  66. </p>',
  67. );
  68. function spice_software_fields($fields) {
  69. return $fields;
  70. }
  71. add_filter('comment_form_default_fields','spice_software_fields');
  72. $defaults = array(
  73. 'fields'=> apply_filters( 'comment_form_default_fields', $fields ),
  74. 'comment_field'=> '<p><span class="blog-form-group-textarea your-message">
  75. <textarea id="comments" type="text" rows="4" name="comment" value="" size="40" class="blog-form-control" placeholder="'.esc_html__('Message','spice-software' ).'" aria-required="true" arai-invalid="false"></textarea>
  76. </span></p>',
  77. 'logged_in_as' => '<p class="blog-post-info-detail">' . esc_html__("Logged in as",'spice-software' ).' '.'<a href="'. esc_url(admin_url( 'profile.php' )).'">'.$user_identity.'</a>'. '<a href="'. esc_url(wp_logout_url( get_permalink() )).'" title="'.esc_html__('Log out from this Account','spice-software' ).'">'.' '.esc_html__("Log out",'spice-software' ).'?</a>' . '</p>',
  78. 'id_submit'=> 'blogdetail-btn',
  79. 'label_submit'=>esc_html__('Send Message','spice-software' ),
  80. 'comment_notes_after'=> '',
  81. 'comment_notes_before' => '',
  82. 'title_reply'=> '<div class="comment-title">'.esc_html__('Leave a Reply', 'spice-software' ).'</div>',
  83. 'id_form'=> 'commentform'
  84. );
  85. ob_start();
  86. comment_form($defaults);
  87. echo '</article>';?>