PluginProbe
WP Click to Chat – Email, Live Chat, Call & Book Now Buttons / trunk
WP Click to Chat – Email, Live Chat, Call & Book Now Buttons vtrunk
trunk 1.2.2 2.0 2.1 2.2 2.3 2.3.1 2.3.2 2.3.3 2.3.4 2.3.6
support-chat / src / WpSaioShortcodes.class.php

WpSaioShortcodes.class.php in WP Click to Chat – Email, Live Chat, Call & Book Now Buttons trunk, at src/WpSaioShortcodes.class.php

489 lines 16.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit;
3 class WpSaioShortcodes {
4
5 private static $_instance = null;
6
7 public function __construct() {
8 // Register shortcodes will be done in init hook to avoid early translation calls
9 add_action( 'init', array( $this, 'registerShortcodes' ) );
10 }
11
12 public function registerShortcodes() {
13 $apps = WpSaio::defaultApps();
14 foreach ( $apps as $k => $v ) {
15 if ( isset( $v['shortcode'] ) && ! empty( $v['shortcode'] ) ) {
16 $func = str_replace( '-', '', $k );
17 if(str_contains($k, 'custom-app')) {
18 add_shortcode( $v['shortcode'], array( $this,'customAppShortcode' ) );
19 } else {
20 add_shortcode( $v['shortcode'], array( $this, $func . 'Shortcode' ) );
21 }
22 }
23 }
24 }
25 public static function instance() {
26 if ( is_null( self::$_instance ) ) {
27 self::$_instance = new self();
28 }
29 return self::$_instance;
30 }
31 public function facebookmessengerShortcode( $atts ) {
32 ob_start();
33 $atts = shortcode_atts(
34 array(
35 'url' => '',
36 ),
37 $atts
38 );
39 $atts = extract( $atts );
40 $urlArray = explode( '/', $url );
41 ?>
42 <div class="nt-aio-popup nt-aio-messenger-popup" id="nt-aio-popup-facebook-messenger">
43 <div class="nt-aio-popup-header">
44 <div class="nt-aio-popup-title">
45 <div class="nt-aio-popup-title-icon"></div>
46 <!-- /.nt-aio-popup-title-icon -->
47 <div class="nt-aio-popup-title-txt"><?php esc_html_e( 'Messenger', 'support-chat' ); ?></div>
48 <!-- /.nt-aio-popup-title-txt -->
49 </div>
50 <!-- /.nt-aio-popup-title -->
51 <div class="nt-aio-popup-close js__nt_aio_close_popup"></div>
52 <!-- /.nt-aio-popup-close -->
53 </div>
54 <!-- /.nt-aio-popup-header -->
55 <div class="nt-aio-popup-content">
56 <a href='<?php echo esc_attr( WpSaioHelper::format_content('messenger', $url, true) ); ?>'></a>
57 <iframe wh-src="fbIframeURL" style="border:none; border-radius: 0 0 16px 16px; overflow:hidden" scrolling="no" allowtransparency="true" src="https://www.facebook.com/plugins/page.php?href=<?php echo esc_url( WpSaioHelper::format_content('messenger', $url, true) ); ?>&amp;tabs=messages&amp;small_header=true&amp;width=300&amp;height=300&amp;adapt_container_width=true&amp;hide_cover=true&amp;show_facepile=false&amp;appId" width="300" height="300" frameborder="0"></iframe>
58 </div>
59 <!-- /.nt-aio-popup-content -->
60 </div>
61 <!-- /#nt-aio-popup-facebook-messenger.nt-aio-popup nt-aio-messenger-popup -->
62 <?php
63 return ob_get_clean();
64 }
65 public function whatsappShortcode( $atts ) {
66 ob_start();
67 $atts = shortcode_atts(
68 array(
69 'phone' => '',
70 ),
71 $atts
72 );
73 $atts = extract( $atts );
74 // preg_match_all( '/\d+/', $phone, $matches );
75 // $phone = isset($matches[0][0]) ? $matches[0][0] : '';
76 ?>
77 <div class="nt-aio-popup nt-aio-whatsapp-popup" id="nt-aio-popup-whatsapp">
78 <div class="nt-aio-popup-header">
79 <div class="nt-aio-popup-title">
80 <div class="nt-aio-popup-title-icon"></div>
81 <!-- /.nt-aio-popup-title-icon -->
82 <div class="nt-aio-popup-title-txt"><?php esc_html_e( 'WhatsApp', 'support-chat' ); ?></div>
83 <!-- /.nt-aio-popup-title-txt -->
84 </div>
85 <!-- /.nt-aio-popup-title -->
86 <div class="nt-aio-popup-close js__nt_aio_close_popup"></div>
87 <!-- /.nt-aio-popup-close -->
88 </div>
89 <!-- /.nt-aio-popup-header -->
90 <div class="nt-aio-popup-content">
91 <a href="https://api.whatsapp.com/send?phone=<?php echo esc_attr( WpSaioHelper::format_content('whatsapp', $phone, false) ); ?>" target="_blank">
92 <?php echo esc_attr( WpSaioHelper::format_content('whatsapp', $phone, false) ); ?>
93 </a>
94 </div>
95 <!-- /.nt-aio-popup-content -->
96 </div>
97 <!-- /#nt-aio-popup-whatsapp.nt-aio-popup nt-aio-whatsapp-popup -->
98 <?php
99 return ob_get_clean();
100 }
101 public function snapchatShortcode( $atts ) {
102 ob_start();
103 $atts = shortcode_atts(
104 array(
105 'username' => '',
106 ),
107 $atts
108 );
109 $atts = extract( $atts );
110 ?>
111 <div class="nt-aio-popup nt-aio-snapchat-popup" id="nt-aio-popup-snapchat">
112 <div class="nt-aio-popup-header">
113 <div class="nt-aio-popup-title">
114 <div class="nt-aio-popup-title-icon"></div>
115 <!-- /.nt-aio-popup-title-icon -->
116 <div class="nt-aio-popup-title-txt"><?php esc_html_e( 'Snapchat', 'support-chat' ); ?></div>
117 <!-- /.nt-aio-popup-title-txt -->
118 </div>
119 <!-- /.nt-aio-popup-title -->
120 <div class="nt-aio-popup-close js__nt_aio_close_popup"></div>
121 <!-- /.nt-aio-popup-close -->
122 </div>
123 <!-- /.nt-aio-popup-header -->
124 <div class="nt-aio-popup-content">
125 <div class="content-snapchat-qrcode" wh-html="snapchatQRCode"><object data="https://feelinsonice-hrd.appspot.com/web/deeplink/snapcode?username=<?php echo esc_attr($username); ?>&amp;type=PNG" type="image/png" width="200px" height="200px"></object></div>
126 <div style="margin: 5px;" class="content-snapchat-name" wh-html-unsafe="snapchatUser">
127 <a href="<?php echo esc_attr(WpSaioHelper::format_content('snapchat', $username, true)); ?>" target="_blank"><?php echo esc_html(WpSaioHelper::format_content('snapchat', $username, false)); ?></a>
128 </div>
129 </div>
130 <!-- /.nt-aio-popup-content -->
131 </div>
132 <!-- /#nt-aio-popup-snapchat.nt-aio-popup nt-aio-snapchat-popup -->
133 <?php
134 return ob_get_clean();
135 }
136 public function lineShortcode( $atts ) {
137 ob_start();
138 $atts = shortcode_atts(
139 array(
140 'url' => '',
141 ),
142 $atts
143 );
144 $atts = extract( $atts );
145 //for websites that use http instead of https
146 $url = str_replace('http://', 'https://', $url);
147 ?>
148 <div class="nt-aio-popup nt-aio-line-popup" id="nt-aio-popup-line">
149 <!-- <p class="test">Test</p> -->
150 <div class="nt-aio-popup-header">
151 <div class="nt-aio-popup-title">
152 <div class="nt-aio-popup-title-icon"></div>
153 <!-- /.nt-aio-popup-title-icon -->
154 <div class="nt-aio-popup-title-txt"><?php esc_html_e( 'Line', 'support-chat' ); ?></div>
155 <!-- /.nt-aio-popup-title-txt -->
156 </div>
157 <!-- /.nt-aio-popup-title -->
158 <div class="nt-aio-popup-close js__nt_aio_close_popup"></div>
159 <!-- /.nt-aio-popup-close -->
160 </div>
161 <!-- /.nt-aio-popup-header -->
162 <div class="nt-aio-popup-content">
163 <?php if( ! empty( $url ) ) : ?>
164 <iframe wh-src="lineIframeURL" scrolling="no" allowtransparency="true" src="<?php echo esc_url( WpSaioHelper::format_content('line', $url, true) ); ?>" frameborder="0"></iframe>
165 <a href="https://line.me/R/ti/p/@<?php echo esc_url( WpSaioHelper::format_content('line', $url, false) ); ?>" target="_blank"></a>
166 <?php endif; ?>
167 </div>
168 <!-- /.nt-aio-popup-content -->
169 </div>
170 <?php
171 return ob_get_clean();
172 }
173 public function viberShortcode( $atts ) {
174 ob_start();
175 $atts = shortcode_atts(
176 array(
177 'account' => '',
178 ),
179 $atts
180 );
181 $atts = extract( $atts );
182 ?>
183 <div class="nt-aio-popup nt-aio-viber-popup" id="nt-aio-popup-viber">
184 <div class="nt-aio-popup-header">
185 <div class="nt-aio-popup-title">
186 <div class="nt-aio-popup-title-icon"></div>
187 <!-- /.nt-aio-popup-title-icon -->
188 <div class="nt-aio-popup-title-txt"><?php esc_html_e( 'Viber', 'support-chat' ); ?></div>
189 <!-- /.nt-aio-popup-title-txt -->
190 </div>
191 <!-- /.nt-aio-popup-title -->
192 <div class="nt-aio-popup-close js__nt_aio_close_popup"></div>
193 <!-- /.nt-aio-popup-close -->
194 </div>
195 <!-- /.nt-aio-popup-header -->
196 <div class="nt-aio-popup-content">
197 <a href="<?php echo esc_attr( WpSaioHelper::format_content('viber', $account, true) ); ?>" target="_blank"><?php echo esc_attr( WpSaioHelper::format_content('viber', $account, false) ); ?></a>
198 </div>
199 <!-- /.nt-aio-popup-content -->
200 </div>
201 <?php
202 return ob_get_clean();
203 }
204 public function phoneShortcode( $atts ) {
205 ob_start();
206 $atts = shortcode_atts(
207 array(
208 'phone_number' => '',
209 ),
210 $atts
211 );
212 $atts = extract( $atts );
213 ?>
214 <div class="nt-aio-popup nt-aio-phone-popup" id="nt-aio-popup-phone">
215 <div class="nt-aio-popup-header">
216 <div class="nt-aio-popup-title">
217 <div class="nt-aio-popup-title-icon"></div>
218 <!-- /.nt-aio-popup-title-icon -->
219 <div class="nt-aio-popup-title-txt"><?php esc_html_e( 'Phone', 'support-chat' ); ?></div>
220 <!-- /.nt-aio-popup-title-txt -->
221 </div>
222 <!-- /.nt-aio-popup-title -->
223 <div class="nt-aio-popup-close js__nt_aio_close_popup"></div>
224 <!-- /.nt-aio-popup-close -->
225 </div>
226 <!-- /.nt-aio-popup-header -->
227 <div class="nt-aio-popup-content">
228 <a href="<?php echo esc_attr(WpSaioHelper::format_content('phone', $phone_number, true)); ?>"><?php echo esc_attr(WpSaioHelper::format_content('phone', $phone_number, false)); ?></a>
229 </div>
230 <!-- /.nt-aio-popup-content -->
231 </div>
232 <?php
233 return ob_get_clean();
234 }
235 public function emailShortcode( $atts ) {
236 ob_start();
237 $atts = shortcode_atts(
238 array(
239 'email' => '',
240 ),
241 $atts
242 );
243 $atts = extract( $atts );
244 ?>
245 <div class="nt-aio-popup nt-aio-email-popup" id="nt-aio-popup-email">
246 <div class="nt-aio-popup-header">
247 <div class="nt-aio-popup-title">
248 <div class="nt-aio-popup-title-icon"></div>
249 <!-- /.nt-aio-popup-title-icon -->
250 <div class="nt-aio-popup-title-txt"><?php esc_html_e( 'Email', 'support-chat' ); ?></div>
251 <!-- /.nt-aio-popup-title-txt -->
252 </div>
253 <!-- /.nt-aio-popup-title -->
254 <div class="nt-aio-popup-close js__nt_aio_close_popup"></div>
255 <!-- /.nt-aio-popup-close -->
256 </div>
257 <!-- /.nt-aio-popup-header -->
258 <div class="nt-aio-popup-content">
259 <a href="<?php echo esc_attr(WpSaioHelper::format_content('email', $email, true)); ?>" target="_blank"><?php echo esc_attr(WpSaioHelper::format_content('email', $email, false)); ?></a>
260 </div>
261 <!-- /.nt-aio-popup-content -->
262 </div>
263 <?php
264 return ob_get_clean();
265 }
266
267 public function telegramShortcode( $atts ) {
268 ob_start();
269 $atts = shortcode_atts(
270 array(
271 'username' => '',
272 ),
273 $atts
274 );
275 $atts = extract( $atts );
276 ?>
277 <div class="nt-aio-popup nt-aio-telegram-popup" id="nt-aio-popup-telegram">
278 <div class="nt-aio-popup-header">
279 <div class="nt-aio-popup-title">
280 <div class="nt-aio-popup-title-icon"></div>
281 <!-- /.nt-aio-popup-title-icon -->
282 <div class="nt-aio-popup-title-txt"><?php esc_html_e( 'Telegram', 'support-chat' ); ?></div>
283 <!-- /.nt-aio-popup-title-txt -->
284 </div>
285 <!-- /.nt-aio-popup-title -->
286 <div class="nt-aio-popup-close js__nt_aio_close_popup"></div>
287 <!-- /.nt-aio-popup-close -->
288 </div>
289 <!-- /.nt-aio-popup-header -->
290 <div class="nt-aio-popup-content">
291 <a href="<?php echo esc_attr(WpSaioHelper::format_content('telegram', $username, true)); ?>" target="_blank">
292 <?php echo esc_attr(WpSaioHelper::format_content('telegram', $username, false)); ?>
293 </a>
294 </div>
295 <!-- /.nt-aio-popup-content -->
296 </div>
297 <?php
298 return ob_get_clean();
299 }
300
301 public function skypeShortcode( $atts ) {
302 ob_start();
303 $atts = shortcode_atts(
304 array(
305 'username' => '',
306 ),
307 $atts
308 );
309 $atts = extract( $atts );
310 ?>
311 <div class="nt-aio-popup nt-aio-skype-popup" id="nt-aio-popup-skype">
312 <div class="nt-aio-popup-header">
313 <div class="nt-aio-popup-title">
314 <div class="nt-aio-popup-title-icon"></div>
315 <!-- /.nt-aio-popup-title-icon -->
316 <div class="nt-aio-popup-title-txt"><?php esc_html_e( 'Skype', 'support-chat' ); ?></div>
317 <!-- /.nt-aio-popup-title-txt -->
318 </div>
319 <!-- /.nt-aio-popup-title -->
320 <div class="nt-aio-popup-close js__nt_aio_close_popup"></div>
321 <!-- /.nt-aio-popup-close -->
322 </div>
323 <!-- /.nt-aio-popup-header -->
324 <div class="nt-aio-popup-content">
325 <a href="skype:<?php echo esc_attr($username); ?>?chat" target="_blank">
326 <?php echo esc_attr($username); ?>
327 </a>
328 </div>
329 <!-- /.nt-aio-popup-content -->
330 </div>
331 <?php
332 return ob_get_clean();
333 }
334
335 public function zaloShortcode( $atts ) {
336 ob_start();
337 $atts = shortcode_atts(
338 array(
339 'username' => '',
340 ),
341 $atts
342 );
343 $atts = extract( $atts );
344 ?>
345 <div class="nt-aio-popup nt-aio-zalo-popup" id="nt-aio-popup-zalo">
346 <div class="nt-aio-popup-header">
347 <div class="nt-aio-popup-title">
348 <div class="nt-aio-popup-title-icon"></div>
349 <!-- /.nt-aio-popup-title-icon -->
350 <div class="nt-aio-popup-title-txt"><?php esc_html_e( 'Zalo', 'support-chat' ); ?></div>
351 <!-- /.nt-aio-popup-title-txt -->
352 </div>
353 <!-- /.nt-aio-popup-title -->
354 <div class="nt-aio-popup-close js__nt_aio_close_popup"></div>
355 <!-- /.nt-aio-popup-close -->
356 </div>
357 <!-- /.nt-aio-popup-header -->
358 <div class="nt-aio-popup-content">
359 <a href="<?php echo esc_attr(WpSaioHelper::format_content('zalo', $username, true)); ?>" target="_blank">
360 <?php echo esc_attr(WpSaioHelper::format_content('zalo', $username, false)); ?>
361 </a>
362 </div>
363 <!-- /.nt-aio-popup-content -->
364 </div>
365 <?php
366 return ob_get_clean();
367 }
368
369 public function kakaotalkShortcode( $atts ) {
370 ob_start();
371 $atts = shortcode_atts(
372 array(
373 'username' => '',
374 ),
375 $atts
376 );
377 $atts = extract( $atts );
378 ?>
379 <div class="nt-aio-popup nt-aio-kakaotalk-popup" id="nt-aio-popup-kakaotalk">
380 <div class="nt-aio-popup-header">
381 <div class="nt-aio-popup-title">
382 <div class="nt-aio-popup-title-icon"></div>
383 <!-- /.nt-aio-popup-title-icon -->
384 <div class="nt-aio-popup-title-txt"><?php esc_html_e( 'Kakaotalk', 'support-chat' ); ?></div>
385 <!-- /.nt-aio-popup-title-txt -->
386 </div>
387 <!-- /.nt-aio-popup-title -->
388 <div class="nt-aio-popup-close js__nt_aio_close_popup"></div>
389 <!-- /.nt-aio-popup-close -->
390 </div>
391 <!-- /.nt-aio-popup-header -->
392 <div class="nt-aio-popup-content">
393 <a href="kakaotalk:<?php echo esc_attr(WpSaioHelper::format_content('kakaotalk', $username, false)); ?>?chat" target="_blank">
394 <?php echo esc_attr(WpSaioHelper::format_content('kakaotalk', $username, false)); ?>
395 </a>
396 </div>
397 <!-- /.nt-aio-popup-content -->
398 </div>
399 <?php
400 return ob_get_clean();
401 }
402
403 public function wechatShortcode( $atts ) {
404 ob_start();
405 $atts = shortcode_atts(
406 array(
407 'email' => '',
408 ),
409 $atts
410 );
411 $atts = extract( $atts );
412 ?>
413 <div class="nt-aio-popup nt-aio-wechat-popup" id="nt-aio-popup-wechat">
414 <div class="nt-aio-popup-header">
415 <div class="nt-aio-popup-title">
416 <div class="nt-aio-popup-title-icon"></div>
417 <!-- /.nt-aio-popup-title-icon -->
418 <div class="nt-aio-popup-title-txt"><?php esc_html_e( 'Wechat', 'support-chat' ); ?></div>
419 <!-- /.nt-aio-popup-title-txt -->
420 </div>
421 <!-- /.nt-aio-popup-title -->
422 <div class="nt-aio-popup-close js__nt_aio_close_popup"></div>
423 <!-- /.nt-aio-popup-close -->
424 </div>
425 <!-- /.nt-aio-popup-header -->
426 <div class="nt-aio-popup-content">
427 <a href="<?php echo esc_attr(WpSaioHelper::format_content('wechat', $email, true)); ?>" target="_blank">
428 <?php echo esc_attr(WpSaioHelper::format_content('wechat', $email, false)); ?>
429 </a>
430 </div>
431 <!-- /.nt-aio-popup-content -->
432 </div>
433 <?php
434 return ob_get_clean();
435 }
436
437 public function customAppShortcode( $atts ) {
438 ob_start();
439 $atts = shortcode_atts(
440 array(
441 'url' => '',
442 'custom-app-title' => '',
443 'url-icon' => '',
444 'color-icon' => '',
445 'custom-app-key' => '',
446 ),
447 $atts
448 );
449 // $atts = extract($atts);
450 ?>
451 <div class="nt-aio-popup nt-aio-custom-app-popup" id="<?php echo !empty($atts['custom-app-key']) ? 'nt-aio-popup-' . esc_attr($atts['custom-app-key']) : 'nt-aio-popup-custom-app'; ?>">
452 <div class="nt-aio-popup-header">
453 <div class="nt-aio-popup-title">
454 <div class="nt-aio-popup-title-icon"></div>
455 <!-- /.nt-aio-popup-title-icon -->
456 <div class="nt-aio-popup-title-txt">
457 <?php
458 $custom_app_title = ($atts['custom-app-title'] && ($atts['custom-app-title'] !== '')) ? $atts['custom-app-title'] : esc_html__('Custom App', 'support-chat');
459 echo esc_html($custom_app_title);
460 ?>
461 </div>
462 <!-- /.nt-aio-popup-title-txt -->
463 </div>
464 <!-- /.nt-aio-popup-title -->
465 <div class="nt-aio-popup-close js__nt_aio_close_popup"></div>
466 <!-- /.nt-aio-popup-close -->
467 </div>
468 <!-- /.nt-aio-popup-header -->
469 <div class="nt-aio-popup-content">
470 <a href="<?php echo esc_url( $atts['url'] ); ?>" target="_blank">
471 <?php echo esc_url( $atts['url'] ); ?>
472 </a>
473 </div>
474 <!-- /.nt-aio-popup-content -->
475 </div>
476 <style>
477 .nt-aio-popup-header {
478 --backgroundColorCustomApp: <?php echo $atts['color-icon'] ? esc_attr( $atts['color-icon'] ) : '#007cc4'; ?>;
479 }
480
481 .nt-aio-popup-title-icon {
482 --backgroundIconCustomApp: <?php echo $atts['url-icon'] ? 'url(' . esc_attr( $atts['url-icon'] ) . ')' : 'url("../images/custom-app.svg")'; ?>;
483 }
484 </style>
485 <?php
486 return ob_get_clean();
487 }
488 }
489