forked from WordPress/phpdoc-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaster.php
More file actions
84 lines (74 loc) · 2 KB
/
Master.php
File metadata and controls
84 lines (74 loc) · 2 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
<?php
namespace Aivec\Plugins\DocParser;
/**
* Top-level class
*/
class Master
{
const REACT_DOM_NODE = 'avcpdp_react';
/**
* Error store object
*
* @var ErrorStore
*/
public $estore;
/**
* Routes object
*
* @var Routes
*/
public $routes;
/**
* Initializes plugin
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return void
*/
public function init() {
if (defined('WP_CLI') && WP_CLI) {
\WP_CLI::add_command('parser', __NAMESPACE__ . '\\CLI\\Commands');
}
add_action('init', function () {
$this->routes = new Routes('/avcpdp', 'avcpdp_nonce_key', 'avcpdp_nonce_name');
$this->routes->dispatcher->listen();
}, 12);
(new Views\ImporterPage\ImporterPage($this))->init();
(new Importer\Relationships())->init();
(new Registrations())->init();
(new Explanations\Explanations())->init();
(new PostAddons\ParsedContent\ParsedContent())->init();
Views\SettingsPage::init();
PostAddons\ItemImportance\ItemImportance::init();
Queries::init();
Formatting::init();
SourceTypeTerm::init();
PostsPluginFilter::init();
if (is_admin()) {
Admin::init();
}
}
/**
* Returns `ErrorStore` instance
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return ErrorStore
*/
public static function getErrorStore() {
$estore = new ErrorStore();
$estore->populate();
return $estore;
}
/**
* Returns variables to be injected into JS scripts
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return array
*/
public function getScriptInjectionVariables() {
return array_merge(
['reactDomNode' => self::REACT_DOM_NODE],
self::getErrorStore()->getScriptInjectionVariables(),
$this->routes->getScriptInjectionVariables()
);
}
}