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 keyLengthRegistered inUsed by
as24ci_every_5_minutes300 s (5 min)Main plugin file adp-car-market-hub.php. Always registered.AI generation queue.
as24ci_every_6_hours6 hAS24CI\Scheduler::add_cron_intervals().Importer when "Every 6 hours" is selected.
as24ci_customN minutesAS24CI\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, daily or as24ci_custom). For daily/twicedaily, the start time comes from as24ci_cron_start_time (HH:MM, WordPress site timezone).
  • Active when: as24ci_auto_import_enabled is '1'. Refreshed by Scheduler::reschedule() whenever automation settings are saved.
  • Callback: Scheduler::run_scheduled_import()Scheduler::run_import('wp-cron').
  • Lock: as24ci_cron_import_running transient (~40 minute TTL). Stale locks older than the TTL are auto-cleared.
  • Notes: Shared with the manual "Start Import Now" admin button and the REST cron endpoint. All three paths use the same Scheduler::run_import() runner and respect the same lock.
  • Connections — carcuro and mobile.de: The carcuro connector (AS24CI\Import_Carcuro) and the mobile.de connector hook their run() callbacks onto this central hook in register_hooks() and have no cron event of their own; they run on every central import and are a no-op unless the source is enabled and configured. The legacy per-source event as24ci_import_carcuro_event (its Import_Carcuro::CRON_HOOK) is no longer scheduled — register_hooks() self-heals by clearing any leftover from older installations. The AutoScout24 import is driven directly by Scheduler::run_import().

as24ci_import_feed_event

  • Owner: AS24CI\Import_Feed (Import_Feed::CRON_HOOK) — the Connections file / feed connector.
  • Schedule: A standard WordPress interval (hourly, twicedaily or daily) taken from the connector settings. Unlike carcuro, this connector registers its own recurring cron event: Import_Feed::reschedule() clears and re-schedules the event whenever the feed settings are saved, and only schedules it when the connector is enabled and a feed URL is set.
  • Callback: Import_Feed::run() → fetches the configured file (https / ftp / sftp / server path) and imports it through the saved mapping template (as24ci_import_csv_template).
  • Notes: Cleared by Import_Feed::clear_schedule(). Requires a saved mapping template before it can import.

as24ci_import_mail_event

  • Owner: AS24CI\Import_Mail (Import_Mail::CRON_HOOK) — the Connections e-mail (IMAP) connector.
  • Schedule: A standard WordPress interval (hourly, twicedaily or daily) taken from the connector settings. This connector also registers its own recurring cron event: Import_Mail::reschedule() clears and re-schedules it on save, and only schedules it when the connector is enabled and a mailbox host is set.
  • Callback: Import_Mail::run() → connects to the mailbox over IMAP, takes the newest matching unread message's supported attachment and imports it through the saved mapping template (as24ci_import_csv_template).
  • Notes: Cleared by Import_Mail::clear_schedule(). Requires the PHP imap extension and a saved mapping template.

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_running transient (~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_queue option. Per-batch statistics are written to as24ci_image_queue_last_run for 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 by AS24CI\Scheduler even 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 by Ai_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 by AS24CI\Plugin on activation if not already scheduled; cleared on deactivation.
  • Callback: Analytics::cleanup_old_data().
  • Behaviour: Removes analytics rows older than as24ci_analytics_retention_days from the {$wpdb->prefix}as24ci_analytics table.

as24ci_intelligence_sync

  • Owner: the Market Intelligence subsystem.
  • Schedule: daily.
  • Behaviour: Performs the daily synchronisation of market intelligence data used by Market Insights.

as24ci_pricing_analysis_cron

  • Owner: AS24CI\Pricing_Engine (Pricing_Engine::CRON_HOOK).
  • Schedule: daily. Scheduled via Pricing_Engine::schedule(); cleared via Pricing_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: daily or twicedaily, controlled by as24ci_dq_scan_frequency. The first-run time is derived from as24ci_dq_scan_time (HH:MM in WordPress site timezone). The schedule is rebuilt whenever the related options are saved.
  • Active when: as24ci_dq_scan_enabled is '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 by License_Manager::ensure_cron_scheduled() on admin_init and on plugin activation; cleared via License_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 endpointGET /wp-json/as24ci/v1/cron-import, authenticated with the Authorization: Bearer <token> header (the legacy ?token=<token> query parameter still works but is deprecated, as it exposes the secret in access logs). See REST Endpoint Reference.
  • Manual admin trigger — the "Start Import 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_import is in the cron list but never runs. WP-Cron is request-driven. Either visit the site, run wp cron event run --due-now via WP-CLI, or configure an external trigger.
  • Import runs report "Import already in progress". The as24ci_cron_import_running lock 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_run option (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.