View Single Post
Old 10-12-2010, 07:27 PM  
georgeyw
58008 53773
 
georgeyw's Avatar
 
Industry Role:
Join Date: Jul 2005
Location: Australia
Posts: 9,864
Got the shits with an install this morning so made a *basic* solution for it :

Creates menu tab called 'Delete' - > it will delete ALL of your UNAPPROVED comments with one click.

Any problems with it - suck my nuts

Copy the code here - create a php file called 'deletecomments.php' upload to plugin folder.

PHP Code:
<?php
/*
Plugin Name: Delete Comments
Plugin URI: [email protected]
Description: Deletes ALL comments from a wordpress install.
Version:  1.0
Author: Georgeyw
Author URI: [email protected]
License: GPL1
*/

/*  Copyright 2010  Georgeyw  (email : [email protected])

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License, version 2, as 
    published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

add_action('admin_menu''delete_comments_plugin_menu');

function 
delete_comments_plugin_menu() {
  
add_menu_page"Delete Comments""Delete"10"delete_comments_menu""delete_comments_main"'',20 );
}

function 
delete_comments_main() {

  if (!
current_user_can('manage_options'))  {
    
wp_die__('You do not have sufficient permissions to access this page.') );
  }
  if(
$_POST['delete_hidden'] == 'Y')
  {
    echo 
func_delete_comments();  
  }
  echo 
'<div class="wrap">';
  echo 
'<div id="icon-index" class="icon32"><br /></div><h2>Delete Wordpress Comments</h2>';
  echo 
'<p><strong>WARNING :</strong> Clicking on the button below will delete ALL comments from your Wordpress install.</p>';
  echo 
'<p><form method="post" action="'str_replace"%7E""~"$_SERVER["REQUEST_URI"]).'" >
<input type="submit" name="Delete" value="Delete">
<input type="hidden" name="delete_hidden" value="Y"> </form></p>'
;
  echo 
'</div>';

}

function 
func_delete_comments()
{
    global 
$wpdb;
    if(isset(
$_POST['Delete']))
    {
        
// delete unapproved comments from db
        
$wpdb->query("DELETE FROM wp_comments WHERE comment_approved = '0'");
        
$success '<div id="message" class="updated fade">Successfully <b>DELETED</b> ALL Comments.</b></div>';
    }
    return 
$success;
}
?>
georgeyw is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote