| Server IP : 167.179.152.94 / Your IP : 216.73.216.169 Web Server : Apache/2.4.66 (Debian) System : Linux 6d8cbb3dc321 6.8.0-117-generic #117-Ubuntu SMP PREEMPT_DYNAMIC Tue May 5 19:26:24 UTC 2026 x86_64 User : ( 1000) PHP Version : 8.3.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/html/wp-content/plugins/google-analytics-for-wordpress/includes/cache/ |
Upload File : |
<?php
/**
* Cache Cron Handler
*
* Ensures the cache cleanup cron job is scheduled for both new installs
* and existing users updating the plugin. This file is loaded on every
* request to ensure the cron is always scheduled when it should be.
*
* @since 9.11.0
* @package MonsterInsights
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Ensure cache cleanup cron is scheduled.
*
* This function runs on plugins_loaded to check if the cache cleanup
* cron job is scheduled. If not, it schedules it. This ensures that:
* 1. Fresh installs get the cron scheduled
* 2. Existing users updating to this version get the cron scheduled
* 3. If the cron somehow gets unscheduled, it will be re-scheduled
*
* This approach is used by major plugins like WooCommerce and Yoast SEO.
*
* @since 9.11.0
* @return void
*/
function monsterinsights_ensure_cache_cleanup_scheduled() {
// Only run in admin or cron context to avoid unnecessary checks on frontend
if ( ! is_admin() && ( ! defined( 'DOING_CRON' ) || ! DOING_CRON ) ) {
return;
}
// Check if cleanup is already scheduled
if ( ! wp_next_scheduled( 'monsterinsights_cache_daily_cleanup' ) ) {
monsterinsights_schedule_cache_cleanup();
}
}
// Hook into plugins_loaded with priority 20 to ensure cache functions are loaded first
add_action( 'plugins_loaded', 'monsterinsights_ensure_cache_cleanup_scheduled', 20 );