-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwp-hook-attributes.php
59 lines (52 loc) · 1.24 KB
/
wp-hook-attributes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
declare(strict_types=1);
use BoxUk\WpHookAttributes\HookAttributesManager;
use BoxUk\WpHookAttributes\WordPressHookAttributes;
use Doctrine\Common\Annotations\AnnotationReader;
/**
* Plugin Name: WordPress Hook Attributes
* Plugin URI: https://boxuk.com/
* Description: A library to allow the use of PHP attributes for WordPress hooks.
* Version: 0.0.1
* Author: Box UK
* Author URI: https://boxuk.com
*/
// autoloader.
if (! class_exists(HookAttributesManager::class)) {
require __DIR__ . '/vendor/autoload.php';
}
$annotationIgnores = apply_filters('wp_hook_attributes_annotation_ignores', [
// WordPress.
'type',
'blessed',
// WP CLI.
'when',
'When',
'then',
'Then',
'given',
'Given',
'subcommand',
'string',
'alias',
'all',
'prod',
'dev',
'local',
'both',
'multiservers',
// Timber
'jarednova',
'date',
]);
foreach ($annotationIgnores as $annotationIgnore) {
AnnotationReader::addGlobalIgnoredName($annotationIgnore);
}
// Run after all plugins and theme has loaded.
add_action(
'init',
static function (): void {
(new WordPressHookAttributes())();
},
0 // Should be the first or one of the first thing that runs on init.
);