includes/Scheduler/class-cron.php
Cron Class for scheduling and managing cron jobs in the PerformanceOptimise plugin.
Class Cron
Class Cron
class CronConstants
| Constant | Visibility | Value | Line |
|---|---|---|---|
PRELOAD_QUEUE_OPTION | public | \'wppo_preload_queue\' | 48 |
PRELOAD_RESUME_CHUNK_SIZE | private | 50 | 372 |
TO_FETCH_LIMIT | private | 50 | 379 |
SCHEDULED_HOOKS | public | Job_Registry::CRON_HOOKS | 401 |
AS_HOOKS | public | Job_Registry::AS_HOOKS | 412 |
publicstatic get_preload_queue()
public static function get_preload_queue(): arrayRead the resumable sitemap preload queue.
Return: array{queued:string[],done:int,failed:string[],total:int,status:string,updated_at:int}.
privatestatic save_preload_queue()
private static function save_preload_queue(array $queue): voidPersist the preload queue (fail-open, never fatal). Parameter Type Default Description $queuearray— Queue payload.
Return: void.
publicstatic init_preload_queue()
public static function init_preload_queue(array $urls): voidSeed or extend the preload queue with freshly scheduled URLs. Parameter Type Default Description $urlsarray— Freshly scheduled sitemap URLs.
Return: void.
publicstatic mark_preload_done()
public static function mark_preload_done(string $url): voidMark a sitemap URL as done (removes it from queued, bumps done). Parameter Type Default Description $urlstring— Preloaded URL.
Return: void.
publicstatic mark_preload_failed()
public static function mark_preload_failed(string $url): voidMark a sitemap URL as failed (removes it from queued). Parameter Type Default Description $urlstring— Failed URL.
Return: void.
publicstatic get_preload_status()
public static function get_preload_status(): arrayHonest preload progress counters for the SPA.
Return: array{queued:int,done:int,failed:int,total:int,status:string,failed_urls:string[],cache_bytes:int,cache_files:int,stalled:bool}.
publicstatic resume_preload_queue()
public static function resume_preload_queue(): intResume the preload queue by re-scheduling queued + failed URLs.
Return: int — Number of URLs re-scheduled.
public preload_url_batch()
public function preload_url_batch($urls): voidProcess a resumed preload batch (chunk of URLs). Parameter Type Default Description $urlsmixed— Chunk of URLs to preload.
Return: void.
public __construct()
public function __construct()Constructor: registers the actions and filters used to schedule and run the plugin\’s cron jobs (audit #1362: hooks docblock moved here from the constants block so IDEs attach it correctly).
publicstatic trigger_preload()
public static function trigger_preload(): voidTrigger the cache preload directly (not via cron hook).
Return: void.
public add_custom_cron_interval()
public function add_custom_cron_interval($schedules): arrayAdd a custom cron interval. Parameter Type Default Description $schedulesarray— Existing cron schedules.
Return: array — Modified schedules with \’every_5_hours\’ added.
public schedule_cron_jobs()
public function schedule_cron_jobs(): voidSchedule the main cron job that triggers the processing of all pages.
Return: void.
private is_object_cache_circuit_open()
private function is_object_cache_circuit_open(): boolWhether the object-cache circuit breaker is currently open.
Return: bool — True when the circuit is open.
public object_cache_probe_cron()
public function object_cache_probe_cron(): voidCallback for the object-cache recovery probe cron.
Return: void.
public llms_txt_cron()
public function llms_txt_cron(): voidCallback for LLMs.txt daily regeneration cron.
Return: void.
public ccss_regeneration_cron()
public function ccss_regeneration_cron()Callback for CCSS daily regeneration cron.
Return: void.
public web_vitals_rescan_cron()
public function web_vitals_rescan_cron(): voidCallback for the daily Web Vitals auto-rescan cron.
Return: void.
public wppo_page_cron_callback()
public function wppo_page_cron_callback(): voidTriggers scheduling of the next batch of per-page static-generation jobs.
Return: void.
private schedule_page_cron_jobs()
private function schedule_page_cron_jobs(): voidSchedules per-page static-generation cron events in paged batches.
Return: void.
private schedule_sitemap_url_jobs()
private function schedule_sitemap_url_jobs(array $exclude_urls): voidSchedule single cron events for sitemap-discovered URLs. Parameter Type Default Description $exclude_urlsarray— Exclusion rules (processed URLs/patterns).
Return: void.
private is_woo_excluded_url()
private function is_woo_excluded_url(string $url, ?bool=null $woo_safe, ?array=null $woo_paths): boolWhether a preload URL targets a WooCommerce dynamic route. Parameter Type Default Description $urlstring— Absolute URL. $woo_safe?bool=null— Optional pre-resolved safe-mode flag (hoisted by batch callers). $woo_paths?array=null— Optional pre-resolved Woo excluded paths (hoisted by batch callers).
Return: bool — True when the URL must not be preloaded.
private is_editor_preview_url()
private function is_editor_preview_url(string $url): boolWhether a preload URL targets an admin or editor-preview context. Parameter Type Default Description $urlstring— Absolute URL.
Return: bool — True when the URL must not be preloaded.
private get_scheduled_args_set()
private function get_scheduled_args_set(string $hook): ?arraySnapshot scheduled args for a cron hook into an in-memory set. Parameter Type Default Description $hookstring— Cron hook name.
Return: array<string, — bool>|null Args set, or null on fallback.
private is_hook_arg_scheduled()
private function is_hook_arg_scheduled(string $hook, array $args, ?array $scheduled): boolWhether a hook+args event is already scheduled. Parameter Type Default Description $hookstring— Hook name. $argsarray— Event args. $scheduled?array— —
Return: bool — True when already scheduled.
private get_rest_route_param()
private function get_rest_route_param(string $url, string $query): stringExtract the `rest_route` query value from a preload URL. Parameter Type Default Description $urlstring— Absolute URL. $querystring— Pre-parsed query string.
Return: string — The `rest_route` value or \’\’.
public used_css_cron()
public function used_css_cron()Callback for used-CSS background regeneration cron.
Return: void.
publicstatic clear_cron_jobs()
public static function clear_cron_jobs(): voidClear all scheduled cron jobs.
Return: void.
public process_page()
public function process_page($page_id): voidProcess a specific page by generating its static version. Parameter Type Default Description $page_idint— The ID of the page to process.
Return: void.
public process_url()
public function process_url($url): voidGenerate a static cache file for an arbitrary URL. Parameter Type Default Description $urlstring— The URL to preload.
Return: void.
public get_sitemap_urls()
public function get_sitemap_urls(int=500 $cap): arrayDiscover preloadable URLs from the site\’s sitemap. Parameter Type Default Description $capint=500— Maximum number of URLs to return.
Return: string[] — List of absolute sitemap URLs.
private load_page()
private function load_page($page_id): voidLoad a specific page. Parameter Type Default Description $page_idint— The ID of the page to load.
Return: void.
public litespeed_crawler_batch()
public function litespeed_crawler_batch($arg): voidCrawl batch via curl_multi variant matrix (P4). Parameter Type Default Description $argstring|string[]— Batch ID or URL list.
Return: void.
privatestatic peek_crawler_batch_arg()
private static function peek_crawler_batch_arg($arg): arrayResolve a deferred crawler batch argument into its URL list without deleting the payload. Parameter Type Default Description $argmixed— Batch ID or URL list.
Return: string[] — URLs to crawl.
public crawler_warm_single()
public function crawler_warm_single($url): voidWarm a single URL via crawler (post-publish lane). Parameter Type Default Description $urlstring— URL.
Return: void.
private mark_page_as_processed()
private function mark_page_as_processed($page_id): voidMark a page as processed by clearing any previously generated cache files. Parameter Type Default Description $page_idint— The ID of the page to mark as processed.
Return: void.
public img_convert_cron()
public function img_convert_cron()Convert images to optimized formats.
public database_cleanup_cron()
public function database_cleanup_cron()Callback for database automatic cleanup cron.
Return: void.
Hooks
Hooks referenced in includes/Scheduler/class-cron.php: Hook Type Line Notes wppo_page_cron_hookaction registration 433 — wppo_page_cron_batchaction registration 434 — wppo_img_conversionaction registration 435 — wppo_generate_static_pageaction registration 438 — wppo_generate_static_urlaction registration 439 — wppo_preload_url_batchaction registration 440 — wppo_litespeed_crawler_batchaction registration 441 — wppo_crawler_warmaction registration 442 — wppo_database_cleanup_cronaction registration 444 — wppo_web_vitals_rescanaction registration 446 — wppo_llms_txt_dailyaction registration 448 — wppo_used_css_cronaction registration 450 — wppo_ccss_regenerationaction registration 451 — wppo_rum_flushaction registration 452 — wppo_object_cache_probeaction registration 453 — wppo_object_cache_probe_intervalfilter 490 @param ×1 wppo_cron_discovery_limitfilter 1702 —