Documentation · Appendices
Cron Hook Reference
This appendix lists every WP-Cron hook and custom interval registered by the ADP Car Market Hub plugin.
When to use this document
Use this reference when diagnosing missed scheduled work, when integrating with WP-CLI's cron commands, or when planning an external system cron. For the complete narrative explanation, see Cron Events And Scheduler and Cron Hooks For Developers.
Overview
The plugin uses WP-Cron for all of its periodic background work. WP-Cron is request-driven: events fire on the next page load on or after their scheduled time. On a low-traffic site, schedule a server-side cron to call wp-cron.php or the plugin's cron-import REST endpoint.
Custom intervals
| Interval key | Length | Registered in | Used by |
|---|---|---|---|
as24ci_every_5_minutes | 300 s (5 min) | Main plugin file adp-car-market-hub.php. Always registered. | AI generation queue. |
as24ci_every_6_hours | 6 h | AS24CI\Scheduler::add_cron_intervals(). | Importer when "Every 6 hours" is selected. |
as24ci_custom | N minutes | AS24CI\Scheduler::add_cron_intervals(). N is as24ci_cron_custom_minutes, clamped to a minimum of 15 minutes. | Importer when "Custom" is selected. |
Standard WordPress intervals (hourly, twicedaily, daily) are also accepted by the import schedule.
Recurring cron hooks
as24ci_scheduled_import
- Owner:
AS24CI\Scheduler(Scheduler::CRON_HOOK). - Schedule: Driven by
as24ci_cron_schedule(hourly,as24ci_every_6_hours,twicedaily,dailyoras24ci_custom). Fordaily/twicedaily, the start time comes fromas24ci_cron_start_time(HH:MM, WordPress site timezone). - Active when:
as24ci_auto_import_enabledis'1'. Refreshed byScheduler::reschedule()whenever automation settings are saved. - Callback:
Scheduler::run_scheduled_import()→Scheduler::run_import('wp-cron'). - Lock:
as24ci_cron_import_runningtransient (~40 minute TTL). Stale locks older than the TTL are auto-cleared. - Notes: Shared with the manual "Trigger now" admin button and the REST cron endpoint. All three paths use the same
Scheduler::run_import()runner and respect the same lock.
as24ci_image_queue_process
- Owner:
AS24CI\Scheduler(Scheduler::IMAGE_QUEUE_HOOK). - Schedule: Single events. The Importer schedules the worker when it queues images instead of downloading them inline; the worker re-schedules itself with
wp_schedule_single_event()while items remain in the queue. - Callback:
Scheduler::run_image_queue(). - Lock:
as24ci_image_queue_runningtransient (~10 minute TTL). - Batch size:
Scheduler::IMAGE_QUEUE_BATCH_SIZE(30 images per batch in the current source — verify before publishing if you need an exact value). - Notes: The queue itself is stored in the
as24ci_image_queueoption. Per-batch statistics are written toas24ci_image_queue_last_runfor the dashboard widget and the System & Help tab.
as24ci_process_ai_queue
- Owner:
AS24CI\Ai_Assistant(Ai_Assistant::AI_QUEUE_HOOK); the cron action callback is bound byAS24CI\Schedulereven when the AI feature toggle is off, so WP-Cron always has a callback for the hook. - Schedule: Custom interval
as24ci_every_5_minutes(300 seconds). Scheduling is gated byAi_Assistant::maybe_schedule_ai_queue(), which enforces all preconditions (AI feature enabled, managed Gemini configured, automation active). - Callback:
Ai_Assistant::process_ai_queue(). - Notes: When AI automation is disabled or unconfigured, the hook is unscheduled but its callback remains bound so manual triggers from the admin still work.
as24ci_daily_cleanup
- Owner:
AS24CI\Analytics(Analytics::ANALYTICS_CLEANUP_CRON_HOOK). - Schedule:
daily. Scheduled byAS24CI\Pluginon activation if not already scheduled; cleared on deactivation. - Callback:
Analytics::cleanup_old_data(). - Behaviour: Removes analytics rows older than
as24ci_analytics_retention_daysfrom the{$wpdb->prefix}as24ci_analyticstable.
as24ci_pricing_analysis_cron
- Owner:
AS24CI\Pricing_Engine(Pricing_Engine::CRON_HOOK). - Schedule:
daily. Scheduled viaPricing_Engine::schedule(); cleared viaPricing_Engine::clear_schedule()on deactivation. - Callback:
Pricing_Engine::run_daily_analysis().
as24ci_automated_taxonomy_scan
- Owner:
AS24CI\Data_Quality_Scanner(Data_Quality_Scanner::CRON_HOOK). - Schedule:
dailyortwicedaily, controlled byas24ci_dq_scan_frequency. The first-run time is derived fromas24ci_dq_scan_time(HH:MM in WordPress site timezone). The schedule is rebuilt whenever the related options are saved. - Active when:
as24ci_dq_scan_enabledis'1'. - Callback:
Data_Quality_Scanner::run_scan().
as24ci_license_refresh
- Owner:
AS24CI\License_Manager(License_Manager::REFRESH_CRON_HOOK). - Schedule:
daily. The first run is scheduled one hour after the event is created. Scheduled lazily byLicense_Manager::ensure_cron_scheduled()onadmin_initand on plugin activation; cleared viaLicense_Manager::clear_cron()on deactivation. - Callback:
License_Manager::scheduled_refresh()— performs a background re-validation of the license against the API Platform. - Notes: The cron callback is always bound; only the scheduling is lazy so no scheduling work runs on ordinary front-end requests.
as24ci_webhook_retry
- Owner: Webhooks subsystem.
- Schedule: Single events. Scheduled after a webhook attempt to perform a follow-up blocking re-send and for bounded exponential-style retries on transient failures (~60 s, ~2 min, ~4 min, up to three attempts in total).
- Notes: Verify the exact intervals and attempt count in the current source before publishing them in customer documentation.
as24ci_competitor_watcher_cron (legacy cleanup only)
This hook belonged to a removed Competitor Watcher feature and is not an active feature of the plugin. The hook name is retained only so that Competitor_Watcher::clear_schedule() can clear any leftover scheduled event from older installations on plugin deactivation. There is no scheduling, no AJAX action and no admin UI for it. Do not rely on this hook from external code.
Triggering imports outside WP-Cron
Two officially supported paths exist for triggering an import outside WP-Cron, both delegating to the same Scheduler::run_import() runner and respecting the same lock:
- REST cron endpoint —
GET /wp-json/as24ci/v1/cron-importwith token authentication. See REST Endpoint Reference. - Manual admin trigger — the "Trigger now" button on the Import & Limits admin tab. The underlying AJAX action is
as24ci_trigger_import_now.
The plugin also records a heartbeat timestamp in as24ci_last_external_cron_run whenever any URL on the site is hit with the ?as24ci_cron=1 query parameter. This heartbeat is for monitoring only; it does not start an import.
Operational notes
- WP-Cron events on a low-traffic site can be late or missed entirely. For predictable behaviour, configure a server-side cron and disable WP-Cron in
wp-config.php(define( 'DISABLE_WP_CRON', true );). - When you disable a feature module in the admin, its related cron events are unscheduled. They are re-scheduled the next time the feature is re-enabled and its
register_hooks()runs during plugin bootstrap. - The image-queue worker uses single events rather than a recurring schedule. It only schedules itself if there are items left in the queue.
- All hook names and constants above reflect the current plugin code. Verify against the version you target before publishing extension code that observes these hooks.
Troubleshooting
as24ci_scheduled_importis in the cron list but never runs. WP-Cron is request-driven. Either visit the site, runwp cron event run --due-nowvia WP-CLI, or configure an external trigger.- Import runs report "Import already in progress". The
as24ci_cron_import_runninglock is held by another runner. The plugin clears stale locks automatically once they exceed the TTL; otherwise, deactivating and reactivating the plugin clears the transient. - Image queue stops. Check the
as24ci_image_queue_last_runoption (processed,failed,remaining). If items remain but no event is scheduled, run "Process image queue now" in the admin to re-prime the worker. - AI queue does not advance. Confirm that the AI feature is enabled, the managed Gemini configuration is provisioned (
Ai_Config::is_configured()) and automation is on; otherwise scheduling stays off. - Data quality scan runs at the wrong time. Save the relevant options to trigger a reschedule, and confirm the WordPress site timezone in Settings → General.