PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/comments.php

https://github.com/philips/lpcwp
PHP | 127 lines | 101 code | 26 blank | 0 comment | 29 complexity | abf62a1af2a3b18c7eb52c4c59203203 MD5 | raw file
  1. <?php
  2. if ( 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']) )
  3. die ( 'Please do not load this page directly. Thanks.' );
  4. ?>
  5. <div id="comments">
  6. <?php
  7. if ( !empty($post->post_password) ) :
  8. if ( $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password ) :
  9. ?>
  10. <div class="nopassword"><?php _e( 'This post is protected. Enter the password to view any comments.', 'sandbox' ) ?></div>
  11. </div><!-- .comments -->
  12. <?php
  13. return;
  14. endif;
  15. endif;
  16. ?>
  17. <?php if ( $comments ) : ?>
  18. <?php global $sandbox_comment_alt ?>
  19. <?php // Number of pings and comments
  20. $ping_count = $comment_count = 0;
  21. foreach ( $comments as $comment )
  22. get_comment_type() == "comment" ? ++$comment_count : ++$ping_count;
  23. ?>
  24. <?php if ( $comment_count ) : ?>
  25. <?php $sandbox_comment_alt = 0 ?>
  26. <div id="comments-list" class="comments">
  27. <h3><?php printf($comment_count > 1 ? __('<span>%d</span> Comments', 'sandbox') : __('<span>One</span> Comment', 'sandbox'), $comment_count) ?></h3>
  28. <ol>
  29. <?php foreach ($comments as $comment) : ?>
  30. <?php if ( get_comment_type() == "comment" ) : ?>
  31. <li id="comment-<?php comment_ID() ?>" class="<?php sandbox_comment_class() ?>">
  32. <div class="comment-author vcard"><?php sandbox_commenter_link() ?></div>
  33. <div class="comment-meta"><?php printf(__('Posted %1$s at %2$s <span class="meta-sep">|</span> <a href="%3$s" title="Permalink to this comment">Permalink</a>', 'sandbox'),
  34. get_comment_date(),
  35. get_comment_time(),
  36. '#comment-' . get_comment_ID() );
  37. edit_comment_link(__('Edit', 'sandbox'), ' <span class="meta-sep">|</span> <span class="edit-link">', '</span>'); ?></div>
  38. <?php if ($comment->comment_approved == '0') _e("\t\t\t\t\t<span class='unapproved'>Your comment is awaiting moderation.</span>\n", 'sandbox') ?>
  39. <?php comment_text() ?>
  40. </li>
  41. <?php endif; // REFERENCE: if ( get_comment_type() == "comment" ) ?>
  42. <?php endforeach; ?>
  43. </ol>
  44. </div><!-- #comments-list .comments -->
  45. <?php endif; // REFERENCE: if ( $comment_count ) ?>
  46. <?php if ( $ping_count ) : ?>
  47. <?php $sandbox_comment_alt = 0 ?>
  48. <div id="trackbacks-list" class="comments">
  49. <h3><?php printf($ping_count > 1 ? __('<span>%d</span> Trackbacks', 'sandbox') : __('<span>One</span> Trackback', 'sandbox'), $ping_count) ?></h3>
  50. <ol>
  51. <?php foreach ( $comments as $comment ) : ?>
  52. <?php if ( get_comment_type() != "comment" ) : ?>
  53. <li id="comment-<?php comment_ID() ?>" class="<?php sandbox_comment_class() ?>">
  54. <div class="comment-author"><?php printf(__('By %1$s on %2$s at %3$s', 'sandbox'),
  55. get_comment_author_link(),
  56. get_comment_date(),
  57. get_comment_time() );
  58. edit_comment_link(__('Edit', 'sandbox'), ' <span class="meta-sep">|</span> <span class="edit-link">', '</span>'); ?></div>
  59. <?php if ($comment->comment_approved == '0') _e('\t\t\t\t\t<span class="unapproved">Your trackback is awaiting moderation.</span>\n', 'sandbox') ?>
  60. <?php comment_text() ?>
  61. </li>
  62. <?php endif // REFERENCE: if ( get_comment_type() != "comment" ) ?>
  63. <?php endforeach; ?>
  64. </ol>
  65. </div><!-- #trackbacks-list .comments -->
  66. <?php endif // REFERENCE: if ( $ping_count ) ?>
  67. <?php endif // REFERENCE: if ( $comments ) ?>
  68. <?php if ( 'open' == $post->comment_status ) : ?>
  69. <?php $req = get_option('require_name_email'); // Checks if fields are required. Thanks, Adam. ;-) ?>
  70. <div id="respond">
  71. <h3><?php _e( 'Post a Comment', 'sandbox' ) ?></h3>
  72. <?php if ( get_option('comment_registration') && !$user_ID ) : ?>
  73. <p id="login-req"><?php printf(__('You must be <a href="%s" title="Log in">logged in</a> to post a comment.', 'sandbox'),
  74. get_bloginfo('wpurl') . '/wp-login.php?redirect_to=' . get_permalink() ) ?></p>
  75. <?php else : ?>
  76. <div class="formcontainer">
  77. <form id="commentform" action="<?php bloginfo('wpurl') ?>/wp-comments-post.php" method="post">
  78. <?php if ( $user_ID ) : ?>
  79. <p id="login"><?php printf( __( '<span class="loggedin">Logged in as <a href="%1$s" title="Logged in as %2$s">%2$s</a>.</span> <span class="logout"><a href="%3$s" title="Log out of this account">Log out?</a></span>', 'sandbox' ),
  80. get_bloginfo('wpurl') . '/wp-admin/profile.php',
  81. wp_specialchars( $user_identity, 1 ),
  82. get_bloginfo('wpurl') . '/wp-login.php?action=logout&amp;redirect_to=' . get_permalink() ) ?></p>
  83. <?php else : ?>
  84. <p id="comment-notes"><?php _e( 'Your email is <em>never</em> shared.', 'sandbox' ) ?> <?php if ($req) _e( 'Required fields are marked <span class="required">*</span>', 'sandbox' ) ?></p>
  85. <div class="form-label"><label for="author"><?php _e( 'Name', 'sandbox' ) ?></label> <?php if ($req) _e( '<span class="required">*</span>', 'sandbox' ) ?></div>
  86. <div class="form-input"><input id="author" name="author" class="text<?php if ($req) echo ' required'; ?>" type="text" value="<?php echo $comment_author ?>" size="30" maxlength="50" tabindex="3" /></div>
  87. <div class="form-label"><label for="email"><?php _e( 'Email', 'sandbox' ) ?></label> <?php if ($req) _e( '<span class="required">*</span>', 'sandbox' ) ?></div>
  88. <div class="form-input"><input id="email" name="email" class="text<?php if ($req) echo ' required'; ?>" type="text" value="<?php echo $comment_author_email ?>" size="30" maxlength="50" tabindex="4" /></div>
  89. <div class="form-label"><label for="url"><?php _e( 'Website', 'sandbox' ) ?></label></div>
  90. <div class="form-input"><input id="url" name="url" class="text" type="text" value="<?php echo $comment_author_url ?>" size="30" maxlength="50" tabindex="5" /></div>
  91. <?php endif // REFERENCE: * if ( $user_ID ) ?>
  92. <div class="form-label"><label for="comment"><?php _e( 'Comment', 'sandbox' ) ?></label></div>
  93. <div class="form-textarea"><textarea id="comment" name="comment" class="text required" cols="45" rows="8" tabindex="6"></textarea></div>
  94. <div class="form-submit"><input id="submit" name="submit" class="button" type="submit" value="<?php _e( 'Post Comment', 'sandbox' ) ?>" tabindex="7" /><input type="hidden" name="comment_post_ID" value="<?php echo $id ?>" /></div>
  95. <div class="form-option"><?php do_action( 'comment_form', $post->ID ) ?></div>
  96. </form><!-- #commentform -->
  97. </div><!-- .formcontainer -->
  98. <?php endif // REFERENCE: if ( get_option('comment_registration') && !$user_ID ) ?>
  99. </div><!-- #respond -->
  100. <?php endif // REFERENCE: if ( 'open' == $post->comment_status ) ?>
  101. </div><!-- #comments -->