PluginProbe
Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code / 5.5.4
Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code v5.5.4
5.5.4 5.5.3 3.1.0 3.2.0 3.2.1 3.3.0 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.6.0 3.7.0 3.8.0 3.8.1 3.8.2 3.8.3 4.0.0 4.0.2 4.0.3 4.0.4 4.0.5 4.1.0 All 79 releases
copy-the-code / includes / elementor / widgets / ai-prompt-generator / widget.php

widget.php in Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code 5.5.4, at includes/elementor/widgets/ai-prompt-generator/widget.php

454 lines 14.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Elementor AI Prompt Generator Block
5 *
6 * @package CTC
7 * @since 5.0.0
8 */
9 namespace CTC\Elementor\Block\AI\Prompt;
10
11 use CTC\Helpers;
12 use Elementor\Widget_Base;
13 use Elementor\Controls_Manager;
14 /**
15 * AI Prompt Generator Block
16 *
17 * @since 5.0.0
18 */
19 class Generator extends Widget_Base {
20 /**
21 * Constructor
22 *
23 * @param array $data
24 * @param array $args
25 *
26 * @since 5.0.0
27 */
28 public function __construct( $data = [], $args = null ) {
29 parent::__construct( $data, $args );
30 // Register assets; Elementor enqueues via get_*_depends() when used.
31 wp_register_style(
32 'ctc-blocks-core',
33 CTC_URI . 'includes/assets/css/style.css',
34 [],
35 CTC_VER,
36 'all'
37 );
38 wp_register_script(
39 'ctc-lib-core',
40 CTC_URI . 'assets/frontend/js/lib/ctc.js',
41 ['jquery'],
42 CTC_VER,
43 true
44 );
45 wp_register_script(
46 'ctc-blocks-core',
47 CTC_URI . 'includes/assets/js/core.js',
48 ['ctc-lib-core'],
49 CTC_VER,
50 true
51 );
52 wp_register_script(
53 'ctc-el-ai-prompt-generator',
54 CTC_URI . 'includes/elementor/widgets/ai-prompt-generator/script.js',
55 ['jquery', 'ctc-lib-core', 'ctc-blocks-core'],
56 CTC_VER,
57 true
58 );
59 wp_register_style(
60 'ctc-el-ai-prompt-generator',
61 CTC_URI . 'includes/elementor/widgets/ai-prompt-generator/style.css',
62 ['ctc-blocks-core'],
63 CTC_VER,
64 'all'
65 );
66 }
67
68 /**
69 * Get script dependencies
70 */
71 public function get_script_depends() {
72 return ['ctc-el-ai-prompt-generator'];
73 }
74
75 /**
76 * Get style dependencies
77 */
78 public function get_style_depends() {
79 return ['ctc-el-ai-prompt-generator'];
80 }
81
82 /**
83 * Get name
84 */
85 public function get_name() {
86 return 'ctc_ai_prompt_generator';
87 }
88
89 /**
90 * Get title
91 */
92 public function get_title() {
93 return esc_html__( 'AI Prompt Generator', 'ctc' );
94 }
95
96 /**
97 * Get icon
98 */
99 public function get_icon() {
100 return 'eicon-ai';
101 }
102
103 /**
104 * Get categories
105 */
106 public function get_categories() {
107 return Helpers::get_categories();
108 }
109
110 /**
111 * Get keywords
112 */
113 public function get_keywords() {
114 return Helpers::get_keywords( [
115 'chat',
116 'gpt',
117 'chatgpt',
118 'ai',
119 'prompt',
120 'prompts',
121 'generator'
122 ] );
123 }
124
125 /**
126 * Render
127 */
128 public function render() {
129 $task = $this->get_settings_for_display( 'task' );
130 $topic = $this->get_settings_for_display( 'topic' );
131 $style = $this->get_settings_for_display( 'style' );
132 $tone = $this->get_settings_for_display( 'tone' );
133 $audience = $this->get_settings_for_display( 'audience' );
134 $length = $this->get_settings_for_display( 'length' );
135 $format = $this->get_settings_for_display( 'format' );
136 $output_heading = $this->get_settings_for_display( 'output_heading' );
137 $button_text = $this->get_settings_for_display( 'copy_button_text' );
138 $button_text_copied = $this->get_settings_for_display( 'copy_button_text_copied' );
139 $show_icon = $this->get_settings_for_display( 'copy_show_icon' );
140 $icon_direction = $this->get_settings_for_display( 'copy_icon_direction' );
141 $display_task = $this->get_settings_for_display( 'display_task' );
142 $display_topic = $this->get_settings_for_display( 'display_topic' );
143 $display_style = $this->get_settings_for_display( 'display_style' );
144 $display_tone = $this->get_settings_for_display( 'display_tone' );
145 $display_audience = $this->get_settings_for_display( 'display_audience' );
146 $display_length = $this->get_settings_for_display( 'display_length' );
147 $display_format = $this->get_settings_for_display( 'display_format' );
148 $with_icon = ( 'yes' === $this->get_settings_for_display( 'show_icon' ) ? 'with-icon' : '' );
149 ?>
150 <div class="ctc-block ctc-ai-prompt-generator">
151 <div class="ctc-block-fields">
152
153 <?php
154 if ( 'yes' === $display_task ) {
155 ?>
156 <div class="ctc-block-field">
157 <div class="ctc-block-field-label"><?php
158 echo esc_html__( 'Task', 'ctc' );
159 ?></div>
160 <div class="ctc-block-field-value"><input class="ctc-ai-prompt-generator-task" type="text" value="<?php
161 echo esc_html( $task );
162 ?>" /></div>
163 </div>
164 <?php
165 }
166 ?>
167
168 <?php
169 if ( 'yes' === $display_topic ) {
170 ?>
171 <div class="ctc-block-field">
172 <div class="ctc-block-field-label"><?php
173 echo esc_html__( 'Topic', 'ctc' );
174 ?></div>
175 <div class="ctc-block-field-value"><input class="ctc-ai-prompt-generator-topic" type="text" value="<?php
176 echo esc_html( $topic );
177 ?>" /></div>
178 </div>
179 <?php
180 }
181 ?>
182
183 <?php
184 if ( 'yes' === $display_style ) {
185 ?>
186 <div class="ctc-block-field">
187 <div class="ctc-block-field-label"><?php
188 echo esc_html__( 'Style', 'ctc' );
189 ?></div>
190 <div class="ctc-block-field-value"><input class="ctc-ai-prompt-generator-style" type="text" value="<?php
191 echo esc_html( $style );
192 ?>" /></div>
193 </div>
194 <?php
195 }
196 ?>
197
198 <?php
199 if ( 'yes' === $display_tone ) {
200 ?>
201 <div class="ctc-block-field">
202 <div class="ctc-block-field-label"><?php
203 echo esc_html__( 'Tone', 'ctc' );
204 ?></div>
205 <div class="ctc-block-field-value"><input class="ctc-ai-prompt-generator-tone" type="text" value="<?php
206 echo esc_html( $tone );
207 ?>" /></div>
208 </div>
209 <?php
210 }
211 ?>
212
213 <?php
214 if ( 'yes' === $display_audience ) {
215 ?>
216 <div class="ctc-block-field">
217 <div class="ctc-block-field-label"><?php
218 echo esc_html__( 'Audience', 'ctc' );
219 ?></div>
220 <div class="ctc-block-field-value"><input class="ctc-ai-prompt-generator-audience" type="text" value="<?php
221 echo esc_html( $audience );
222 ?>" /></div>
223 </div>
224 <?php
225 }
226 ?>
227
228 <?php
229 if ( 'yes' === $display_length ) {
230 ?>
231 <div class="ctc-block-field">
232 <div class="ctc-block-field-label"><?php
233 echo esc_html__( 'Length', 'ctc' );
234 ?></div>
235 <div class="ctc-block-field-value"><input class="ctc-ai-prompt-generator-length" type="text" value="<?php
236 echo esc_html( $length );
237 ?>" /></div>
238 </div>
239 <?php
240 }
241 ?>
242
243 <?php
244 if ( 'yes' === $display_format ) {
245 ?>
246 <div class="ctc-block-field">
247 <div class="ctc-block-field-label"><?php
248 echo esc_html__( 'Format', 'ctc' );
249 ?></div>
250 <div class="ctc-block-field-value"><input class="ctc-ai-prompt-generator-format" type="text" value="<?php
251 echo esc_html( $format );
252 ?>" /></div>
253 </div>
254 <?php
255 }
256 ?>
257
258 </div>
259 <div class="ctc-block-content">
260 <h3 class="ctc-ai-prompt-heading"><?php
261 echo esc_html( $output_heading );
262 ?></h3>
263 <textarea class="ctc-ai-prompt-generator-textarea" placeholder="Enter your prompt here..."></textarea>
264 </div>
265 <div class="ctc-block-actions">
266 <?php
267 echo Helpers::get_copy_button( [
268 'show_icon' => $show_icon,
269 'as_raw' => 'yes',
270 'button_text' => $button_text,
271 'button_class' => 'ctc-ai-generator-button',
272 'button_text_copied' => $button_text_copied,
273 'icon_direction' => $icon_direction,
274 ] );
275 ?>
276 </div>
277 </div>
278 <?php
279 }
280
281 /**
282 * Register controls
283 */
284 protected function _register_controls() {
285 /**
286 * Group: Task
287 */
288 $this->start_controls_section( 'prompt_fields', [
289 'label' => esc_html__( 'Prompt Fields', 'ctc' ),
290 ] );
291 $this->add_control( 'display_task', [
292 'label' => esc_html__( 'Display Task Field', 'ctc' ),
293 'type' => Controls_Manager::SWITCHER,
294 'label_on' => esc_html__( 'Show', 'ctc' ),
295 'label_off' => esc_html__( 'Hide', 'ctc' ),
296 'return_value' => 'yes',
297 'default' => 'yes',
298 ] );
299 $this->add_control( 'task', [
300 'label' => esc_html__( 'Task', 'ctc' ),
301 'type' => Controls_Manager::TEXT,
302 'default' => 'Write a cold email',
303 'placeholder' => esc_html__( 'E.g. Write a cold email, Write a sales email, etc.', 'ctc' ),
304 'condition' => [
305 'display_task' => 'yes',
306 ],
307 ] );
308 /**
309 * Group: Topic
310 */
311 $this->add_control( 'display_topic', [
312 'label' => esc_html__( 'Display Topic Field', 'ctc' ),
313 'type' => Controls_Manager::SWITCHER,
314 'label_on' => esc_html__( 'Show', 'ctc' ),
315 'label_off' => esc_html__( 'Hide', 'ctc' ),
316 'return_value' => 'yes',
317 'default' => 'yes',
318 ] );
319 $this->add_control( 'topic', [
320 'label' => esc_html__( 'Topic', 'ctc' ),
321 'type' => Controls_Manager::TEXT,
322 'default' => 'Job Application',
323 'placeholder' => esc_html__( 'E.g. Job Application, Sales, etc.', 'ctc' ),
324 'condition' => [
325 'display_topic' => 'yes',
326 ],
327 ] );
328 /**
329 * Group: Style
330 */
331 $this->add_control( 'display_style', [
332 'label' => esc_html__( 'Display Style Field', 'ctc' ),
333 'type' => Controls_Manager::SWITCHER,
334 'label_on' => esc_html__( 'Show', 'ctc' ),
335 'label_off' => esc_html__( 'Hide', 'ctc' ),
336 'return_value' => 'yes',
337 'default' => 'yes',
338 ] );
339 $this->add_control( 'style', [
340 'label' => esc_html__( 'Style', 'ctc' ),
341 'type' => Controls_Manager::TEXT,
342 'default' => 'Business',
343 'placeholder' => esc_html__( 'E.g. Academic, Business, Informative, etc.', 'ctc' ),
344 'condition' => [
345 'display_style' => 'yes',
346 ],
347 ] );
348 /**
349 * Group: Tone
350 */
351 $this->add_control( 'display_tone', [
352 'label' => esc_html__( 'Display Tone Field', 'ctc' ),
353 'type' => Controls_Manager::SWITCHER,
354 'label_on' => esc_html__( 'Show', 'ctc' ),
355 'label_off' => esc_html__( 'Hide', 'ctc' ),
356 'return_value' => 'yes',
357 'default' => 'yes',
358 ] );
359 $this->add_control( 'tone', [
360 'label' => esc_html__( 'Tone', 'ctc' ),
361 'type' => Controls_Manager::TEXT,
362 'default' => 'Formal',
363 'placeholder' => esc_html__( 'E.g. Formal, Informal, Empathetic, Confident, etc.', 'ctc' ),
364 'condition' => [
365 'display_tone' => 'yes',
366 ],
367 ] );
368 /**
369 * Group: Audience
370 */
371 $this->add_control( 'display_audience', [
372 'label' => esc_html__( 'Display Audience Field', 'ctc' ),
373 'type' => Controls_Manager::SWITCHER,
374 'label_on' => esc_html__( 'Show', 'ctc' ),
375 'label_off' => esc_html__( 'Hide', 'ctc' ),
376 'return_value' => 'yes',
377 'default' => 'yes',
378 ] );
379 $this->add_control( 'audience', [
380 'label' => esc_html__( 'Audience', 'ctc' ),
381 'type' => Controls_Manager::TEXT,
382 'default' => 'Hiring Manager',
383 'placeholder' => esc_html__( 'E.g. Hiring Manager, CEO, College Student, etc.', 'ctc' ),
384 'condition' => [
385 'display_audience' => 'yes',
386 ],
387 ] );
388 /**
389 * Group: Length
390 */
391 $this->add_control( 'display_length', [
392 'label' => esc_html__( 'Display Length Field', 'ctc' ),
393 'type' => Controls_Manager::SWITCHER,
394 'label_on' => esc_html__( 'Show', 'ctc' ),
395 'label_off' => esc_html__( 'Hide', 'ctc' ),
396 'return_value' => 'yes',
397 'default' => 'yes',
398 ] );
399 $this->add_control( 'length', [
400 'label' => esc_html__( 'Length', 'ctc' ),
401 'type' => Controls_Manager::TEXT,
402 'default' => '1 paragraph',
403 'placeholder' => esc_html__( 'E.g. 1 paragraph, 20 words, 500 words, etc.', 'ctc' ),
404 'condition' => [
405 'display_length' => 'yes',
406 ],
407 ] );
408 /**
409 * Group: Format
410 */
411 $this->add_control( 'display_format', [
412 'label' => esc_html__( 'Display Format Field', 'ctc' ),
413 'type' => Controls_Manager::SWITCHER,
414 'label_on' => esc_html__( 'Show', 'ctc' ),
415 'label_off' => esc_html__( 'Hide', 'ctc' ),
416 'return_value' => 'yes',
417 'default' => 'yes',
418 ] );
419 $this->add_control( 'format', [
420 'label' => esc_html__( 'Format', 'ctc' ),
421 'type' => Controls_Manager::TEXT,
422 'default' => 'Text',
423 'placeholder' => esc_html__( 'E.g. Text, HTML, JSON, Markup, etc.', 'ctc' ),
424 'condition' => [
425 'display_format' => 'yes',
426 ],
427 ] );
428 $this->end_controls_section();
429 /**
430 * Group: Prompt Output
431 */
432 $this->start_controls_section( 'prompt_output_section', [
433 'label' => esc_html__( 'Prompt Output', 'ctc' ),
434 ] );
435 $this->add_control( 'output_heading', [
436 'label' => esc_html__( 'Heading', 'ctc' ),
437 'type' => Controls_Manager::TEXT,
438 'default' => esc_html__( 'Generated prompt:', 'ctc' ),
439 ] );
440 $this->end_controls_section();
441 Helpers::register_copy_button_section( $this, [
442 'button_text' => esc_html__( 'Copy Prompt', 'ctc' ),
443 ] );
444 Helpers::register_pro_sections( $this, [
445 'Prompt Form',
446 'Heading',
447 'Input Fields',
448 'Textarea'
449 ] );
450 Helpers::register_copy_button_style_section( $this );
451 }
452
453 }
454