PluginProbe
Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code / 4.0.3
Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code v4.0.3
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 4.1.1 All 78 releases
copy-the-code / classes / class-helpers.php

class-helpers.php in Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code 4.0.3, at classes/class-helpers.php

809 lines 27.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Helpers
4 *
5 * @package Copy the Code
6 * @since 1.0.0
7 */
8
9 namespace CopyTheCode;
10
11 use Elementor\Controls_Manager;
12 use Elementor\Group_Control_Background;
13 use Elementor\Group_Control_Typography;
14 use Elementor\Group_Control_Border;
15 use Elementor\Group_Control_Box_Shadow;
16
17 /**
18 * Helpers
19 *
20 * @since 1.0.0
21 */
22 class Helpers {
23 public static function get_svg_link_icon() {
24 return '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
25 <path fill="#B6BEC6" d="M8.818 8.818l.128-.121a3 3 0 014.115.12l1.06 1.061-1.414 1.415-1.06-1.061-.088-.078a1 1 0 00-1.327.078l-4.95 4.95-.077.087a1 1 0 00.078 1.327l2.12 2.121.088.078a1 1 0 001.327-.078l2.122-2.121 1.414 1.414-2.122 2.121-.128.121a3 3 0 01-4.114-.12L3.868 18.01l-.12-.128a3 3 0 01.12-4.115l4.95-4.95zm4.95-4.95l.128-.121a3 3 0 014.114.12l2.122 2.122.12.128a3 3 0 01-.12 4.115l-4.95 4.95-.128.12a3 3 0 01-4.114-.12L9.879 14.12l1.414-1.414 1.06 1.06.088.078a1 1 0 001.327-.078l4.95-4.95.077-.087a1 1 0 00-.077-1.327l-2.122-2.12-.087-.079a1 1 0 00-1.327.078l-2.121 2.121-1.414-1.414 2.12-2.121z">
26 </path>
27 </svg>';
28 }
29
30 public static function get_svg_pinterest_icon() {
31 return '<svg class="gUZ GjR U9O kVc" height="24" width="24" viewBox="0 0 24 24" aria-label="Pinterest" role="img"><path fill="#e60023" d="M0 12c0 5.123 3.211 9.497 7.73 11.218-.11-.937-.227-2.482.025-3.566.217-.932 1.401-5.938 1.401-5.938s-.357-.715-.357-1.774c0-1.66.962-2.9 2.161-2.9 1.02 0 1.512.765 1.512 1.682 0 1.025-.653 2.557-.99 3.978-.281 1.189.597 2.159 1.769 2.159 2.123 0 3.756-2.239 3.756-5.471 0-2.861-2.056-4.86-4.991-4.86-3.398 0-5.393 2.549-5.393 5.184 0 1.027.395 2.127.889 2.726a.36.36 0 0 1 .083.343c-.091.378-.293 1.189-.332 1.355-.053.218-.173.265-.4.159-1.492-.694-2.424-2.875-2.424-4.627 0-3.769 2.737-7.229 7.892-7.229 4.144 0 7.365 2.953 7.365 6.899 0 4.117-2.595 7.431-6.199 7.431-1.211 0-2.348-.63-2.738-1.373 0 0-.599 2.282-.744 2.84-.282 1.084-1.064 2.456-1.549 3.235C9.584 23.815 10.77 24 12 24c6.627 0 12-5.373 12-12S18.627 0 12 0 0 5.373 0 12"></path></svg>';
32 }
33
34 public static function get_svg_linkedin_icon() {
35 return '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
36 <path fill="#3277D4" fill-rule="evenodd" d="M21 5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2V5zm-2.5 8.2v5.3h-2.79v-4.93a1.4 1.4 0 00-1.4-1.4c-.77 0-1.39.63-1.39 1.4v4.93h-2.79v-8.37h2.79v1.11c.48-.78 1.47-1.3 2.32-1.3 1.8 0 3.26 1.46 3.26 3.26zM6.88 8.56a1.686 1.686 0 000-3.37 1.69 1.69 0 00-1.69 1.69c0 .93.76 1.68 1.69 1.68zm1.39 1.57v8.37H5.5v-8.37h2.77z" clip-rule="evenodd"></path>
37 </svg>';
38 }
39
40 public static function get_svg_twitter_icon() {
41 return '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
42 <path fill="#4BA8F5" d="M22.92 6c-.77.35-1.6.58-2.46.69.88-.53 1.56-1.37 1.88-2.38-.83.5-1.75.85-2.72 1.05C18.83 4.5 17.72 4 16.46 4c-2.35 0-4.27 1.92-4.27 4.29 0 .34.04.67.11.98-3.56-.18-6.73-1.89-8.84-4.48-.37.63-.58 1.37-.58 2.15 0 1.49.75 2.81 1.91 3.56-.71 0-1.37-.2-1.95-.5v.03c0 2.08 1.48 3.82 3.44 4.21a4.22 4.22 0 01-1.93.07 4.28 4.28 0 004 2.98 8.521 8.521 0 01-5.33 1.84c-.34 0-.68-.02-1.02-.06C3.9 20.29 6.16 21 8.58 21c7.88 0 12.21-6.54 12.21-12.21 0-.19 0-.37-.01-.56.84-.6 1.56-1.36 2.14-2.23z">
43 </path>
44 </svg>';
45 }
46
47 public static function get_svg_whatsapp_icon() {
48 return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 241.19" class="whatsapp"><path class="cls-1" fill="#25d366" d="M205,35.05A118.61,118.61,0,0,0,120.46,0C54.6,0,1,53.61,1,119.51a119.5,119.5,0,0,0,16,59.74L0,241.19l63.36-16.63a119.43,119.43,0,0,0,57.08,14.57h0A119.54,119.54,0,0,0,205,35.07v0ZM120.5,219A99.18,99.18,0,0,1,69.91,205.1l-3.64-2.17-37.6,9.85,10-36.65-2.35-3.76A99.37,99.37,0,0,1,190.79,49.27,99.43,99.43,0,0,1,120.49,219ZM175,144.54c-3-1.51-17.67-8.71-20.39-9.71s-4.72-1.51-6.75,1.51-7.72,9.71-9.46,11.72-3.49,2.27-6.45.76-12.63-4.66-24-14.84A91.1,91.1,0,0,1,91.25,113.3c-1.75-3-.19-4.61,1.33-6.07s3-3.48,4.47-5.23a19.65,19.65,0,0,0,3-5,5.51,5.51,0,0,0-.24-5.23C99,90.27,93,75.57,90.6,69.58s-4.89-5-6.73-5.14-3.73-.09-5.7-.09a11,11,0,0,0-8,3.73C67.48,71.05,59.75,78.3,59.75,93s10.69,28.88,12.19,30.9S93,156.07,123,169c7.12,3.06,12.68,4.9,17,6.32a41.18,41.18,0,0,0,18.8,1.17c5.74-.84,17.66-7.21,20.17-14.18s2.5-13,1.75-14.19-2.69-2.06-5.7-3.59l0,0Z"></path></svg>';
49 }
50
51 public static function get_svg_facebook_icon() {
52 return '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
53 <path fill="#425993" fill-rule="evenodd" d="M19 3H5a2 2 0 00-2 2v14a2 2 0 002 2h7v-7h-2v-3h2V8.5A3.5 3.5 0 0115.5 5H18v3h-2a1 1 0 00-1 1v2h3v3h-3v7h4a2 2 0 002-2V5a2 2 0 00-2-2z" clip-rule="evenodd"></path>
54 </svg>';
55 }
56
57 public static function get_svg_copy_icon() {
58 return '<svg aria-hidden="true" focusable="false" role="img" class="copy-icon" viewBox="0 0 16 16" width="16" height="16" fill="currentColor"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg>';
59 }
60
61 public static function get_svg_checked_icon() {
62 return '<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="check-icon" fill="currentColor"><path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path></svg>';
63 }
64
65 public static function get_copy_button( $args = [] ) {
66 $show_icon = isset( $args['show_icon'] ) ? $args['show_icon'] : 'yes';
67 $with_icon = 'yes' === $show_icon ? 'with-icon' : 'without-icon';
68 $as_raw = isset( $args['as_raw'] ) ? 'yes' : '';
69 $button_text = isset( $args['button_text'] ) ? $args['button_text'] : esc_html__( 'Copy to Clipboard', 'copy-the-code' );
70 $button_class = isset( $args['button_class'] ) ? $args['button_class'] : '';
71 $button_text_copied = isset( $args['button_text_copied'] ) ? $args['button_text_copied'] : esc_html__( 'Copied!', 'copy-the-code' );
72 $icon_direction = isset( $args['icon_direction'] ) ? $args['icon_direction'] : 'before';
73
74 ob_start();
75 ?>
76 <button class="ctc-block-copy ctc-<?php echo esc_attr( $with_icon ); ?>" copy-as-raw='<?php echo esc_html( $as_raw ); ?>' data-copied="<?php echo esc_html( $button_text_copied ); ?>">
77 <?php
78 if ( 'before' === $icon_direction && 'yes' === $show_icon ) {
79 echo self::get_svg_copy_icon();
80 echo self::get_svg_checked_icon();
81 }
82 echo '<span class="ctc-button-text">' . esc_html( $button_text ) . '</span>';
83 if ( 'after' === $icon_direction && 'yes' === $show_icon ) {
84 echo self::get_svg_copy_icon();
85 echo self::get_svg_checked_icon();
86 }
87 ?>
88 </button>
89 <?php
90 return ob_get_clean();
91 }
92
93 /**
94 * Is shortcode used
95 *
96 * @param string $shortcode
97 * @since 3.1.0
98 */
99 public static function is_shortcode_used( $shortcode = '' ) {
100 global $post;
101 if ( ! $post ) {
102 return false;
103 }
104
105 $found = false;
106 if ( strpos( $post->post_content, '[' . $shortcode ) !== false ) {
107 $found = true;
108 }
109
110 return $found;
111 }
112
113 /**
114 * Get categories
115 *
116 * @since 3.2.0
117 */
118 public static function get_categories() {
119 return [ 'copy-the-code', 'basic' ];
120 }
121
122 /**
123 * Get common keywords
124 *
125 * @param array $keywords New keywords.
126 * @since 3.2.0
127 */
128 public static function get_keywords( $keywords = [] ) {
129 $default = [ 'copy', 'paste', 'clipboard', 'copy clipboard', 'copy to clipboard', 'copy anything to clipboard' ];
130
131 return array_merge( $default, $keywords );
132 }
133
134 /**
135 * Register "Copy Content" Section
136 *
137 * @param object $self
138 */
139 public static function register_copy_content_section( $self, $args = [] ) {
140 $self->start_controls_section(
141 'copy_content_section',
142 [
143 'label' => esc_html__( 'Content to Copy', 'copy-the-code' ),
144 ]
145 );
146
147 if ( isset( $args['before_controls'] ) ) {
148 foreach ( $args['before_controls'] as $control_id => $options ) {
149 $self->add_control( $control_id, $options );
150 }
151 }
152
153 $self->add_control(
154 'have_selector',
155 [
156 'label' => esc_html__( 'Have Selector?', 'copy-the-code' ),
157 'type' => Controls_Manager::SWITCHER,
158 'label_on' => esc_html__( 'Yes', 'copy-the-code' ),
159 'label_off' => esc_html__( 'No', 'copy-the-code' ),
160 'return_value' => 'yes',
161 'default' => 'no',
162 ]
163 );
164
165 $self->add_control(
166 'selector',
167 [
168 'label' => esc_html__( 'Selector', 'copy-the-code' ),
169 'type' => Controls_Manager::TEXT,
170 'default' => '',
171 'condition' => [
172 'have_selector' => 'yes',
173 ],
174 ]
175 );
176
177 $self->add_control(
178 'copy_content',
179 [
180 'label' => isset( $args['label'] ) ? $args['label'] : esc_html__( 'Enter Text that Copy to Clipboard', 'copy-the-code' ),
181 'type' => Controls_Manager::TEXTAREA,
182 'default' => isset( $args['default'] ) ? $args['default'] : '',
183 'rows' => 10,
184 'condition' => [
185 'have_selector' => [ 'no', '' ],
186 ],
187 ]
188 );
189
190 if ( isset( $args['after_controls'] ) ) {
191 foreach ( $args['after_controls'] as $control_id => $options ) {
192 $self->add_control( $control_id, $options );
193 }
194 }
195
196 $self->end_controls_section();
197 }
198
199 /**
200 * Register "Copy Button" Section
201 *
202 * @param array $args
203 * @param object $self
204 */
205 public static function register_copy_button_section( $self, $args = [] ) {
206 $default = [
207 'button_text' => isset( $args['button_text'] ) ? $args['button_text'] : esc_html__( 'Copy to Clipboard', 'copy-the-code' ),
208 'button_text_copied' => isset( $args['button_text_copied'] ) ? $args['button_text_copied'] : esc_html__( 'Copied!', 'copy-the-code' ),
209 'show_icon' => 'yes',
210 'icon_direction' => 'before',
211 ];
212
213 $self->start_controls_section(
214 'copy_button_section',
215 [
216 'label' => esc_html__( 'Copy Button', 'copy-the-code' ),
217 ]
218 );
219
220 $self->add_control(
221 'copy_button_text',
222 [
223 'label' => esc_html__( 'Button Text', 'copy-the-code' ),
224 'type' => Controls_Manager::TEXT,
225 'default' => $default['button_text'],
226 ]
227 );
228
229 $self->add_control(
230 'copy_button_text_copied',
231 [
232 'label' => esc_html__( 'After Copy Text', 'copy-the-code' ),
233 'type' => Controls_Manager::TEXT,
234 'default' => $default['button_text_copied'],
235 ]
236 );
237
238 // Alignment.
239 $self->add_responsive_control(
240 'copy_button_align',
241 [
242 'label' => esc_html__( 'Alignment', 'copy-the-code' ),
243 'type' => Controls_Manager::CHOOSE,
244 'options' => [
245 'left' => [
246 'title' => esc_html__( 'Left', 'copy-the-code' ),
247 'icon' => 'eicon-text-align-left',
248 ],
249 'center' => [
250 'title' => esc_html__( 'Center', 'copy-the-code' ),
251 'icon' => 'eicon-text-align-center',
252 ],
253 'right' => [
254 'title' => esc_html__( 'Right', 'copy-the-code' ),
255 'icon' => 'eicon-text-align-right',
256 ],
257 ],
258 'selectors' => [
259 '{{WRAPPER}} .ctc-block-actions' => 'text-align: {{VALUE}};',
260 ],
261 ]
262 );
263
264 // Show Icon.
265 $self->add_control(
266 'copy_show_icon',
267 [
268 'label' => esc_html__( 'Show Icon', 'copy-the-code' ),
269 'type' => Controls_Manager::SWITCHER,
270 'label_on' => esc_html__( 'Show', 'copy-the-code' ),
271 'label_off' => esc_html__( 'Hide', 'copy-the-code' ),
272 'return_value' => 'yes',
273 'default' => 'yes',
274 ]
275 );
276
277 $self->add_control(
278 'copy_icon_direction',
279 [
280 'label' => esc_html__( 'Icon Direction', 'copy-the-code' ),
281 'type' => Controls_Manager::SELECT,
282 'default' => 'before',
283 'options' => [
284 'before' => esc_html__( 'Before', 'copy-the-code' ),
285 'after' => esc_html__( 'After', 'copy-the-code' ),
286 ],
287 'condition' => [
288 'copy_show_icon' => 'yes',
289 ],
290 ]
291 );
292
293 $self->add_responsive_control(
294 'copy_icon_text_gap',
295 [
296 'label' => esc_html__( 'Icon and Text Gap', 'copy-the-code' ),
297 'type' => Controls_Manager::SLIDER,
298 'size_units' => [ 'px', 'em' ],
299 'range' => [
300 'px' => [
301 'min' => 0,
302 'max' => 100,
303 ],
304 'em' => [
305 'min' => 0,
306 'max' => 10,
307 ],
308 ],
309 'selectors' => [
310 '{{WRAPPER}} .ctc-with-icon' => 'gap: {{SIZE}}{{UNIT}};',
311 ],
312 'condition' => [
313 'copy_show_icon' => 'yes',
314 ],
315 ]
316 );
317
318 $self->end_controls_section();
319 }
320
321 /**
322 * Register "Copy Button Style" Section
323 *
324 * @param object $self
325 */
326 public static function register_copy_button_style_section( $self ) {
327 self::register_style_section(
328 $self,
329 'Copy Button',
330 '.ctc-block-copy',
331 [
332 'text_align' => false,
333 'normal_text_color' => [
334 'selectors' => [
335 '{{WRAPPER}} .ctc-block-copy' => 'color: {{VALUE}};',
336 '{{WRAPPER}} .ctc-block-copy svg' => 'fill: {{VALUE}};',
337 ],
338 ],
339 'hover_text_color' => [
340 'selectors' => [
341 '{{WRAPPER}} .ctc-block-copy:hover' => 'color: {{VALUE}};',
342 '{{WRAPPER}} .ctc-block-copy:hover svg' => 'fill: {{VALUE}};',
343 ],
344 ],
345 ]
346 );
347 }
348
349 /**
350 * Render "Copy Button"
351 *
352 * @param object $self
353 */
354 public static function render_copy_button( $self ) {
355 $button_text = $self->get_settings_for_display( 'copy_button_text' );
356 $button_text_copied = $self->get_settings_for_display( 'copy_button_text_copied' );
357 $show_icon = $self->get_settings_for_display( 'copy_show_icon' );
358 $icon_direction = $self->get_settings_for_display( 'copy_icon_direction' );
359
360 echo self::get_copy_button(
361 [
362 'as_raw' => 'yes',
363 'button_text' => $button_text,
364 'button_text_copied' => $button_text_copied,
365 'icon_direction' => $icon_direction,
366 'show_icon' => $show_icon,
367 ]
368 );
369 }
370
371 /**
372 * Render "Copy Content"
373 *
374 * @param object $self
375 * @param array $args
376 */
377 public static function render_copy_content( $self, $args = [] ) {
378 $selection_target = '';
379 $content = isset( $args['content'] ) ? $args['content'] : $self->get_settings_for_display( 'copy_content' );
380 $have_selector = $self->get_settings_for_display( 'have_selector' );
381 if ( 'yes' === $have_selector ) {
382 $selection_target = $self->get_settings_for_display( 'selector' );
383 }
384 ?>
385 <textarea selection-target="<?php echo esc_attr( $selection_target ); ?>" class="ctc-copy-content" style="display: none;"><?php echo wp_kses_post( apply_shortcodes( $content ) ); ?></textarea>
386 <?php
387 }
388
389 /**
390 * Register "Get Pro" Section
391 *
392 * @param object $self
393 * @param array $args
394 */
395 public static function register_pro_section( $self, $label ) {
396 $id = str_replace( ' ', '-', $label );
397 $id = strtolower( $id );
398
399 $self->start_controls_section(
400 $id . '_box',
401 [
402 'label' => $label . ' (Pro)',
403 'tab' => Controls_Manager::TAB_STYLE,
404 ]
405 );
406
407 // Buy pro.
408 $self->add_control(
409 $id . '_box_content',
410 [
411 'type' => Controls_Manager::RAW_HTML,
412 'raw' => '<div style="text-align: center;"><h2 style="font-weight: 600;margin: 0 0 10px 0;font-size: 14px;">Unlock Premium Features!</h2><p style="margin: 0 0 10px 0;">Upgrade to Clipboard Pro for enhanced functionality and exclusive benefits.</p><p style="margin: 0 0 10px 0;">Ready to level up your experience?</p><a href="https://clipboard.agency/#pricing" class="button button-primary" target="_blank">See Pricing Plans</a></div>',
413 ]
414 );
415
416 $self->end_controls_section();
417 }
418
419 /**
420 * Register "Get Pro" Sections
421 *
422 * @param object $self
423 * @param array $labels
424 */
425 public static function register_pro_sections( $self, $labels = [] ) {
426 foreach ( $labels as $label ) {
427 self::register_pro_section( $self, $label );
428 }
429 }
430
431 /**
432 * Register normal and hover styles.
433 *
434 * @param object $self
435 * @param string $label
436 * @param array $args
437 */
438 public static function register_style_section( $self, $label = '', $selector = '', $args = [] ) {
439 $id = 'reusable-' . sanitize_title_with_dashes( $label );
440
441 $size = isset( $args['size'] ) ? $args['size'] : false;
442 $text_decoration = isset( $args['text_decoration'] ) ? $args['text_decoration'] : false;
443 $margin = isset( $args['margin'] ) ? $args['margin'] : true;
444 $padding = isset( $args['padding'] ) ? $args['padding'] : true;
445 $border = isset( $args['border'] ) ? $args['border'] : false; // Disabled.
446 $border_radius = isset( $args['border_radius'] ) ? $args['border_radius'] : true;
447 $background = isset( $args['background'] ) ? $args['background'] : false; // Disabled.
448 $text_color = isset( $args['text_color'] ) ? $args['text_color'] : false; // Disabled.
449 $typography = isset( $args['typography'] ) ? $args['typography'] : true;
450 $text_align = isset( $args['text_align'] ) ? $args['text_align'] : true;
451 $box_shadow = isset( $args['box_shadow'] ) ? $args['box_shadow'] : false; // Disabled.
452 $tabs = isset( $args['tabs'] ) ? $args['tabs'] : true;
453 $normal_background = isset( $args['normal_background'] ) ? $args['normal_background'] : true;
454 $normal_text_color = isset( $args['normal_text_color'] ) ? $args['normal_text_color'] : true;
455 $normal_typography = isset( $args['normal_typography'] ) ? $args['normal_typography'] : false; // Disabled.
456 $normal_border = isset( $args['normal_border'] ) ? $args['normal_border'] : true;
457 $normal_box_shadow = isset( $args['normal_box_shadow'] ) ? $args['normal_box_shadow'] : true;
458
459 // Section.
460 $self->start_controls_section(
461 $id . '_style_section',
462 [
463 'label' => $label,
464 'tab' => Controls_Manager::TAB_STYLE,
465 ]
466 );
467
468 if ( $margin ) :
469 $self->add_responsive_control(
470 $id . '_margin',
471 [
472 'label' => esc_html__( 'Margin', 'copy-the-code' ),
473 'type' => Controls_Manager::DIMENSIONS,
474 'size_units' => [ 'px', 'em', '%' ],
475 'selectors' => [
476 '{{WRAPPER}} ' . $selector => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
477 ],
478 ]
479 );
480 endif;
481
482 if ( $padding ) :
483 $self->add_responsive_control(
484 $id . '_padding',
485 [
486 'label' => esc_html__( 'Padding', 'copy-the-code' ),
487 'type' => Controls_Manager::DIMENSIONS,
488 'size_units' => [ 'px', 'em', '%' ],
489 'selectors' => [
490 '{{WRAPPER}} ' . $selector => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
491 ],
492 ]
493 );
494 endif;
495
496 if ( $border ) :
497 $border_selector = '{{WRAPPER}} ' . $selector;
498 if ( isset( $args['border'] ) && is_array( $args['border'] ) ) {
499 if ( isset( $args['border']['selector'] ) ) {
500 $border_selector = $args['border']['selector'];
501 }
502 }
503 $self->add_group_control(
504 Group_Control_Border::get_type(),
505 [
506 'name' => $id . '_border',
507 'selector' => $border_selector,
508 ]
509 );
510 endif;
511
512 if ( $border_radius ) :
513 $self->add_responsive_control(
514 $id . '_border_radius',
515 [
516 'label' => esc_html__( 'Border Radius', 'copy-the-code' ),
517 'type' => Controls_Manager::DIMENSIONS,
518 'size_units' => [ 'px', '%' ],
519 'selectors' => [
520 '{{WRAPPER}} ' . $selector => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
521 ],
522 ]
523 );
524 endif;
525
526 if ( $background ) :
527 $self->add_group_control(
528 Group_Control_Background::get_type(),
529 [
530 'name' => $id . '_background',
531 'types' => [ 'classic', 'gradient', 'image', 'video' ],
532 'selector' => '{{WRAPPER}} ' . $selector,
533 ]
534 );
535 endif;
536
537 if ( $text_color ) :
538 $self->add_control(
539 $id . '_text_color',
540 [
541 'label' => esc_html__( 'Text Color', 'copy-the-code' ),
542 'type' => Controls_Manager::COLOR,
543 'selectors' => [
544 '{{WRAPPER}} ' . $selector => 'color: {{VALUE}};',
545 ],
546 ]
547 );
548 endif;
549
550 if ( $typography ) :
551 $self->add_group_control(
552 Group_Control_Typography::get_type(),
553 [
554 'name' => $id . '_typography',
555 'selector' => '{{WRAPPER}} ' . $selector,
556 ]
557 );
558 endif;
559
560 if ( $size ) :
561 $size_label = esc_html__( 'Width', 'copy-the-code' );
562 $size_selectors = [
563 '{{WRAPPER}} ' . $selector => 'width: {{SIZE}}{{UNIT}};',
564 ];
565 if ( isset( $args['size'] ) && is_array( $args['size'] ) ) {
566 if ( isset( $args['size']['selectors'] ) ) {
567 $size_selectors = $args['size']['selectors'];
568 }
569 if ( isset( $args['size']['label'] ) ) {
570 $size_label = $args['size']['label'];
571 }
572 }
573
574 $self->add_responsive_control(
575 $id . '_size',
576 [
577 'label' => $size_label,
578 'type' => Controls_Manager::SLIDER,
579 'size_units' => [ 'px', 'em', '%' ],
580 'selectors' => $size_selectors,
581 ]
582 );
583 endif;
584
585 if ( $text_decoration ) :
586 $text_decoration_selectors = [
587 '{{WRAPPER}} ' . $selector => 'text-decoration: {{VALUE}};',
588 ];
589 if ( isset( $args['text_decoration'] ) && is_array( $args['text_decoration'] ) ) {
590 if ( isset( $args['text_decoration']['selectors'] ) ) {
591 $text_decoration_selectors = $args['text_decoration']['selectors'];
592 }
593 }
594
595 $self->add_control(
596 $id . '_text_decoration',
597 [
598 'label' => esc_html__( 'Text Decoration', 'copy-the-code' ),
599 'type' => Controls_Manager::SELECT,
600 'options' => [
601 'none' => esc_html__( 'None', 'copy-the-code' ),
602 'underline' => esc_html__( 'Underline', 'copy-the-code' ),
603 'overline' => esc_html__( 'Overline', 'copy-the-code' ),
604 'line-through' => esc_html__( 'Line Through', 'copy-the-code' ),
605 ],
606 'selectors' => $text_decoration_selectors,
607 ]
608 );
609 endif;
610
611 if ( $text_align ) :
612 $self->add_responsive_control(
613 $id . '_text_align',
614 [
615 'label' => esc_html__( 'Alignment', 'copy-the-code' ),
616 'type' => Controls_Manager::CHOOSE,
617 'options' => [
618 'left' => [
619 'title' => esc_html__( 'Left', 'copy-the-code' ),
620 'icon' => 'eicon-text-align-left',
621 ],
622 'center' => [
623 'title' => esc_html__( 'Center', 'copy-the-code' ),
624 'icon' => 'eicon-text-align-center',
625 ],
626 'right' => [
627 'title' => esc_html__( 'Right', 'copy-the-code' ),
628 'icon' => 'eicon-text-align-right',
629 ],
630 ],
631 'selectors' => [
632 '{{WRAPPER}} ' . $selector => 'text-align: {{VALUE}};',
633 ],
634 ]
635 );
636 endif;
637
638 if ( $box_shadow ) :
639 $self->add_group_control(
640 Group_Control_Box_Shadow::get_type(),
641 [
642 'name' => $id . '_box_shadow',
643 'selector' => '{{WRAPPER}} ' . $selector,
644 ]
645 );
646 endif;
647
648 if ( $tabs ) :
649 // Tabs.
650 $self->start_controls_tabs(
651 $id . '_style_tabs'
652 );
653
654 // Normal.
655 $self->start_controls_tab(
656 $id . '_style_normal_tab',
657 [
658 'label' => esc_html__( 'Normal', 'copy-the-code' ),
659 ]
660 );
661
662 if ( $normal_background ) :
663 $self->add_group_control(
664 Group_Control_Background::get_type(),
665 [
666 'name' => $id . '_normal_background',
667 'types' => [ 'classic', 'gradient', 'image', 'video' ],
668 'selector' => '{{WRAPPER}} ' . $selector,
669 ]
670 );
671 endif;
672
673 if ( $normal_text_color ) :
674 $normal_text_color_label = esc_html__( 'Text Color', 'copy-the-code' );
675 $normal_text_color_selectors = [
676 '{{WRAPPER}} ' . $selector => 'color: {{VALUE}};',
677 ];
678 if ( isset( $args['normal_text_color'] ) && is_array( $args['normal_text_color'] ) ) {
679 if ( isset( $args['normal_text_color']['selectors'] ) ) {
680 $normal_text_color_selectors = $args['normal_text_color']['selectors'];
681 }
682 if ( isset( $args['normal_text_color']['label'] ) ) {
683 $normal_text_color_label = $args['normal_text_color']['label'];
684 }
685 }
686 $self->add_control(
687 $id . '_normal_text_color',
688 [
689 'label' => $normal_text_color_label,
690 'type' => Controls_Manager::COLOR,
691 'selectors' => $normal_text_color_selectors,
692 ]
693 );
694 endif;
695
696 if ( $normal_typography ) :
697 $self->add_group_control(
698 Group_Control_Typography::get_type(),
699 [
700 'name' => $id . '_normal_typography',
701 'selector' => '{{WRAPPER}} ' . $selector,
702 ]
703 );
704 endif;
705
706 if ( $normal_border ) :
707 $self->add_group_control(
708 Group_Control_Border::get_type(),
709 [
710 'name' => $id . '_normal_border',
711 'default' => 'red',
712 'selector' => '{{WRAPPER}} ' . $selector,
713 ]
714 );
715 endif;
716
717 if ( $normal_box_shadow ) :
718 $self->add_group_control(
719 Group_Control_Box_Shadow::get_type(),
720 [
721 'name' => $id . '_normal_box_shadow',
722 'selector' => '{{WRAPPER}} ' . $selector,
723 ]
724 );
725 endif;
726
727 $self->end_controls_tab();
728 // Normal End.
729
730 // Hover.
731 $self->start_controls_tab(
732 $id . '_style_hover_tab',
733 [
734 'label' => esc_html__( 'Hover', 'copy-the-code' ),
735 ]
736 );
737
738 if ( $normal_background ) :
739 $self->add_group_control(
740 Group_Control_Background::get_type(),
741 [
742 'name' => $id . '_hover_background',
743 'types' => [ 'classic', 'gradient', 'image', 'video' ],
744 'selector' => '{{WRAPPER}} ' . $selector . ':hover',
745 ]
746 );
747 endif;
748
749 if ( $normal_text_color ) :
750
751 $hover_text_color_label = esc_html__( 'Text Color', 'copy-the-code' );
752 $hover_text_color_selectors = [
753 '{{WRAPPER}} ' . $selector => 'color: {{VALUE}};',
754 ];
755 if ( isset( $args['hover_text_color'] ) && is_array( $args['hover_text_color'] ) ) {
756 if ( isset( $args['hover_text_color']['selectors'] ) ) {
757 $hover_text_color_selectors = $args['hover_text_color']['selectors'];
758 }
759 if ( isset( $args['hover_text_color']['label'] ) ) {
760 $hover_text_color_label = $args['hover_text_color']['label'];
761 }
762 }
763
764 $self->add_control(
765 $id . '_hover_text_color',
766 [
767 'label' => $hover_text_color_label,
768 'type' => Controls_Manager::COLOR,
769 'selectors' => $hover_text_color_selectors,
770 ]
771 );
772 endif;
773
774 if ( $normal_border ) :
775 $self->add_control(
776 $id . '_hover_border',
777 [
778 'label' => esc_html__( 'Border Color', 'copy-the-code' ),
779 'type' => Controls_Manager::COLOR,
780 'selectors' => [
781 '{{WRAPPER}} ' . $selector . ':hover' => 'border-color: {{VALUE}};',
782 ],
783 ]
784 );
785 endif;
786
787 if ( $normal_box_shadow ) :
788 $self->add_group_control(
789 Group_Control_Box_Shadow::get_type(),
790 [
791 'name' => $id . '_hover_box_shadow',
792 'selector' => '{{WRAPPER}} ' . $selector . ':hover',
793 ]
794 );
795 endif;
796
797 $self->end_controls_tab();
798 // Hover End.
799
800 $self->end_controls_tabs();
801 // Tabs.
802 endif;
803
804 $self->end_controls_section();
805 // Section End.
806 }
807
808 }
809