PageRenderTime 49ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/data/wpcom-themes/unsleepable/comments.php

https://gitlab.com/Blueprint-Marketing/wordpress-unit-tests
PHP | 178 lines | 131 code | 46 blank | 1 comment | 26 complexity | f59f301cf5382f486f18a2c811c7462a MD5 | raw file
  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 comments_rss_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">No Comments Yet</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. <!-- Reply Form -->
  96. <?php if (comments_open()) : ?>
  97. <div id="respond">
  98. <h4><?php comment_form_title( 'Leave a Reply', 'Leave a Reply to %s' ); ?></h4>
  99. <div id="cancel-comment-reply"><small><?php cancel_comment_reply_link() ?></small></div>
  100. <?php if ( get_option('comment_registration') && !$user_ID ) : ?>
  101. <p>You must <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php the_permalink(); ?>">log in</a> to post a comment.</p>
  102. <?php else : ?>
  103. <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
  104. <?php if ( $user_ID ) { ?>
  105. <p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="<?php _e('Log out of this account') ?>">Logout &raquo;</a></p>
  106. <?php } elseif ($comment_author != "") { ?>
  107. <p><small>Welcome back <strong><?php echo $comment_author; ?></strong></p>
  108. <?php } ?>
  109. <?php if ( !$user_ID ) { ?>
  110. <div id="authorinfo">
  111. <p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" />
  112. <label for="author"><small><strong>Name</strong> <?php if ($req) _e('(required)'); ?></small></label></p>
  113. <p><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" />
  114. <label for="email"><small><strong>E-mail</strong> (will not be published) <?php if ($req) _e('(required)'); ?></small></label></p>
  115. <p><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" />
  116. <label for="url"><small><strong>Website</strong></small></label></p>
  117. </div>
  118. <?php } ?>
  119. <!--<p><small><strong>XHTML:</strong> You can use these tags: <?php echo allowed_tags(); ?></small></p>-->
  120. <p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p>
  121. <p>
  122. <input name="submit" type="submit" id="submit" tabindex="5" value="Submit" />
  123. <?php comment_id_fields(); ?>
  124. <br class="clear" />
  125. </p>
  126. <?php do_action('comment_form', $post->ID); ?>
  127. </form>
  128. <?php endif; // If registration required and not logged in ?>
  129. </div>
  130. <?php endif; // if you delete this the sky will fall on your head ?>
  131. </div> <!-- Close .comments container -->
  132. <?php } ?>