mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-09 07:00:01 +00:00
Hook up bulk comment operations.
git-svn-id: http://svn.automattic.com/wordpress/trunk@6999 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b793e1846f
commit
cfb44d3d90
@ -6,32 +6,28 @@ $parent_file = 'edit-comments.php';
|
|||||||
wp_enqueue_script( 'admin-comments' );
|
wp_enqueue_script( 'admin-comments' );
|
||||||
wp_enqueue_script('admin-forms');
|
wp_enqueue_script('admin-forms');
|
||||||
|
|
||||||
if ( !empty( $_POST['delete_comments'] ) ) :
|
if ( !empty( $_REQUEST['delete_comments'] ) ) :
|
||||||
check_admin_referer('bulk-comments');
|
check_admin_referer('bulk-comments');
|
||||||
|
|
||||||
$i = 0;
|
$comments_deleted = $comments_approved = $comments_spammed = 0;
|
||||||
foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each
|
foreach ($_REQUEST['delete_comments'] as $comment) : // Check the permissions on each
|
||||||
$comment = (int) $comment;
|
$comment = (int) $comment;
|
||||||
$post_id = (int) $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
|
$post_id = (int) $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
|
||||||
// $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") );
|
// $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") );
|
||||||
if ( current_user_can('edit_post', $post_id) ) {
|
if ( !current_user_can('edit_post', $post_id) )
|
||||||
if ( !empty( $_POST['spam_button'] ) )
|
continue;
|
||||||
wp_set_comment_status($comment, 'spam');
|
if ( !empty( $_REQUEST['spamit'] ) ) {
|
||||||
else
|
wp_set_comment_status($comment, 'spam');
|
||||||
wp_set_comment_status($comment, 'delete');
|
$comments_spammed++;
|
||||||
++$i;
|
} elseif ( !empty( $_REQUEST['deleteit'] ) ) {
|
||||||
|
wp_set_comment_status($comment, 'delete');
|
||||||
|
$comments_deleted++;
|
||||||
|
} elseif ( !empty( $_REQUEST['approveit'] ) ) {
|
||||||
|
wp_set_comment_status($comment, 'approve');
|
||||||
|
$comments_approved++;
|
||||||
}
|
}
|
||||||
endforeach;
|
endforeach;
|
||||||
/*
|
wp_redirect( basename( __FILE__ ) . '?deleted=' . $comments_deleted . '&approved=' . $comments_approved . '&spam=' . $comments_spammed );
|
||||||
echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>';
|
|
||||||
if ( !empty( $_POST['spam_button'] ) ) {
|
|
||||||
printf(__ngettext('%s comment marked as spam.', '%s comments marked as spam.', $i), $i);
|
|
||||||
} else {
|
|
||||||
printf(__ngettext('%s comment deleted.', '%s comments deleted.', $i), $i);
|
|
||||||
}
|
|
||||||
echo '</p></div>';
|
|
||||||
*/
|
|
||||||
// TODO redirect with message
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
require_once('admin-header.php');
|
require_once('admin-header.php');
|
||||||
@ -67,6 +63,35 @@ unset($status_links);
|
|||||||
?>
|
?>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['spam'] ) ) {
|
||||||
|
$approved = isset( $_GET['approved'] ) ? (int) $_GET['approved'] : 0;
|
||||||
|
$deleted = isset( $_GET['deleted'] ) ? (int) $_GET['deleted'] : 0;
|
||||||
|
$spam = isset( $_GET['spam'] ) ? (int) $_GET['spam'] : 0;
|
||||||
|
|
||||||
|
if ( $approved > 0 || $deleted > 0 || $spam > 0 ) {
|
||||||
|
echo '<div id="moderated" class="updated fade"><p>';
|
||||||
|
|
||||||
|
if ( $approved > 0 ) {
|
||||||
|
printf( __ngettext( '%s comment approved', '%s comments approved', $approved ), $approved );
|
||||||
|
echo '<br />';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $deleted > 0 ) {
|
||||||
|
printf( __ngettext( '%s comment deleted', '%s comments deleted', $deleted ), $deleted );
|
||||||
|
echo '<br />';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $spam > 0 ) {
|
||||||
|
printf( __ngettext( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam );
|
||||||
|
echo '<br />';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</p></div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
<p id="post-search">
|
<p id="post-search">
|
||||||
<input type="text" id="post-search-input" name="s" value="<?php if (isset($_GET['s'])) echo attribute_escape($_GET['s']); ?>" />
|
<input type="text" id="post-search-input" name="s" value="<?php if (isset($_GET['s'])) echo attribute_escape($_GET['s']); ?>" />
|
||||||
<input type="submit" value="<?php _e( 'Search Comments' ); ?>" class="button" />
|
<input type="submit" value="<?php _e( 'Search Comments' ); ?>" class="button" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user