WhatsApp me - Version 1.4.1

Version Description

  • Fix JS frontend sometimes can't load WhatsApp me settings.
  • Fix better Google Analitycs event tracking when leave page.
Download this release

Release Info

Developer creapuntome
Plugin Icon 128x128 WhatsApp me
Version 1.4.1
Comparing to
See all releases

Code changes from version 1.4.0 to 1.4.1

Files changed (3) hide show
  1. README.txt +5 -1
  2. public/js/whatsappme.js +21 -7
  3. whatsappme.php +2 -2
README.txt CHANGED
@@ -5,7 +5,7 @@ Tags: whatsapp, button, chat, support, contact
5
Requires at least: 3.0.1
6
Tested up to: 4.9.4
7
Requires PHP: 5.3
8
- Stable tag: 1.4.0
9
License: GPLv2 or later
10
License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
@@ -54,6 +54,10 @@ Greater values of z-index are left over, the default value is 400.
54
55
== Changelog ==
56
57
= 1.4.0 =
58
* **NEW:** Added the option to define the first message to send. You can include variables such as {SITE}, {URL} or {TITLE}.
59
* Fix PHP notice when global $post is null (e.g. search results or login page).
5
Requires at least: 3.0.1
6
Tested up to: 4.9.4
7
Requires PHP: 5.3
8
+ Stable tag: 1.4.1
9
License: GPLv2 or later
10
License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
54
55
== Changelog ==
56
57
+ = 1.4.1 =
58
+ * Fix JS frontend sometimes can't load WhatsApp me settings.
59
+ * Fix better Google Analitycs event tracking when leave page.
60
+
61
= 1.4.0 =
62
* **NEW:** Added the option to define the first message to send. You can include variables such as {SITE}, {URL} or {TITLE}.
63
* Fix PHP notice when global $post is null (e.g. search results or login page).
public/js/whatsappme.js CHANGED
@@ -4,16 +4,25 @@
4
$(function () {
5
var delay_on_start = 3000;
6
var $whatsappme = $('.whatsappme');
7
8
// only works if whatsappme is defined
9
- if ($whatsappme.length && typeof ($whatsappme.data('settings')) == 'object') {
10
whatsappme_magic();
11
}
12
13
function whatsappme_magic() {
14
var is_mobile = !!navigator.userAgent.match(/Android|iPhone|BlackBerry|IEMobile|Opera Mini/i);
15
var timeoutID = null;
16
- var settings = $whatsappme.data('settings');
17
18
// stored values
19
var is_clicked = localStorage.whatsappme_click == 'yes';
@@ -21,18 +30,18 @@
21
localStorage.whatsappme_views = views;
22
23
// show button / dialog
24
- if (!settings.mobile_only || is_mobile) {
25
setTimeout(function () {
26
$whatsappme.addClass('whatsappme--show');
27
}, delay_on_start);
28
if (views > 1 && !is_clicked) {
29
setTimeout(function () {
30
$whatsappme.addClass('whatsappme--dialog');
31
- }, delay_on_start + settings.message_delay);
32
}
33
}
34
35
- if (!is_mobile && settings.message_text !== '') {
36
$('.whatsappme__button').mouseenter(function () {
37
timeoutID = setTimeout(function () {
38
$whatsappme.addClass('whatsappme--dialog');
@@ -48,10 +57,15 @@
48
49
// Send Google Analytics event
50
if (typeof (ga) !== 'undefined') {
51
- ga('send', 'event', 'WhatsAppMe', 'click');
52
}
53
54
- whatsapp_open(settings.telephone, settings.message_send);
55
});
56
57
$('.whatsappme__close').click(function () {
4
$(function () {
5
var delay_on_start = 3000;
6
var $whatsappme = $('.whatsappme');
7
+ var wame_settings = $whatsappme.data('settings');
8
+
9
+ // In some strange cases data settings are empty
10
+ if (typeof($whatsappme.data('settings')) == 'undefined') {
11
+ try {
12
+ wame_settings = JSON.parse($whatsappme.attr('data-settings'));
13
+ } catch (error) {
14
+ wame_settings = undefined;
15
+ }
16
+ }
17
18
// only works if whatsappme is defined
19
+ if ($whatsappme.length && !!wame_settings && !!wame_settings.telephone) {
20
whatsappme_magic();
21
}
22
23
function whatsappme_magic() {
24
var is_mobile = !!navigator.userAgent.match(/Android|iPhone|BlackBerry|IEMobile|Opera Mini/i);
25
var timeoutID = null;
26
27
// stored values
28
var is_clicked = localStorage.whatsappme_click == 'yes';
30
localStorage.whatsappme_views = views;
31
32
// show button / dialog
33
+ if (!wame_settings.mobile_only || is_mobile) {
34
setTimeout(function () {
35
$whatsappme.addClass('whatsappme--show');
36
}, delay_on_start);
37
if (views > 1 && !is_clicked) {
38
setTimeout(function () {
39
$whatsappme.addClass('whatsappme--dialog');
40
+ }, delay_on_start + wame_settings.message_delay);
41
}
42
}
43
44
+ if (!is_mobile && wame_settings.message_text !== '') {
45
$('.whatsappme__button').mouseenter(function () {
46
timeoutID = setTimeout(function () {
47
$whatsappme.addClass('whatsappme--dialog');
57
58
// Send Google Analytics event
59
if (typeof (ga) !== 'undefined') {
60
+ ga('send', 'event', {
61
+ eventCategory: 'WhatsAppMe',
62
+ eventAction: 'click',
63
+ eventLabel: window.location.toString(),
64
+ transport: 'beacon'
65
+ });
66
}
67
68
+ whatsapp_open(wame_settings.telephone, wame_settings.message_send);
69
});
70
71
$('.whatsappme__close').click(function () {
whatsappme.php CHANGED
@@ -9,7 +9,7 @@
9
* Plugin Name: WhatsApp me
10
* Plugin URI: https://crea.me/productos/whatsapp-me/
11
* Description: Add support to your clients directly with WhatsApp.
12
- * Version: 1.4.0
13
* Author: Creame
14
* Author URI: https://crea.me
15
* License: GPL-2.0+
@@ -27,7 +27,7 @@ if ( ! defined( 'WPINC' ) ) {
27
* Currently plugin version.
28
* Start at version 1.0.0 and use SemVer - https://semver.org
29
*/
30
- define( 'WHATSAPPME_VERSION', '1.4.0' );
31
32
/**
33
* The core plugin class that is used to define internationalization,
9
* Plugin Name: WhatsApp me
10
* Plugin URI: https://crea.me/productos/whatsapp-me/
11
* Description: Add support to your clients directly with WhatsApp.
12
+ * Version: 1.4.1
13
* Author: Creame
14
* Author URI: https://crea.me
15
* License: GPL-2.0+
27
* Currently plugin version.
28
* Start at version 1.0.0 and use SemVer - https://semver.org
29
*/
30
+ define( 'WHATSAPPME_VERSION', '1.4.1' );
31
32
/**
33
* The core plugin class that is used to define internationalization,