PluginProbe
BeyondWords – AI audio for publishers / 4.0.6
BeyondWords – AI audio for publishers v4.0.6
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 / Beyondwords.php

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

127 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\Compatibility\Elementor\ControlsSections;
6
7
8 use Elementor\Controls_Manager;
9 use Elementor\Core\DocumentTypes\PageBase as PageBase;
10
11 use WP_Post;
12
13 use Beyondwords\Wordpress\Component\Post\PostMetaUtils;
14
15 /**
16 * BeyondWords Controls Section
17 *
18 * @codeCoverageIgnore
19 *
20 * @since 3.10.0
21 */
22 class Beyondwords
23 {
24 /**
25 * Register additional document controls.
26 *
27 * @todo replace with `$post = get_post();` with `$document->get_post();`?
28 *
29 * @param PageBase $document The PageBase document.
30 * @param string $tab The Elementor tab.
31 */
32 public static function registerControls(&$document, $tab)
33 {
34 // PageBase is the base class for documents like `post` `page` and etc.
35 if (! $document instanceof PageBase || ! $document::get_property('has_elements')) {
36 return;
37 }
38
39 $post = get_post();
40
41 if (!($post instanceof \WP_Post)) {
42 return;
43 }
44
45 $projectId = PostMetaUtils::getProjectId($post->ID);
46 $contentId = PostMetaUtils::getContentId($post->ID);
47 $generateAudio = PostMetaUtils::hasGenerateAudio($post->ID);
48 $disabled = PostMetaUtils::getDisabled($post->ID);
49
50 $document->start_controls_section(
51 'beyondwords_status_section',
52 [
53 'label' => __('BeyondWords', 'speechkit'),
54 'tab' => $tab,
55 ]
56 );
57
58 $document->add_control(
59 'control_beyondwords_project_id',
60 [
61 'label' => 'Project ID',
62 'type' => Controls_Manager::HIDDEN,
63 'default' => $projectId,
64 'render_type' => 'template',
65 ]
66 );
67
68 $document->add_control(
69 'control_beyondwords_content_id',
70 [
71 'label' => 'Content ID',
72 'type' => Controls_Manager::HIDDEN,
73 'default' => $contentId,
74 'render_type' => 'template',
75 ]
76 );
77
78 $document->add_control(
79 'control_beyondwords_generate_audio',
80 [
81 'separator' => 'none',
82 'label' => __('Generate audio', 'speechkit'),
83 'type' => Controls_Manager::SWITCHER,
84 'default' => $generateAudio ? 'yes' : '',
85 'render_type' => 'template',
86 'conditions' => [
87 'relation' => 'and',
88 'terms' => [
89 ['name' => 'control_beyondwords_content_id', 'operator' => '==', 'value' => ''],
90 ],
91 ],
92 ]
93 );
94
95 $document->add_control(
96 'control_beyondwords_player',
97 [
98 'separator' => 'none',
99 'content_id' => $contentId,
100 'project_id' => $projectId,
101 'type' => 'beyondwords_player',
102 'render_type' => 'template',
103 ]
104 );
105
106 $document->add_control(
107 'control_beyondwords_display_player',
108 [
109 'separator' => 'none',
110 'label' => __('Display player', 'speechkit'),
111 'type' => Controls_Manager::SWITCHER,
112 'default' => $disabled ? '' : 'yes',
113 'render_type' => 'template',
114 'conditions' => [
115 'relation' => 'or',
116 'terms' => [
117 ['name' => 'control_beyondwords_generate_audio', 'operator' => '==', 'value' => 'yes'],
118 ['name' => 'control_beyondwords_content_id', 'operator' => '!=', 'value' => ''],
119 ],
120 ],
121 ]
122 );
123
124 $document->end_controls_section();
125 }
126 }
127