Allow plugins to add their own context data for automation editor

[PREMIUM-215]
This commit is contained in:
Jan Jakes
2023-01-06 15:30:23 +01:00
committed by Aschepikov
parent 4ddcc14eee
commit 6b7ffbc4ad
6 changed files with 34 additions and 0 deletions

View File

@@ -22,6 +22,9 @@ class Registry {
/** @var array<string, Action> */
private $actions = [];
/** @var array<string, callable> */
private $contextFactories = [];
/** @var WordPress */
private $wordPress;
@@ -107,6 +110,15 @@ class Registry {
return $this->actions;
}
public function addContextFactory(string $key, callable $factory): void {
$this->contextFactories[$key] = $factory;
}
/** @return callable[] */
public function getContextFactories(): array {
return $this->contextFactories;
}
public function onBeforeAutomationSave(callable $callback, int $priority = 10): void {
$this->wordPress->addAction(Hooks::AUTOMATION_BEFORE_SAVE, $callback, $priority);
}