/comments.php

https://github.com/somerandomdude/Frank · PHP · 113 lines · 93 code · 17 blank · 3 comment · 11 complexity · 020e4becdb37f5f8baa460340dbc722c MD5 · raw file

  1. <?php
  2. /**
  3. * @package Frank
  4. */
  5. ?>
  6. <div id='comments-container'>
  7. <?php if ( post_password_required() ) : ?>
  8. <p class="nocomments">This post is password protected. Enter the password to view comments.</p> ?></p>
  9. </div>
  10. <?php
  11. return;
  12. endif;
  13. $oddcomment = 'class="alt" ';
  14. ?>
  15. <?php if ( have_comments() ) : ?>
  16. <header id="comments-header">
  17. <h1 id="comments-title">
  18. <?php
  19. comments_number(
  20. __( 'No Comments', 'frank_theme' ),
  21. __( 'One Comment', 'frank_theme' ),
  22. __( '% Comments', 'frank_theme' )
  23. );
  24. ?>
  25. </h1>
  26. </header>
  27. <ul id="comments">
  28. <?php wp_list_comments( array( 'callback' => 'frank_comment' ) ); ?>
  29. </ul>
  30. <?php if ( (int) get_option( 'page_comments' ) === 1 && ! is_null( paginate_comments_links( array( 'echo' => false ) ) ) ): ?>
  31. <div class="pagination small">
  32. <span class="title">Comments:</span>
  33. <?php paginate_comments_links( 'prev_text=Previous&next_text=Next' ); ?>
  34. </div>
  35. <?php endif; ?>
  36. <?php
  37. elseif ( ! comments_open() && ! is_page() && post_type_supports( get_post_type(), 'comments' ) ) :
  38. ?>
  39. <p id="comments" class="no_comments">Comments are closed.</p>
  40. <?php elseif (comments_open()) : ?>
  41. <p id="comments" class="no_comments">
  42. <?php _e( 'Be the first to leave a comment. Don&rsquo;t be shy.', 'frank_theme' ); ?>
  43. </p>
  44. <?php endif; ?>
  45. <?php if ( 'open' == $post->comment_status ) : ?>
  46. <?php if ( get_option( 'comment_registration' ) && ! $user_ID ) : ?>
  47. <p>You must be <a href="<?php echo get_option( 'siteurl' ); ?>/wp-login.php?redirect_to=<?php echo urlencode( get_permalink() ); ?>">logged in</a> to post a comment.</p>
  48. <?php else : ?>
  49. <?php
  50. $req = get_option( 'require_name_email' );
  51. $aria_req = ( $req ? " aria-required='true'" : '' );
  52. $name_label = __( 'Name (required)', 'frank_theme' );
  53. $email_label = __( 'Email (required)', 'frank_theme' );
  54. $website_label = __( 'Website', 'frank_theme' );
  55. $fields = array(
  56. 'author' => '<div id="comment-form-info">' .
  57. '<label for="author">' . __( 'Name', 'frank_theme' ) . '' . ( $req ? '<span class="required">*</span>' : '' ) . '</label> ' .
  58. '<input id="author" name="author" type="text" placeholder=\'' . $name_label . '\' value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' />',
  59. 'email' => '<label for="email">' . __( 'Email', 'frank_theme' ) . '' . ( $req ? '<span class="required">*</span>' : '' ) . '</label> ' .
  60. '<input id="email" name="email" type="text" placeholder=\'' . $email_label . '\' value=""' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' />',
  61. 'url' => '<label for="url">' . __( 'Website', 'frank_theme' ) . '</label>' .
  62. '<input id="url" name="url" type="text" placeholder=\'' . $website_label . '\' value=""' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></div>',
  63. );
  64. $comment_placeholder = __( 'Your Comment', 'frank_theme' );
  65. $comment_field = '<div id="comment-form-content"><label for="comment">' . _x( 'Comment', 'noun', 'frank_theme' ) . '</label><textarea id="comment-form-textarea" placeholder="' . $comment_placeholder . '" name="comment" aria-required="true"></textarea></div>';
  66. $logged_in_string = __( 'Logged in as', 'frank_theme' );
  67. $log_out_string = __( 'Log out?', 'frank_theme' );
  68. $log_out_hover = __( 'Log out of this account', 'frank_theme' );
  69. $logged_in_as = '<div id="comment-form-logged-in-as"><p>' . $logged_in_string . ' ' . sprintf(
  70. '<a href="%1$s">%2$s</a>. <a href="%3$s" title="%4$s">%5$s</a>',
  71. admin_url( 'profile.php' ),
  72. $user_identity,
  73. wp_logout_url( apply_filters( 'the_permalink', get_permalink( ) ) ),
  74. $log_out_hover,
  75. $log_out_string
  76. ) . '</p></div>';
  77. $html_explanation = sprintf( __( 'You may use these %1$s tags and attributes:', 'frank_theme' ), '<abbr title="HyperText Markup Language">HTML</abbr>' );
  78. $comment_notes_after = '<div class="row"><div id="comment-form-allowed-tags"><p>' . $html_explanation . ' ' . '<code>' . allowed_tags() . '</code>' . '</p></div></div>';
  79. $reply_title = __( 'Join the Discussion', 'frank_theme' );
  80. comment_form(
  81. array(
  82. 'id_form' => 'comment-form',
  83. 'logged_in_as' => $logged_in_as,
  84. 'comment_notes_before' => '',
  85. 'comment_notes_after' => $comment_notes_after,
  86. 'title_reply' => $reply_title,
  87. 'fields' => $fields,
  88. 'comment_field' => $comment_field,
  89. )
  90. );
  91. ?>
  92. <?php
  93. endif;
  94. endif;
  95. ?>
  96. </div>