Floating Chat Widget: Contact Chat Icons, Telegram Chat, Line, WeChat, Email, SMS, Call Button – Chaty - Version 1.3.3

Version Description

  • added an option to add phone numbers with asterisk, now Chaty won't load FB SDK unless FB Messenger channel is chosen, fixed "'" in CTA bug, fixed Viber bug (works great on desktop on mobile now)
Download this release

Release Info

Developer galdub
Plugin Icon wp plugin Floating Chat Widget: Contact Chat Icons, Telegram Chat, Line, WeChat, Email, SMS, Call Button – Chaty
Version 1.3.3
Comparing to
See all releases

Code changes from version 1.3.2 to 1.3.3

admin/class-admin-base.php CHANGED
@@ -86,14 +86,16 @@ class CHT_Admin_Base
86
  $errorArray[] = $error;
87
  }
88
  if(empty($errorArray)) {
 
89
  $text_message = $postData['textarea_text'];
90
  $email = $postData['user_email'];
91
  $domain = site_url();
92
-
93
- $subject = "Chaty bug report: ".$domain;
94
  $headers = "MIME-Version: 1.0\r\n";
95
  $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
96
- $headers .= 'Reply-To: '.$email.'\r\n';
 
97
  $headers .= 'X-Mailer: PHP/' . phpversion();
98
  ob_start();
99
  ?>
86
  $errorArray[] = $error;
87
  }
88
  if(empty($errorArray)) {
89
+ global $current_user;
90
  $text_message = $postData['textarea_text'];
91
  $email = $postData['user_email'];
92
  $domain = site_url();
93
+ $user_name = $current_user->first_name." ".$current_user->last_name;
94
+ $subject = "Chaty request: ".$domain;
95
  $headers = "MIME-Version: 1.0\r\n";
96
  $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
97
+ $headers .= 'From: '.$user_name.' <'.$email.'>'.PHP_EOL ;
98
+ $headers .= 'Reply-To: '.$user_name.' <'.$email.'>'.PHP_EOL ;
99
  $headers .= 'X-Mailer: PHP/' . phpversion();
100
  ob_start();
101
  ?>
cht-icons.php CHANGED
@@ -5,7 +5,7 @@
5
  Description: Chat with your website visitors via their favorite channels. Show a chat icon on the bottom of your site and communicate with your customers.
6
  Author: Premio
7
  Author URI: https://premio.io/downloads/chaty/
8
- Version: 1.3.2
9
  License: GPL2
10
  */
11
 
5
  Description: Chat with your website visitors via their favorite channels. Show a chat icon on the bottom of your site and communicate with your customers.
6
  Author: Premio
7
  Author URI: https://premio.io/downloads/chaty/
8
+ Version: 1.3.3
9
  License: GPL2
10
  */
11
 
frontend/class-frontend.php CHANGED
@@ -170,7 +170,20 @@ class CHT_Frontend extends CHT_Admin_Base
170
  }
171
  if ($value = get_option('cht_social_' . $social['slug'])) {
172
  if (!empty($value['value']) && (wp_is_mobile() ? isset($value['is_mobile']) : isset($value['is_desktop']))) {
173
- $arr[mb_strtolower($social['slug'])] = $value['value'];
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  }
175
  };
176
  endforeach;
170
  }
171
  if ($value = get_option('cht_social_' . $social['slug'])) {
172
  if (!empty($value['value']) && (wp_is_mobile() ? isset($value['is_mobile']) : isset($value['is_desktop']))) {
173
+ if($social['slug'] == "Viber") {
174
+ $val = $value['value'];
175
+ $fc = substr($val, 0, 1);
176
+ if($fc == "+") {
177
+ $length = -1*(strlen($val)-1);
178
+ $val = substr($val, $length);
179
+ }
180
+ if(!wp_is_mobile()) {
181
+ $val = "+".$val;
182
+ }
183
+ $arr[mb_strtolower($social['slug'])] = $val;
184
+ } else {
185
+ $arr[mb_strtolower($social['slug'])] = $value['value'];
186
+ }
187
  }
188
  };
189
  endforeach;
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: galdub, tomeraharon, premio
3
  Tags: whatsapp, facebook messenger, click to chat, chat, chat button, call now button
4
  Requires at least: 3.1
5
  Tested up to: 5.1
6
- Stable tag: 1.3.2
7
  Plugin URI: https://premio.io/downloads/chaty/
8
 
9
  FREE customizable live chat and call buttons. Let your visitors contact you via Facebook Messenger, Whatsapp, Telegram, Viber, Email, SMS and more.
@@ -125,6 +125,9 @@ Just follow our <a href="https://premio.io/wordpress-premio-pro-version-installa
125
 
126
  == Changelog ==
127
 
 
 
 
128
  = 1.1 =
129
  * Initial release.
130
 
3
  Tags: whatsapp, facebook messenger, click to chat, chat, chat button, call now button
4
  Requires at least: 3.1
5
  Tested up to: 5.1
6
+ Stable tag: 1.3.3
7
  Plugin URI: https://premio.io/downloads/chaty/
8
 
9
  FREE customizable live chat and call buttons. Let your visitors contact you via Facebook Messenger, Whatsapp, Telegram, Viber, Email, SMS and more.
125
 
126
  == Changelog ==
127
 
128
+ = 1.3.3 =
129
+ * added an option to add phone numbers with asterisk, now Chaty won't load FB SDK unless FB Messenger channel is chosen, fixed "'" in CTA bug, fixed Viber bug (works great on desktop on mobile now)
130
+
131
  = 1.1 =
132
  * Initial release.
133
 
views/admin.php CHANGED
@@ -89,16 +89,16 @@ if (!$this->is_pro()) {
89
  phoneNumberReg = /^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/;
90
  if (jQuery("#cht-form #Whatsapp").length && jQuery("#cht-form #Whatsapp").val() != "") {
91
  InputVal = jQuery.trim(jQuery("#cht-form #Whatsapp").val());
92
- if (check_for_number_chaty(InputVal)) {
93
- alert("<?php echo __("For channel Whatsapp please enter a valid phone number", CHT_OPT) ?>");
94
  jQuery("#cht-form #Whatsapp").focus();
95
  return false;
96
  }
97
  }
98
  if (jQuery("#cht-form #Phone").length && jQuery("#cht-form #Phone").val() != "") {
99
  InputVal = jQuery.trim(jQuery("#cht-form #Phone").val());
100
- if (check_for_number_chaty(InputVal)) {
101
- alert("<?php echo __("For channel Phone please enter a valid phone number", CHT_OPT) ?>");
102
  jQuery("#cht-form #Phone").focus();
103
  return false;
104
  }
@@ -115,27 +115,32 @@ if (!$this->is_pro()) {
115
  }
116
  if (jQuery("#cht-form #SMS").length && jQuery("#cht-form #SMS").val() != "") {
117
  InputVal = jQuery.trim(jQuery("#cht-form #SMS").val());
118
- if (check_for_number_chaty(InputVal)) {
119
- alert("<?php echo __("For channel SMS please enter a valid phone number", CHT_OPT) ?>");
120
  jQuery("#cht-form #SMS").focus();
121
  return false;
122
  }
123
  }
124
  if (jQuery("#cht-form #Viber").length && jQuery("#cht-form #Viber").val() != "") {
125
  InputVal = jQuery.trim(jQuery("#cht-form #Viber").val());
126
- if (check_for_number_chaty(InputVal)) {
127
- alert("<?php echo __("For channel Viber please enter a valid phone number", CHT_OPT) ?>");
128
  jQuery("#cht-form #Viber").focus();
129
  return false;
130
  }
131
  }
132
- });
133
  });
134
 
135
- function check_for_number_chaty(phoneNumber) {
136
  if(phoneNumber != "") {
137
  if(phoneNumber[0] == "+") {
138
- phoneNumber.substr(1,phoneNumber.length)
 
 
 
 
 
139
  }
140
  if(isNaN(phoneNumber)) {
141
  return true;
89
  phoneNumberReg = /^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/;
90
  if (jQuery("#cht-form #Whatsapp").length && jQuery("#cht-form #Whatsapp").val() != "") {
91
  InputVal = jQuery.trim(jQuery("#cht-form #Whatsapp").val());
92
+ if (check_for_number_chaty(InputVal, "Whatsapp")) {
93
+ alert("<?php echo __("For channel Whatsapp, please enter a valid phone number", CHT_OPT) ?>");
94
  jQuery("#cht-form #Whatsapp").focus();
95
  return false;
96
  }
97
  }
98
  if (jQuery("#cht-form #Phone").length && jQuery("#cht-form #Phone").val() != "") {
99
  InputVal = jQuery.trim(jQuery("#cht-form #Phone").val());
100
+ if (check_for_number_chaty(InputVal, "Phone")) {
101
+ alert("<?php echo __("For channel Phone, please enter a valid phone number", CHT_OPT) ?>");
102
  jQuery("#cht-form #Phone").focus();
103
  return false;
104
  }
115
  }
116
  if (jQuery("#cht-form #SMS").length && jQuery("#cht-form #SMS").val() != "") {
117
  InputVal = jQuery.trim(jQuery("#cht-form #SMS").val());
118
+ if (check_for_number_chaty(InputVal, "SMS")) {
119
+ alert("<?php echo __("For channel SMS, please enter a valid phone number", CHT_OPT) ?>");
120
  jQuery("#cht-form #SMS").focus();
121
  return false;
122
  }
123
  }
124
  if (jQuery("#cht-form #Viber").length && jQuery("#cht-form #Viber").val() != "") {
125
  InputVal = jQuery.trim(jQuery("#cht-form #Viber").val());
126
+ if (check_for_number_chaty(InputVal, "Viber")) {
127
+ alert("<?php echo __("For channel Viber, please enter a valid phone number", CHT_OPT) ?>");
128
  jQuery("#cht-form #Viber").focus();
129
  return false;
130
  }
131
  }
132
+ });
133
  });
134
 
135
+ function check_for_number_chaty(phoneNumber, validationFor) {
136
  if(phoneNumber != "") {
137
  if(phoneNumber[0] == "+") {
138
+ phoneNumber = phoneNumber.substr(1,phoneNumber.length)
139
+ }
140
+ if(validationFor == "Phone") {
141
+ if (phoneNumber[0] == "*") {
142
+ phoneNumber = phoneNumber.substr(1, phoneNumber.length)
143
+ }
144
  }
145
  if(isNaN(phoneNumber)) {
146
  return true;
views/parts/section2.php CHANGED
@@ -197,7 +197,8 @@
197
  <div class="position-pro">
198
  <div>
199
  <label>Side selection:</label>
200
- <?php $pos_custom = empty(get_option('positionSide')) ? 'right' : get_option('positionSide'); ?>
 
201
  <div class="custom-control-group">
202
  <label class="custom-control custom-radio custom-radio-btn">
203
  <input type="radio" value="left" name="positionSide" class="custom-control-input"
197
  <div class="position-pro">
198
  <div>
199
  <label>Side selection:</label>
200
+ <?php $positionSide = get_option('positionSide') ?>
201
+ <?php $pos_custom = empty($positionSide) ? 'right' : $positionSide; ?>
202
  <div class="custom-control-group">
203
  <label class="custom-control custom-radio custom-radio-btn">
204
  <input type="radio" value="left" name="positionSide" class="custom-control-input"
views/widget.php CHANGED
@@ -1,34 +1,52 @@
1
- <div id="fb-root"></div>
2
- <script>(function(d, s, id) {
3
- var js, fjs = d.getElementsByTagName(s)[0];
4
- if (d.getElementById(id)) return;
5
- js = d.createElement(s); js.id = id;
6
- js.src = 'https://connect.facebook.net/locale/sdk.js#xfbml=1&version=v3.0';
7
- fjs.parentNode.insertBefore(js, fjs);
8
- }(document, 'script', 'facebook-jssdk'));
9
- </script>
 
 
 
 
 
 
 
 
 
 
10
 
11
  <?php $bg_color = $this->get_current_color();?>
12
  <?php $len = strlen( $this->int_arr());?>
13
  <?php $cta = $this->getCallToAction(); ?>
14
 
 
 
 
 
 
 
 
 
15
  <script src="<?php echo CHT_PLUGIN_URL ?>assets/js/cht-front-script.js?<?php echo rand();?>" settings='
16
  {
17
  "object_settings":{
18
  "isPRO": 0,
19
  "position":"<?php echo (get_option('cht_position'));?>",
20
- "social":<?php echo $this->int_arr()?>,
21
- "pos_side":"<?php echo empty(get_option('positionSide')) ? 'right' : get_option('positionSide');?>",
22
- "bot":"<?php echo (get_option('cht_bottom_spacing')) ? get_option('cht_bottom_spacing') : '25';?>",
23
- "side": "<?php echo (get_option('cht_side_spacing')) ? get_option('cht_side_spacing') : '25';?>",
24
  "device":"<?php echo $this->device();?>",
25
  "color":"<?php echo ($bg_color) ? $bg_color : '#A886CD'; ?>",
26
- "widget_size":"<?php echo (get_option('cht_widget_size')) ? get_option('cht_widget_size'): '54';?>",
27
  "widget_type":"<?php echo get_option('widget_icon');?>",
28
  "widget_img":"<?php echo $this->getCustomWidgetImg();?>",
29
- "cta":"<?php echo $cta; ?>",
30
  "link_active":"<?php echo get_option('cht_credit') ?>",
31
- "active":"<?php echo (get_option('cht_active') && $len>2) ? 'true' : 'false' ?>"
32
  }
33
  }'>
34
  </script>
1
+ <?php
2
+ $social = $this->int_arr();
3
+ $cht_active = get_option("cht_active");
4
+ if(!empty($social) && $cht_active) {
5
+ $social = json_decode($social, true);
6
+ if (array_key_exists("facebook_messenger", $social)) {
7
+ ?>
8
+ <div id="fb-root"></div>
9
+ <script>(function (d, s, id) {
10
+ var js, fjs = d.getElementsByTagName(s)[0];
11
+ if (d.getElementById(id)) return;
12
+ js = d.createElement(s);
13
+ js.id = id;
14
+ js.src = 'https://connect.facebook.net/locale/sdk.js#xfbml=1&version=v3.0';
15
+ fjs.parentNode.insertBefore(js, fjs);
16
+ }(document, 'script', 'facebook-jssdk'));
17
+ </script>
18
+ <?php }
19
+ }?>
20
 
21
  <?php $bg_color = $this->get_current_color();?>
22
  <?php $len = strlen( $this->int_arr());?>
23
  <?php $cta = $this->getCallToAction(); ?>
24
 
25
+ <?php
26
+ $positionSide = get_option('positionSide');
27
+ $cht_bottom_spacing = get_option('cht_bottom_spacing');
28
+ $cht_side_spacing = get_option('cht_side_spacing');
29
+ $cht_widget_size = get_option('cht_widget_size');
30
+ $cta = str_replace("'","&#39;",$cta);
31
+ $cta = str_replace('"',"&#34;",$cta);
32
+ ?>
33
  <script src="<?php echo CHT_PLUGIN_URL ?>assets/js/cht-front-script.js?<?php echo rand();?>" settings='
34
  {
35
  "object_settings":{
36
  "isPRO": 0,
37
  "position":"<?php echo (get_option('cht_position'));?>",
38
+ "social":<?php echo $this->int_arr() ?>,
39
+ "pos_side":"<?php echo empty($positionSide) ? 'right' : $positionSide ;?>",
40
+ "bot":"<?php echo ($cht_bottom_spacing) ? $cht_bottom_spacing : '25';?>",
41
+ "side": "<?php echo ($cht_side_spacing) ? $cht_side_spacing : '25';?>",
42
  "device":"<?php echo $this->device();?>",
43
  "color":"<?php echo ($bg_color) ? $bg_color : '#A886CD'; ?>",
44
+ "widget_size":"<?php echo ($cht_widget_size) ? $cht_widget_size: '54';?>",
45
  "widget_type":"<?php echo get_option('widget_icon');?>",
46
  "widget_img":"<?php echo $this->getCustomWidgetImg();?>",
47
+ "cta":"<?php echo addslashes($cta); ?>",
48
  "link_active":"<?php echo get_option('cht_credit') ?>",
49
+ "active":"<?php echo ($cht_active && $len>2) ? 'true' : 'false' ?>"
50
  }
51
  }'>
52
  </script>