Skip to content

Commit

Permalink
Merge pull request #22 from dartiss/development
Browse files Browse the repository at this point in the history
Version 1.5.7
  • Loading branch information
dartiss authored Nov 6, 2018
2 parents b28d167 + 08f9213 commit 3ffbeb0
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 44 deletions.
2 changes: 1 addition & 1 deletion artiss-transient-cleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Transient Cleaner
Plugin URI: https://github.com/dartiss/transient-cleaner
Description: Housekeep expired transients from your options table.
Version: 1.5.6
Version: 1.5.7
Author: David Artiss
Author URI: https://artiss.blog
Text Domain: artiss-transient-cleaner
Expand Down
3 changes: 2 additions & 1 deletion includes/clean-transients.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ function tc_transient_delete( $clear_all ) {

// Save options field with number & timestamp

$results = array();

$results[ 'timestamp' ] = time() + ( get_option( 'gmt_offset' ) * 3600 );
$results[ 'records' ] = $records;

Expand All @@ -202,4 +204,3 @@ function tc_transient_delete( $clear_all ) {

return $cleaned;
}
?>
56 changes: 28 additions & 28 deletions includes/options-general.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
$options[ 'schedule' ] = '00';
}

if ( $options[ 'schedule' ] != $old_options[ 'schedule' ] ) {
if ( $options[ 'schedule' ] !== $old_options[ 'schedule' ] ) {
wp_clear_scheduled_hook( 'housekeep_transients' );
tc_set_schedule( $options[ 'schedule' ] );
}
Expand Down Expand Up @@ -69,8 +69,8 @@
$total_transients = $wpdb -> get_var( "SELECT COUNT(*) FROM $wpdb->options WHERE option_name LIKE '%_transient_%'" );
$total_timed_transients = $wpdb -> get_var( "SELECT COUNT(*) FROM $wpdb->options WHERE option_name LIKE '%_transient_timeout_%'" );
if ( is_multisite() ) {
$total_transients .= $wpdb -> get_var( "SELECT COUNT(*) FROM $wpdb->sitemeta WHERE meta_key LIKE '_site_transient_%'" );
$total_timed_transients .= $wpdb -> get_var( "SELECT COUNT(*) FROM $wpdb->sitemeta WHERE meta_key LIKE '_site_transient_timeout_%'" );
$total_transients += $wpdb -> get_var( "SELECT COUNT(*) FROM $wpdb->sitemeta WHERE meta_key LIKE '_site_transient_%'" );
$total_timed_transients += $wpdb -> get_var( "SELECT COUNT(*) FROM $wpdb->sitemeta WHERE meta_key LIKE '_site_transient_timeout_%'" );
}
$transient_number = $total_transients - $total_timed_transients;

Expand All @@ -81,7 +81,7 @@
$expired_transients = $wpdb -> get_var( "SELECT COUNT(*) FROM $wpdb->options WHERE option_name LIKE '%_transient_timeout_%' AND option_value < UNIX_TIMESTAMP()" );
if ( is_multisite() ) { $expired_transients .= $wpdb -> get_var( "SELECT COUNT(*) FROM $wpdb->sitemeta WHERE meta_key LIKE '%_transient_timeout_%' AND meta_value < UNIX_TIMESTAMP()" ); }
$text .= ' ';
if ( 1 == $expired_transients ) {
if ( 1 === $expired_transients ) {
$text .= sprintf( __( '%s transient has expired.', 'artiss-transient-cleaner' ), $expired_transients );
} else {
$text .= sprintf( __( '%s transients have expired.', 'artiss-transient-cleaner' ), $expired_transients );
Expand Down Expand Up @@ -122,30 +122,30 @@
<tr>
<th scope="row"><?php echo ucwords( __( 'When to run', 'artiss-transient-cleaner' ) ); ?></th>
<td><label for="when_to_run"><select name="when_to_run">
<option value="00"<?php if ( "00" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>00:00</option>
<option value="01"<?php if ( "02" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>01:00</option>
<option value="02"<?php if ( "02" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>02:00</option>
<option value="03"<?php if ( "03" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>03:00</option>
<option value="04"<?php if ( "04" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>04:00</option>
<option value="05"<?php if ( "05" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>05:00</option>
<option value="06"<?php if ( "06" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>06:00</option>
<option value="07"<?php if ( "07" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>07:00</option>
<option value="08"<?php if ( "08" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>08:00</option>
<option value="09"<?php if ( "09" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>09:00</option>
<option value="10"<?php if ( "10" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>10:00</option>
<option value="11"<?php if ( "11" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>11:00</option>
<option value="12"<?php if ( "12" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>12:00</option>
<option value="13"<?php if ( "13" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>13:00</option>
<option value="14"<?php if ( "14" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>14:00</option>
<option value="15"<?php if ( "15" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>15:00</option>
<option value="16"<?php if ( "16" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>16:00</option>
<option value="17"<?php if ( "17" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>17:00</option>
<option value="18"<?php if ( "18" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>18:00</option>
<option value="19"<?php if ( "19" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>19:00</option>
<option value="20"<?php if ( "20" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>20:00</option>
<option value="21"<?php if ( "21" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>21:00</option>
<option value="22"<?php if ( "22" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>22:00</option>
<option value="23"<?php if ( "23" == $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>23:00</option>
<option value="00"<?php if ( "00" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>00:00</option>
<option value="01"<?php if ( "02" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>01:00</option>
<option value="02"<?php if ( "02" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>02:00</option>
<option value="03"<?php if ( "03" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>03:00</option>
<option value="04"<?php if ( "04" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>04:00</option>
<option value="05"<?php if ( "05" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>05:00</option>
<option value="06"<?php if ( "06" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>06:00</option>
<option value="07"<?php if ( "07" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>07:00</option>
<option value="08"<?php if ( "08" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>08:00</option>
<option value="09"<?php if ( "09" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>09:00</option>
<option value="10"<?php if ( "10" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>10:00</option>
<option value="11"<?php if ( "11" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>11:00</option>
<option value="12"<?php if ( "12" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>12:00</option>
<option value="13"<?php if ( "13" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>13:00</option>
<option value="14"<?php if ( "14" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>14:00</option>
<option value="15"<?php if ( "15" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>15:00</option>
<option value="16"<?php if ( "16" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>16:00</option>
<option value="17"<?php if ( "17" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>17:00</option>
<option value="18"<?php if ( "18" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>18:00</option>
<option value="19"<?php if ( "19" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>19:00</option>
<option value="20"<?php if ( "20" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>20:00</option>
<option value="21"<?php if ( "21" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>21:00</option>
<option value="22"<?php if ( "22" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>22:00</option>
<option value="23"<?php if ( "23" === $options[ 'schedule' ] ) { echo " selected='selected'"; } ?>>23:00</option>
</select></label><p class="description"><?php echo __( 'Housekeeping will occur at this time every day.', 'artiss-transient-cleaner' ); ?></p></td>
</tr>

Expand Down
10 changes: 8 additions & 2 deletions includes/set-admin-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ function tc_show_admin_messages() {
global $_wp_using_ext_object_cache;

if ( $_wp_using_ext_object_cache ) {
echo '<div id="message" class="error"><p>' . __( 'An external object cache is in use so Transient Cleaner is not required. <strong>Please disable the plugin.</strong>', 'artiss-transient-cleaner' ) . '</p></div>';
echo '<div class="notice notice-warning"><p>' . __( 'An external object cache is in use so Transient Cleaner is not required. <strong>Please disable the plugin.</strong>', 'artiss-transient-cleaner' ) . '</p></div>';
}

global $wp_version;

if ( version_compare( $wp_version, '4.9', '>=' ) ) {
echo '<div class="notice notice-warning"><p>' . __( 'Transient housekeeping is now part of WordPress core, as of version 4.9. <strong>Please disable the Transient Cleaner plugin.</strong>', 'artiss-transient-cleaner' ) . '</p></div>';
}
}

Expand Down Expand Up @@ -142,7 +148,7 @@ function tc_add_options_help() {
global $tc_options_hook;
$screen = get_current_screen();

if ( $screen->id != $tc_options_hook ) { return; }
if ( $screen->id !== $tc_options_hook ) { return; }

$screen -> add_help_tab( array( 'id' => 'tc-options-help-tab', 'title' => __( 'Help', 'artiss-transient-cleaner' ), 'content' => tc_options_help() ) );

Expand Down
4 changes: 1 addition & 3 deletions includes/shared-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function tc_get_options() {

// Update the options, if changed, and return the result

if ( $options != $new_options && !$lite ) { update_option( 'transient_clean_options', $new_options ); }
if ( $options !== $new_options && !$lite ) { update_option( 'transient_clean_options', $new_options ); }

return $new_options;
}
Expand Down Expand Up @@ -66,6 +66,4 @@ function tc_set_schedule( $hour ) {
wp_schedule_event( strtotime( $hour ) , 'daily', 'housekeep_transients' );

return $hour;

}
?>
25 changes: 17 additions & 8 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
Contributors: dartiss
Tags: cache, clean, database, housekeep, options, table, tidy, transient, update, upgrade
Requires at least: 4.6
Tested up to: 4.9.4
Tested up to: 4.8.7
Requires PHP: 5.3
Stable tag: 1.5.6
Stable tag: 1.5.7
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Housekeep expired transients from your options table. The original and best!

== Description ==

**As of version 4.9 of WordPress, transient housekeeping now takes place automatically - this plugin is therefore no longer required!**

Housekeep expired transients from your options table. The original and best!

"Transients are a simple and standardized way of storing cached data in the WordPress database temporarily by giving it a custom name and a timeframe after which it will expire and be deleted."
Expand Down Expand Up @@ -44,16 +46,18 @@ You can even request an optimization of the options table to give your system a

A "lite" mode is available. By activating this the options screen will no longer appear and default settings will be used. The advantage? Improved performance to Admin and, especially if you're running multi-site, no chance of anybody "tinkering" with the settings.

To activate, add the following to your `wp-config.php` file...
To activate, use the following...

`define( 'TC_LITE', true );`
`define( 'TC_LITE', true );`

This should be added to your `wp-config.php` file.

== Using hooks ==

If you're the type of odd person who likes to code for WordPress (really?) then I've added a couple of hooks so you can call our rather neat housekeeping functions...

`housekeep_transients` - this will clear down any expired transients
`clear_all_transients` - this will remove any and all transients, expired or otherwise
* `housekeep_transients` - this will clear down any expired transients
* `clear_all_transients` - this will remove any and all transients, expired or otherwise

== Installation ==

Expand Down Expand Up @@ -98,6 +102,11 @@ A transient may consist of one or more records (normally a timed transient - the

[Learn more about my version numbering methodology](https://artiss.blog/2016/09/wordpress-plugin-versioning/ "WordPress Plugin Versioning")

= 1.5.7 =
* Maintenance: Transient housekeeping now takes place as part of WordPress 4.9 and above. Therefore, on all installations >= 4.9, an admin message will be shown to indicate as such
* Maintenance: Some further tidying up of code
* Bug: Fixed a multisite counting issue

= 1.5.6 =
* Bug: Had changed the settings screen name to fix another issue but forget to change it in one location, which meant settings couldn't be saved. Fixed and abject apologies.

Expand Down Expand Up @@ -190,5 +199,5 @@ A transient may consist of one or more records (normally a timed transient - the

== Upgrade Notice ==

= 1.5.6 =
* Bug fix
= 1.5.7 =
* Important admin notice added for those running WP 4.9 or greater!
1 change: 0 additions & 1 deletion uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@

delete_option( 'transient_clean_expired' );
delete_option( 'transient_clean_all' );
?>

0 comments on commit 3ffbeb0

Please sign in to comment.