Allow plugins to add their own context data for automation editor
[PREMIUM-215]
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user