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

360 lines 10.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 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 * Constructor
22 *
23 * @param array $data
24 * @param array $args
25 *
26 * @since 3.1.0
27 */
28 public function __construct( $data = [], $args = null ) {
29 parent::__construct( $data, $args );
30 // Core.
31 wp_enqueue_style(
32 'ctc-blocks-core',
33 COPY_THE_CODE_URI . 'classes/blocks/assets/css/style.css',
34 [],
35 COPY_THE_CODE_VER,
36 'all'
37 );
38 wp_enqueue_script(
39 'ctc-clipboard',
40 COPY_THE_CODE_URI . 'assets/js/clipboard.js',
41 ['jquery'],
42 COPY_THE_CODE_VER,
43 true
44 );
45 wp_enqueue_script(
46 'ctc-blocks-core',
47 COPY_THE_CODE_URI . 'classes/blocks/assets/js/core.js',
48 ['ctc-clipboard'],
49 COPY_THE_CODE_VER,
50 true
51 );
52 // Block.
53 wp_enqueue_style(
54 'ctc-el-contact-information',
55 COPY_THE_CODE_URI . 'classes/elementor/widgets/contact-information/style.css',
56 ['ctc-blocks-core'],
57 COPY_THE_CODE_VER,
58 'all'
59 );
60 }
61
62 /**
63 * Get script dependencies
64 */
65 public function get_script_depends() {
66 return ['ctc-el-contact-information'];
67 }
68
69 /**
70 * Get style dependencies
71 */
72 public function get_style_depends() {
73 return ['ctc-blocks-core'];
74 }
75
76 /**
77 * Get name
78 */
79 public function get_name() {
80 return 'ctc_contact_information';
81 }
82
83 /**
84 * Get title
85 */
86 public function get_title() {
87 return esc_html__( 'Contact Information', 'copy-the-code' );
88 }
89
90 /**
91 * Get icon
92 */
93 public function get_icon() {
94 return 'eicon-menu-toggle';
95 }
96
97 /**
98 * Get categories
99 */
100 public function get_categories() {
101 return Helpers::get_categories();
102 }
103
104 /**
105 * Get keywords
106 */
107 public function get_keywords() {
108 return Helpers::get_keywords( [
109 'contact',
110 'information',
111 'copy',
112 'content',
113 'template'
114 ] );
115 }
116
117 /**
118 * Get SVG icon
119 */
120 public function get_svg_icon( $link = '' ) {
121 if ( strpos( $link, 'facebook' ) !== false ) {
122 return Helpers::get_svg_facebook_icon();
123 }
124 if ( strpos( $link, 'twitter' ) !== false ) {
125 return Helpers::get_svg_twitter_icon();
126 }
127 if ( strpos( $link, 'linkedin' ) !== false ) {
128 return Helpers::get_svg_linkedin_icon();
129 }
130 if ( strpos( $link, 'pinterest' ) !== false ) {
131 return Helpers::get_svg_pinterest_icon();
132 }
133 if ( strpos( $link, 'whatsapp' ) !== false ) {
134 return Helpers::get_svg_whatsapp_icon();
135 }
136 return Helpers::get_svg_link_icon();
137 }
138
139 /**
140 * Render
141 */
142 public function render() {
143 $contact_heading = $this->get_settings_for_display( 'contact_heading' );
144 $contact_fields = $this->get_settings_for_display( 'contact_fields' );
145 $social_heading = $this->get_settings_for_display( 'social_heading' );
146 $social_profiles = $this->get_settings_for_display( 'social_profiles' );
147 if ( empty( $contact_fields ) && empty( $social_profiles ) && empty( $contact_heading ) && empty( $social_heading ) ) {
148 return;
149 }
150 ?>
151 <div class="ctc-block ctc-contact-information">
152 <div class="ctc-block-content">
153
154 <?php
155 if ( !empty( $contact_heading ) ) {
156 ?>
157 <div class="ctc-block-heading ctc-contact-heading">
158 <?php
159 echo esc_html( $contact_heading );
160 ?>
161 </div>
162 <?php
163 }
164 ?>
165
166 <?php
167 if ( !empty( $contact_fields ) ) {
168 ?>
169 <div class="ctc-block-fields">
170 <?php
171 foreach ( $contact_fields as $contact_field ) {
172 ?>
173 <div class="ctc-block-field">
174 <div class="ctc-block-field-label">
175 <?php
176 echo esc_html( $contact_field['label'] );
177 ?>
178 </div>
179 <div class="ctc-block-field-value">
180 <?php
181 echo do_shortcode( '[copy_inline text="' . esc_html( $contact_field['value'] ) . '"]' );
182 ?>
183 </div>
184 </div>
185 <?php
186 }
187 ?>
188 </div>
189 <?php
190 }
191 ?>
192
193 <?php
194 if ( !empty( $social_heading ) ) {
195 ?>
196 <div class="ctc-block-heading ctc-social-heading">
197 <?php
198 echo esc_html( $social_heading );
199 ?>
200 </div>
201 <?php
202 }
203 ?>
204
205 <?php
206 if ( !empty( $social_profiles ) ) {
207 ?>
208 <div class="ctc-block-social">
209 <?php
210 foreach ( $social_profiles as $social_profile ) {
211 ?>
212 <div class="ctc-block-social-profile-link">
213 <a href="<?php
214 echo esc_url( $social_profile['link'] );
215 ?>" target="_blank" rel="nofollow noopener noreferrer">
216 <?php
217 echo $this->get_svg_icon( $social_profile['link'] );
218 ?>
219 </a>
220 </div>
221 <?php
222 }
223 ?>
224 </div>
225 <?php
226 }
227 ?>
228
229 </div>
230 <div class="ctc-block-actions">
231 <?php
232 Helpers::render_copy_button( $this );
233 ?>
234 </div>
235 <?php
236 Helpers::render_copy_content( $this );
237 ?>
238 </div>
239 <?php
240 }
241
242 /**
243 * Register controls
244 */
245 protected function _register_controls() {
246 $default = 'Contact Information
247
248 Name: John Doe
249 Email: contact@clipboard.agency
250 Phone: +1 123 456 7890
251 Address: 123 Street, City, Country
252
253 Social Profiles:
254
255 https://facebook.com
256 https://twitter.com
257 https://linkedin.com';
258 Helpers::register_copy_content_section( $this, [
259 'default' => $default,
260 ] );
261 /**
262 * Group: Contact Information Section
263 */
264 $this->start_controls_section( 'fields_section', [
265 'label' => esc_html__( 'Contact Information', 'copy-the-code' ),
266 ] );
267 // Contact fields.
268 $this->add_control( 'contact_heading', [
269 'label' => esc_html__( 'Heading', 'copy-the-code' ),
270 'type' => Controls_Manager::TEXT,
271 'default' => esc_html__( 'Contact Information', 'copy-the-code' ),
272 'placeholder' => esc_html__( 'Enter your contact fields heading', 'copy-the-code' ),
273 ] );
274 // Contact fields.
275 $this->add_control( 'contact_fields', [
276 'label' => esc_html__( 'Contact Fields', 'copy-the-code' ),
277 'type' => Controls_Manager::REPEATER,
278 'fields' => [[
279 'name' => 'label',
280 'label' => esc_html__( 'Label', 'copy-the-code' ),
281 'type' => Controls_Manager::TEXT,
282 'label_block' => true,
283 ], [
284 'name' => 'value',
285 'label' => esc_html__( 'Value', 'copy-the-code' ),
286 'type' => Controls_Manager::TEXT,
287 'label_block' => true,
288 ]],
289 'default' => [
290 [
291 'label' => esc_html__( 'Name: ', 'copy-the-code' ),
292 'value' => 'John Doe',
293 ],
294 [
295 'label' => esc_html__( 'Email: ', 'copy-the-code' ),
296 'value' => 'contact@clipboard.agency',
297 ],
298 [
299 'label' => esc_html__( 'Phone: ', 'copy-the-code' ),
300 'value' => '+1 123 456 7890',
301 ],
302 [
303 'label' => esc_html__( 'Address: ', 'copy-the-code' ),
304 'value' => '123 Street, City, Country',
305 ]
306 ],
307 'title_field' => '{{{ name }}}',
308 ] );
309 $this->end_controls_section();
310 /**
311 * Group: Social Profiles Section
312 */
313 $this->start_controls_section( 'social_profiles_section', [
314 'label' => esc_html__( 'Social Profiles', 'copy-the-code' ),
315 ] );
316 // Social profiles.
317 $this->add_control( 'social_heading', [
318 'label' => esc_html__( 'Heading', 'copy-the-code' ),
319 'type' => Controls_Manager::TEXT,
320 'default' => esc_html__( 'Social Profiles', 'copy-the-code' ),
321 'placeholder' => esc_html__( 'Enter your social profiles heading', 'copy-the-code' ),
322 ] );
323 // Social profiles.
324 $this->add_control( 'social_profiles', [
325 'label' => esc_html__( 'Social Profiles', 'copy-the-code' ),
326 'type' => Controls_Manager::REPEATER,
327 'fields' => [[
328 'name' => 'link',
329 'label' => esc_html__( 'Link', 'copy-the-code' ),
330 'type' => Controls_Manager::TEXT,
331 'label_block' => true,
332 ]],
333 'default' => [[
334 'link' => 'https://facebook.com',
335 ], [
336 'link' => 'https://twitter.com',
337 ], [
338 'link' => 'https://linkedin.com',
339 ]],
340 'title_field' => '{{{ name }}}',
341 ] );
342 $this->end_controls_section();
343 Helpers::register_copy_button_section( $this, [
344 'button_text' => esc_html__( 'Copy Contact Information', 'copy-the-code' ),
345 ] );
346 Helpers::register_pro_sections( $this, [
347 'Box',
348 'Contact Heading',
349 'Contact Fields',
350 'Contact Field',
351 'Field Label',
352 'Field Value',
353 'Social Heading',
354 'Social Icon'
355 ] );
356 Helpers::register_copy_button_style_section( $this );
357 }
358
359 }
360