executeJob($job_id); } catch (\Exception $e) { try { $job_manager = new AutomationJobManager(); $job_manager->updateJobStatus($job_id, 'failed', $e->getMessage()); } catch (\Exception $update_error) { } } } /** * Register job execution hook for a specific job * * @param int $job_id Job ID */ public static function register_job_hook($job_id) { $hook_name = 'aipt_execute_job_' . $job_id; if (!has_action($hook_name)) { add_action($hook_name, [self::class, 'execute_job_callback'], 10, 1); } } /** * Unregister job execution hook for a specific job * * @param int $job_id Job ID */ public static function unregister_job_hook($job_id) { $hook_name = 'aipt_execute_job_' . $job_id; remove_action($hook_name, [self::class, 'execute_job_callback'], 10); } /** * Register catch-all hook for job execution * * A generic hook that can handle any job execution. It makes no database * query: per-job hooks are registered by register_dynamic_hooks(). */ public static function register_catch_all_hook() { add_action('aipt_execute_any_job', [self::class, 'execute_job_callback'], 10, 1); } }