Documentation

CronRegistrar
in package

FinalYes

Per-component WP-Cron registrar.

Wires each event to a CronInterval instead of a magic recurrence string, and registers the custom intervals on the cron_schedules filter keyed by the host component (resolved through the plugin's own DI), so two plugins in the same request keep independent schedules. Interval labels are translated through the host TranslatorInterface.

Table of Contents

Properties

$context  : HostComponentContextInterface
$events  : array<string|int, CronInterval, callback: callable}>
$translator  : TranslatorInterface

Methods

__construct()  : mixed
addEvent()  : void
getRegisteredHooks()  : array<string|int, mixed>
Get all registered event hooks.
register()  : void
registerIntervals()  : array<string|int, mixed>
Filter callback: add every {@see CronInterval} to WP cron schedules, keyed `{component}_{case}` so plugins never collide on a shared slot.
unregister()  : void

Properties

$context read-only

private HostComponentContextInterface $context

$events

private array<string|int, CronInterval, callback: callable}> $events = []

$translator read-only

private TranslatorInterface $translator

Methods

__construct()

public __construct(HostComponentContextInterface $context, TranslatorInterface $translator) : mixed
Parameters
$context : HostComponentContextInterface
$translator : TranslatorInterface

getRegisteredHooks()

Get all registered event hooks.

public getRegisteredHooks() : array<string|int, mixed>
Return values
array<string|int, mixed>

registerIntervals()

Filter callback: add every {@see CronInterval} to WP cron schedules, keyed `{component}_{case}` so plugins never collide on a shared slot.

public registerIntervals(array<string|int, mixed> $schedules) : array<string|int, mixed>

Pre-existing keys are left untouched.

Parameters
$schedules : array<string|int, mixed>
Return values
array<string|int, mixed>
On this page

Search results