-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathclass-plugin.php
More file actions
149 lines (126 loc) · 3.63 KB
/
Copy pathclass-plugin.php
File metadata and controls
149 lines (126 loc) · 3.63 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
/**
* Class file for the Accessibility Checker plugin.
*
* @package Accessibility_Checker
*/
namespace EDAC\Inc;
use EDAC\Admin\Admin;
use EDAC\Admin\Meta_Boxes;
use EDAC\Admin\Orphaned_Issues_Cleanup;
use EqualizeDigital\AccessibilityChecker\Admin\AdminPage\AccessibilityReportsPage;
use EqualizeDigital\AccessibilityChecker\Blocks\SimplifiedSummaryBlock;
use EqualizeDigital\AccessibilityChecker\MyDot\Connector;
use EqualizeDigital\AccessibilityChecker\Shortcodes\SimplifiedSummaryShortcode;
use EqualizeDigital\AccessibilityChecker\WPCLI\BootstrapCLI;
use EqualizeDigital\AccessibilityChecker\Fixes\FixesManager;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Main plugin functionality class.
*/
class Plugin {
/**
* Class constructor.
*/
public function __construct() {
if ( \is_admin() ) {
$meta_boxes = new Meta_Boxes();
$admin = new Admin( $meta_boxes );
$admin->init();
} else {
$this->init();
}
// The REST api must load if admin or not.
$rest_api = new REST_Api();
$rest_api->init_hooks();
// Initialize the admin toolbar.
$admin_toolbar = new Admin_Toolbar();
$admin_toolbar->init();
$cleanup = new Orphaned_Issues_Cleanup();
$cleanup->init_hooks();
// The block and shortcode must register in admin (for the editor) and on the front end.
$simplified_summary_block = new SimplifiedSummaryBlock();
$simplified_summary_block->init_hooks();
$simplified_summary_shortcode = new SimplifiedSummaryShortcode();
$simplified_summary_shortcode->init_hooks();
$this->register_fixes_manager();
$this->register_sr_only_meta_hooks();
$accessibility_reports = new AccessibilityReportsPage( 'manage_options' );
$accessibility_reports->add_page();
$connector = new Connector();
$connector->init();
// When WP CLI is enabled, load the CLI commands.
if ( defined( 'WP_CLI' ) && WP_CLI ) {
add_action(
'init',
function () {
$cli = new BootstrapCLI();
$cli->register();
}
);
}
}
/**
* Initialize.
*
* @return void
*/
private function init() {
add_action( 'wp_enqueue_scripts', [ 'EDAC\Inc\Enqueue_Frontend', 'enqueue' ] );
$accessibility_statement = new Accessibility_Statement();
$accessibility_statement->init_hooks();
$simplified_summary = new Simplified_Summary();
$simplified_summary->init_hooks();
$lazyload_filter = new Lazyload_Filter();
$lazyload_filter->init_hooks();
}
/**
* Register hooks for the screen reader only user meta.
*
* @return void
*/
public function register_sr_only_meta_hooks(): void {
add_action( 'init', [ $this, 'register_sr_only_user_meta' ] );
}
/**
* Register user meta for the screen reader text always-show preference.
*
* @return void
*/
public function register_sr_only_user_meta(): void {
register_meta(
'user',
'show_sr_text_in_editor',
[
'type' => 'boolean',
'single' => true,
'show_in_rest' => true,
]
);
}
/**
* Register the FixesManager.
*
* @return void
*/
public function register_fixes_manager() {
add_action( 'plugins_loaded', [ $this, 'init_fixes_manager' ], 20 );
}
/**
* Init the FixesManager.
*
* This is done on the plugins_loaded hook with a priority of 20 to ensure that fixes that
* rely on running early, like on init or before init, can be hooked in and ready to go.
* Fixes should be registered to the manager using the the plugins_loaded hook with a
* priority of less than 20.
*
* @return void
*/
public function init_fixes_manager() {
$fixes_manager = FixesManager::get_instance();
$fixes_manager->register_fixes();
add_action( 'rest_api_init', [ $fixes_manager, 'register_rest_routes' ] );
}
}