PluginProbe
BeyondWords – AI audio for publishers / 4.6.0
BeyondWords – AI audio for publishers v4.6.0
7.2.0 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 All 44 releases
speechkit / src / Compatibility / Elementor / ControlsSections / Beyondwords.php

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

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