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

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