WordPress.org

Plugin Directory

Changeset 173296


Ignore:
Timestamp:
11/13/09 19:55:33 (4 years ago)
Author:
ruhanirabin
Message:

Added cleanup of POST META Table along with the revisions
Fixed some minor PHP tags

Location:
wp-optimize/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-optimize/trunk/readme.txt

    r104012 r173296  
    44Tags: comments, spam, optimize, database, revisions, users, security, posts 
    55Requires at least: 2.7 
    6 Tested up to: 2.7.1 
    7 Stable tag: 0.6.1 
     6Tested up to: 2.8.6 
     7Stable tag: 0.7.0 
    88 
    9 This plugin allows you to clean up your wordpress database and optimize it without phpMyAdmin. Also renames any username. 
     9This plugin allows you to clean up your wordpress database and optimize it without phpMyAdmin. Also renames any username.  
    1010 
    1111== Description == 
    1212 
    1313WP-Optimize is a wordpress 2.7++ database cleanup and optimization tool. It doesn't require PhpMyAdmin to optimize your database tables.  
    14 It allows you to remove post revisions, comments in the spam queue, un-approved comments within few clicks. Additionally you can rename any username to another username too. 
     14It allows you to remove post revisions, cleanup post meta data, comments in the spam queue, un-approved comments within few clicks.  
     15 
     16Additionally you can rename any username to another username too. 
     17 
     18Requires MySQL 5.1.x and PHP 5.3.x 
     19 
    1520 
    1621**Features:** 
    1722 
    18 *   Remove the wordpress post revisions 
     23*   Remove the wordpress post revisions including post meta data garbage 
    1924*   Remove all the comments in the spam queue 
    2025*   Remove all the un-approved comments 
     
    2328*   Display Database table statistics. Shows how much space can be optimzied and how much space has been cleared. 
    2429 
    25 **Changes:** 
    26 *   compatible with https sites now 
     30**Change Log: NOV - 14 - 2009 ** 
     31*   Added cleanup of POST META Table along with the revisions 
     32*   Fixed some minor PHP tags 
    2733 
    2834**How this could help you?** 
  • wp-optimize/trunk/wp-optimize-admin.php

    r104012 r173296  
    6262            $clean = "DELETE FROM $wpdb->posts WHERE post_type = 'revision'"; 
    6363            $revisions = $wpdb->query( $clean ); 
     64             
     65            $allposts = get_posts('numberposts=-1&orderby=ID&order=ASC&post_type=any&post_status='); 
     66            $allpost_ids = array(); 
     67            foreach ($allposts as $onepost) 
     68                $allpost_ids[$onepost->ID] = true; 
     69                $cleaned_ids = array(); 
     70                $total_cleaned_metas = 0; 
     71                $postmeta = $wpdb->get_results("SELECT * FROM $wpdb->postmeta", OBJECT); 
     72                    foreach ($postmeta as $meta) 
     73                        if (!isset($allpost_ids[$meta->post_id]) && !isset($cleaned_ids[$meta->post_id])) { 
     74                            $cleaned_metas = $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '".$meta->post_id."'"); 
     75                            $total_cleaned_metas += $cleaned_metas; 
     76                            $cleaned_ids[$meta->post_id] = true; 
     77                        } 
     78                         
    6479            $message .= $revisions.__(' post revisions deleted<br>', $textdomain); 
    6580            break; 
     81 
     82        //case "postmeta": 
     83 
     84        //  $message .= $total_cleaned_metas.__(' postmeta items from revisions and nonexistant posts deleted', $textdomain); 
     85        //    break; 
    6686 
    6787        case "spam": 
     
    183203    <td>&nbsp;</td> 
    184204  </tr> 
     205  <tr> 
     206    <td><h3><?php _e('Database Optimization Options',$textdomain); ?></h3></td> 
     207  </tr> 
    185208 
    186209  <tr> 
    187210    <td width="25%">&nbsp;</td> 
    188211    <td width="75%"><input name="clean-revisions" id="clean-revisions" type="checkbox" value="" /> 
    189      <?php _e('Remove all Post revisions', $textdomain); ?><br /> 
     212     <?php _e('Remove all Post revisions (Also cleanup Post meta data)', $textdomain); ?><br /> 
    190213   <small><?php _e(getInfo('revisions')); ?></small></td> 
    191214  </tr> 
     
    223246    <td>&nbsp;</td> 
    224247  </tr> 
     248   
     249  <tr> 
     250    <td><h3><?php _e('Security Tools',$textdomain); ?></h3></td> 
     251  </tr> 
     252 
    225253  <tr> 
    226254    <td><p align="right"><?php _e('Old username:', $textdomain); ?>&nbsp;</p></td> 
     
    277305?> 
    278306 
    279 <h3><?php echo __('Database Tables Report',$textdomain); ?></h3> 
    280 <h3><?php echo __('Database Name:',$textdomain); ?> '<?php _e(DB_NAME);?>'</h3> 
     307<h3><?php _e('Database Tables Report',$textdomain); ?></h3> 
     308<h3><?php _e('Database Name:',$textdomain); ?> '<?php _e(DB_NAME);?>'</h3> 
    281309<?php if($Optimize){ 
    282310    ?> 
    283311 
    284 <p><?php echo __('Optimized all the tables found in the database.',$textdomain)?></p> 
     312<p><?php _e('Optimized all the tables found in the database.',$textdomain)?></p> 
    285313<?php } ?> 
    286314 
     
    290318<thead> 
    291319    <tr> 
    292     <th scope="col"><?php echo __('Table',$textdomain); ?></th> 
    293     <th scope="col"><?php echo __('Size',$textdomain)?></th> 
    294     <th scope="col"><?php echo __('Status',$textdomain); ?></th> 
    295     <th scope="col"><?php echo __('Space Save',$textdomain); ?></th> 
     320    <th scope="col"><?php _e('Table',$textdomain); ?></th> 
     321    <th scope="col"><?php _e('Size',$textdomain)?></th> 
     322    <th scope="col"><?php _e('Status',$textdomain); ?></th> 
     323    <th scope="col"><?php _e('Space Save',$textdomain); ?></th> 
    296324    </tr> 
    297325</thead> 
    298326<tfoot> 
    299327    <tr> 
    300     <th scope="col"><?php echo __('Table',$textdomain); ?></th> 
    301     <th scope="col"><?php echo __('Size',$textdomain)?></th> 
    302     <th scope="col"><?php echo __('Status',$textdomain); ?></th> 
    303     <th scope="col"><?php echo __('Space Save',$textdomain); ?></th> 
     328    <th scope="col"><?php _e('Table',$textdomain); ?></th> 
     329    <th scope="col"><?php _e('Size',$textdomain)?></th> 
     330    <th scope="col"><?php _e('Status',$textdomain); ?></th> 
     331    <th scope="col"><?php _e('Space Save',$textdomain); ?></th> 
    304332    </tr> 
    305333</tfoot> 
     
    367395    ?> 
    368396 
    369 <?php $total_gain = round ($total_gain,3); ?> 
    370 <h3><?php echo __('Optimization Results:',$textdomain); ?></h3> 
    371 <p style="color: #0000FF;"><?php echo __('Total Space Saved:',$textdomain); ?> <?=$total_gain?> Kb</p> 
     397<?php $total_gain = round ($total_gain,3);?> 
     398 
     399<h3><?php _e('Optimization Results:',$textdomain); ?></h3> 
     400<p style="color: #0000FF;"><?php _e('Total Space Saved:',$textdomain); ?> <?php echo $total_gain?> Kb</p> 
    372401  <?php } else { ?> 
    373402<?php $total_gain = round ($total_gain,3); ?> 
    374403  <?php if(!$total_gain==0){ ?> 
    375404 
    376 <h3><?php echo __('Optimization:',$textdomain); ?></h3> 
    377 <p style="color: #FF0000;"><?php echo __('Total space can be saved:',$textdomain); ?> <?=$total_gain?> Kb</p> 
     405<h3><?php _e('Optimization Possibility:',$textdomain); ?></h3> 
     406<p style="color: #FF0000;"><?php _e('Total space can be saved:',$textdomain); ?> <?php echo $total_gain?> Kb</p> 
    378407  <?php } ?> 
    379408<?php 
Note: See TracChangeset for help on using the changeset viewer.