Skip to content

Commit e9577ae

Browse files
committed
👌 IMPROVE: Action extends Filter
1 parent 3d3d55c commit e9577ae

File tree

1 file changed

+4
-26
lines changed

1 file changed

+4
-26
lines changed

src/Attributes/Action.php

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,11 @@
88

99
/**
1010
* Action attribute class
11+
*
12+
* Extends Filter, because add_action and add_filter is actually the same:
13+
* https://developer.wordpress.org/reference/functions/add_action/#source
1114
*/
1215
#[Attribute(Attribute::TARGET_METHOD|Attribute::IS_REPEATABLE)]
13-
class Action implements HookInterface
16+
class Action extends Filter
1417
{
15-
/**
16-
* Construct the action class
17-
*
18-
* @param string $hook
19-
* @param integer $priority
20-
* @param integer $acceptedArgs
21-
*/
22-
public function __construct(
23-
public string $hook,
24-
public int $priority = 10,
25-
public int $acceptedArgs = 1
26-
)
27-
{
28-
}
29-
30-
/**
31-
* Register the action
32-
*
33-
* @param callable|array $method
34-
* @return void
35-
*/
36-
public function register(callable|array $method): void
37-
{
38-
add_action($this->hook, $method, $this->priority, $this->acceptedArgs);
39-
}
4018
}

0 commit comments

Comments
 (0)