PluginProbe
Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code / 5.5.4
Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code v5.5.4
5.5.4 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 All 79 releases
copy-the-code / includes / elementor / widgets / contact-information / widget.php

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

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