| 1 |
<?php |
| 2 |
/** |
| 3 |
* OpenStation App Framework — WordPress Hooks adapter. |
| 4 |
* |
| 5 |
* `filter()` is `apply_filters()`, `action()` is `do_action()`. An |
| 6 |
* app's seams are therefore ordinary WordPress hooks that any plugin |
| 7 |
* can attach to with `add_filter()` / `add_action()`. |
| 8 |
* |
| 9 |
* @package OpenStation |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace OpenStation\App\WordPress; |
| 13 |
|
| 14 |
use OpenStation\App\Contracts\Hooks as HooksContract; |
| 15 |
|
| 16 |
defined( 'ABSPATH' ) || exit; |
| 17 |
|
| 18 |
/** |
| 19 |
* WordPress filters and actions. |
| 20 |
*/ |
| 21 |
final class Hooks implements HooksContract { |
| 22 |
|
| 23 |
/** {@inheritDoc} */ |
| 24 |
public function filter( $hook, $value, ...$args ) { |
| 25 |
// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores -- The app names the hook; the adapter only relays it. |
| 26 |
return apply_filters( (string) $hook, $value, ...$args ); |
| 27 |
} |
| 28 |
|
| 29 |
/** {@inheritDoc} */ |
| 30 |
public function action( $hook, ...$args ) { |
| 31 |
// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores -- The app names the hook; the adapter only relays it. |
| 32 |
do_action( (string) $hook, ...$args ); |
| 33 |
} |
| 34 |
} |
| 35 |
|