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

283 lines 8.1 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-testimonial';
102 }
103
104 /**
105 * Get categories
106 */
107 public function get_categories()
108 {
109 return [ 'copy-the-code' ];
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 $author = $this->get_settings_for_display( 'author' );
128 $button_text = $this->get_settings_for_display( 'button_text' );
129 $button_text_copied = $this->get_settings_for_display( 'button_text_copied' );
130 $show_icon = $this->get_settings_for_display( 'show_icon' );
131 $icon_direction = $this->get_settings_for_display( 'icon_direction' );
132 if ( empty($message) ) {
133 return;
134 }
135 $message = wpautop( $message );
136 $with_icon = ( 'yes' === $this->get_settings_for_display( 'show_icon' ) ? 'with-icon' : '' );
137 ?>
138 <div class="ctc-block ctc-message">
139 <div class="ctc-block-content">
140 <div class="ctc-message-box">
141 <div class="ctc-message-text"><?php
142 echo wp_kses_post( $message ) ;
143 ?></div>
144 </div>
145 </div>
146 <div class="ctc-block-actions">
147 <?php
148 echo Helpers::get_copy_button( [
149 'as_raw' => 'yes',
150 'copy_button_text' => $button_text,
151 'copy_button_text_copied' => $button_text_copied,
152 'icon_direction' => $icon_direction,
153 'show_icon' => $show_icon,
154 ] ) ;
155 ?>
156 </div>
157 <textarea class="ctc-copy-content" style="display: none;"><?php
158 echo esc_html( $copy_text ) ;
159 ?></textarea>
160 </div>
161 <?php
162 }
163
164 /**
165 * Register controls
166 */
167 protected function _register_controls()
168 {
169 /**
170 * Group: Copy Text Section
171 */
172 $this->start_controls_section( 'copy_text_section', [
173 'label' => esc_html__( 'Copy to Clipboard', 'copy-the-code' ),
174 ] );
175 $this->add_control( 'copy_text', [
176 'label' => esc_html__( 'Add Text to Copy', 'copy-the-code' ),
177 'type' => Controls_Manager::TEXTAREA,
178 'default' => 'May your birthday be filled with many happy hours and your life with many happy birthdays.
179
180 HAPPY BIRTHDAY !!',
181 'rows' => 10,
182 ] );
183 $this->end_controls_section();
184 /**
185 * Group: message Section
186 */
187 $this->start_controls_section( 'message_section', [
188 'label' => esc_html__( 'Message', 'copy-the-code' ),
189 ] );
190 $this->add_control( 'message', [
191 'label' => esc_html__( 'Message', 'copy-the-code' ),
192 'type' => Controls_Manager::WYSIWYG,
193 'default' => 'May your birthday be filled with many happy hours and your life with many happy birthdays.
194
195 HAPPY BIRTHDAY !!',
196 ] );
197 // Two paragraph gap in pixcel.
198 $this->add_responsive_control( 'line_gap', [
199 'label' => esc_html__( 'Line Gap', 'copy-the-code' ),
200 'type' => Controls_Manager::SLIDER,
201 'size_units' => [ 'px', 'em' ],
202 'range' => [
203 'px' => [
204 'min' => 0,
205 'max' => 100,
206 ],
207 ],
208 'selectors' => [
209 '{{WRAPPER}} .ctc-message-text p' => 'margin-bottom: {{SIZE}}{{UNIT}};',
210 ],
211 ] );
212 $this->end_controls_section();
213 $this->button();
214 }
215
216 /**
217 * Button
218 */
219 protected function button()
220 {
221 /**
222 * Group - Button
223 */
224 $this->start_controls_section( 'button_section', [
225 'label' => esc_html__( 'Button', 'copy-the-code' ),
226 ] );
227 $this->add_control( 'button_text', [
228 'label' => esc_html__( 'Button Text', 'copy-the-code' ),
229 'type' => Controls_Manager::TEXT,
230 'default' => esc_html__( 'Copy to Clipboard', 'copy-the-code' ),
231 ] );
232 $this->add_control( 'button_text_copied', [
233 'label' => esc_html__( 'Button Text (After Copied)', 'copy-the-code' ),
234 'type' => Controls_Manager::TEXT,
235 'default' => esc_html__( 'Copied to Clipboard', 'copy-the-code' ),
236 ] );
237 // Show Icon.
238 $this->add_control( 'show_icon', [
239 'label' => esc_html__( 'Show Icon', 'copy-the-code' ),
240 'type' => Controls_Manager::SWITCHER,
241 'label_on' => esc_html__( 'Show', 'copy-the-code' ),
242 'label_off' => esc_html__( 'Hide', 'copy-the-code' ),
243 'return_value' => 'yes',
244 'default' => 'yes',
245 ] );
246 $this->add_control( 'icon_direction', [
247 'label' => esc_html__( 'Icon Direction', 'copy-the-code' ),
248 'type' => Controls_Manager::SELECT,
249 'default' => 'before',
250 'options' => [
251 'before' => esc_html__( 'Before', 'copy-the-code' ),
252 'after' => esc_html__( 'After', 'copy-the-code' ),
253 ],
254 'condition' => [
255 'show_icon' => 'yes',
256 ],
257 ] );
258 $this->add_responsive_control( 'icon_text_gap', [
259 'label' => esc_html__( 'Icon and Text Gap', 'copy-the-code' ),
260 'type' => Controls_Manager::SLIDER,
261 'size_units' => [ 'px', 'em' ],
262 'range' => [
263 'px' => [
264 'min' => 0,
265 'max' => 100,
266 ],
267 'em' => [
268 'min' => 0,
269 'max' => 10,
270 ],
271 ],
272 'selectors' => [
273 '{{WRAPPER}} .ctc-with-icon' => 'gap: {{SIZE}}{{UNIT}};',
274 ],
275 'condition' => [
276 'show_icon' => 'yes',
277 ],
278 ] );
279 $this->end_controls_section();
280 // Group - Button End.
281 }
282
283 }