PageRenderTime 52ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/blog/wp-content/themes/unsleepable/comments.php

https://bitbucket.org/sergiohzlz/reportaprod
PHP | 127 lines | 96 code | 30 blank | 1 comment | 17 complexity | f892b0d4acd3a54836fe44b03cb96b24 MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, AGPL-1.0, LGPL-2.1
  1. <?php // Do not delete these lines
  2. if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
  3. die ('Please do not load this page directly. Thanks!');
  4. if (post_password_required()) {
  5. ?>
  6. <p class="center"><?php _e("This post is password protected. Enter the password to view comments."); ?><p>
  7. <?php return; }
  8. /* Function for seperating comments from track- and pingbacks. */
  9. function k2_comment_type_detection($commenttxt = 'Comment', $trackbacktxt = 'Trackback', $pingbacktxt = 'Pingback') {
  10. global $comment;
  11. if (preg_match('|trackback|', $comment->comment_type))
  12. return $trackbacktxt;
  13. elseif (preg_match('|pingback|', $comment->comment_type))
  14. return $pingbacktxt;
  15. else
  16. return $commenttxt;
  17. }
  18. function unsleepable_comment($comment, $args, $depth) {
  19. $GLOBALS['comment'] = $comment;
  20. global $count_pings;
  21. extract($args, EXTR_SKIP);
  22. ?>
  23. <li <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">
  24. <div id="div-comment-<?php comment_ID() ?>">
  25. <div class="comment-author vcard">
  26. <?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?>
  27. <a href="#comment-<?php comment_ID() ?>" class="counter" title="Permanent Link to this Comment"><?php echo $count_pings; $count_pings++; ?></a>
  28. <span class="commentauthor fn" style="font-weight: bold;"><?php comment_author_link() ?></span><small class="commentmetadata"> on <a href="#comment-<?php comment_ID() ?>" title="<?php if (function_exists('time_since')) { $comment_datetime = strtotime($comment->comment_date); echo time_since($comment_datetime) ?> ago<?php } else { ?>Permalink to Comment<?php } ?>"><?php comment_date() ?></a> said:</small>
  29. <?php if ( $user_ID ) { edit_comment_link('<img src="'.get_bloginfo(template_directory).'/images/pencil.png" alt="Edit Link" />','<span class="commentseditlink">','</span>'); } ?>
  30. </div>
  31. <div class="itemtext2">
  32. <?php comment_text() ?>
  33. </div>
  34. <?php if ($comment->comment_approved == '0') : ?>
  35. <p class="alert"><strong>Your comment is awaiting moderation.</strong></p>
  36. <?php endif; ?>
  37. <div class="reply">
  38. <?php comment_reply_link(array_merge( $args, array('add_below' => 'div-comment', 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
  39. </div>
  40. </div>
  41. <?php
  42. }
  43. function unsleepable_ping($comment, $args, $depth) {
  44. $GLOBALS['comment'] = $comment;
  45. global $count_pings;
  46. extract($args, EXTR_SKIP);
  47. ?>
  48. <li <?php comment_class(empty( $args['has_children'] ) ? 'item' : 'item parent') ?> id="comment-<?php comment_ID() ?>">
  49. <a href="#comment-<?php comment_ID() ?>" title="Permanent Link to this Comment" class="counter"><?php echo $count_pings; $count_pings++; ?></a>
  50. <span class="commentauthor"><?php comment_author_link() ?></span>
  51. </li>
  52. <?php
  53. }
  54. if ((have_comments()) or (comments_open())) { ?>
  55. <hr />
  56. <div class="comments" id="comments">
  57. <h4><a href="#comments"><?php comments_number('No Responses Yet', 'One Response', '% Responses' );?> to &#8220;<?php the_title(); ?>&#8221; &nbsp;</a></h4>
  58. <div class="metalinks">
  59. <span class="commentsrsslink"><?php post_comments_feed_link( 'Feed for this Entry' ); ?></span>
  60. <?php if (pings_open()) { ?><span class="trackbacklink"><a href="<?php trackback_url() ?>" title="Copy this URI to trackback this entry.">Trackback Address</a></span><?php } ?>
  61. </div>
  62. <ol class="commentlist" id='commentlist'>
  63. <?php if (have_comments()) {
  64. global $count_pings;
  65. $count_pings = 1;
  66. wp_list_comments(array('callback'=>'unsleepable_comment', 'avatar_size'=>48, 'type'=>'comment'));
  67. ?>
  68. </ol>
  69. <div class="navigation">
  70. <div class="alignleft"><?php previous_comments_link() ?></div>
  71. <div class="alignright"><?php next_comments_link() ?></div>
  72. </div>
  73. <br />
  74. <ol class="pinglist">
  75. <?php
  76. $count_pings = 1;
  77. wp_list_comments(array('callback'=>'unsleepable_ping', 'type'=>'pings'));
  78. ?>
  79. </ol>
  80. <?php } else { // this is displayed if there are no comments so far ?>
  81. <?php if (comments_open()) { ?>
  82. <!-- If comments are open, but there are no comments. -->
  83. <li id="leavecomment">Leave a Comment</li>
  84. <?php } else { // comments are closed ?>
  85. <!-- If comments are closed. -->
  86. <?php if (is_single()) { // To hide comments entirely on Pages without comments ?>
  87. <li>Comments are currently closed.</li>
  88. <?php } ?>
  89. <?php } ?>
  90. </ol>
  91. <?php } ?>
  92. <?php if (have_comments()) { ?>
  93. <?php include (TEMPLATEPATH . '/navigation.php'); ?>
  94. <?php } ?>
  95. <?php comment_form(); ?>
  96. </div> <!-- Close .comments container -->
  97. <?php } ?>