Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
95.83% |
23 / 24 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
Plugin | |
95.83% |
23 / 24 |
|
0.00% |
0 / 1 |
3 | |
0.00% |
0 / 1 |
init | |
95.83% |
23 / 24 |
|
0.00% |
0 / 1 |
3 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Beyondwords\Wordpress; |
6 | |
7 | use Beyondwords\Wordpress\Compatibility\WPGraphQL\WPGraphQL; |
8 | use Beyondwords\Wordpress\Core\Core; |
9 | use Beyondwords\Wordpress\Core\Environment; |
10 | use Beyondwords\Wordpress\Core\Player\Player; |
11 | use Beyondwords\Wordpress\Core\Player\PlayerInline; |
12 | use Beyondwords\Wordpress\Core\Updater; |
13 | use Beyondwords\Wordpress\Component\Post\AddPlayer\AddPlayer; |
14 | use Beyondwords\Wordpress\Component\Post\BlockAttributes\BlockAttributes; |
15 | use Beyondwords\Wordpress\Component\Post\DisplayPlayer\DisplayPlayer; |
16 | use Beyondwords\Wordpress\Component\Post\ErrorNotice\ErrorNotice; |
17 | use Beyondwords\Wordpress\Component\Post\GenerateAudio\GenerateAudio; |
18 | use Beyondwords\Wordpress\Component\Post\Metabox\Metabox; |
19 | use Beyondwords\Wordpress\Component\Post\Panel\Inspect\Inspect; |
20 | use Beyondwords\Wordpress\Component\Post\PlayerContent\PlayerContent; |
21 | use Beyondwords\Wordpress\Component\Post\PlayerStyle\PlayerStyle; |
22 | use Beyondwords\Wordpress\Component\Post\SelectVoice\SelectVoice; |
23 | use Beyondwords\Wordpress\Component\Posts\Column\Column; |
24 | use Beyondwords\Wordpress\Component\Posts\BulkEdit\BulkEdit; |
25 | use Beyondwords\Wordpress\Component\Posts\BulkEdit\Notices as BulkEditNotices; |
26 | use Beyondwords\Wordpress\Component\Settings\Settings; |
27 | use Beyondwords\Wordpress\Component\Settings\SettingsUtils; |
28 | use Beyondwords\Wordpress\Component\SiteHealth\SiteHealth; |
29 | |
30 | /** |
31 | * @SuppressWarnings(PHPMD.CouplingBetweenObjects) |
32 | */ |
33 | class Plugin |
34 | { |
35 | /** |
36 | * Public property required so that we can run bulk edit actions like this: |
37 | * $beyondwords_wordpress_plugin->core->generateAudioForPost($postId); |
38 | * |
39 | * @see \Beyondwords\Wordpress\Component\Posts\BulkEdit\BulkEdit |
40 | */ |
41 | public $core; |
42 | |
43 | /** |
44 | * Public property required so that we can run bulk edit actions like this: |
45 | * $beyondwords_wordpress_plugin->player->getBody; |
46 | * |
47 | * @see \Beyondwords\Wordpress\Component\Post\PostContentUtils |
48 | */ |
49 | public $player; |
50 | |
51 | /** |
52 | * Constructor. |
53 | * |
54 | * @since 3.0.0 |
55 | * @since 4.5.1 Disable plugin features if we don't have valid API settings. |
56 | */ |
57 | public function init() |
58 | { |
59 | // Run plugin update checks before anything else |
60 | (new Updater())->run(); |
61 | |
62 | // Third-party plugin/theme compatibility |
63 | (new WPGraphQL())->init(); |
64 | |
65 | // Core |
66 | $this->core = new Core(); |
67 | $this->core->init(); |
68 | |
69 | // Site health |
70 | (new SiteHealth())->init(); |
71 | |
72 | // Player (inline or not) |
73 | if (Environment::hasPlayerInlineScriptTag()) { |
74 | (new PlayerInline())->init(); |
75 | } else { |
76 | (new Player())->init(); |
77 | } |
78 | |
79 | // Settings |
80 | (new Settings())->init(); |
81 | |
82 | /** |
83 | * To prevent browser JS errors we skip adding admin UI components until |
84 | * we have a valid REST API connection. |
85 | */ |
86 | if (SettingsUtils::hasValidApiConnection()) { |
87 | // Posts screen |
88 | (new BulkEdit())->init(); |
89 | (new BulkEditNotices())->init(); |
90 | (new Column())->init(); |
91 | |
92 | // Post screen |
93 | (new AddPlayer())->init(); |
94 | (new BlockAttributes())->init(); |
95 | (new ErrorNotice())->init(); |
96 | (new Inspect())->init(); |
97 | |
98 | // Post screen metabox |
99 | (new GenerateAudio())->init(); |
100 | (new DisplayPlayer())->init(); |
101 | (new SelectVoice())->init(); |
102 | (new PlayerContent())->init(); |
103 | (new PlayerStyle())->init(); |
104 | (new PlayerContent())->init(); |
105 | (new Metabox())->init(); |
106 | } |
107 | } |
108 | } |