PageRenderTime 53ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/comments.php

https://github.com/tomtom10/required-foundation
PHP | 112 lines | 80 code | 8 blank | 24 comment | 18 complexity | 198d313051b1d620ea1d335aac581ee1 MD5 | raw file
  1. <?php
  2. /**
  3. * The template for displaying Comments.
  4. *
  5. * The area of the page that contains both current comments
  6. * and the comment form. The actual display of comments is
  7. * handled by a callback to required_comment() which is
  8. * located in the functions.php file.
  9. *
  10. * @package required+ Foundation
  11. * @since required+ Foundation 0.3.0
  12. */
  13. ?> <!-- START: comments.php -->
  14. <div id="comments">
  15. <?php if ( post_password_required() ) : ?>
  16. <p class="nopassword"><?php _e( 'This post is password protected. Enter the password to view any comments.', 'requiredfoundation' ); ?></p>
  17. </div><!-- #comments -->
  18. <?php
  19. /* Stop the rest of comments.php from being processed,
  20. * but don't kill the script entirely -- we still have
  21. * to fully load the template.
  22. */
  23. return;
  24. endif;
  25. ?>
  26. <?php // You can start editing here -- including this comment! ?>
  27. <?php if ( have_comments() ) : ?>
  28. <h2 id="comments-title">
  29. <?php
  30. printf( _n( 'One thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', get_comments_number(), 'requiredfoundation' ),
  31. number_format_i18n( get_comments_number() ), '<span>' . get_the_title() . '</span>' );
  32. ?>
  33. </h2>
  34. <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?>
  35. <nav id="comment-nav-above">
  36. <h1 class="assistive-text"><?php _e( 'Comment navigation', 'requiredfoundation' ); ?></h1>
  37. <div class="nav-previous"><?php previous_comments_link( __( '&larr; Older Comments', 'requiredfoundation' ) ); ?></div>
  38. <div class="nav-next"><?php next_comments_link( __( 'Newer Comments &rarr;', 'requiredfoundation' ) ); ?></div>
  39. </nav>
  40. <?php endif; // check for comment navigation ?>
  41. <ol class="commentlist">
  42. <?php
  43. /* Loop through and list the comments. Tell wp_list_comments()
  44. * to use required_comment() to format the comments.
  45. * If you want to overload this in a child theme then you can
  46. * define required_comment() and that will be used instead.
  47. * See required_comment() in required/functions.php for more.
  48. */
  49. wp_list_comments( array( 'callback' => 'required_comment' ) );
  50. ?>
  51. </ol>
  52. <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?>
  53. <nav id="comment-nav-below">
  54. <h1 class="assistive-text"><?php _e( 'Comment navigation', 'requiredfoundation' ); ?></h1>
  55. <div class="nav-previous"><?php previous_comments_link( __( '&larr; Older Comments', 'requiredfoundation' ) ); ?></div>
  56. <div class="nav-next"><?php next_comments_link( __( 'Newer Comments &rarr;', 'requiredfoundation' ) ); ?></div>
  57. </nav>
  58. <?php endif; // check for comment navigation ?>
  59. <?php
  60. /* If there are no comments and comments are closed, let's leave a little note, shall we?
  61. * But we don't want the note on pages or post types that do not support comments.
  62. */
  63. elseif ( ! comments_open() && ! is_page() && post_type_supports( get_post_type(), 'comments' ) ) :
  64. ?>
  65. <p class="nocomments"><?php _e( 'Comments are closed.', 'requiredfoundation' ); ?></p>
  66. <?php endif; ?>
  67. <?php if ( comments_open() ) : ?>
  68. <section id="respond">
  69. <h3><?php comment_form_title( __('Leave a Reply', 'requiredfoundation' ), __('Leave a Reply to %s', 'requiredfoundation' ) ); ?></h3>
  70. <p class="cancel-comment-reply"><?php cancel_comment_reply_link(); ?></p>
  71. <?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?>
  72. <p><?php printf( __('You must be <a href="%s">logged in</a> to post a comment.', 'requiredfoundation' ), wp_login_url( get_permalink() ) ); ?></p>
  73. <?php else : ?>
  74. <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
  75. <?php if ( is_user_logged_in() ) : ?>
  76. <p><?php printf(__('Logged in as <a href="%s/wp-admin/profile.php">%s</a>.', 'requiredfoundation' ), get_option('siteurl'), $user_identity); ?> <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="<?php __('Log out of this account', 'requiredfoundation' ); ?>"><?php _e('Log out &raquo;', 'requiredfoundation' ); ?></a></p>
  77. <?php else : ?>
  78. <p>
  79. <label for="author"><?php _e('Name', 'requiredfoundation' ); if ($req) _e(' (required)', 'requiredfoundation' ); ?></label>
  80. <input type="text" class="input-text" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?>>
  81. </p>
  82. <p>
  83. <label for="email"><?php _e('Email (will not be published)', 'requiredfoundation' ); if ($req) _e(' (required)', 'requiredfoundation' ); ?></label>
  84. <input type="email" class="input-text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?>>
  85. </p>
  86. <p>
  87. <label for="url"><?php _e('Website', 'requiredfoundation' ); ?></label>
  88. <input type="url" class="input-text" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" tabindex="3">
  89. </p>
  90. <?php endif; ?>
  91. <p>
  92. <label for="comment"><?php _e('Comment', 'requiredfoundation' ); ?></label>
  93. <textarea name="comment" id="comment" tabindex="4"></textarea>
  94. </p>
  95. <p id="allowed_tags" class="small"><?php _e('You can use these tags: ', 'requiredfoundation' ); ?><code><?php echo allowed_tags(); ?></code></p>
  96. <p><input name="submit" class="<?php echo esc_attr( apply_filters( 'req_comment_button_classes', 'button' ) ); ?>" type="submit" id="submit" tabindex="5" value="<?php _e('Submit Comment', 'requiredfoundation' ); ?>"></p>
  97. <?php comment_id_fields(); ?>
  98. <?php do_action('comment_form', $post->ID); ?>
  99. </form>
  100. <?php endif; // If registration required and not logged in ?>
  101. </section>
  102. <?php endif; // if you delete this the sky will fall on your head ?>
  103. </div><!-- #comments -->
  104. <!-- END: comments.php -->