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/edit-comments.php

    r7057 r7082  
    5252else
    5353    $comment_status = '';
     54
     55if ( isset($_GET['s']) )
     56    $search_dirty = $_GET['s'];
     57else
     58    $search_dirty = '';
     59$search = attribute_escape( $search );
    5460?>
    5561<?php
     
    106112
    107113<p id="post-search">
    108     <input type="text" id="post-search-input" name="s" value="<?php if (isset($_GET['s'])) echo attribute_escape($_GET['s']); ?>" />
     114    <input type="text" id="post-search-input" name="s" value="<?php echo $search; ?>" />
    109115    <input type="submit" value="<?php _e( 'Search Comments' ); ?>" class="button" />
    110116</p>
     
    112118<input type="hidden" name="mode" value="<?php echo $mode; ?>" />
    113119<input type="hidden" name="comment_status" value="<?php echo $comment_status; ?>" />
     120</form>
    114121
    115122<ul class="view-switch">
     
    127134$start = $offset = ( $page - 1 ) * 20;
    128135
    129 list($_comments, $total) = _wp_get_comment_list( $comment_status, isset($_GET['s']) ? $_GET['s'] : false, $start, 25 ); // Grab a few extra
     136list($_comments, $total) = _wp_get_comment_list( $comment_status, $search_dirty, $start, 25 ); // Grab a few extra
    130137
    131138$comments = array_slice($_comments, 0, 20);
     
    140147
    141148?>
     149
     150<form id="comments-form" action="" method="post">
    142151
    143152<div class="tablenav">
     
    176185<tbody id="the-comment-list" class="list:comment">
    177186<?php
    178     foreach ($comments as $comment) {
    179         $post = get_post($comment->comment_post_ID);
    180         $authordata = get_userdata($post->post_author);
    181         $the_comment_status = wp_get_comment_status($comment->comment_ID);
    182         $class = ('unapproved' == $the_comment_status) ? 'unapproved' : '';
    183         $post_link = '<a href="' . get_comment_link() . '">' . get_the_title($comment->comment_post_ID) . '</a>';
    184         $author_url = get_comment_author_url();
    185         if ( 'http://' == $author_url )
    186             $author_url = '';
    187         $author_url_display = $author_url;
    188         if ( strlen($author_url_display) > 50 )
    189             $author_url_display = substr($author_url_display, 0, 49) . '...';
    190         $ptime = get_post_time('G', true);
    191         if ( ( abs(time() - $ptime) ) < 86400 )
    192             $ptime = sprintf( __('%s ago'), human_time_diff( $ptime ) );
    193         else
    194             $ptime = mysql2date(__('Y/m/d \a\t g:i A'), $post->post_date);
    195 
    196         $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" ) );
    197         $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" ) );
    198         $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" ) );
    199            
    200 ?>
    201   <tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $class; ?>'>
    202     <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>
    203     <td class="comment">
    204     <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 />
    205     <?php if ( !empty($author_url) ) : ?>
    206     <a href="<?php echo $author_url ?>"><?php echo $author_url_display; ?></a> |
    207     <?php endif; ?>
    208     <?php if ( !empty($comment->comment_author_email) ): ?>
    209     <?php comment_author_email_link() ?> |
    210     <?php endif; ?>
    211     <a href="edit-comments.php?s=<?php comment_author_IP() ?>&amp;mode=detail"><?php comment_author_IP() ?></a>
    212     </p>
    213     <p><?php if ( 'list' == $mode ) comment_excerpt(); else comment_text(); ?></p>
    214     <p><?php printf(__('From %1$s, %2$s'), $post_link, $ptime) ?></p>
    215     </td>
    216     <td><?php comment_date(__('Y/m/d')); ?></td>
    217     <td>
    218     <?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
    219         if ( 'approved' != $the_comment_status ) {
    220         if ( $comment_status ) // we're looking at list of only approved or only unapproved comments
    221             echo "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:33FF33:action=dim-comment' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a> | ';
    222         else // we're looking at all comments
    223             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>';
    224     }
    225         echo "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1' title='" . __( 'Mark this comment as spam' ) . "'>" . __( 'Spam' ) . '</a> | ';
    226         echo "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete'>" . __('Delete') . '</a>';
    227     }
    228     ?>
    229     </td>
    230   </tr>
    231         <?php
    232         } // end foreach
    233     ?></tbody>
     187    foreach ($comments as $comment)
     188        _wp_comment_row( $comment->comment_ID, $mode );
     189?>
     190</tbody>
     191<tbody id="the-extra-comment-list" class="list:comment" style="display: none;">
     192<?php
     193    foreach ($extra_comments as $comment)
     194        _wp_comment_row( $comment->comment_ID, $mode );
     195?>
     196</tbody>
    234197</table>
     198
     199</form>
     200
     201<form id="get-extra-comments" method="post" action="" class="add:the-extra-comment-list:" style="display: none;">
     202    <input type="hidden" name="s" value="<?php echo $search; ?>" />
     203    <input type="hidden" name="mode" value="<?php echo $mode; ?>" />
     204    <input type="hidden" name="comment_status" value="<?php echo $comment_status; ?>" />
     205    <input type="hidden" name="page" value="<?php echo isset($_REQUEST['page']) ? absint( $_REQUEST['page'] ) : 1; ?>" />
     206    <?php wp_nonce_field( 'add-comment', '_ajax_nonce', false ); ?>
     207</form>
    235208
    236209<div id="ajax-response"></div>
     
    252225</div>
    253226
     227</div>
     228
    254229<?php include('admin-footer.php'); ?>
Note: See TracChangeset for help on using the changeset viewer.