PluginProbe
BeyondWords – AI audio for publishers / 4.6.2
BeyondWords – AI audio for publishers v4.6.2
7.1.0 trunk 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.1.0 4.1.1 4.1.2 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.3.0 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 4.7.0 All 43 releases
speechkit / src / Plugin.php

Plugin.php in BeyondWords – AI audio for publishers 4.6.2, at src/Plugin.php

122 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Beyondwords\Wordpress;
6
7 use Beyondwords\Wordpress\Compatibility\Elementor\Elementor;
8 use Beyondwords\Wordpress\Core\ApiClient;
9 use Beyondwords\Wordpress\Core\Core;
10 use Beyondwords\Wordpress\Core\Player\LegacyPlayer;
11 use Beyondwords\Wordpress\Core\Player\Player;
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\PlayerStyle\PlayerStyle;
21 use Beyondwords\Wordpress\Component\Post\SelectVoice\SelectVoice;
22 use Beyondwords\Wordpress\Component\Posts\Column\Column;
23 use Beyondwords\Wordpress\Component\Posts\BulkEdit\BulkEdit;
24 use Beyondwords\Wordpress\Component\Posts\BulkEdit\Notices as BulkEditNotices;
25 use Beyondwords\Wordpress\Component\Settings\Settings;
26 use Beyondwords\Wordpress\Component\Settings\SettingsUtils;
27 use Beyondwords\Wordpress\Component\SiteHealth\SiteHealth;
28
29 /**
30 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
31 */
32 class Plugin
33 {
34 /**
35 * Public property required so that we can run bulk edit actions like this:
36 * $beyondwords_wordpress_plugin->core->generateAudioForPost($postId);
37 *
38 * @see \Beyondwords\Wordpress\Component\Posts\BulkEdit\BulkEdit
39 */
40 public $core;
41
42 /**
43 * Public property required so that we can run bulk edit actions like this:
44 * $beyondwords_wordpress_plugin->player->getBody;
45 *
46 * @see \Beyondwords\Wordpress\Component\Post\PostContentUtils
47 */
48 public $player;
49
50 /**
51 * The API client - this enables various components to access the API.
52 *
53 * @todo Consider switching from dependency injection to singleton or another
54 * pattern so that components can perform API calls without DI.
55 */
56 public $apiClient;
57
58 /**
59 * Constructor.
60 */
61 public function __construct()
62 {
63 $this->apiClient = new ApiClient();
64 }
65
66 /**
67 * Constructor.
68 *
69 * @since 3.0.0
70 * @since 4.5.1 Disable plugin features if we don't have valid API settings.
71 */
72 public function init()
73 {
74 // Run plugin update checks before anything else
75 (new Updater())->run();
76
77 // Elementor compatibility
78 (new Elementor())->init();
79
80 // Core
81 $this->core = new Core($this->apiClient);
82 $this->core->init();
83
84 // Site health
85 (new SiteHealth())->init();
86
87 // Player
88 if (SettingsUtils::useLegacyPlayer()) {
89 (new LegacyPlayer())->init();
90 } else {
91 (new Player())->init();
92 }
93
94 // Settings
95 (new Settings($this->apiClient))->init();
96
97 /**
98 * To prevent browser JS errors we skip adding admin UI components until
99 * we have a valid REST API connection.
100 */
101 if (SettingsUtils::hasApiSettings()) {
102 // Posts screen
103 (new BulkEdit())->init();
104 (new BulkEditNotices())->init();
105 (new Column())->init();
106
107 // Post screen
108 (new AddPlayer())->init();
109 (new BlockAttributes())->init();
110 (new ErrorNotice())->init();
111 (new Inspect())->init();
112
113 // Post screen metabox
114 (new GenerateAudio())->init();
115 (new DisplayPlayer())->init();
116 (new SelectVoice($this->apiClient))->init();
117 (new PlayerStyle())->init();
118 (new Metabox($this->apiClient))->init();
119 }
120 }
121 }
122