wordPress = $wordPress; } public function initialize(): void { $this->wordPress->addAction(Hooks::WORKFLOW_STEP, [$this, 'run']); } /** @param mixed $args */ public function run($args): void { // Action Scheduler catches only Exception instances, not other errors. // We need to convert them to exceptions to be processed and logged. try { $this->runStep($args); } catch (Throwable $e) { if (!$e instanceof Exception) { throw new Exception($e->getMessage(), intval($e->getCode()), $e); } throw $e; } } /** @param mixed $args */ private function runStep($args): void { // TODO: args validation if (!is_array($args)) { throw new InvalidStateException(); } // TODO: process step } }