PluginProbe
BeyondWords – AI audio for publishers / 4.2.4
BeyondWords – AI audio for publishers v4.2.4
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 / Compatibility / Elementor / ControlsSections / Inspect.php

Inspect.php in BeyondWords – AI audio for publishers 4.2.4, at src/Compatibility/Elementor/ControlsSections/Inspect.php

195 lines 5.9 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\Compatibility\Elementor\ControlsSections;
6
7 use Elementor\Controls_Manager;
8 use Elementor\Core\DocumentTypes\PageBase as PageBase;
9
10 use WP_Post;
11
12 use Beyondwords\Wordpress\Compatibility\Elementor\Controls\InspectText;
13 use Beyondwords\Wordpress\Compatibility\Elementor\Controls\InspectTextarea;
14 use Beyondwords\Wordpress\Component\Post\PostMetaUtils;
15
16 /**
17 * Inspect Controls Section
18 *
19 * @codeCoverageIgnore
20 *
21 * @since 3.10.0
22 */
23 class Inspect
24 {
25 /**
26 * Register additional document controls.
27 *
28 * @todo replace with `$post = get_post();` with `$document->get_post();`?
29 *
30 * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
31 *
32 * @param PageBase $document The PageBase document.
33 * @param string $tab The Elementor tab.
34 */
35 public static function registerControls(&$document, $tab)
36 {
37 // PageBase is the base class for documents like `post` `page` and etc.
38 if (! $document instanceof PageBase || ! $document::get_property('has_elements')) {
39 return;
40 }
41
42 $post = get_post();
43
44 if (!($post instanceof \WP_Post)) {
45 return;
46 }
47
48 $contentId = PostMetaUtils::getContentId($post->ID);
49 $languageId = PostMetaUtils::getLanguageId($post->ID);
50 $projectId = PostMetaUtils::getProjectId($post->ID);
51 $bodyVoiceId = PostMetaUtils::getBodyVoiceId($post->ID);
52 $titleVoiceId = PostMetaUtils::getTitleVoiceId($post->ID);
53 $summaryVoiceId = PostMetaUtils::getSummaryVoiceId($post->ID);
54
55 $document->start_controls_section(
56 'beyondwords_inspect_section',
57 [
58 'label' => __('Inspect', 'speechkit'),
59 'tab' => $tab,
60 ]
61 );
62
63 // post_id
64 $document->add_control(
65 'inspect_post_id',
66 [
67 'label' => 'post_id',
68 'label_block' => true,
69 'default' => $post->ID,
70 'type' => Controls_Manager::TEXT,
71 ]
72 );
73
74 // beyondwords_generate_audio
75 $document->add_control(
76 'inspect_beyondwords_generate_audio',
77 [
78 'label' => 'beyondwords_generate_audio',
79 'label_block' => true,
80 'default' => get_post_meta($post->ID, 'beyondwords_generate_audio', true),
81 'type' => Controls_Manager::TEXT,
82 ]
83 );
84
85 // beyondwords_project_id
86 $document->add_control(
87 'inspect_beyondwords_project_id',
88 [
89 'label' => 'beyondwords_project_id',
90 'label_block' => true,
91 'default' => $projectId,
92 'type' => Controls_Manager::TEXT,
93 ]
94 );
95
96 // beyondwords_content_id
97 $document->add_control(
98 'inspect_beyondwords_content_id',
99 [
100 'label' => 'beyondwords_content_id',
101 'label_block' => true,
102 'default' => $contentId,
103 'type' => Controls_Manager::TEXT,
104 ]
105 );
106
107 // beyondwords_language_id
108 $document->add_control(
109 'inspect_beyondwords_language_id',
110 [
111 'label' => 'beyondwords_language_id',
112 'label_block' => true,
113 'default' => $languageId,
114 'type' => Controls_Manager::TEXT,
115 ]
116 );
117
118 // beyondwords_body_voice_id
119 $document->add_control(
120 'inspect_beyondwords_body_voice_id',
121 [
122 'label' => 'beyondwords_body_voice_id',
123 'label_block' => true,
124 'default' => $bodyVoiceId,
125 'type' => Controls_Manager::TEXT,
126 ]
127 );
128
129 // beyondwords_title_voice_id
130 $document->add_control(
131 'inspect_beyondwords_title_voice_id',
132 [
133 'label' => 'beyondwords_title_voice_id',
134 'label_block' => true,
135 'default' => $titleVoiceId,
136 'type' => Controls_Manager::TEXT,
137 ]
138 );
139
140 // beyondwords_summary_voice_id
141 $document->add_control(
142 'inspect_beyondwords_summary_voice_id',
143 [
144 'label' => 'beyondwords_summary_voice_id',
145 'label_block' => true,
146 'default' => $summaryVoiceId,
147 'type' => Controls_Manager::TEXT,
148 ]
149 );
150
151 // beyondwords_access_key
152 $document->add_control(
153 'inspect_beyondwords_access_key',
154 [
155 'label' => 'beyondwords_access_key',
156 'label_block' => true,
157 'default' => get_post_meta($post->ID, 'beyondwords_access_key', true),
158 'type' => Controls_Manager::TEXT,
159 ]
160 );
161
162 // beyondwords_error_message
163 $document->add_control(
164 'inspect_beyondwords_error_message',
165 [
166 'label' => 'beyondwords_error_message',
167 'label_block' => true,
168 'default' => get_post_meta($post->ID, 'beyondwords_error_message', true),
169 'type' => Controls_Manager::TEXT,
170 ]
171 );
172
173 // beyondwords_disabled
174 $document->add_control(
175 'inspect_beyondwords_disabled',
176 [
177 'label' => 'beyondwords_disabled',
178 'label_block' => true,
179 'default' => get_post_meta($post->ID, 'beyondwords_disabled', true),
180 'type' => Controls_Manager::TEXT,
181 ]
182 );
183
184 $document->add_control(
185 'inspect_copy_data',
186 [
187 'text' => __('Copy', 'speechkit'),
188 'type' => Controls_Manager::BUTTON,
189 'event' => 'beyondwords:copy-inspect-data'
190 ]
191 );
192 $document->end_controls_section();
193 }
194 }
195