PageRenderTime 36ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 1ms

/templates/comments.php

https://github.com/amtdev/roots
PHP | 107 lines | 95 code | 12 blank | 0 comment | 25 complexity | 76a892123baab37c811d1815c1afd962 MD5 | raw file
  1. <?php function roots_comment($comment, $args, $depth) {
  2. $GLOBALS['comment'] = $comment; ?>
  3. <li <?php comment_class(); ?>>
  4. <article id="comment-<?php comment_ID(); ?>">
  5. <header class="comment-author vcard">
  6. <?php echo get_avatar($comment, $size = '32'); ?>
  7. <?php printf(__('<cite class="fn">%s</cite>', 'roots'), get_comment_author_link()); ?>
  8. <time datetime="<?php echo comment_date('c'); ?>"><a href="<?php echo htmlspecialchars(get_comment_link($comment->comment_ID)); ?>"><?php printf(__('%1$s', 'roots'), get_comment_date(), get_comment_time()); ?></a></time>
  9. <?php edit_comment_link(__('(Edit)', 'roots'), '', ''); ?>
  10. </header>
  11. <?php if ($comment->comment_approved == '0') : ?>
  12. <div class="alert alert-block fade in">
  13. <a class="close" data-dismiss="alert">&times;</a>
  14. <p><?php _e('Your comment is awaiting moderation.', 'roots'); ?></p>
  15. </div>
  16. <?php endif; ?>
  17. <section class="comment">
  18. <?php comment_text(); ?>
  19. </section>
  20. <?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))); ?>
  21. </article>
  22. <?php } ?>
  23. <?php if (post_password_required()) : ?>
  24. <section id="comments">
  25. <div class="alert alert-block fade in">
  26. <a class="close" data-dismiss="alert">&times;</a>
  27. <p><?php _e('This post is password protected. Enter the password to view comments.', 'roots'); ?></p>
  28. </div>
  29. </section><!-- /#comments -->
  30. <?php endif; ?>
  31. <?php if (have_comments()) : ?>
  32. <section id="comments">
  33. <h3><?php printf(_n('One Response to &ldquo;%2$s&rdquo;', '%1$s Responses to &ldquo;%2$s&rdquo;', get_comments_number(), 'roots'), number_format_i18n(get_comments_number()), get_the_title()); ?></h3>
  34. <ol class="commentlist">
  35. <?php wp_list_comments(array('callback' => 'roots_comment')); ?>
  36. </ol>
  37. <?php if (get_comment_pages_count() > 1 && get_option('page_comments')) : // are there comments to navigate through ?>
  38. <nav id="comments-nav" class="pager">
  39. <ul class="pager">
  40. <?php if (get_previous_comments_link()) : ?>
  41. <li class="previous"><?php previous_comments_link(__('&larr; Older comments', 'roots')); ?></li>
  42. <?php else: ?>
  43. <li class="previous disabled"><a><?php _e('&larr; Older comments', 'roots'); ?></a></li>
  44. <?php endif; ?>
  45. <?php if (get_next_comments_link()) : ?>
  46. <li class="next"><?php next_comments_link(__('Newer comments &rarr;', 'roots')); ?></li>
  47. <?php else: ?>
  48. <li class="next disabled"><a><?php _e('Newer comments &rarr;', 'roots'); ?></a></li>
  49. <?php endif; ?>
  50. </ul>
  51. </nav>
  52. <?php endif; // check for comment navigation ?>
  53. <?php if (!comments_open() && !is_page() && post_type_supports(get_post_type(), 'comments')) : ?>
  54. <div class="alert alert-block fade in">
  55. <a class="close" data-dismiss="alert">&times;</a>
  56. <p><?php _e('Comments are closed.', 'roots'); ?></p>
  57. </div>
  58. <?php endif; ?>
  59. </section><!-- /#comments -->
  60. <?php endif; ?>
  61. <?php if (!have_comments() && !comments_open() && !is_page() && post_type_supports(get_post_type(), 'comments')) : ?>
  62. <section id="comments">
  63. <div class="alert alert-block fade in">
  64. <a class="close" data-dismiss="alert">&times;</a>
  65. <p><?php _e('Comments are closed.', 'roots'); ?></p>
  66. </div>
  67. </section><!-- /#comments -->
  68. <?php endif; ?>
  69. <?php if (comments_open()) : ?>
  70. <section id="respond">
  71. <h3><?php comment_form_title(__('Leave a Reply', 'roots'), __('Leave a Reply to %s', 'roots')); ?></h3>
  72. <p class="cancel-comment-reply"><?php cancel_comment_reply_link(); ?></p>
  73. <?php if (get_option('comment_registration') && !is_user_logged_in()) : ?>
  74. <p><?php printf(__('You must be <a href="%s">logged in</a> to post a comment.', 'roots'), wp_login_url(get_permalink())); ?></p>
  75. <?php else : ?>
  76. <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
  77. <?php if (is_user_logged_in()) : ?>
  78. <p><?php printf(__('Logged in as <a href="%s/wp-admin/profile.php">%s</a>.', 'roots'), get_option('siteurl'), $user_identity); ?> <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="<?php __('Log out of this account', 'roots'); ?>"><?php _e('Log out &raquo;', 'roots'); ?></a></p>
  79. <?php else : ?>
  80. <label for="author"><?php _e('Name', 'roots'); if ($req) _e(' (required)', 'roots'); ?></label>
  81. <input type="text" class="text" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?>>
  82. <label for="email"><?php _e('Email (will not be published)', 'roots'); if ($req) _e(' (required)', 'roots'); ?></label>
  83. <input type="email" class="text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?>>
  84. <label for="url"><?php _e('Website', 'roots'); ?></label>
  85. <input type="url" class="text" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="22" tabindex="3">
  86. <?php endif; ?>
  87. <label for="comment"><?php _e('Comment', 'roots'); ?></label>
  88. <textarea name="comment" id="comment" class="input-xlarge" tabindex="4"></textarea>
  89. <p><input name="submit" class="btn btn-primary" type="submit" id="submit" tabindex="5" value="<?php _e('Submit Comment', 'roots'); ?>"></p>
  90. <?php comment_id_fields(); ?>
  91. <?php do_action('comment_form', $post->ID); ?>
  92. </form>
  93. <?php endif; // if registration required and not logged in ?>
  94. </section><!-- /#respond -->
  95. <?php endif; ?>