WordPress plugin called “SpeedClean Toolkit” that combines five performance and cleanup features: Old Post Cleaner, Media Optimizer, Simple Cache Clear Button, Emoji Remover, and Heartbeat Control. The plugin is designed for non-coders, with a centralized settings page to configure all features and clear instructions for setup. It’s lightweight, secure, and uses best practices to optimize WordPress performance. Each feature can be enabled/disabled independently to minimize resource usage.
Since you’ve previously requested individual plugins for Simple Cache Clear Button, Emoji Remover, and Heartbeat Control, I’ll reuse and adapt their core functionality (with the same artifact IDs where applicable) to ensure consistency, while integrating them into this unified toolkit. The Old Post Cleaner and Media Optimizer are new additions, with the latter using the TinyPNG API for image compression.
Note: For Media Optimizer, you’ll need a TinyPNG API key (free for up to 100 images/month at tinypng.com). The plugin assumes HTTPS for API requests and a server with cURL enabled.
📥 My Awesome Plugin
This plugin helps you automate tasks and improve web performance.
⬇️ Download Plugin ZIP💌 Subscribe to Updates
Installation and Setup Instructions
- Download the Plugin:
- Copy the PHP code above into a file named wp-speedclean-toolkit.php.
- Place this file in a folder named wp-speedclean-toolkit.
- Upload to WordPress:
- Zip the wp-speedclean-toolkit folder.
- In the WordPress admin dashboard, go to Plugins > Add New > Upload Plugin.
- Upload the zipped folder and click Install Now.
- Activate the Plugin:
- After installation, click Activate Plugin.
- Configure Features:
- Go to the new menu item SpeedClean Toolkit in the WordPress admin dashboard.
- Configure each feature:
- Old Post Cleaner:
- Enable Post Cleaner: Check to enable (default: enabled).
- Clean Drafts: Check to delete old drafts (default: enabled).
- Clean Revisions: Check to delete old revisions (default: enabled).
- Age Threshold: Set days for items to be considered old (default: 30).
- Media Optimizer:
- Enable Media Optimizer: Check to enable (default: disabled).
- TinyPNG API Key: Enter your API key from tinypng.com.
- Simple Cache Clear Button:
- Enable Cache Clear Button: Check to add the button to the admin bar (default: enabled).
- Emoji Remover:
- Enable Emoji Remover: Check to remove emoji scripts (default: enabled).
- Heartbeat Control:
- Enable Heartbeat Control: Check to enable (default: enabled).
- Admin Area Interval: Set interval in seconds (default: 120).
- Disable in Admin Area: Check to disable (default: disabled).
- Post Editor Interval: Set interval in seconds (default: 60).
- Disable in Post Editor: Check to disable (default: disabled).
- Front-End Interval: Set interval in seconds (default: 120).
- Disable on Front-End: Check to disable (default: disabled).
- Old Post Cleaner:
- Click Save Changes.
- Test Each Feature:
- Old Post Cleaner:
- Create a draft or revision, wait past the age threshold (e.g., 30 days), and check if it’s deleted after the daily cron runs (force with a plugin like WP Crontrol).
- Verify in the database (wp_posts table) or posts list.
- Media Optimizer:
- Upload a JPEG/PNG image to the Media Library.
- Check the file size before and after upload (via FTP or hosting file manager) to confirm compression.
- Verify TinyPNG API usage at tinypng.com.
- Simple Cache Clear Button:
- Log in as an admin and look for the Clear Cache button in the admin bar.
- Click it and check for the success notice. Test with your caching plugin (e.g., WP Super Cache) to confirm cache is cleared.
- Emoji Remover:
- View your site’s front-end source code (Ctrl+U) and search for wp-emoji-release.min.js or emoji styles; they should be absent.
- Test in the admin area too.
- Heartbeat Control:
- Open the browser’s developer tools (F12), go to the Network tab, and filter for admin-ajax.php.
- Check the frequency of Heartbeat requests in the admin area, post editor, and front-end against your settings.
- Old Post Cleaner:
- Verify Server Requirements:
- Ensure cURL is enabled for TinyPNG API (check with phpinfo() or your host).
- Confirm your server supports HTTPS requests and WP-Cron for scheduled cleanups.
Features
- Old Post Cleaner:
- Deletes old drafts, auto-drafts, and revisions daily via WP-Cron.
- Configurable age threshold (default: 30 days).
- Reduces database size for faster queries.
- Media Optimizer:
- Compresses JPEG/PNG images on upload using TinyPNG API.
- Reduces image file sizes (often 50-70%) without visible quality loss.
- Supports free TinyPNG API tier (100 images/month).
- Simple Cache Clear Button:
- Adds a “Clear Cache” button to the admin bar for admins.
- Clears WordPress object cache, transients, and popular caching plugins (WP Super Cache, W3 Total Cache, LiteSpeed Cache, WP Rocket).
- Shows a success notice after clearing.
- Emoji Remover:
- Removes emoji scripts (wp-emoji-release.min.js) and styles from front-end and admin.
- Disables emoji processing in feeds, comments, emails, and TinyMCE editor.
- Saves ~10-20 KB per page load.
- Heartbeat Control:
- Adjusts Heartbeat API intervals for admin (default: 120s), post editor (60s), and front-end (120s).
- Option to disable Heartbeat in specific areas.
- Reduces admin-ajax.php requests to lower server load.
- Centralized Settings: Enable/disable and configure all features from one page.
- Single File: Core logic in one PHP file for simplicity.
- Secure: Uses nonces, sanitized inputs, and prepared database queries.
How It Works
- Old Post Cleaner: Schedules a daily WP-Cron event to delete drafts/revisions older than the set threshold using direct database queries.
- Media Optimizer: Hooks into add_attachment to send images to TinyPNG API via cURL, then replaces the original file with the compressed version.
- Simple Cache Clear Button: Hooks into admin_bar_menu to add a button and admin_init to handle cache clearing with nonce verification.
- Emoji Remover: Hooks into init to remove emoji-related actions and filters, preventing script/style loading.
- Heartbeat Control: Filters heartbeat_settings to adjust intervals or disable Heartbeat based on context, checked via sct_is_post_editor.
Notes
- Performance Impact:
- Old Post Cleaner: Minimal database queries, runs daily via WP-Cron.
- Media Optimizer: Adds a few seconds to image uploads due to API calls; negligible for most sites.
- Cache Clear Button: Instantaneous, no significant overhead.
- Emoji Remover: Saves HTTP requests and ~10-20 KB per page.
- Heartbeat Control: Reduces server load, especially on high-traffic sites.
- Dependencies:
- Media Optimizer: Requires cURL and a TinyPNG API key.
- All Features: Rely on WP-Cron for scheduling (ensure it’s working via WP Crontrol).
- Compatibility: Works with WordPress 5.0+ and major caching plugins. Test with themes/plugins for conflicts (e.g., page builders).
- Limitations:
- Old Post Cleaner: Permanent deletion; back up your database first.
- Media Optimizer: Free TinyPNG API limits to 100 images/month. Only JPEG/PNG supported.
- Heartbeat Control: Disabling Heartbeat may affect autosave or real-time features.
- Security: All inputs are sanitized, and actions are nonce-protected. Database queries use prepared statements.
- Webloop Integration: Based on your interest in automation and tools like those on webloop.space, this plugin can be branded for Webloop clients to optimize site performance, with potential AI-driven features like predictive cleanup scheduling.
Troubleshooting
- Old Post Cleaner Not Deleting:
- Check WP-Cron status with WP Crontrol. Run the sct_cleanup_posts_event manually to test.
- Verify the age threshold and ensure drafts/revisions exist.
- Check the wp_posts table in phpMyAdmin.
- Media Optimizer Not Compressing:
- Ensure cURL is enabled and the API key is valid (test at tinypng.com).
- Check debug log (wp-content/debug.log) for API errors.
- Confirm images are JPEG/PNG.
- Cache Clear Button Missing:
- Ensure Enable Cache Clear Button is checked and you’re an admin.
- Check if the admin bar is enabled (Users > Your Profile > Show Toolbar).
- Emoji Scripts Still Loading:
- View page source to confirm wp-emoji-release.min.js is absent.
- Check for other plugins/themes adding emoji scripts.
- Heartbeat Still Frequent:
- Use browser dev tools to monitor admin-ajax.php requests.
- Ensure settings are saved and test in the correct context (admin, editor, front-end).
- If disabled, confirm no requests occur.
- General Issues:
- Enable debugging (define(‘WP_DEBUG’, true); in wp-config.php) to log errors.
- Test with a default theme (e.g., Twenty Twenty-Five) and no other plugins to rule out conflicts.
- Use tools like GTmetrix or Query Monitor to measure performance improvements.
This plugin is ready to use and combines five essential performance and cleanup tools into a beginner-friendly package. Let me know if you need additional features (e.g., manual cleanup button, bulk image compression, or integration with Webloop’s AI tools) or help with setup!