Advertisement
sayful

WordPress Comments File

Jul 19th, 2014
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.17 KB | None | 0 0
  1. /*==================================================================
  2. comments.php
  3. ===================================================================*/
  4. <?php comment_ID(); ?>          //the ID of a comment
  5. <?php comment_type(); ?>        //the type of comment; pingback, trackback or a comment
  6. <?php comment_text(); ?>        //the actual comment
  7. <?php comment_date(); ?>        //the date it was posted
  8. <?php comment_time(); ?>        //the time it was posted
  9. <?php comment_author(); ?>      //the author of a comment
  10. <?php comment_author_link(); ?>     //the author of a comment, wrapped with a link to his website if he specified one
  11. <?php edit_comment_link(__('edit comment'), '<p>', '</p>'); ?>      //Displays Edit Comment in Paragraph Tag
  12. <?php echo allowed_tags(); ?>       //Displaying the allowed tags
  13. <?php echo get_avatar( get_comment_author_email(), $size, $default_avatar ); ?>     //the author avater
  14. <?php comments_number('No comments', 'One comment', '% comments'); ?>       //Comment numbers for title
  15. <?php comments_popup_link('No comments', 'One comment', '% comments', 'comments-link', 'Comments are closed'); ?>   //To display a link to the comments part (with the number of comments displaying aswell)
  16.  
  17. /*==================================================================
  18. Displaying The Comments
  19. ===================================================================*/
  20. <?php if($comments) : ?>    //checks if there are comments
  21.     <ol>
  22.         <?php foreach($comments as $comment) : ?>   //loops through comments
  23.             <li id="comment-<?php comment_ID(); ?>">
  24.                 <?php if ($comment->comment_approved == '0') : ?>   //checks if the comment has been approved
  25.                     <p>Your comment is awaiting approval</p><!--shows a message if it's not yet approved-->
  26.                 <?php endif; ?>
  27.                 <?php echo get_avatar( get_comment_author_email(), $size, $default_avatar ); ?>
  28.                 <?php comment_text(); ?>
  29.                 <cite><?php comment_type(); ?> by <?php comment_author_link(); ?> on <?php comment_date(); ?> at <?php comment_time(); ?></cite>
  30.             </li>
  31.         <?php endforeach; ?>
  32.     </ol>
  33. <?php else : ?>
  34.     <p>No comments yet</p>
  35. <?php endif; ?>
  36.  
  37. /*==================================================================
  38. The Comment Form
  39. ===================================================================*/
  40. // WordPress default comment form
  41. <?php comment_form(); ?>
  42.  
  43. //WordPress custom comment form
  44. <h3><?php comment_form_title( 'Leave a Reply', 'Leave a Reply to %s' ); ?></h3>
  45. <?php if(comments_open()) : ?>
  46.  
  47.     <?php if(get_option('comment_registration') && !$user_ID) : ?>
  48.  
  49.         <p>You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>">logged in</a> to post a comment.</p>
  50.  
  51.     <?php else : ?>
  52.         <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
  53.  
  54.             <?php if($user_ID) : ?>
  55.  
  56.                 <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="Log out of this account">Log out &raquo;</a></p>
  57.  
  58.             <?php else : ?>
  59.  
  60.                 <label for="author">
  61.                     <small>Name <?php if($req) echo "(required)"; ?></small>
  62.                 </label>
  63.                 <input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" />
  64.  
  65.                 <label for="email">
  66.                     <small>Mail (will not be published) <?php if($req) echo "(required)"; ?></small>
  67.                 </label>
  68.                 <input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" />
  69.                 <label for="url">
  70.                     <small>Website</small>
  71.                 </label>
  72.                 <input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" />
  73.  
  74.             <?php endif; ?>
  75.  
  76.             <textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea>
  77.             <p>Allowed tags: <?php echo allowed_tags(); ?></p>
  78.  
  79.             <input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
  80.             <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
  81.            
  82.             <?php do_action('comment_form', $post->ID); ?>
  83.         </form>
  84.     <?php endif; ?>
  85. <?php else : ?>
  86.     <p>The comments are closed.</p>
  87. <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement