Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-comments.php

    r3422 r4267  
    44$title = __('Edit Comments');
    55$parent_file = 'edit.php';
    6 $list_js = true;
     6wp_enqueue_script( 'admin-comments' );
    77
    88require_once('admin-header.php');
     
    2424    }
    2525}
     26
     27function getNumChecked(form)
     28{
     29    var num = 0;
     30    for (i = 0, n = form.elements.length; i < n; i++) {
     31        if(form.elements[i].type == "checkbox") {
     32            if(form.elements[i].checked == true)
     33                num++;
     34        }
     35    }
     36    return num;
     37}
    2638//-->
    2739</script>
    2840<div class="wrap">
    2941<h2><?php _e('Comments'); ?></h2>
    30 <form name="searchform" action="" method="get">
     42<form name="searchform" action="" method="get" id="editcomments">
    3143  <fieldset>
    3244  <legend><?php _e('Show Comments That Contain...') ?></legend>
     
    3446  <input type="submit" name="submit" value="<?php _e('Search') ?>"  /> 
    3547  <input type="hidden" name="mode" value="<?php echo $mode; ?>" />
    36   <?php _e('(Searches within comment text, e-mail, URI, and IP address.)') ?>
     48  <?php _e('(Searches within comment text, e-mail, URL, and IP address.)') ?>
    3749  </fieldset>
    3850</form>
     
    4052<?php
    4153if ( !empty( $_POST['delete_comments'] ) ) :
     54    check_admin_referer('bulk-comments');
     55
    4256    $i = 0;
    4357    foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each
    4458        $comment = (int) $comment;
    4559        $post_id = $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
    46         $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") );
    47         if ( current_user_can('edit_post', $post_id) ) :
    48             wp_set_comment_status($comment, "delete");
     60        // $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") );
     61        if ( current_user_can('edit_post', $post_id) ) {
     62            if ( !empty( $_POST['spam_button'] ) )
     63                wp_set_comment_status($comment, 'spam');
     64            else
     65                wp_set_comment_status($comment, 'delete');
    4966            ++$i;
    50         endif;
     67        }
    5168    endforeach;
    52     echo "<div class='wrap'><p>" . sprintf(__('%s comments deleted.'), $i) . "</p></div>";
     69    echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>';
     70    if ( !empty( $_POST['spam_button'] ) )
     71        printf(__('%s comments marked as spam.'), $i);
     72    else
     73        printf(__('%s comments deleted.'), $i);
     74    echo '</p></div>';
    5375endif;
    5476
     
    78100            $start = '';
    79101
    80         echo "<ol id='the-list' class='commentlist' $start>";
     102        echo "<ol id='the-comment-list' class='commentlist' $start>";
    81103        $i = 0;
    82104        foreach ($comments as $comment) {
     
    89111                $class .= ' alternate';
    90112            echo "<li id='comment-$comment->comment_ID' class='$class'>";
    91 ?>     
    92         <p><strong><?php _e('Name:') ?></strong> <?php comment_author() ?> <?php if ($comment->comment_author_email) { ?>| <strong><?php _e('E-mail:') ?></strong> <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url ) { ?> | <strong><?php _e('URI:') ?></strong> <?php comment_author_url_link() ?> <?php } ?>| <strong><?php _e('IP:') ?></strong> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
    93        
    94         <?php comment_text() ?>
    95 
    96         <p><?php _e('Posted'); echo ' '; comment_date('M j, g:i A'); 
    97             if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
    98                 echo " | <a href=\"post.php?action=editcomment&amp;comment=".$comment->comment_ID."\">" . __('Edit Comment') . "</a>";
    99                 echo " | <a href=\"post.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), wp_specialchars( $comment->comment_author, 1 ))  . "' );\">" . __('Delete Comment') . "</a> &#8212; ";
    100             } // end if any comments to show
    101             // Get post title
    102             if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
    103                 $post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID = $comment->comment_post_ID");
    104                 $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
    105                 ?> <a href="post.php?action=edit&amp;post=<?php echo $comment->comment_post_ID; ?>"><?php printf(__('Edit Post &#8220;%s&#8221;'), stripslashes($post_title)); ?></a>
    106                 <?php } ?>
    107              | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php _e('View Post') ?></a></p>
     113?>
     114<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>
     115
     116<?php comment_text() ?>
     117
     118<p><?php comment_date('M j, g:i A');  ?> &#8212; [
     119<?php
     120if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
     121    echo " <a href='comment.php?action=editcomment&amp;comment=".$comment->comment_ID."'>" .  __('Edit') . '</a>';
     122    echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&amp;p=' . $comment->comment_post_ID . '&amp;comment=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), js_escape($comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> ';
     123    if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) {
     124        echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&amp;p=' . $comment->comment_post_ID . '&amp;comment=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>';
     125        echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&amp;p=' . $comment->comment_post_ID . '&amp;comment=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>';
     126    }
     127    echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&amp;delete_type=spam&amp;p=" . $comment->comment_post_ID . "&amp;comment=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . sprintf(__("You are about to mark as spam this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to mark as spam."), js_escape( $comment->comment_author))  . "', theCommentList );\">" . __('Spam') . "</a> ";
     128}
     129$post = get_post($comment->comment_post_ID);
     130$post_title = wp_specialchars( $post->post_title, 'double' );
     131$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
     132?>
     133 | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ]</p>
    108134        </li>
    109135
    110 <?php } // end foreach ?>
     136<?php } // end foreach($comment) ?>
    111137</ol>
    112138
     
    114140
    115141<?php
    116     } else {
     142    } else { //no comments to show
    117143
    118144        ?>
    119145        <p>
    120146        <strong><?php _e('No comments found.') ?></strong></p>
    121        
     147
    122148        <?php
    123149    } // end if ($comments)
     
    125151
    126152    if ($comments) {
    127         echo '<form name="deletecomments" id="deletecomments" action="" method="post">
    128         <table width="100%" cellpadding="3" cellspacing="3">
     153        echo '<form name="deletecomments" id="deletecomments" action="" method="post"> ';
     154        wp_nonce_field('bulk-comments');
     155        echo '<table class="widefat">
     156<thead>
    129157  <tr>
    130     <th scope="col">*</th>
     158    <th scope="col" style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById(\'deletecomments\'));" /></th>
    131159    <th scope="col">' .  __('Name') . '</th>
    132160    <th scope="col">' .  __('E-mail') . '</th>
    133161    <th scope="col">' . __('IP') . '</th>
    134162    <th scope="col">' . __('Comment Excerpt') . '</th>
    135     <th scope="col" colspan="3">' .  __('Actions') . '</th>
    136   </tr>';
     163    <th scope="col" colspan="3" style="text-align: center">' .  __('Actions') . '</th>
     164  </tr>
     165</thead>';
    137166        foreach ($comments as $comment) {
    138167        $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
     168        $comment_status = wp_get_comment_status($comment->comment_ID);
    139169        $class = ('alternate' == $class) ? '' : 'alternate';
    140 ?>
    141   <tr class='<?php echo $class; ?>'>
     170        $class .= ('unapproved' == $comment_status) ? ' unapproved' : '';
     171?>
     172  <tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $class; ?>'>
    142173    <td><?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>
    143174    <td><?php comment_author_link() ?></td>
     
    145176    <td><a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></td>
    146177    <td><?php comment_excerpt(); ?></td>
    147     <td><a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit"><?php _e('View') ?></a></td>
     178    <td>
     179        <?php if ('unapproved' == $comment_status) { ?>
     180            (Unapproved)
     181        <?php } else { ?>
     182            <a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit"><?php _e('View') ?></a>
     183        <?php } ?>
     184    </td>
    148185    <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
    149     echo "<a href='post.php?action=editcomment&amp;comment=$comment->comment_ID' class='edit'>" .  __('Edit') . "</a>"; } ?></td>
     186    echo "<a href='comment.php?action=editcomment&amp;comment=$comment->comment_ID' class='edit'>" .  __('Edit') . "</a>"; } ?></td>
    150187    <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
    151             echo "<a href=\"post.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \'%s\'\\n  \'Cancel\' to stop, \'OK\' to delete."), $comment->comment_author) . "')\"    class='delete'>" . __('Delete') . "</a>"; } ?></td>
     188        echo "<a href=\"comment.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), js_escape( $comment->comment_author ))  . "', theCommentList );\" class='delete'>" . __('Delete') . "</a> ";
     189        } ?></td>
    152190  </tr>
    153191        <?php
    154192        } // end foreach
    155193    ?></table>
    156     <p><a href="javascript:;" onclick="checkAll(document.getElementById('deletecomments')); return false; "><?php _e('Invert Checkbox Selection') ?></a></p>
    157             <p class="submit"><input type="submit" name="Submit" value="<?php _e('Delete Checked Comments') ?> &raquo;" onclick="return confirm('<?php _e("You are about to delete these comments permanently \\n  \'Cancel\' to stop, \'OK\' to delete.") ?>')" /> </p>
     194<p class="submit"><input type="submit" name="delete_button" class="delete" value="<?php _e('Delete Checked Comments &raquo;') ?>" onclick="var numchecked = getNumChecked(document.getElementById('deletecomments')); if(numchecked < 1) { alert('<?php _e("Please select some comments to delete"); ?>'); return false } return confirm('<?php printf(__("You are about to delete %s comments permanently \\n  \'Cancel\' to stop, \'OK\' to delete."), "' + numchecked + '"); ?>')" />
     195            <input type="submit" name="spam_button" value="<?php _e('Mark Checked Comments as Spam &raquo;') ?>" onclick="return confirm('<?php _e("You are about to mark these comments as spam \\n  \'Cancel\' to stop, \'OK\' to mark as spam.") ?>')" /></p>
    158196  </form>
     197<div id="ajax-response"></div>
    159198<?php
    160199    } else {
Note: See TracChangeset for help on using the changeset viewer.