PluginProbe
Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code / 3.7.0
Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code v3.7.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 / contact-information / widget.php

widget.php in Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code 3.7.0, at classes/elementor/widgets/contact-information/widget.php

379 lines 10.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Elementor Contact Information 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 * Contact Information Block
16 *
17 * @since 3.1.0
18 */
19 class ContactInformation 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-contact-information',
57 COPY_THE_CODE_URI . 'classes/elementor/widgets/contact-information/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-contact-information' ];
70 }
71
72 /**
73 * Get style dependencies
74 */
75 public function get_style_depends()
76 {
77 return [ 'ctc-blocks-core' ];
78 }
79
80 /**
81 * Get name
82 */
83 public function get_name()
84 {
85 return 'ctc_contact_information';
86 }
87
88 /**
89 * Get title
90 */
91 public function get_title()
92 {
93 return esc_html__( 'Contact Information', 'copy-the-code' );
94 }
95
96 /**
97 * Get icon
98 */
99 public function get_icon()
100 {
101 return 'eicon-menu-toggle';
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( [
118 'contact',
119 'information',
120 'copy',
121 'content',
122 'template'
123 ] );
124 }
125
126 /**
127 * Get SVG icon
128 */
129 public function get_svg_icon( $link = '' )
130 {
131 if ( strpos( $link, 'facebook' ) !== false ) {
132 return Helpers::get_svg_facebook_icon();
133 }
134 if ( strpos( $link, 'twitter' ) !== false ) {
135 return Helpers::get_svg_twitter_icon();
136 }
137 if ( strpos( $link, 'linkedin' ) !== false ) {
138 return Helpers::get_svg_linkedin_icon();
139 }
140 if ( strpos( $link, 'pinterest' ) !== false ) {
141 return Helpers::get_svg_pinterest_icon();
142 }
143 if ( strpos( $link, 'whatsapp' ) !== false ) {
144 return Helpers::get_svg_whatsapp_icon();
145 }
146 return Helpers::get_svg_link_icon();
147 }
148
149 /**
150 * Render
151 */
152 public function render()
153 {
154 $contact_heading = $this->get_settings_for_display( 'contact_heading' );
155 $contact_fields = $this->get_settings_for_display( 'contact_fields' );
156 $social_heading = $this->get_settings_for_display( 'social_heading' );
157 $social_profiles = $this->get_settings_for_display( 'social_profiles' );
158 if ( empty($contact_fields) && empty($social_profiles) && empty($contact_heading) && empty($social_heading) ) {
159 return;
160 }
161 ?>
162 <div class="ctc-block ctc-contact-information">
163 <div class="ctc-block-content">
164
165 <?php
166
167 if ( !empty($contact_heading) ) {
168 ?>
169 <div class="ctc-block-heading ctc-contact-heading">
170 <?php
171 echo esc_html( $contact_heading ) ;
172 ?>
173 </div>
174 <?php
175 }
176
177 ?>
178
179 <?php
180
181 if ( !empty($contact_fields) ) {
182 ?>
183 <div class="ctc-block-fields">
184 <?php
185 foreach ( $contact_fields as $contact_field ) {
186 ?>
187 <div class="ctc-block-field">
188 <div class="ctc-block-field-label">
189 <?php
190 echo esc_html( $contact_field['label'] ) ;
191 ?>
192 </div>
193 <div class="ctc-block-field-value">
194 <?php
195 echo do_shortcode( '[copy_inline text="' . esc_html( $contact_field['value'] ) . '"]' ) ;
196 ?>
197 </div>
198 </div>
199 <?php
200 }
201 ?>
202 </div>
203 <?php
204 }
205
206 ?>
207
208 <?php
209
210 if ( !empty($social_heading) ) {
211 ?>
212 <div class="ctc-block-heading ctc-social-heading">
213 <?php
214 echo esc_html( $social_heading ) ;
215 ?>
216 </div>
217 <?php
218 }
219
220 ?>
221
222 <?php
223
224 if ( !empty($social_profiles) ) {
225 ?>
226 <div class="ctc-block-social">
227 <?php
228 foreach ( $social_profiles as $social_profile ) {
229 ?>
230 <div class="ctc-block-social-profile-link">
231 <a href="<?php
232 echo esc_url( $social_profile['link'] ) ;
233 ?>" target="_blank" rel="nofollow noopener noreferrer">
234 <?php
235 echo $this->get_svg_icon( $social_profile['link'] ) ;
236 ?>
237 </a>
238 </div>
239 <?php
240 }
241 ?>
242 </div>
243 <?php
244 }
245
246 ?>
247
248 </div>
249 <div class="ctc-block-actions">
250 <?php
251 Helpers::render_copy_button( $this );
252 ?>
253 </div>
254 <?php
255 Helpers::render_copy_content( $this );
256 ?>
257 </div>
258 <?php
259 }
260
261 /**
262 * Register controls
263 */
264 protected function _register_controls()
265 {
266 $default = 'Contact Information
267
268 Name: John Doe
269 Email: [email protected]
270 Phone: +1 123 456 7890
271 Address: 123 Street, City, Country
272
273 Social Profiles:
274
275 https://facebook.com
276 https://twitter.com
277 https://linkedin.com';
278 Helpers::register_copy_content_section( $this, [
279 'default' => $default,
280 ] );
281 /**
282 * Group: Contact Information Section
283 */
284 $this->start_controls_section( 'fields_section', [
285 'label' => esc_html__( 'Contact Information', 'copy-the-code' ),
286 ] );
287 // Contact fields.
288 $this->add_control( 'contact_heading', [
289 'label' => esc_html__( 'Heading', 'copy-the-code' ),
290 'type' => Controls_Manager::TEXT,
291 'default' => esc_html__( 'Contact Information', 'copy-the-code' ),
292 'placeholder' => esc_html__( 'Enter your contact fields heading', 'copy-the-code' ),
293 ] );
294 // Contact fields.
295 $this->add_control( 'contact_fields', [
296 'label' => esc_html__( 'Contact Fields', 'copy-the-code' ),
297 'type' => Controls_Manager::REPEATER,
298 'fields' => [ [
299 'name' => 'label',
300 'label' => esc_html__( 'Label', 'copy-the-code' ),
301 'type' => Controls_Manager::TEXT,
302 'label_block' => true,
303 ], [
304 'name' => 'value',
305 'label' => esc_html__( 'Value', 'copy-the-code' ),
306 'type' => Controls_Manager::TEXT,
307 'label_block' => true,
308 ] ],
309 'default' => [
310 [
311 'label' => esc_html__( 'Name: ', 'copy-the-code' ),
312 'value' => 'John Doe',
313 ],
314 [
315 'label' => esc_html__( 'Email: ', 'copy-the-code' ),
316 'value' => '[email protected]',
317 ],
318 [
319 'label' => esc_html__( 'Phone: ', 'copy-the-code' ),
320 'value' => '+1 123 456 7890',
321 ],
322 [
323 'label' => esc_html__( 'Address: ', 'copy-the-code' ),
324 'value' => '123 Street, City, Country',
325 ]
326 ],
327 'title_field' => '{{{ name }}}',
328 ] );
329 $this->end_controls_section();
330 /**
331 * Group: Social Profiles Section
332 */
333 $this->start_controls_section( 'social_profiles_section', [
334 'label' => esc_html__( 'Social Profiles', 'copy-the-code' ),
335 ] );
336 // Social profiles.
337 $this->add_control( 'social_heading', [
338 'label' => esc_html__( 'Heading', 'copy-the-code' ),
339 'type' => Controls_Manager::TEXT,
340 'default' => esc_html__( 'Social Profiles', 'copy-the-code' ),
341 'placeholder' => esc_html__( 'Enter your social profiles heading', 'copy-the-code' ),
342 ] );
343 // Social profiles.
344 $this->add_control( 'social_profiles', [
345 'label' => esc_html__( 'Social Profiles', 'copy-the-code' ),
346 'type' => Controls_Manager::REPEATER,
347 'fields' => [ [
348 'name' => 'link',
349 'label' => esc_html__( 'Link', 'copy-the-code' ),
350 'type' => Controls_Manager::TEXT,
351 'label_block' => true,
352 ] ],
353 'default' => [ [
354 'link' => 'https://facebook.com',
355 ], [
356 'link' => 'https://twitter.com',
357 ], [
358 'link' => 'https://linkedin.com',
359 ] ],
360 'title_field' => '{{{ name }}}',
361 ] );
362 $this->end_controls_section();
363 Helpers::register_copy_button_section( $this, [
364 'button_text' => esc_html__( 'Copy Contact Information', 'copy-the-code' ),
365 ] );
366 Helpers::register_pro_sections( $this, [
367 'Box',
368 'Contact Heading',
369 'Contact Fields',
370 'Contact Field',
371 'Field Label',
372 'Field Value',
373 'Social Heading',
374 'Social Icon'
375 ] );
376 Helpers::register_copy_button_style_section( $this );
377 }
378
379 }