Plugin Directory

Changeset 579704


Ignore:
Timestamp:
07/31/2012 11:46:08 AM (14 years ago)
Author:
mwaelk
Message:

1.1 some code cleaning and added French language translation

Location:
kt-cleanpress/trunk
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • kt-cleanpress/trunk/includes/css/ktclean.css

    r572415 r579704  
    1919.ktcleanpressright{
    2020    margin:10px 0px 10px 25px;
    21     width: 550px;
     21    width: 500px;
    2222    height:450px;
    2323    float: left;
     
    2727.ktcleanpressleft{
    2828    margin:10px 0px 0px 10px;
    29     width:350px;
     29    width:450px;
    3030    height:450px;
    3131    float: left;
  • kt-cleanpress/trunk/includes/kt-initdisplay.php

    r572415 r579704  
    6868            case 'clean-trash':
    6969            case 'clean-pending':
    70                 if(!array_key_exists('post_options', $ktqueryarr))
    71                     $ktqueryarr['post_options'] = "('" . $value . "'";
     70                if(!isset($ktqueryarr['post']))
     71                    $ktqueryarr['post'] = "('" . $value . "'";
    7272                else
    73                     $ktqueryarr['post_options'] .= ",'" . $value . "'";
     73                    $ktqueryarr['post'] .= ",'" . $value . "'";
    7474                break;
    7575            case 'cleanp-draft':
    7676            case 'cleanp-trash':
    7777            case 'cleanp-pending':
    78                 if(!array_key_exists('pages_options', $ktqueryarr))
    79                     $ktqueryarr['pages_options'] = "('" . $value . "'";
     78                if(!isset($ktqueryarr['page']))
     79                    $ktqueryarr['page'] = "('" . $value . "'";
    8080                else
    81                     $ktqueryarr['pages_options'] .= ",'" .$value . "'";
     81                    $ktqueryarr['page'] .= ",'" .$value . "'";
    8282                break;
    8383            case 'clean-spam':
    8484            case 'clean-unaproved':
    8585            case 'clean-trashcomment':
    86                 if(!array_key_exists('comment_options', $ktqueryarr))
     86                if(!isset($ktqueryarr['comment_options']))
    8787                    $ktqueryarr['comment_options'] = "('" . $value . "'";
    8888                else
     
    138138    global $wpdb;
    139139    $ktextime = microtime(true);
    140     $ktsize['originalsize'] = (int) $wpdb->get_var("SELECT SUM(DATA_LENGTH) + SUM(INDEX_LENGTH) FROM information_schema.TABLES WHERE TABLE_SCHEMA = '" . constant("DB_NAME") . "' GROUP BY TABLE_SCHEMA;");
    141140    $ktterms =  array('clean-emptyc' => 'category' ,'clean-emptyt' => 'post_tag',
    142141            'clean-draft' => 'draft' , 'clean-trash' => 'trash' , 'clean-pending' => 'pending',
     
    157156        }
    158157    }
    159 
     158    if (!empty($ktterms)){
     159    $ktsize['originalsize'] = (int) $wpdb->get_var("SELECT SUM(DATA_LENGTH) + SUM(INDEX_LENGTH) FROM information_schema.TABLES WHERE TABLE_SCHEMA = '" . constant("DB_NAME") . "' GROUP BY TABLE_SCHEMA;");
    160160    $ktqueryarr = kt_crquery_arr($ktterms);
    161161    foreach ($ktqueryarr as $key => $value) {
    162162        switch ($key){
    163             case 'pages_options':
    164                 $wpdb->query("DELETE t1 FROM $wpdb->posts AS t1, $wpdb->posts AS t2 WHERE t1.post_parent = t2.id AND t2.post_type = 'page' AND t2.post_status IN $value ) AND t1.post_type='revision';");
    165                 $wpdb->query("UPDATE $wpdb->posts As t1, $wpdb->posts AS t2 set t1.post_parent = 0 WHERE t1.post_parent = t2.id AND t2.post_type = 'page' AND t2.post_status IN $value );");
    166                 $wpdb->query("DELETE t1 FROM $wpdb->commentmeta AS t1 , $wpdb->comments AS t2 WHERE t1.comment_id = t2.comment_id AND t2.comment_post_id IN (SELECT id FROM $wpdb->posts where post_status IN $value ) AND post_type = 'page');");
    167                 $wpdb->query("DELETE FROM t1 USING $wpdb->comments AS t1 , $wpdb->posts AS t2 WHERE t1.comment_post_id = t2.id AND t2.post_type = 'page' AND t2.post_status IN $value );");
    168                 $wpdb->query("DELETE FROM t1 USING $wpdb->postmeta AS t1 , $wpdb->posts AS t2 WHERE t1.post_id = t2.id AND t2.post_type = 'page' AND t2.post_status IN $value );");
    169                 $wpdb->query("DELETE FROM $wpdb->posts WHERE post_type = 'page' AND post_status IN $value ) ;");
    170                 break;
    171                
    172             case 'post_options':
    173                 $wpdb->query("DELETE t1 FROM $wpdb->posts AS t1, $wpdb->posts AS t2 WHERE t1.post_parent = t2.id AND t2.post_type = 'post' AND t2.post_status IN $value ) AND t1.post_type='revision';");
    174                 $wpdb->query("UPDATE $wpdb->posts As t1, $wpdb->posts AS t2 set t1.post_parent = 0 WHERE t1.post_parent = t2.id AND t2.post_type = 'post' AND t2.post_status IN $value );");
    175                 $wpdb->query("DELETE FROM t1 USING $wpdb->postmeta AS t1 , $wpdb->posts AS t2 WHERE t1.post_id = t2.id AND t2.post_type = 'post' AND t2.post_status IN $value );");
    176                 $wpdb->query("DELETE t1 FROM $wpdb->commentmeta AS t1 , $wpdb->comments AS t2 WHERE t1.comment_id = t2.comment_id AND t2.comment_post_id IN (SELECT id FROM $wpdb->posts where post_status IN $value ) AND post_type = 'post');");
    177                 $wpdb->query("DELETE FROM t1 USING $wpdb->comments AS t1 , $wpdb->posts AS t2 WHERE t1.comment_post_id = t2.id AND t2.post_type = 'post' AND t2.post_status IN $value );");
    178                 $wpdb->query("DELETE t1 FROM $wpdb->term_relationships AS t1 , $wpdb->term_taxonomy AS t2 WHERE t1.term_taxonomy_id = t2.term_taxonomy_id AND t2.taxonomy IN ('category','post_tag') AND t1.object_id IN (SELECT id FROM $wpdb->posts where post_status IN $value ) AND post_type = 'post');");
    179                 $wpdb->query("DELETE FROM $wpdb->posts WHERE post_type = 'post' AND post_status IN $value ) ;");
    180                 break;
     163            case 'page':
     164            case 'post':
     165                $wpdb->query("DELETE t1 FROM $wpdb->posts AS t1, $wpdb->posts AS t2 WHERE t1.post_parent = t2.id AND t2.post_type = '$key' AND t2.post_status IN $value ) AND t1.post_type='revision';");
     166                $wpdb->query("UPDATE $wpdb->posts As t1, $wpdb->posts AS t2 set t1.post_parent = 0 WHERE t1.post_parent = t2.id AND t2.post_type = '$key' AND t2.post_status IN $value );");
     167                $wpdb->query("DELETE t1 FROM $wpdb->commentmeta AS t1 , $wpdb->comments AS t2 WHERE t1.comment_id = t2.comment_id AND t2.comment_post_id IN (SELECT id FROM $wpdb->posts where post_status IN $value ) AND post_type = '$key');");
     168                $wpdb->query("DELETE FROM t1 USING $wpdb->comments AS t1 , $wpdb->posts AS t2 WHERE t1.comment_post_id = t2.id AND t2.post_type = '$key' AND t2.post_status IN $value );");
     169                $wpdb->query("DELETE FROM t1 USING $wpdb->postmeta AS t1 , $wpdb->posts AS t2 WHERE t1.post_id = t2.id AND t2.post_type = '$key' AND t2.post_status IN $value );");
     170                if($key == 'post')
     171                    $wpdb->query("DELETE t1 FROM $wpdb->term_relationships AS t1 , $wpdb->term_taxonomy AS t2 WHERE t1.term_taxonomy_id = t2.term_taxonomy_id AND t2.taxonomy IN ('category','post_tag') AND t1.object_id IN (SELECT id FROM $wpdb->posts where post_status IN $value ) AND post_type = '$key');");
     172                $wpdb->query("DELETE FROM $wpdb->posts WHERE post_type = '$key' AND post_status IN $value ) ;");
     173                break;
     174               
    181175               
    182176            case 'comment_options':
     
    214208        }
    215209    }
     210    if (isset($ktterms['clean-optimize']))
     211        kt_optimize($kttables);
     212    else
     213        kt_optimize(kt_croptdb_arr($ktterms));
     214    $ktsize['finalsize'] = (int) $wpdb->get_var("SELECT SUM(DATA_LENGTH) + SUM(INDEX_LENGTH) FROM information_schema.TABLES WHERE TABLE_SCHEMA = '" . constant("DB_NAME") . "' GROUP BY TABLE_SCHEMA;");
     215    $ktsize['difference'] = $ktsize['originalsize'] - $ktsize['finalsize'];
     216    foreach ($ktsize as $key => $value)
     217            $ktsize[$key] = kt_format_bytes($value);
     218    }
    216219   
    217 
    218     if (empty($ktterms)) {
     220    else
    219221        $ktsize['empty']='empty';
    220     }
    221     else{
    222         if (isset($ktterms['clean-optimize']))
    223             kt_optimize($kttables);
    224         else
    225             kt_optimize(kt_croptdb_arr($ktterms));
    226     }
    227    
    228 $ktsize['finalsize'] = (int) $wpdb->get_var("SELECT SUM(DATA_LENGTH) + SUM(INDEX_LENGTH) FROM information_schema.TABLES WHERE TABLE_SCHEMA = '" . constant("DB_NAME") . "' GROUP BY TABLE_SCHEMA;");
    229 $ktsize['difference'] = $ktsize['originalsize'] - $ktsize['finalsize'];
    230 
    231 foreach ($ktsize as $key => $value) {
    232     if($key != 'empty')
    233         $ktsize[$key] = kt_format_bytes($value);
    234 }
    235222
    236223$ktextime -= microtime(true);
  • kt-cleanpress/trunk/includes/kt-left-display-options.php

    r572415 r579704  
    55<script type="text/javascript">
    66function ktselectall(formid) {
    7     for (i=0;i<formid.elements.length;i++)
    8     if (formid.elements[i].className == 'ktcheckbox') {
     7    var i = 0;
     8    for (i;i<formid.elements.length;i++)
     9    if (formid.elements[i].type == 'checkbox') {
    910        formid.elements[i].checked = 'checked';
    1011    }
     
    3435                <legend><?php _e( 'Posts Cleaning options' , 'kt-cleanpress' )?></legend>
    3536                <label for="clean-draft"><?php _e('Clean Draft Posts' , 'kt-cleanpress')?></label>
    36                 <input type="checkbox" id="clean-draft" name="clean-draft" class="ktcheckbox">
     37                <input type="checkbox" id="clean-draft" name="clean-draft" >
    3738                <label for="clean-pending"><?php _e('Clean Pending Posts' , 'kt-cleanpress')?></label>
    38                 <input type="checkbox" id="clean-pending" name="clean-pending" class="ktcheckbox">
     39                <input type="checkbox" id="clean-pending" name="clean-pending" >
    3940                <label for="clean-trash"><?php _e('Clean Trash Posts' , 'kt-cleanpress')?></label>
    40                 <input type="checkbox" id="clean-trash" name="clean-trash" class="ktcheckbox">
     41                <input type="checkbox" id="clean-trash" name="clean-trash" >
    4142            </fieldset>
    4243                <fieldset>
    4344                <legend><?php _e( 'Pages Cleaning options' , 'kt-cleanpress' )?></legend>
    4445                <label for="cleanp-draft"><?php _e('Clean Draft Pages' , 'kt-cleanpress')?></label>
    45                 <input type="checkbox" id="cleanp-draft" name="cleanp-draft" class="ktcheckbox">
     46                <input type="checkbox" id="cleanp-draft" name="cleanp-draft" >
    4647                <label for="cleanp-pending"><?php _e('Clean Pending Pages' , 'kt-cleanpress')?></label>
    47                 <input type="checkbox" id="cleanp-pending" name="cleanp-pending" class="ktcheckbox">
     48                <input type="checkbox" id="cleanp-pending" name="cleanp-pending" >
    4849                <label for="cleanp-trash"><?php _e('Clean Trash Pages' , 'kt-cleanpress')?></label>
    49                 <input type="checkbox" id="cleanp-trash" name="cleanp-trash" class="ktcheckbox">
     50                <input type="checkbox" id="cleanp-trash" name="cleanp-trash" >
    5051            </fieldset>
    5152            <fieldset>
    5253                <legend><?php _e( 'Comments Cleaning options' , 'kt-cleanpress' )?></legend>
    5354                <label for="clean-spam"><?php _e('Clean Spam Comments' , 'kt-cleanpress')?></label>
    54                 <input type="checkbox" id="clean-spam" name="clean-spam" class="ktcheckbox">       
     55                <input type="checkbox" id="clean-spam" name="clean-spam" >     
    5556                <label for="clean-unaproved"><?php _e('Clean Unapproved  Comments' , 'kt-cleanpress')?></label>
    56                 <input type="checkbox" id="clean-unaproved" name="clean-unaproved" class="ktcheckbox"
     57                <input type="checkbox" id="clean-unaproved" name="clean-unaproved" >   
    5758                <label for="clean-trashcomment"><?php _e('Clean Trash  Comments' , 'kt-cleanpress')?></label>
    58                 <input type="checkbox" id="clean-trashcomment" name="clean-trashcomment" class="ktcheckbox">                       
     59                <input type="checkbox" id="clean-trashcomment" name="clean-trashcomment" >                     
    5960            </fieldset>
    6061            <fieldset>
    6162                <legend><?php _e( 'Other Cleaning options' , 'kt-cleanpress' )?></legend>
    6263                <label for="clean-revision"><?php _e('Clean Post Revisions' , 'kt-cleanpress')?></label>
    63                 <input type="checkbox" id="clean-revision" name="clean-revision" class="ktcheckbox">
     64                <input type="checkbox" id="clean-revision" name="clean-revision" >
    6465                <label for="clean-autodraft"><?php _e('Clean Auto Draft' , 'kt-cleanpress')?></label>
    65                 <input type="checkbox" id="clean-autodraft" name="clean-autodraft" class="ktcheckbox">     
     66                <input type="checkbox" id="clean-autodraft" name="clean-autodraft" >       
    6667                <label for="clean-navmenulock"><?php _e('Clean Other Left Overs' , 'kt-cleanpress')?></label>
    67                 <input type="checkbox" id="clean-navmenulock" name="clean-navmenulock" class="ktcheckbox">
     68                <input type="checkbox" id="clean-navmenulock" name="clean-navmenulock" >
    6869                <label for="clean-emptyc"><?php _e('Clean Empty  Categories' , 'kt-cleanpress')?></label>
    69                 <input type="checkbox" id="clean-emptyc" name="clean-emptyc" class="ktcheckbox">   
     70                <input type="checkbox" id="clean-emptyc" name="clean-emptyc"
    7071                <label for="clean-emptyt"><?php _e('Clean Empty  Tags' , 'kt-cleanpress')?></label>
    71                 <input type="checkbox" id="clean-emptyt" name="clean-emptyt" class="ktcheckbox">   
     72                <input type="checkbox" id="clean-emptyt" name="clean-emptyt"
    7273                <label for="clean-optimize"><?php _e('Optimize Tables' , 'kt-cleanpress')?></label>
    73                 <input type="checkbox" id="clean-optimize" name="clean-optimize" class="ktcheckbox">                                   
     74                <input type="checkbox" id="clean-optimize" name="clean-optimize" >                                 
    7475            </fieldset>
    7576            <input type="button" class="button-primary" onclick="ktselectall(document.getElementById('ktcleanpost'));" value="<?php _e('Select All','kt-cleanpress')?>">
  • kt-cleanpress/trunk/includes/kt-right-display-options.php

    r572415 r579704  
    1010    <span class = "kttitle"><?php _e("Clean Draft Posts:" , 'kt-cleanpress')?></span>
    1111    <span class = "kttext"><?php _e("Will remove all posts marked as Draft including any related database data." , 'kt-cleanpress')?></span><br>
    12     <span class = "kttitle"><?php _e("Clean Pending Posts:")?></span>
     12    <span class = "kttitle"><?php _e("Clean Pending Posts:" , 'kt-cleanpress')?></span>
    1313    <span class = "kttext"><?php _e("Will remove all posts marked as pending including any related database data." , 'kt-cleanpress')?></span><br>
    14     <span class = "kttitle"><?php _e("Clean trash Posts:")?></span>
     14    <span class = "kttitle"><?php _e("Clean trash Posts:" , 'kt-cleanpress')?></span>
    1515    <span class = "kttext"><?php _e("Will remove all posts marked as trash including any related database data." , 'kt-cleanpress')?></span><br>
    1616</fieldset>
    1717<fieldset>
    1818<legend><?php _e("Pages Cleaning Options" , 'kt-cleanpress')?></legend>
    19 <span class = "kttitle"><?php _e("Clean Draft Pages:")?></span>
     19<span class = "kttitle"><?php _e("Clean Draft Pages:" , 'kt-cleanpress')?></span>
    2020<span class = "kttext"><?php _e("Will remove all pages marked as Draft including any related database data." , 'kt-cleanpress')?></span><br>
    21 <span class = "kttitle"><?php _e("Clean Pending Pages:")?></span>
     21<span class = "kttitle"><?php _e("Clean Pending Pages:" , 'kt-cleanpress')?></span>
    2222<span class = "kttext"><?php _e("Will remove all pages marked as Pending any related database data." , 'kt-cleanpress')?></span><br>
    23 <span class = "kttitle"><?php _e("Clean Trash Pages:")?></span>
     23<span class = "kttitle"><?php _e("Clean Trash Pages:" , 'kt-cleanpress')?></span>
    2424<span class = "kttext"><?php _e("Will remove all pages marked as Trash any related database data." , 'kt-cleanpress')?></span><br>
    2525</fieldset>
    2626<fieldset>
    2727<legend><?php _e("Comments Cleaning Options" , 'kt-cleanpress')?></legend>
    28 <span class = "kttitle"><?php _e("Clean Spam Comments:")?></span>
     28<span class = "kttitle"><?php _e("Clean Spam Comments:" , 'kt-cleanpress')?></span>
    2929<span class = "kttext"><?php _e("Will remove all comments marked as spam including any related database data." , 'kt-cleanpress')?></span><br>
    30 <span class = "kttitle"><?php _e("Clean Unapproved Comments:")?></span>
     30<span class = "kttitle"><?php _e("Clean Unapproved Comments:" , 'kt-cleanpress')?></span>
    3131<span class = "kttext"><?php _e("Will remove all comments marked as unapproved including any related database data." , 'kt-cleanpress')?></span><br>
    32 <span class = "kttitle"><?php _e("Clean Trash Comments:")?></span>
     32<span class = "kttitle"><?php _e("Clean Trash Comments:" , 'kt-cleanpress')?></span>
    3333<span class = "kttext"><?php _e("Will remove all comments marked as trash including any related database data." , 'kt-cleanpress')?></span><br>
    3434</fieldset>
    3535<fieldset>
    3636<legend><?php _e("Other Cleaning Options" , 'kt-cleanpress')?></legend>
    37 <span class = "kttitle"><?php _e("Clean Post Revisions:")?></span>
     37<span class = "kttitle"><?php _e("Clean Post Revisions:" , 'kt-cleanpress')?></span>
    3838<span class = "kttext"><?php _e("Whenever a post is edited and saved WordPress automatically creates a backup to which one can revert. This option will remove all posts backups." , 'kt-cleanpress')?></span><br>
    39 <span class = "kttitle"><?php _e("Clean Auto Draft :")?></span>
     39<span class = "kttitle"><?php _e("Clean Auto Draft :" , 'kt-cleanpress')?></span>
    4040<span class = "kttext"><?php _e("This is a left over from the process of creating a new WordPress page or post and not saving it as a draft of publishing it." , 'kt-cleanpress')?></span><br>
    41 <span class = "kttitle"><?php _e("Clean Other Left Overs:")?></span>
     41<span class = "kttitle"><?php _e("Clean Other Left Overs:" , 'kt-cleanpress')?></span>
    4242<span class = "kttext"><?php _e("Will remove navigation menus that are created but not saved , and all their related data ,  and will also remove  unneeded lock and last entries in the database." , 'kt-cleanpress')?></span><br>
    43 <span class = "kttitle"><?php _e("Clean Empty Categories:")?></span>
     43<span class = "kttitle"><?php _e("Clean Empty Categories:" , 'kt-cleanpress')?></span>
    4444<span class = "kttext"><?php _e("Will delete all categories that don’t have any post or link associated with them but will not remove the default WordPress categories." , 'kt-cleanpress')?></span><br>
    45 <span class = "kttitle"><?php _e("Clean Empty Tags:")?></span>
     45<span class = "kttitle"><?php _e("Clean Empty Tags:" , 'kt-cleanpress')?></span>
    4646<span class = "kttext"><?php _e("Will delete all tags that don’t have any post associated with them." , 'kt-cleanpress')?></span><br>
    47 <span class = "kttitle"><?php _e("Optimize Tables:")?></span>
     47<span class = "kttitle"><?php _e("Optimize Tables:" , 'kt-cleanpress')?></span>
    4848<span class = "kttext"><?php _e("Reclaim unused space and defragment the data file." , 'kt-cleanpress')?></span><br>
    4949</fieldset>
  • kt-cleanpress/trunk/kt-cleanpress.php

    r572415 r579704  
    33/*
    44Plugin Name: kt-cleanpress
    5 Plugin URI: http://keefthis.info
     5Plugin URI: https://wordpress.org/extend/plugins/kt-cleanpress/
    66Description: Clean and Optimize wordpress
    7 Version: 1.0
     7Version: 1.1
    88Author: MWK
    99Author URI: http://keefthis.info
  • kt-cleanpress/trunk/readme.txt

    r572415 r579704  
    22Contributors: mwaelk
    33Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GZ2SG97EGBFH4
    4 Tags: clean, optimize, database, remove, trash
     4Tags: clean, optimize, database, remove, trash, revision, autodraft
    55Requires at least: 3.1
    6 Tested up to: 3.4
    7 Stable tag: 1.0
     6Tested up to: 3.4.1
     7Stable tag: 1.1
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    27276. Clean Other Left Overs: Will remove navigation menus that are created but not saved, and all their related data,  and will also remove  unneeded lock and last entries in the database.
    2828
    29 7. Clean Empty Categories / Tags: Will delete all categories/Tags that dot have any post or link associated with them but will not remove the default WordPress categories.
     297. Clean Empty Categories / Tags: Will delete all categories/Tags that do not have any post or link associated with them but will not remove the default WordPress categories.
    3030
    31318. Optimize The Tables: Reclaim unused space and defragment the data file.
    32 
    3332
    3433
     
    4847== Changelog ==
    4948
    50 
     491.  Some code cleaning , and added French translation.
    5150
    5251
Note: See TracChangeset for help on using the changeset viewer.