Descrição
Clean expired transients from your options table. The original and best!
Transient housekeeping was added to the core of WordPress after version 5.8. However, I have decided to open up this plugin to all versions to allow for manual transient cleaning. Longer term I am working on a new version of the plugin, designed specifically for all WordPress releases.
- Tested up to PHP 8.2
- Fully complies with WordPress coding standards
- Compliant with the stronger WordPress VIP coding standards, as well as compatibility with their platform
- Community plugin – visit the [Github page](https://github.com/dartiss/[repo link] “Github”) to get involved with the latest code development, request enhancements and report issues
“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.”
Unfortunately, expired transients only get deleted when you attempt to access them. If you don’t access the transient then, even though it’s expired, WordPress will not remove it. This is a known “issue” but due to reasons, which are explained in the FAQ, this has not been adequately resolved.
Why is this a problem? Transients are often used by plugins to “cache” data (my own plugins included). Because of this it means that expired data can be left and build up, resulting in a bloated database table.
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.
The Settings Screen
Within Administration
-> Tools
-> Transients
an options screen exists allowing you to tweak when you’d like cleaning to happen, including the ability to perform an ad-hoc run, and when you’d like the to be automatically scheduled.
You can even request an optimization of the options table to give your system a real “pep”!
Running in Lite mode
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, use the following…
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 cleaning functions…
housekeep_transients
– this will clear down any expired transientsclear_all_transients
– this will remove any and all transients, expired or otherwise
Acknowledgements
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 for ensuring the proposed solution made sense, and W-Shadow.com for the cleaning code.
Iconography is courtesy of the very talented Janki Rathod.
Ecrãs
Instalação
This plugin can be found and installed via the Plugin menu within WP Admin (Plugins -> Add New). Alternatively, it can be downloaded from WordPress.org and installed manually…
- Upload the entire unzipped plugin folder to your
wp-content/plugins/
directory, either from WP Admin (Plugins -> Add New), your favorite FTP client or any other file manager - Activate the plugin through the ‘Plugins’ menu in WP Admin (Plugins -> Installed Plugins)
Perguntas frequentes
-
Why does this not work on WordPress 5.9 or later?
-
Because transient housekeeping was fixed in WordPress 5.9, so it’s not needed!
-
How often will expired transients be cleared down?
-
Once a day and, by default, at midnight. However, the hour at which is runs can be changed in the settings screen.
It should be noted too that this will only run once the appropriate hour has passed AND somebody has been onto your site (with anybody visiting, the scheduler will not run).
-
In the administration screen it sometimes refers to the number of transients and other times the number of records. What’s the difference?
-
A transient may consist of one or more records (normally a timed transient – the type that expires – has two) and without checking and matching them all up it can sometimes be hard to work out. So, where possible, it’ll tell you the number of transients but, where it can’t, it’ll refer to the number of records on the database.
Avaliações
Contribuidores e programadores
“Transient Cleaner” é software de código aberto. As seguintes pessoas contribuíram para este plugin:
Contribuidores“Transient Cleaner” foi traduzido para 5 locales. Obrigado aos tradutores pelas suas contribuições.
Traduza o “Transient Cleaner” para o seu idioma.
Interessado no desenvolvimento?
Consulte o código, consulte o repositório SVN, ou subscreva o registo de alterações por RSS.
Registo de alterações
I use semantic versioning, with the first release being 1.0.
1.7
- Enhancement: Code quality improvements – major code changes to make sure all code guidelines are met
- Enhancement: Using new cross-plugin shared functions
- Enhancement: Tidy up of this README
1.6.2
- Bug: Fixed a bug in the settings screen. Remember kids – listen to your teachers when they tell you that spelling is important! Especially function names
1.6.1
- Maintenance: Removed the WordPress version check so that the plugin will remain active on all versions
1.6
- Enhancement: Added new error screens to prevent activation after WordPress 5.8
- Enhancement: Code quality improved
- Maintenance: Removed links to Github repo, as this will be retired
1.5.8
- Enhancement: Changed some of the language used by the plugin to be more inclusive
- Enhancement: New header meta added to the plugin
- Bug: The scheduled event was not being removed during the uninstall routine – that’s now been added
1.5.7
- Maintenance: Transient cleaning 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.
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 cleaning 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
- Maintenance: Changing of some on-screen wording – correct spelling in some cases and to make US English in others
1.5.3
- Enhancement: README updates to reflect changed plugin directory
- Maintenance: Minimum WordPress level for the plugin has been raised to 4.6, so various changes have been made to accommodate that
- Maintenance: Because of the new minimum WordPress level loading of the language scripts is no longer required. The folder has also been removed, as has the link to it
1.5.2
- Bug: Oops. Although it seemed to work fine on my test system, it looks as if the code for the new ‘lite’ mode was causing some users errors. I’ve now (I hope) corrected that. Apologies.
1.5.1
- Maintenance: Beware the Atom editor and it’s default setting of appending extra blank lines! Extra lines have now been removed from the bottom of various files
- Maintenance: Also took the opportunity to correct my site URLs, as my domain has recently changed (the old URLs still work as I’m smart enough to put redirects in place but, still, it’s neater to do it properly)
1.5
- Enhancement: A new option has been added to allow you to run in “lite” mode, where no option screen will be present and default settings will be used. Useful for multi-site installations or just where you want to run with minimal performance impact
- Enhancement: Re-instated the code change that I removed in 1.4.1 – this time it performs a version check and only calls the extra function if available
- Enhancement: After WP 4.6 you no longer need to load the plugin’s text domain. So I don’t!
- Enhancement: Added a links sidebar to the help drop-down
- Maintenance: Changed the menu names so they no longer clash with other plugins
- Maintenance: Making use of Yoda conditions to ensure stability of code
- Bug: Sorted bug which meant that changing the scheduled run time didn’t work
1.4.2
- Maintenance: Updated branding, inc. adding donation links
1.4.1
- Bug: Awww… biscuits. I was being smart by including a call to a function to check something without realizing you have to have WordPress 4.4 for it to work. Thankfully, it’s not critical so I’ve removed it for now and will add a “proper” solution in future
1.4
- Enhancement: Re-written core code to work better with multisite installations
- Enhancement: Administration screen re-written to be more “in keeping” with the WordPress standard layout. More statistics about cleared transients are also shown
- Enhancement: Instead of piggy-backing the existing cleaning schedule (which some people turn off) I’ve instead implemented my own – it defaults to midnight but, via the administration screen, you can change it to whatever hour floats your boat
- Enhancement: For those nerdy enough that they want to code links to our amazing cleaning functions, we’ve added some super whizzy hooks. Check the instructions about for further details
- Maintenance: This is now a Code Art production, so the author name has been updated and the donation link (including matching plugin meta) ripped out. I for one welcome our new overlords.
- Maintenance: Renamed the functions that began with atc_ to tc_
- Maintenance: I admit it, I’ve been naughty. I’ve been hard-coding the plugin folder in INCLUDES. Yes, I know. But I’ve fixed that now
- Maintenance: I’ve validated, sanitized, escaped and licked the data that’s sent around the options screen. Okay, I didn’t do that last one
- Bug: Some PHP errors were vanquished
1.3.1
- Maintenance: Added a text domain and domain path
1.3
- Enhancement: Added links to settings in plugin meta
- Enhancement: Updated admin screen headings for WP 4.3
- Enhancement: Now used time() instead of gmmktime(), so as to follow strict usage
- Bug: Big PHP error clean-up
1.2.4
- Maintenance: Updated links on plugin meta
1.2.3
- Bug: Removed PHP error
1.2.2
- Enhancement: Options are now only available to admin (super admin if a multisite)
- Bug: Removed reporting of “orphaned” transients – these are actually transients without a timeout
1.2.1
- Maintenance: Updated the branding of the plugin
- Enhancement: Added support link to plugin meta
1.2
- Maintenance: Split files because of additional code size
- Maintenance: Removed run upon activation
- Enhancement: Improved transient cleaning code efficiency (including cleaning MU wide transients)
- Enhancement: Added administration screen (Tools->Transients) to allow ad-hoc runs and specify run options
- Enhancement: Show within new admin screen whether orphaned transients have been found (in this case full clear of the option table is recommended)
- Enhancement: Added internationalization
- Enhancement: If external memory cache is in use display an admin box to indicate this plugin is not required
1.1
- Enhancement: Transients will be initially cleaned when the plugin is activated
1.0
- Release inicial