Make WordPress Core


Ignore:
Timestamp:
03/27/2007 09:20:16 PM (18 years ago)
Author:
ryan
Message:

Dynamically refill comment list when a comment is deleted. Props mdawaffe. fixes #4038

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-functions.php

    r5110 r5118  
    908908    $r .= "</td>\n\t</tr>";
    909909    return $r;
     910}
     911
     912function _wp_get_comment_list( $s = false, $start, $num ) {
     913    global $wpdb;
     914
     915    $start = (int) $start;
     916    $num = (int) $num;
     917
     918    if ( $s ) {
     919        $s = $wpdb->escape($s);
     920        $comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE
     921            (comment_author LIKE '%$s%' OR
     922            comment_author_email LIKE '%$s%' OR
     923            comment_author_url LIKE ('%$s%') OR
     924            comment_author_IP LIKE ('%$s%') OR
     925            comment_content LIKE ('%$s%') ) AND
     926            comment_approved != 'spam'
     927            ORDER BY comment_date DESC LIMIT $start, $num");
     928    } else {
     929        $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $start, $num" );
     930    }
     931
     932    $total = $wpdb->get_var( "SELECT FOUND_ROWS()" );
     933
     934    return array($comments, $total);
     935}
     936
     937function _wp_comment_list_item( $id, $alt = 0 ) {
     938    global $authordata, $comment, $wpdb;
     939    $id = (int) $id;
     940    $comment =& get_comment( $id );
     941    $class = '';
     942    $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
     943    $comment_status = wp_get_comment_status($comment->comment_ID);
     944    if ( 'unapproved' == $comment_status )
     945        $class .= ' unapproved';
     946    if ( $alt % 2 )
     947        $class .= ' alternate';
     948    echo "<li id='comment-$comment->comment_ID' class='$class'>";
     949?>
     950<p><strong><?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>
     951
     952<?php comment_text() ?>
     953
     954<p><?php comment_date(__('M j, g:i A'));  ?> &#8212; [
     955<?php
     956if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
     957    echo " <a href='comment.php?action=editcomment&amp;c=".$comment->comment_ID."'>" .  __('Edit') . '</a>';
     958    echo ' | <a href="' . wp_nonce_url('ocomment.php?action=deletecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> ';
     959    if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) {
     960        echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>';
     961        echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>';
     962    }
     963    echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&amp;dt=spam&amp;p=" . $comment->comment_post_ID . "&amp;c=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to mark as spam this comment by '%s'.\n'Cancel' to stop, 'OK' to mark as spam."), $comment->comment_author))  . "', theCommentList );\">" . __('Spam') . "</a> ";
     964}
     965$post = get_post($comment->comment_post_ID);
     966$post_title = wp_specialchars( $post->post_title, 'double' );
     967$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
     968?>
     969 ] &#8212; <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php echo $post_title; ?></a></p>
     970        </li>
     971<?php
    910972}
    911973
Note: See TracChangeset for help on using the changeset viewer.