PluginProbe
Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code / 3.3.0
Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code v3.3.0
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 / elementor / widgets / message / widget.php

widget.php in Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code 3.3.0, at classes/elementor/widgets/message/widget.php

404 lines 13.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Elementor Message Block
5 *
6 * @package Copy the Code
7 * @since 3.1.0
8 */
9 namespace CopyTheCode\Elementor\Block;
10
11 use CopyTheCode\Helpers ;
12 use Elementor\Widget_Base ;
13 use Elementor\Controls_Manager ;
14 /**
15 * Message Block
16 *
17 * @since 3.1.0
18 */
19 class Message extends Widget_Base
20 {
21 /**
22 * Constructor
23 *
24 * @param array $data
25 * @param array $args
26 *
27 * @since 3.1.0
28 */
29 public function __construct( $data = array(), $args = null )
30 {
31 parent::__construct( $data, $args );
32 // Core.
33 wp_enqueue_style(
34 'ctc-blocks-core',
35 COPY_THE_CODE_URI . 'classes/blocks/assets/css/style.css',
36 [],
37 COPY_THE_CODE_VER,
38 'all'
39 );
40 wp_enqueue_script(
41 'ctc-clipboard',
42 COPY_THE_CODE_URI . 'assets/js/clipboard.js',
43 [ 'jquery' ],
44 COPY_THE_CODE_VER,
45 true
46 );
47 wp_enqueue_script(
48 'ctc-blocks-core',
49 COPY_THE_CODE_URI . 'classes/blocks/assets/js/core.js',
50 [ 'ctc-clipboard' ],
51 COPY_THE_CODE_VER,
52 true
53 );
54 // Block.
55 wp_enqueue_style(
56 'ctc-el-message',
57 COPY_THE_CODE_URI . 'classes/elementor/widgets/message/style.css',
58 [ 'ctc-blocks-core' ],
59 COPY_THE_CODE_VER,
60 'all'
61 );
62 }
63
64 /**
65 * Get script dependencies
66 */
67 public function get_script_depends()
68 {
69 return [ 'ctc-el-message' ];
70 }
71
72 /**
73 * Get style dependencies
74 */
75 public function get_style_depends()
76 {
77 return [ 'ctc-clipboard', 'ctc-blocks-core' ];
78 }
79
80 /**
81 * Get name
82 */
83 public function get_name()
84 {
85 return 'ctc_message';
86 }
87
88 /**
89 * Get title
90 */
91 public function get_title()
92 {
93 return esc_html__( 'Message', 'copy-the-code' );
94 }
95
96 /**
97 * Get icon
98 */
99 public function get_icon()
100 {
101 return 'eicon-columns';
102 }
103
104 /**
105 * Get categories
106 */
107 public function get_categories()
108 {
109 return Helpers::get_categories();
110 }
111
112 /**
113 * Get keywords
114 */
115 public function get_keywords()
116 {
117 return Helpers::get_keywords( [ 'message' ] );
118 }
119
120 /**
121 * Render
122 */
123 public function render()
124 {
125 $message = $this->get_settings_for_display( 'message' );
126 $copy_text = $this->get_settings_for_display( 'copy_text' );
127 $button_text = $this->get_settings_for_display( 'button_text' );
128 $button_text_copied = $this->get_settings_for_display( 'button_text_copied' );
129 $show_icon = $this->get_settings_for_display( 'show_icon' );
130 $icon_direction = $this->get_settings_for_display( 'icon_direction' );
131 if ( empty($message) ) {
132 return;
133 }
134 $message = wpautop( $message );
135 ?>
136 <div class="ctc-block ctc-message">
137 <div class="ctc-block-content">
138 <div class="ctc-message-box">
139 <div class="ctc-message-text"><?php
140 echo wp_kses_post( $message ) ;
141 ?></div>
142 </div>
143 </div>
144 <div class="ctc-block-actions">
145 <?php
146 echo Helpers::get_copy_button( [
147 'as_raw' => 'yes',
148 'copy_button_text' => $button_text,
149 'copy_button_text_copied' => $button_text_copied,
150 'icon_direction' => $icon_direction,
151 'show_icon' => $show_icon,
152 ] ) ;
153 ?>
154 </div>
155 <textarea class="ctc-copy-content" style="display: none;"><?php
156 echo esc_html( $copy_text ) ;
157 ?></textarea>
158 </div>
159 <?php
160 }
161
162 /**
163 * Register controls
164 */
165 protected function _register_controls()
166 {
167 /**
168 * Group: Copy Text Section
169 */
170 $this->start_controls_section( 'copy_text_section', [
171 'label' => esc_html__( 'Copy to Clipboard', 'copy-the-code' ),
172 ] );
173 $this->add_control( 'copy_text', [
174 'label' => esc_html__( 'Add Text to Copy', 'copy-the-code' ),
175 'type' => Controls_Manager::TEXTAREA,
176 'default' => 'May your birthday be filled with many happy hours and your life with many happy birthdays.
177
178 HAPPY BIRTHDAY !!',
179 'rows' => 10,
180 ] );
181 $this->end_controls_section();
182 /**
183 * Group: message Section
184 */
185 $this->start_controls_section( 'message_section', [
186 'label' => esc_html__( 'Message', 'copy-the-code' ),
187 ] );
188 $this->add_control( 'message', [
189 'label' => esc_html__( 'Message', 'copy-the-code' ),
190 'type' => Controls_Manager::WYSIWYG,
191 'default' => 'May your birthday be filled with many happy hours and your life with many happy birthdays.
192
193 HAPPY BIRTHDAY !!',
194 ] );
195 // Two paragraph gap in pixcel.
196 $this->add_responsive_control( 'line_gap', [
197 'label' => esc_html__( 'Line Gap', 'copy-the-code' ),
198 'type' => Controls_Manager::SLIDER,
199 'size_units' => [ 'px', 'em' ],
200 'range' => [
201 'px' => [
202 'min' => 0,
203 'max' => 100,
204 ],
205 ],
206 'selectors' => [
207 '{{WRAPPER}} .ctc-message-text p' => 'margin-bottom: {{SIZE}}{{UNIT}};',
208 ],
209 ] );
210 $this->end_controls_section();
211 $this->button();
212 $this->button_style();
213 }
214
215 /**
216 * Button
217 */
218 protected function button()
219 {
220 /**
221 * Group - Button
222 */
223 $this->start_controls_section( 'button_section', [
224 'label' => esc_html__( 'Button', 'copy-the-code' ),
225 ] );
226 $this->add_control( 'button_text', [
227 'label' => esc_html__( 'Button Text', 'copy-the-code' ),
228 'type' => Controls_Manager::TEXT,
229 'default' => esc_html__( 'Copy to Clipboard', 'copy-the-code' ),
230 ] );
231 $this->add_control( 'button_text_copied', [
232 'label' => esc_html__( 'Button Text (After Copied)', 'copy-the-code' ),
233 'type' => Controls_Manager::TEXT,
234 'default' => esc_html__( 'Copied to Clipboard', 'copy-the-code' ),
235 ] );
236 // Show Icon.
237 $this->add_control( 'show_icon', [
238 'label' => esc_html__( 'Show Icon', 'copy-the-code' ),
239 'type' => Controls_Manager::SWITCHER,
240 'label_on' => esc_html__( 'Show', 'copy-the-code' ),
241 'label_off' => esc_html__( 'Hide', 'copy-the-code' ),
242 'return_value' => 'yes',
243 'default' => 'yes',
244 ] );
245 $this->add_control( 'icon_direction', [
246 'label' => esc_html__( 'Icon Direction', 'copy-the-code' ),
247 'type' => Controls_Manager::SELECT,
248 'default' => 'before',
249 'options' => [
250 'before' => esc_html__( 'Before', 'copy-the-code' ),
251 'after' => esc_html__( 'After', 'copy-the-code' ),
252 ],
253 'condition' => [
254 'show_icon' => 'yes',
255 ],
256 ] );
257 $this->add_responsive_control( 'icon_text_gap', [
258 'label' => esc_html__( 'Icon and Text Gap', 'copy-the-code' ),
259 'type' => Controls_Manager::SLIDER,
260 'size_units' => [ 'px', 'em' ],
261 'range' => [
262 'px' => [
263 'min' => 0,
264 'max' => 100,
265 ],
266 'em' => [
267 'min' => 0,
268 'max' => 10,
269 ],
270 ],
271 'selectors' => [
272 '{{WRAPPER}} .ctc-with-icon' => 'gap: {{SIZE}}{{UNIT}};',
273 ],
274 'condition' => [
275 'show_icon' => 'yes',
276 ],
277 ] );
278 $this->end_controls_section();
279 // Group - Button End.
280 }
281
282 /**
283 * Button Style
284 */
285 protected function button_style()
286 {
287 $this->start_controls_section( 'button_style_section', [
288 'label' => esc_html__( 'Button', 'copy-the-code' ),
289 'tab' => Controls_Manager::TAB_STYLE,
290 ] );
291 $this->add_control( 'button_align', [
292 'label' => esc_html__( 'Alignment', 'copy-the-code' ),
293 'type' => \Elementor\Controls_Manager::SELECT,
294 'default' => 'left',
295 'options' => [
296 '' => esc_html__( 'Default', 'copy-the-code' ),
297 'left' => esc_html__( 'Left', 'copy-the-code' ),
298 'center' => esc_html__( 'Center', 'copy-the-code' ),
299 'right' => esc_html__( 'Right', 'copy-the-code' ),
300 ],
301 'selectors' => [
302 '{{WRAPPER}} .ctc-block-actions' => 'text-align: {{VALUE}};',
303 ],
304 ] );
305 // Tabs.
306 $this->start_controls_tabs( 'button_style_tabs' );
307 // button Style Normal.
308 $this->start_controls_tab( 'button_style_normal_tab', [
309 'label' => esc_html__( 'Normal', 'copy-the-code' ),
310 ] );
311 $this->add_group_control( \Elementor\Group_Control_Background::get_type(), [
312 'name' => 'button_normal_background',
313 'types' => [ 'classic', 'gradient' ],
314 'selector' => '{{WRAPPER}} .ctc-block-copy',
315 'exclude' => [ 'image' ],
316 ] );
317 $this->add_control( 'button_normal_text_color', [
318 'label' => esc_html__( 'Text Color', 'copy-the-code' ),
319 'type' => Controls_Manager::COLOR,
320 'selectors' => [
321 '{{WRAPPER}} .ctc-block-copy' => 'color: {{VALUE}};',
322 '{{WRAPPER}} .ctc-block-copy svg' => 'fill: {{VALUE}};',
323 ],
324 ] );
325 $this->add_group_control( \Elementor\Group_Control_Typography::get_type(), [
326 'name' => 'button_normal_typography',
327 'selector' => '{{WRAPPER}} .ctc-block-copy',
328 ] );
329 $this->add_group_control( \Elementor\Group_Control_Border::get_type(), [
330 'name' => 'button_normal_border',
331 'selector' => '{{WRAPPER}} .ctc-block-copy',
332 ] );
333 $this->add_group_control( \Elementor\Group_Control_Box_Shadow::get_type(), [
334 'name' => 'button_normal_box_shadow',
335 'selector' => '{{WRAPPER}} .ctc-block-copy',
336 ] );
337 $this->end_controls_tab();
338 // button Style Normal End.
339 // button Style Hover.
340 $this->start_controls_tab( 'button_style_hover_tab', [
341 'label' => esc_html__( 'Hover', 'copy-the-code' ),
342 ] );
343 $this->add_group_control( \Elementor\Group_Control_Background::get_type(), [
344 'name' => 'button_hover_background',
345 'types' => [ 'classic', 'gradient' ],
346 'selector' => '{{WRAPPER}} .ctc-block-copy:hover',
347 'exclude' => [ 'image' ],
348 ] );
349 $this->add_control( 'button_hover_text_color', [
350 'label' => esc_html__( 'Text Color', 'copy-the-code' ),
351 'type' => Controls_Manager::COLOR,
352 'selectors' => [
353 '{{WRAPPER}} .ctc-block-copy:hover' => 'color: {{VALUE}};',
354 '{{WRAPPER}} .ctc-block-copy:hover svg' => 'fill: {{VALUE}};',
355 ],
356 ] );
357 // $this->add_group_control(
358 // \Elementor\Group_Control_Typography::get_type(),
359 // [
360 // 'name' => 'button_hover_typography',
361 // 'selector' => '{{WRAPPER}} .ctc-block-copy:hover',
362 // ]
363 // );
364 $this->add_group_control( \Elementor\Group_Control_Border::get_type(), [
365 'name' => 'button_hover_border',
366 'selector' => '{{WRAPPER}} .ctc-block-copy:hover',
367 ] );
368 $this->add_group_control( \Elementor\Group_Control_Box_Shadow::get_type(), [
369 'name' => 'button_hover_box_shadow',
370 'selector' => '{{WRAPPER}} .ctc-block-copy:hover',
371 ] );
372 $this->end_controls_tab();
373 // button Style Hover End.
374 $this->end_controls_tabs();
375 // button Tabs.
376 $this->add_responsive_control( 'button_border_radius', [
377 'label' => esc_html__( 'Border Radius', 'copy-the-code' ),
378 'type' => Controls_Manager::DIMENSIONS,
379 'size_units' => [ 'px', '%' ],
380 'selectors' => [
381 '{{WRAPPER}} .ctc-block-copy' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
382 ],
383 ] );
384 $this->add_responsive_control( 'button_padding', [
385 'label' => esc_html__( 'Padding', 'copy-the-code' ),
386 'type' => Controls_Manager::DIMENSIONS,
387 'size_units' => [ 'px', 'em', '%' ],
388 'selectors' => [
389 '{{WRAPPER}} .ctc-block-copy' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
390 ],
391 ] );
392 $this->add_responsive_control( 'button_margin', [
393 'label' => esc_html__( 'Margin', 'copy-the-code' ),
394 'type' => Controls_Manager::DIMENSIONS,
395 'size_units' => [ 'px', 'em', '%' ],
396 'selectors' => [
397 '{{WRAPPER}} .ctc-block-copy' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
398 ],
399 ] );
400 $this->end_controls_section();
401 // button Style Section End.
402 }
403
404 }