Skip to content

Commit

Permalink
Merge pull request #16 from dartiss/development
Browse files Browse the repository at this point in the history
Version 1.5.5
  • Loading branch information
dartiss authored Feb 7, 2018
2 parents cb52a9a + d166ae2 commit 4db0398
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 34 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Why is this a problem? Transients are often used by plugins to "cache" data (my

Meantime, this plugin is the hero that you've been waiting for. Simply activate the plugin, sit back and enjoy a much cleaner, smaller options table. It also adds the additional recommendation that after a database upgrade all transients will be cleared down.

I'd like to thank WordPress Developer Andrew Nacin for his early discussion on this. Also, I'd like to acknowledge [the useful article at Everybody Staze](http://www.staze.org/wordpress-_transient-buildup/ "WordPress _transient buildup") for ensuring the proposed solution wasn't totally mad, and [W-Shadow.com](http://w-shadow.com/blog/2012/04/17/delete-stale-transients/ "Cleaning Up Stale Transients") for the cleaning code.
I'd like to thank WordPress Developer Andrew Nacin for his early discussion on this. Also, I'd like to acknowledge [the useful article at Everybody Staze](http://www.staze.org/wordpress-_transient-buildup/ "WordPress _transient buildup") for ensuring the proposed solution wasn't totally mad, and [W-Shadow.com](http://w-shadow.com/blog/2012/04/17/delete-stale-transients/ "Cleaning Up Stale Transients") for the cleaning code.
3 changes: 1 addition & 2 deletions 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.4
Version: 1.5.5
Author: David Artiss
Author URI: https://artiss.blog
Text Domain: artiss-transient-cleaner
Expand Down Expand Up @@ -31,4 +31,3 @@
include_once( $functions_dir . 'set-admin-config.php' ); // Administration configuration

}
?>
4 changes: 3 additions & 1 deletion includes/clean-transients.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ function tc_clean_transients() {

function tc_set_up_scheduler() {

global $_wp_using_ext_object_cache;

// Check for conditions under which the scheduler requires settings up

if ( !wp_next_scheduled( 'housekeep_transients' ) && !wp_installing() ) { $schedule = true; } else { $schedule = false; }
if ( !wp_next_scheduled( 'housekeep_transients' ) && !wp_installing() && !$_wp_using_ext_object_cache ) { $schedule = true; } else { $schedule = false; }

// Set up schedule, if required

Expand Down
40 changes: 22 additions & 18 deletions includes/options-general.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
?>
<div class="wrap">

<h1><?php _e( 'Transient Cleaner Options', 'artiss-transient-cleaner' ); ?></h1>
<h1><?php echo ucwords( __( 'Transient Cleaner options', 'artiss-transient-cleaner' ) ); ?></h1>

<?php
if ( ( ( !empty( $_POST[ 'Options' ] ) ) or ( !empty( $_POST[ 'Upgrade' ] ) ) or ( !empty( $_POST[ 'Clean' ] ) ) ) && ( check_admin_referer( 'transient-cleaner-options' , 'transient_cleaner_options_nonce' ) ) ) {
Expand Down Expand Up @@ -91,7 +91,7 @@
echo '<p>' . $text . '</p>';
?>

<h3><?php _e( 'Clear Expired Transients', 'artiss-transient-cleaner' ); ?></h3>
<h3><?php echo __( 'Clear Expired Transients', 'artiss-transient-cleaner' ); ?></h3>

<?php

Expand All @@ -114,12 +114,13 @@
<table class="form-table">

<tr>
<th scope="row"><label for="clean_enable"><?php _e( 'Enable', 'artiss-transient-cleaner' ); ?></label></th>
<td><input type="checkbox" name="clean_enable" value="1"<?php if ( isset( $options[ 'clean_enable' ] ) && ( $options[ 'clean_enable' ] ) ) { echo ' checked="checked"'; } ?>/><?php _e( 'Housekeep expired transients daily', 'artiss-transient-cleaner' ); ?></td>
<th scope="row"><label for="clean_enable"><?php echo __( 'Enable', 'artiss-transient-cleaner' ); ?></label></th>
<?php if ( isset( $options[ 'clean_enable' ] ) && ( $options[ 'clean_enable' ] ) ) { $checked = true; } else { $checked = false; } ?>
<td><input type="checkbox" name="clean_enable" value="1"<?php checked( $checked ); ?>/><?php echo __( 'Housekeep expired transients daily', 'artiss-transient-cleaner' ); ?></td>
</tr>

<tr>
<th scope="row"><?php _e( 'When to run', 'artiss-transient-cleaner' ); ?></th>
<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>
Expand All @@ -145,22 +146,23 @@
<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 _e( 'Housekeeping will occur at this time every day.', 'artiss-transient-cleaner' ); ?></p></td>
</select></label><p class="description"><?php echo __( 'Housekeeping will occur at this time every day.', 'artiss-transient-cleaner' ); ?></p></td>
</tr>

<tr>
<th scope="row"><label for="clean_optimize"><?php _e( 'Optimize', 'artiss-transient-cleaner' ); ?></label></th>
<td><input type="checkbox" name="clean_optimize" value="1"<?php if ( isset( $options[ 'clean_optimize' ] ) && ( $options[ 'clean_optimize' ] ) ) { echo ' checked="checked"'; } ?>/><?php _e( 'Optimize table(s) afterward the housekeeping.', 'artiss-transient-cleaner' ); ?> <strong><?php _e( 'Not recommended', 'artiss-transient-cleaner' ); ?></strong></td>
<th scope="row"><label for="clean_optimize"><?php echo __( 'Optimize', 'artiss-transient-cleaner' ); ?></label></th>
<?php if ( isset( $options[ 'clean_optimize' ] ) && ( $options[ 'clean_optimize' ] ) ) { $checked = true; } else { $checked = false; } ?>
<td><input type="checkbox" name="clean_optimize" value="1"<?php checked( $checked ); ?>/><?php echo __( 'Optimize table(s) afterward the housekeeping.', 'artiss-transient-cleaner' ); ?> <strong><?php echo __( 'Not recommended', 'artiss-transient-cleaner' ); ?></strong></td>
</tr>

<tr>
<th scope="row"><label for="Clean"><?php _e( 'Clean now', 'artiss-transient-cleaner' ); ?></label></th>
<td><input type="checkbox" name="Clean" value="1"/><?php _e( 'Remove all expired transients', 'artiss-transient-cleaner' ); ?></td>
<th scope="row"><label for="Clean"><?php echo ucwords( __( 'Clean now', 'artiss-transient-cleaner' ) ); ?></label></th>
<td><input type="checkbox" name="Clean" value="1"/><?php echo __( 'Remove all expired transients', 'artiss-transient-cleaner' ); ?></td>
</tr>

</table>

<h3><?php _e( 'Remove All Transients', 'artiss-transient-cleaner' ); ?></h3>
<h3><?php echo ucwords( __( 'Remove all transients', 'artiss-transient-cleaner' ) ); ?></h3>

<?php

Expand All @@ -180,25 +182,27 @@
<table class="form-table">

<tr>
<th scope="row"><label for="upgrade_enable"><?php _e( 'Enable', 'artiss-transient-cleaner' ); ?></label></th>
<td><input type="checkbox" name="upgrade_enable" value="1"<?php if ( isset( $options[ 'upgrade_enable' ] ) && ( $options[ 'upgrade_enable' ] ) ) { echo ' checked="checked"'; } ?>/><?php _e( 'Remove all transients when a database upgrade occurs', 'artiss-transient-cleaner' ); ?></td>
<th scope="row"><label for="upgrade_enable"><?php echo __( 'Enable', 'artiss-transient-cleaner' ); ?></label></th>
<?php if ( isset( $options[ 'upgrade_enable' ] ) && ( $options[ 'upgrade_enable' ] ) ) { $checked = true; } else { $checked = false; } ?>
<td><input type="checkbox" name="upgrade_enable" value="1"<?php checked( $checked ); ?>/><?php echo __( 'Remove all transients when a database upgrade occurs', 'artiss-transient-cleaner' ); ?></td>
</tr>

<tr>
<th scope="row"><label for="upgrade_optimize"><?php _e( 'Optimize afterwards', 'artiss-transient-cleaner' ); ?></label></th>
<td><input type="checkbox" name="upgrade_optimize" value="1"<?php if ( isset( $options[ 'upgrade_optimize' ] ) && ( $options[ 'upgrade_optimize' ] ) ) { echo ' checked="checked"'; } ?>/><?php _e( 'Optimize table(s) afterward the housekeeping', 'artiss-transient-cleaner' ); ?></td>
<th scope="row"><label for="upgrade_optimize"><?php echo ucwords( __( 'Optimize afterwards', 'artiss-transient-cleaner' ) ); ?></label></th>
<?php if ( isset( $options[ 'upgrade_optimize' ] ) && ( $options[ 'upgrade_optimize' ] ) ) { $checked = true; } else { $checked = false; } ?>
<td><input type="checkbox" name="upgrade_optimize" value="1"<?php checked( $checked ); ?>/><?php echo __( 'Optimize table(s) afterward the housekeeping', 'artiss-transient-cleaner' ); ?></td>
</tr>

<tr>
<th scope="row"><label for="Upgrade"><?php _e( 'Clean now', 'artiss-transient-cleaner' ); ?></label></th>
<td><input type="checkbox" name="Upgrade" value="1"/><?php _e( 'Remove all transients', 'artiss-transient-cleaner' ); ?></td>
<th scope="row"><label for="Upgrade"><?php echo ucwords( __( 'Clean now', 'artiss-transient-cleaner' ) ); ?></label></th>
<td><input type="checkbox" name="Upgrade" value="1"/><?php echo __( 'Remove all transients', 'artiss-transient-cleaner' ); ?></td>
</tr>

</table>

<?php wp_nonce_field( 'transient-cleaner-options', 'transient_cleaner_options_nonce', true, true ); ?>

<input type="submit" name="Options" class="button-primary" value="<?php _e( 'Save Changes', 'artiss-transient-cleaner' ); ?>"/>
<input type="submit" name="Options" class="button-primary" value="<?php echo ucwords( __( 'Save changes', 'artiss-transient-cleaner' ) ); ?>"/>

</form>

Expand Down
16 changes: 10 additions & 6 deletions includes/set-admin-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ function tc_set_plugin_meta( $links, $file ) {
if ( strpos( $file, 'artiss-transient-cleaner.php' ) !== false ) {

$links = array_merge( $links, array( '<a href="https://github.com/dartiss/transient-cleaner">' . __( 'Github', 'artiss-transient-cleaner' ) . '</a>' ) );
$links = array_merge( $links, array( '<a href="http://wordpress.org/support/plugin/artiss-transient-cleaner">' . __( 'Support', 'artiss-transient-cleaner' ) . '</a>' ) );

$links = array_merge( $links, array( '<a href="http://wordpress.org/support/plugin/artiss-transient-cleaner">' . __( 'Support', 'artiss-transient-cleaner' ) . '</a>' ) );

}

Expand All @@ -49,11 +49,15 @@ function tc_set_plugin_meta( $links, $file ) {
function tc_add_settings_link( $links, $file ) {

static $this_plugin;

if ( !$this_plugin ) { $this_plugin = plugin_basename( __FILE__ ); }

if ( strpos( $file, 'artiss-transient-cleaner.php' ) !== false ) {
$settings_link = '<a href="tools.php?page=tc-options">' . __( 'Settings', 'artiss-transient-cleaner' ) . '</a>';
global $_wp_using_ext_object_cache;
if ( defined( 'TC_LITE' ) && TC_LITE ) { $lite = true; } else { $lite = false; }

if ( !$_wp_using_ext_object_cache && !$lite && strpos( $file, 'artiss-transient-cleaner.php' ) !== false ) {

$settings_link = '<a href="tools.php?page=transient-options">' . __( 'Settings', 'artiss-transient-cleaner' ) . '</a>';

array_unshift( $links, $settings_link );
}

Expand All @@ -76,7 +80,7 @@ function tc_show_admin_messages() {
global $_wp_using_ext_object_cache;

if ( $_wp_using_ext_object_cache ) {
echo '<div id="message" class="error" style="font-weight: bold; text-align: center"><p>' . __( 'An external object cache is in use so Transient Cleaner is not required. Please disable the plugin!', 'artiss-transient-cleaner' ) . '</p></div>';
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>';
}
}

Expand All @@ -102,7 +106,7 @@ function tc_menu_initialise() {

global $tc_options_hook;

$tc_options_hook = add_submenu_page( 'tools.php', __( 'Transient Cleaner Options', 'artiss-transient-cleaner' ), __( 'Transient Cleaner', 'artiss-transient-cleaner' ), 'install_plugins', 'tc-options', 'tc_options' );
$tc_options_hook = add_submenu_page( 'tools.php', __( 'Transient Cleaner Options', 'artiss-transient-cleaner' ), __( 'Transient Cleaner', 'artiss-transient-cleaner' ), 'install_plugins', 'transient-options', 'tc_options' );

add_action( 'load-' . $tc_options_hook, 'tc_add_options_help' );
}
Expand Down
18 changes: 12 additions & 6 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
=== Transient Cleaner ===
Contributors: dartiss
Donate link: https://artiss.blog/donate
Tags: cache, clean, database, housekeep, options, table, tidy, transient, update, upgrade
Requires at least: 4.6
Tested up to: 4.9
Tested up to: 4.9.4
Requires PHP: 5.3
Stable tag: 1.5.4
Stable tag: 1.5.5
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -28,7 +27,8 @@ Technical specification...
* Licensed under [GPLv2 (or later)](http://wordpress.org/about/gpl/ "GNU General Public License")
* Designed for both single and multi-site installations
* PHP7 compatible
* Fully internationalized, ready for translations. **If you would like to add a translation to this plugin then please head to our [Translating WordPress](https://translate.wordpress.org/projects/wp-plugins/artiss-transient-cleaner "Translating WordPress") page**
* Fully internationalized, ready for translations. **If you would like to add a translation to this plugin then please head to our [Translating WordPress](https://translate.wordpress.org/projects/wp-plugins/artiss-transient-cleaner "Translating WordPress") page**
* Gutenberg ready

I'd like to thank WordPress Developer Andrew Nacin for his early discussion on this. Also, I'd like to acknowledge [the useful article at Everybody Staze](http://www.staze.org/wordpress-_transient-buildup/ "WordPress _transient buildup") for ensuring the proposed solution wasn't totally mad, and [W-Shadow.com](http://w-shadow.com/blog/2012/04/17/delete-stale-transients/ "Cleaning Up Stale Transients") for the cleaning code.

Expand Down Expand Up @@ -98,6 +98,12 @@ 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.5 =
* Enhancement: Minor tweaks to how the options screen contents are generated
* Enhancement: Improved the error reporting when the plugin is used with object caching
* Bug: Settings link on plugin meta no longer appears if you're using object cache or using the 'lite' version of the plugin (i.e. when there is no options screen!)
* Bug: If you were using object cache then the plugin was still queueing up a daily job to run the housekeeping anyway. I've now stopped that

= 1.5.4 =
* Maintenance: Assorted tweaks to the README
* Maintenance: Removal of donation links BUT addition of Github links
Expand Down Expand Up @@ -181,5 +187,5 @@ A transient may consist of one or more records (normally a timed transient - the

== Upgrade Notice ==

= 1.5.4 =
* Various maintenance changes
= 1.5.5 =
* Assorted maintenance changes and a couple of bug fixes

0 comments on commit 4db0398

Please sign in to comment.