Delete Pending Comments - Version 0.2.0

Version Description

  • Manipulate the database directly. Using WordPress functions was way too slow with 10k or more pending comments.
Download this release

Release Info

Developer nkuttler
Plugin Icon wp plugin Delete Pending Comments
Version 0.2.0
Comparing to
See all releases

Code changes from version 0.1.1.1 to 0.2.0

Files changed (2) hide show
  1. inc/admin.php +12 -1
  2. readme.txt +3 -1
inc/admin.php CHANGED
@@ -55,13 +55,24 @@ function nkdeletepending_options_page() {
55
  $nonce = $_REQUEST['_wpnonce'];
56
  if ( !wp_verify_nonce( $nonce, 'delete-pending-comments' ) ) die( 'Security check' );
57
 
58
- $comments = get_comments( 'status=hold' );
 
 
59
 
60
  if ( $comments ) {
61
  if ( stripslashes( $_POST['nkdeletepending'] ) == $magic_string ) {
 
 
 
62
  foreach ( $comments as $comment ) {
63
  wp_delete_comment( $comment->comment_ID );
64
  }
 
 
 
 
 
 
65
  echo '<div class="updated">';
66
  _e( 'I deleted all pending comments!', 'delete-pending-comments' );
67
  echo '</div>';
55
  $nonce = $_REQUEST['_wpnonce'];
56
  if ( !wp_verify_nonce( $nonce, 'delete-pending-comments' ) ) die( 'Security check' );
57
 
58
+ // Limit. Timeout with 10k comments...
59
+ // We only need this to see if there are any pending anyway
60
+ $comments = get_comments( 'status=hold&number=1' );
61
 
62
  if ( $comments ) {
63
  if ( stripslashes( $_POST['nkdeletepending'] ) == $magic_string ) {
64
+
65
+ /* This was waaaay to slow with 10k+ comments
66
+ /*
67
  foreach ( $comments as $comment ) {
68
  wp_delete_comment( $comment->comment_ID );
69
  }
70
+ */
71
+ global $wpdb;
72
+ $wpdb->query(
73
+ $wpdb->prepare( "DELETE FROM $wpdb->comments WHERE comment_approved = 0" )
74
+ );
75
+
76
  echo '<div class="updated">';
77
  _e( 'I deleted all pending comments!', 'delete-pending-comments' );
78
  echo '</div>';
readme.txt CHANGED
@@ -6,7 +6,7 @@ Donate link: http://www.amazon.de/gp/registry/24F64AHKD51LY
6
  Tags: admin, plugin, comments, spam, pending, delete, delete comments, mass delete, mass delete comments
7
  Requires at least: 2.7
8
  Tested up to: 2.9-rare
9
- Stable tag: 0.1.1.1
10
 
11
  A quick way to delete all pending comments. Useful for victims of spammer attacks.
12
 
@@ -55,6 +55,8 @@ A: The plugin page is located under the top level menu entry "Comments". Copy an
55
  </p>
56
 
57
  == Changelog ==
 
 
58
  = 0.1.1.1 =
59
  * Fix version number...
60
  = 0.1.1 =
6
  Tags: admin, plugin, comments, spam, pending, delete, delete comments, mass delete, mass delete comments
7
  Requires at least: 2.7
8
  Tested up to: 2.9-rare
9
+ Stable tag: 0.2.0
10
 
11
  A quick way to delete all pending comments. Useful for victims of spammer attacks.
12
 
55
  </p>
56
 
57
  == Changelog ==
58
+ = 0.2.0 =
59
+ * Manipulate the database directly. Using WordPress functions was way too slow with 10k or more pending comments.
60
  = 0.1.1.1 =
61
  * Fix version number...
62
  = 0.1.1 =