WordPress.org

Make WordPress Core


Ignore:
File:
1 edited

Legend:

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

    r4267 r3422  
    44$title = __('Edit Comments');
    55$parent_file = 'edit.php';
    6 wp_enqueue_script( 'admin-comments' );
     6$list_js = true;
    77
    88require_once('admin-header.php');
     
    2424    }
    2525}
    26 
    27 function 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 }
    3826//-->
    3927</script>
    4028<div class="wrap">
    4129<h2><?php _e('Comments'); ?></h2>
    42 <form name="searchform" action="" method="get" id="editcomments">
     30<form name="searchform" action="" method="get">
    4331  <fieldset>
    4432  <legend><?php _e('Show Comments That Contain...') ?></legend>
     
    4634  <input type="submit" name="submit" value="<?php _e('Search') ?>"  /> 
    4735  <input type="hidden" name="mode" value="<?php echo $mode; ?>" />
    48   <?php _e('(Searches within comment text, e-mail, URL, and IP address.)') ?>
     36  <?php _e('(Searches within comment text, e-mail, URI, and IP address.)') ?>
    4937  </fieldset>
    5038</form>
     
    5240<?php
    5341if ( !empty( $_POST['delete_comments'] ) ) :
    54     check_admin_referer('bulk-comments');
    55 
    5642    $i = 0;
    5743    foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each
    5844        $comment = (int) $comment;
    5945        $post_id = $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
    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');
     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");
    6649            ++$i;
    67         }
     50        endif;
    6851    endforeach;
    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>';
     52    echo "<div class='wrap'><p>" . sprintf(__('%s comments deleted.'), $i) . "</p></div>";
    7553endif;
    7654
     
    10078            $start = '';
    10179
    102         echo "<ol id='the-comment-list' class='commentlist' $start>";
     80        echo "<ol id='the-list' class='commentlist' $start>";
    10381        $i = 0;
    10482        foreach ($comments as $comment) {
     
    11189                $class .= ' alternate';
    11290            echo "<li id='comment-$comment->comment_ID' class='$class'>";
    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>
     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() ?>
    11595
    116 <?php comment_text() ?>
    117 
    118 <p><?php comment_date('M j, g:i A');  ?> &#8212; [
    119 <?php
    120 if ( 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>
     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>
    134108        </li>
    135109
    136 <?php } // end foreach($comment) ?>
     110<?php } // end foreach ?>
    137111</ol>
    138112
     
    140114
    141115<?php
    142     } else { //no comments to show
     116    } else {
    143117
    144118        ?>
    145119        <p>
    146120        <strong><?php _e('No comments found.') ?></strong></p>
    147 
     121       
    148122        <?php
    149123    } // end if ($comments)
     
    151125
    152126    if ($comments) {
    153         echo '<form name="deletecomments" id="deletecomments" action="" method="post"> ';
    154         wp_nonce_field('bulk-comments');
    155         echo '<table class="widefat">
    156 <thead>
     127        echo '<form name="deletecomments" id="deletecomments" action="" method="post">
     128        <table width="100%" cellpadding="3" cellspacing="3">
    157129  <tr>
    158     <th scope="col" style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById(\'deletecomments\'));" /></th>
     130    <th scope="col">*</th>
    159131    <th scope="col">' .  __('Name') . '</th>
    160132    <th scope="col">' .  __('E-mail') . '</th>
    161133    <th scope="col">' . __('IP') . '</th>
    162134    <th scope="col">' . __('Comment Excerpt') . '</th>
    163     <th scope="col" colspan="3" style="text-align: center">' .  __('Actions') . '</th>
    164   </tr>
    165 </thead>';
     135    <th scope="col" colspan="3">' .  __('Actions') . '</th>
     136  </tr>';
    166137        foreach ($comments as $comment) {
    167138        $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);
    169139        $class = ('alternate' == $class) ? '' : 'alternate';
    170         $class .= ('unapproved' == $comment_status) ? ' unapproved' : '';
    171140?>
    172   <tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $class; ?>'>
     141  <tr class='<?php echo $class; ?>'>
    173142    <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>
    174143    <td><?php comment_author_link() ?></td>
     
    176145    <td><a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></td>
    177146    <td><?php comment_excerpt(); ?></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>
     147    <td><a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit"><?php _e('View') ?></a></td>
    185148    <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
    186     echo "<a href='comment.php?action=editcomment&amp;comment=$comment->comment_ID' class='edit'>" .  __('Edit') . "</a>"; } ?></td>
     149    echo "<a href='post.php?action=editcomment&amp;comment=$comment->comment_ID' class='edit'>" .  __('Edit') . "</a>"; } ?></td>
    187150    <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
    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>
     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>
    190152  </tr>
    191153        <?php
    192154        } // end foreach
    193155    ?></table>
    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>
     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>
    196158  </form>
    197 <div id="ajax-response"></div>
    198159<?php
    199160    } else {
Note: See TracChangeset for help on using the changeset viewer.