Advertisement
Guest User

field

a guest
Sep 24th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.29 KB | None | 0 0
  1. // Add extra field to comment form
  2. function add_bcw_fields($fields){
  3.    $fields['test'] = '<input type="text" name="test" id="test" size="22" />';
  4.    return $fields;
  5. }
  6. add_filter( 'comment_form_default_fields', 'add_bcw_fields' );
  7. //Save the extra comment field value
  8. function bcw_handle_comment($id) {
  9.    if (array_key_exists('test', $_POST))
  10.       update_comment_meta( $id, 'bcw_test', $_POST['test']);
  11. }
  12. add_action('wp_insert_comment', 'bcw_handle_comment');
  13. //Override default theme function to display a comment
  14.  
  15. function twentyten_comment( $comment, $args, $depth ) {
  16.     $GLOBALS['comment'] = $comment;
  17.     switch ( $comment->comment_type ) :
  18.         case '' :
  19.     ?>
  20.     <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  21.         <div id="comment-<?php comment_ID(); ?>">
  22.  
  23.             <div class="comment-author vcard">
  24.                 <?php echo get_avatar( $comment, 40 ); ?>
  25.                 <?php printf( __( '%s <span class="says">says:</span>', 'twentyten' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
  26.             </div><!-- .comment-author .vcard -->
  27.             <?php if ( $comment->comment_approved == '0' ) : ?>
  28.                 <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentyten' ); ?></em>
  29.                 <br />
  30.             <?php endif; ?>
  31.  
  32.             <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
  33.                 <?php
  34.                     /* translators: 1: date, 2: time */
  35.                     printf( __( '%1$s at %2$s', 'twentyten' ), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' );
  36.                 ?>
  37.             </div><!-- .comment-meta .commentmetadata -->
  38.  
  39.             <div class="comment-body"><?php comment_text(); ?></div>
  40.                          <?php echo get_comment_meta( $comment->comment_ID, 'bcw_test', true ); ?>
  41.  
  42.             <div class="reply">
  43.                 <?php /* <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?> */ ?>
  44.             </div><!-- .reply -->
  45.         </div><!-- #comment-##  -->
  46.  
  47.     <?php
  48.             break;
  49.         case 'pingback'  :
  50.         case 'trackback' :
  51.     ?>
  52.     <li class="post pingback">
  53.         <p><?php _e( 'Pingback:', 'twentyten' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' ); ?></p>
  54.     <?php
  55.             break;
  56.     endswitch;
  57. }
  58. endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement