Advertisement
bcworkz

twentyten custom comments.php

Oct 14th, 2013
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.12 KB | None | 0 0
  1. <?php
  2. /**
  3.  * The template for displaying Comments.
  4.  * Modified for "sicktb"
  5.  *
  6.  * For variants of this template alter "Test:" at line 91 (input) and 142 (output)
  7.  * Coordinate with bcw_handle_comment() on functions.php
  8.  *
  9.  * The area of the page that contains both current comments
  10.  * and the comment form.
  11.  *
  12.  * @package WordPress
  13.  * @subpackage Twenty_Ten
  14.  * @since Twenty Ten 1.0
  15.  */
  16. ?>
  17.  
  18.             <div id="comments">
  19. <?php if ( post_password_required() ) : ?>
  20.                 <p class="nopassword"><?php _e( 'This post is password protected. Enter the password to view any comments.', 'twentyten' ); ?></p>
  21.             </div><!-- #comments -->
  22. <?php
  23.         /* Stop the rest of comments.php from being processed,
  24.          * but don't kill the script entirely -- we still have
  25.          * to fully load the template.
  26.          */
  27.         return;
  28.     endif;
  29. ?>
  30.  
  31. <?php
  32.     // You can start editing here -- including this comment!
  33. ?>
  34.  
  35. <?php if ( have_comments() ) : ?>
  36.             <h3 id="comments-title"><?php
  37.             printf( _n( 'One Response to %2$s', '%1$s Responses to %2$s', get_comments_number(), 'twentyten' ),
  38.             number_format_i18n( get_comments_number() ), '<em>' . get_the_title() . '</em>' );
  39.             ?></h3>
  40.  
  41. <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
  42.             <div class="navigation">
  43.                 <div class="nav-previous"><?php previous_comments_link( __( '<span class="meta-nav">&larr;</span> Older Comments', 'twentyten' ) ); ?></div>
  44.                 <div class="nav-next"><?php next_comments_link( __( 'Newer Comments <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div>
  45.             </div> <!-- .navigation -->
  46. <?php endif; // check for comment navigation ?>
  47.  
  48.             <ol class="commentlist">
  49.                 <?php
  50.                     /* Loop through and list the comments. Tell wp_list_comments()
  51.                      * to use twentyten_comment() to format the comments.
  52.                      * If you want to overload this in a child theme then you can
  53.                      * define twentyten_comment() and that will be used instead.
  54.                      * See twentyten_comment() in twentyten/functions.php for more.
  55.                      */
  56.                     wp_list_comments( array( 'callback' => 'twentyten_comment1' ) );
  57.                 ?>
  58.             </ol>
  59.  
  60. <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
  61.             <div class="navigation">
  62.                 <div class="nav-previous"><?php previous_comments_link( __( '<span class="meta-nav">&larr;</span> Older Comments', 'twentyten' ) ); ?></div>
  63.                 <div class="nav-next"><?php next_comments_link( __( 'Newer Comments <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div>
  64.             </div><!-- .navigation -->
  65. <?php endif; // check for comment navigation ?>
  66.  
  67.     <?php
  68.     /* If there are no comments and comments are closed, let's leave a little note, shall we?
  69.      * But we only want the note on posts and pages that had comments in the first place.
  70.      */
  71.     if ( ! comments_open() && get_comments_number() ) : ?>
  72.         <p class="nocomments"><?php _e( 'Comments are closed.' , 'twentyten' ); ?></p>
  73.     <?php endif;  ?>
  74.  
  75. <?php endif; // end have_comments() ?>
  76.  
  77. <?php $post_id = get_the_ID();
  78.     if ( comments_open( $post_id ) ) : ?>
  79.     <div id="respond" class="comment-respond">
  80.         <h3 id="reply-title" class="comment-reply-title"><?php comment_form_title(__( 'Leave a Reply' ),__( 'Leave a Reply to %s' )); ?> <small><?php cancel_comment_reply_link(__( 'Cancel reply' )); ?></small></h3>
  81.         <?php if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) : ?>
  82.             <?php echo '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>'; ?>
  83.         <?php else : ?>
  84.             <form action="<?php echo site_url( '/wp-comments-post.php' ); ?>" method="post" id="<?php echo 'commentform'; ?>" class="comment-form">
  85.                 <?php $args = '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>' ), get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>';
  86.                 echo apply_filters( 'comment_form_logged_in', $args, $commenter, $user_identity ); ?>
  87.                 <?php $args = '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>';
  88.                 echo apply_filters( 'comment_form_field_comment', $args ); ?>
  89.  
  90.                 <!-- !!!!!! Custom form fields start here !!!!!!! -->
  91.                 Test: <input type="text" name="test" id="test" size="22" /><br style="clear: both;"><br>
  92.  
  93.                 <p class="form-submit">
  94.                     <input name="submit" type="submit" id="<?php echo esc_attr( $args['id_submit'] ); ?>" value="<?php echo __( 'Post Comment' ); ?>" />
  95.                     <?php comment_id_fields( $post_id ); ?>
  96.                 </p>
  97.             </form>
  98.         <?php endif; ?>
  99.     </div><!-- #respond -->
  100. <?php else :
  101.     do_action( 'comment_form_comments_closed' );
  102. endif; ?>
  103.  
  104. </div><!-- #comments -->
  105. <?php
  106. /**
  107.  * Template for comments and pingbacks.
  108.  *
  109.  * To override this walker in a child theme without modifying the comments template
  110.  * simply create your own twentyten_comment(), and that function will be used instead.
  111.  *
  112.  * Used as a callback by wp_list_comments() for displaying the comments.
  113.  *
  114.  * @since Twenty Ten 1.0
  115.  */
  116. function twentyten_comment1( $comment, $args, $depth ) {
  117.     $GLOBALS['comment'] = $comment;
  118.     switch ( $comment->comment_type ) :
  119.         case '' :
  120.     ?>
  121.     <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  122.         <div id="comment-<?php comment_ID(); ?>">
  123.             <div class="comment-author vcard">
  124.                 <?php echo get_avatar( $comment, 40 ); ?>
  125.                 <?php printf( __( '%s <span class="says">says:</span>', 'twentyten' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
  126.             </div><!-- .comment-author .vcard -->
  127.             <?php if ( $comment->comment_approved == '0' ) : ?>
  128.                 <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentyten' ); ?></em>
  129.                 <br />
  130.             <?php endif; ?>
  131.  
  132.             <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
  133.                 <?php
  134.                     /* translators: 1: date, 2: time */
  135.                     printf( __( '%1$s at %2$s', 'twentyten' ), get_comment_date(),  get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' );
  136.                 ?>
  137.             </div><!-- .comment-meta .commentmetadata -->
  138.  
  139.             <div class="comment-body"><?php comment_text(); ?></div>
  140.            
  141.             <!-- !!!!!! Custom form field output starts here !!!!!!! -->
  142.             Test: <?php echo get_comment_meta( $comment->comment_ID, 'bcw_test', true ); ?>
  143.            
  144.             <div class="reply">
  145.                 <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  146.             </div><!-- .reply -->
  147.         </div><!-- #comment-##  -->
  148.  
  149.     <?php
  150.             break;
  151.         case 'pingback'  :
  152.         case 'trackback' :
  153.     ?>
  154.     <li class="post pingback">
  155.         <p><?php _e( 'Pingback:', 'twentyten' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' ); ?></p>
  156.     <?php
  157.             break;
  158.     endswitch;
  159. }
  160. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement