| Conditions | 8 |
| Paths | 7 |
| Total Lines | 23 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 72 |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 7 | public function removeHook(string $hook, string $fn, string $className, int $priority = 10): bool |
||
| 8 | { |
||
| 9 | global $wp_filter; |
||
| 10 | if (!isset($wp_filter[$hook])) { |
||
| 11 | return false; |
||
| 12 | } |
||
| 13 | if (!isset($wp_filter[$hook]->callbacks[$priority])) { |
||
| 14 | return false; |
||
| 15 | } |
||
| 16 | foreach ($wp_filter[$hook]->callbacks[$priority] as $callback) { |
||
| 17 | if (!isset($callback['function'][0]) || !isset($callback['function'][1])) { |
||
| 18 | continue; |
||
| 19 | } |
||
| 20 | if (!is_a($callback['function'][0], $className)) { |
||
| 21 | continue; |
||
| 22 | } |
||
| 23 | if ($fn !== $callback['function'][1]) { |
||
| 24 | continue; |
||
| 25 | } |
||
| 26 | remove_filter($hook, [$callback['function'][0], $fn], $priority); |
||
| 27 | return true; |
||
| 28 | } |
||
| 29 | return false; |
||
| 30 | } |
||
| 32 |