Make WordPress Core


Ignore:
Timestamp:
02/28/2008 06:50:25 AM (17 years ago)
Author:
ryan
Message:

Unify comment display. Props mdawaffe. fixes #6025

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/template.php

    r7078 r7082  
    593593}
    594594
    595 function _wp_comment_list_item( $id, $alt = 0 ) {
    596     global $authordata, $comment;
    597     $comment =& get_comment( $id );
    598     $id = (int) $comment->comment_ID;
    599     $class = '';
     595function _wp_comment_row( $comment_id, $mode, $checkbox = true ) {
     596    global $comment, $post;
     597    $comment = get_comment( $comment_id );
    600598    $post = get_post($comment->comment_post_ID);
    601599    $authordata = get_userdata($post->post_author);
    602     $comment_status = wp_get_comment_status($id);
    603     if ( 'unapproved' == $comment_status )
    604         $class .= ' unapproved';
    605     if ( $alt % 2 )
    606         $class .= ' alternate';
    607     echo "<li id='comment-$id' class='$class'>";
     600    $the_comment_status = wp_get_comment_status($comment->comment_ID);
     601    $class = ('unapproved' == $the_comment_status) ? 'unapproved' : '';
     602    $post_link = '<a href="' . get_comment_link() . '">' . get_the_title($comment->comment_post_ID) . '</a>';
     603    $author_url = get_comment_author_url();
     604    if ( 'http://' == $author_url )
     605        $author_url = '';
     606    $author_url_display = $author_url;
     607    if ( strlen($author_url_display) > 50 )
     608        $author_url_display = substr($author_url_display, 0, 49) . '...';
     609    $ptime = get_post_time('G', true);
     610    if ( ( abs(time() - $ptime) ) < 86400 )
     611        $ptime = sprintf( __('%s ago'), human_time_diff( $ptime ) );
     612    else
     613        $ptime = mysql2date(__('Y/m/d \a\t g:i A'), $post->post_date);
     614
     615    $delete_url  = clean_url( wp_nonce_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
     616    $approve_url = clean_url( wp_nonce_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ) );
     617    $spam_url    = clean_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
     618           
    608619?>
    609 <p><strong class="comment-author"><?php comment_author(); ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
    610 
    611 <?php comment_text() ?>
    612 
    613 <p><?php comment_date(__('M j, g:i A'));  ?> &#8212; [
    614 <?php
    615 if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
    616     echo " <a href='comment.php?action=editcomment&amp;c=$id'>" .  __('Edit') . '</a>';
    617     $url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&amp;p=$comment->comment_post_ID&amp;c=$id", "delete-comment_$id" ) );
    618     echo " | <a href='$url' class='delete:the-comment-list:comment-$id'>" . __('Delete') . '</a> ';
    619     if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) {
    620         $url = clean_url( wp_nonce_url( "comment.php?action=unapprovecomment&amp;p=$comment->comment_post_ID&amp;c=$id", "unapprove-comment_$id" ) );
    621         echo "<span class='unapprove'> | <a href='$url' class='dim:the-comment-list:comment-$id:unapproved:FFFF33'>" . __('Unapprove') . '</a> </span>';
    622         $url = clean_url( wp_nonce_url( "comment.php?action=approvecomment&amp;p=$comment->comment_post_ID&amp;c=$id", "approve-comment_$id" ) );
    623         echo "<span class='approve'> | <a href='$url' class='dim:the-comment-list:comment-$id:unapproved:33FF33:33FF33'>" . __('Approve') . '</a> </span>';
    624     }
    625     $url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&amp;dt=spam&amp;p=$comment->comment_post_ID&amp;c=$id", "delete-comment_$id" ) );
    626     echo " | <a href='$url' class='delete:the-comment-list:comment-$id::spam=1'>" . __('Spam') . '</a> ';
    627 }
    628 if ( !is_single() ) {
    629     $post = get_post($comment->comment_post_ID, OBJECT, 'display');
    630     $post_title = wp_specialchars( $post->post_title, 'double' );
    631     $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
    632 ?>
    633  ] &#8212; <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php echo $post_title; ?></a>
    634 <?php } ?>
    635 </p>
    636         </li>
    637 <?php
     620  <tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $class; ?>'>
     621<?php if ( $checkbox ) : ?>
     622    <td style="text-align: center;"><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { ?><input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /><?php } ?></td>
     623<?php endif; ?>
     624    <td class="comment">
     625    <p class="comment-author"><strong><a class="row-title" href="comment.php?action=editcomment&amp;c=<?php echo $comment->comment_ID?>"><?php comment_author(); ?></a></strong><br />
     626    <?php if ( !empty($author_url) ) : ?>
     627    <a href="<?php echo $author_url ?>"><?php echo $author_url_display; ?></a> |
     628    <?php endif; ?>
     629    <?php if ( !empty($comment->comment_author_email) ): ?>
     630    <?php comment_author_email_link() ?> |
     631    <?php endif; ?>
     632    <a href="edit-comments.php?s=<?php comment_author_IP() ?>&amp;mode=detail"><?php comment_author_IP() ?></a>
     633    </p>
     634    <p><?php if ( 'list' == $mode ) comment_excerpt(); else comment_text(); ?></p>
     635    <p><?php printf(__('From %1$s, %2$s'), $post_link, $ptime) ?></p>
     636    </td>
     637    <td><?php comment_date(__('Y/m/d')); ?></td>
     638    <td>
     639    <?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
     640        if ( 'approved' != $the_comment_status ) {
     641        if ( $comment_status ) // we're looking at list of only approved or only unapproved comments
     642            echo "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:33FF33:action=dim-comment' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a> | ';
     643        else // we're looking at all comments
     644            echo "<span class='approve'><a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:none:33FF33' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a> | </span>';
     645    }
     646        echo "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1' title='" . __( 'Mark this comment as spam' ) . "'>" . __( 'Spam' ) . '</a> | ';
     647        echo "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete'>" . __('Delete') . '</a>';
     648    }
     649    ?>
     650    </td>
     651  </tr>
     652    <?php
    638653}
    639654
Note: See TracChangeset for help on using the changeset viewer.