Each endpoint will be a class that can implement get/post/put/delete methods. The routes are registered to WP REST API automatically based on the existence of implemented methods. The endpoint classes are handled standard services and therefore can leverage full powers of the DI container. [MAILPOET-4135]
14 lines
473 B
PHP
14 lines
473 B
PHP
<?php declare(strict_types = 1);
|
|
|
|
namespace MailPoet\Automation;
|
|
|
|
class WordPress {
|
|
public function addAction(string $hookName, callable $callback, int $priority = 10, int $acceptedArgs = 1): bool {
|
|
return add_action($hookName, $callback, $priority, $acceptedArgs);
|
|
}
|
|
|
|
public function registerRestRoute(string $namespace, string $route, array $args = [], bool $override = false): bool {
|
|
return register_rest_route($namespace, $route, $args, $override);
|
|
}
|
|
}
|