Version Description
- NEW: Now can change telephone number on every post/page.
- NEW: Send Google Tag Manager event on click.
- NEW: New filter 'whatsappme_whastapp_web'. Set true if you prefer to open WhatsApp Web on desktop.
- NEW: "Send button" change when dialog is opened.
- UPDATED Tested up to Wordpress v.5.1.
- UPDATED International Telephone Input library to v.15.
Download this release
Release Info
Developer | creapuntome |
Plugin | WhatsApp me |
Version | 2.2.0 |
Comparing to | |
See all releases |
Code changes from version 2.1.3 to 2.2.0
- README.txt +14 -4
- admin/class-whatsappme-admin.php +43 -11
- admin/js/whatsappme.js +61 -56
- public/class-whatsappme-public.php +16 -6
- public/css/whatsappme.css +31 -3
- public/js/whatsappme.js +25 -17
- whatsappme.php +3 -3
README.txt
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
=== WhatsApp me ===
|
2 |
Contributors: creapuntome, pacotole, davidlillo
|
3 |
Donate link: https://www.paypal.me/creapuntome/
|
4 |
-
Tags: whatsapp, button, chat, support, contact
|
5 |
Requires at least: 3.0.1
|
6 |
-
Tested up to:
|
7 |
Requires PHP: 5.3
|
8 |
-
Stable tag: 2.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -13,7 +13,7 @@ Add support to your visitors directly with WhatsApp.
|
|
13 |
|
14 |
== Description ==
|
15 |
|
16 |
-
### The perfect plugin to engage and retain customers.
|
17 |
|
18 |
#### Communication with your customers can be very easy
|
19 |
|
@@ -34,6 +34,8 @@ Options:
|
|
34 |
8. If you have Google Analytics, an event is triggered when the user launches WhatsApp.
|
35 |
9. Can override call to action, message or visibility on every post, page or custom post.
|
36 |
|
|
|
|
|
37 |
== Installation ==
|
38 |
|
39 |
1. Upload the entire `creame-whatsapp-me` folder to the `/wp-content/plugins/` directory.
|
@@ -61,6 +63,14 @@ WhatsApp me don't save any personal data and don't use cookies.
|
|
61 |
|
62 |
== Changelog ==
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
= 2.1.3 =
|
65 |
* FIX PHP warning on some rare cases.
|
66 |
|
1 |
=== WhatsApp me ===
|
2 |
Contributors: creapuntome, pacotole, davidlillo
|
3 |
Donate link: https://www.paypal.me/creapuntome/
|
4 |
+
Tags: whatsapp, button, chat, support, contact, click to chat, directly message whatsapp, floating whatsapp, whatsapp chat, whatsapp support, whatsapp business, wame chat, messaging, help desk
|
5 |
Requires at least: 3.0.1
|
6 |
+
Tested up to: 5.1
|
7 |
Requires PHP: 5.3
|
8 |
+
Stable tag: 2.2.0
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
13 |
|
14 |
== Description ==
|
15 |
|
16 |
+
### The perfect plugin to engage and retain customers. Support for ecommece and online stores. Your clients will love it. Analytics integration.
|
17 |
|
18 |
#### Communication with your customers can be very easy
|
19 |
|
34 |
8. If you have Google Analytics, an event is triggered when the user launches WhatsApp.
|
35 |
9. Can override call to action, message or visibility on every post, page or custom post.
|
36 |
|
37 |
+
More info, news and tricks in [wame.chat](https://wame.chat)
|
38 |
+
|
39 |
== Installation ==
|
40 |
|
41 |
1. Upload the entire `creame-whatsapp-me` folder to the `/wp-content/plugins/` directory.
|
63 |
|
64 |
== Changelog ==
|
65 |
|
66 |
+
= 2.2.0 =
|
67 |
+
* **NEW:** Now can change telephone number on every post/page.
|
68 |
+
* **NEW:** Send Google Tag Manager event on click.
|
69 |
+
* **NEW:** New filter 'whatsappme_whastapp_web'. Set true if you prefer to open WhatsApp Web on desktop.
|
70 |
+
* **NEW:** "Send button" change when dialog is opened.
|
71 |
+
* UPDATED Tested up to Wordpress v.5.1.
|
72 |
+
* UPDATED International Telephone Input library to v.15.
|
73 |
+
|
74 |
= 2.1.3 =
|
75 |
* FIX PHP warning on some rare cases.
|
76 |
|
admin/class-whatsappme-admin.php
CHANGED
@@ -102,14 +102,16 @@ class WhatsAppMe_Admin {
|
|
102 |
*
|
103 |
* @since 1.2.0
|
104 |
* @since 2.0.0 Added whatsappme-admin styles
|
|
|
105 |
* @param string $hook The name of the page.
|
106 |
* @return void
|
107 |
*/
|
108 |
public function enqueue_styles($hook) {
|
109 |
|
110 |
-
|
111 |
-
|
112 |
-
|
|
|
113 |
}
|
114 |
|
115 |
}
|
@@ -118,14 +120,17 @@ class WhatsAppMe_Admin {
|
|
118 |
* Register the JavaScript for the admin area.
|
119 |
*
|
120 |
* @since 1.2.0
|
|
|
121 |
* @param string $hook The id of the page.
|
122 |
* @return void
|
123 |
*/
|
124 |
public function enqueue_scripts($hook) {
|
125 |
|
126 |
-
if (
|
127 |
-
|
128 |
-
|
|
|
|
|
129 |
}
|
130 |
|
131 |
}
|
@@ -271,8 +276,10 @@ class WhatsAppMe_Admin {
|
|
271 |
$input['message_badge'] = isset( $input['message_badge'] ) ? 'yes' : 'no';
|
272 |
$input['message_send'] = $this->clean_input( $input['message_send'] );
|
273 |
$input['position'] = $input['position'] != 'left' ? 'right' : 'left';
|
274 |
-
|
275 |
-
|
|
|
|
|
276 |
|
277 |
add_settings_error( 'whatsappme', 'settings_updated', __( 'Settings saved', 'creame-whatsapp-me' ), 'updated' );
|
278 |
|
@@ -325,8 +332,7 @@ class WhatsAppMe_Admin {
|
|
325 |
* @return void
|
326 |
*/
|
327 |
public function field_telephone() {
|
328 |
-
|
329 |
-
echo '<input id="whatsappme_phone" name="' . $name . '" value="' . $this->settings['telephone'] . '" type="text" style="width:15em;height:28px;line-height:1;">' .
|
330 |
'<p class="description">' . __( "Contact phone number. <strong>The button will not be shown if it's empty.</strong>", 'creame-whatsapp-me' ) . '</p>';
|
331 |
}
|
332 |
|
@@ -349,7 +355,7 @@ class WhatsAppMe_Admin {
|
|
349 |
* @return void
|
350 |
*/
|
351 |
public function field_message_delay() {
|
352 |
-
echo '<input name="whatsappme[message_delay]" value="' . $this->settings['message_delay'] . '"
|
353 |
'<p class="description"> ' . __( 'The <strong>Call to action</strong> will be automatically displayed once when the user exceeds the estimated delay on a page.', 'creame-whatsapp-me' ) . '</p>';
|
354 |
}
|
355 |
|
@@ -473,10 +479,19 @@ class WhatsAppMe_Admin {
|
|
473 |
* Generate the options page in the wordpress admin
|
474 |
*
|
475 |
* @since 1.0.0
|
|
|
476 |
* @access public
|
477 |
* @return void
|
478 |
*/
|
479 |
function options_page() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
480 |
?>
|
481 |
<div class="wrap">
|
482 |
<h1>WhatsApp me</h1>
|
@@ -525,13 +540,22 @@ class WhatsAppMe_Admin {
|
|
525 |
*
|
526 |
* @since 1.1.0 (previously named "add_meta_box")
|
527 |
* @since 2.0.0 Now can set as [show, hide, default]
|
|
|
528 |
* @access public
|
529 |
* @return void
|
530 |
*/
|
531 |
public function meta_box( $post ) {
|
532 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
533 |
$metadata = get_post_meta( $post->ID, '_whatsappme', true ) ?: array();
|
534 |
$metadata = array_merge( array(
|
|
|
535 |
'message_text' => '',
|
536 |
'message_send' => '',
|
537 |
'hide' => false,
|
@@ -547,6 +571,10 @@ class WhatsAppMe_Admin {
|
|
547 |
wp_nonce_field( 'whatsappme_data', 'whatsappme_nonce' );
|
548 |
?>
|
549 |
<div class="whatsappme-metabox">
|
|
|
|
|
|
|
|
|
550 |
<p>
|
551 |
<label for="whatsappme_message"><?php _e( 'Call to action', 'creame-whatsapp-me' ); ?></label><br>
|
552 |
<textarea name="whatsappme_message" rows="2" class="large-text"><?php echo $metadata['message_text']; ?></textarea>
|
@@ -568,6 +596,8 @@ class WhatsAppMe_Admin {
|
|
568 |
<style>
|
569 |
.whatsappme-metabox code { font-size:smaller; vertical-align:text-bottom; }
|
570 |
.whatsappme-metabox .dashicons { opacity:.5; }
|
|
|
|
|
571 |
.whatsappme-metabox input[type=radio] { margin-right:1px; }
|
572 |
.whatsappme-metabox input[type=radio]+span { margin-right:5px; transition:all 200ms; }
|
573 |
.whatsappme-metabox input[type=radio]:checked+span { color:#79ba49; opacity:1; }
|
@@ -581,6 +611,7 @@ class WhatsAppMe_Admin {
|
|
581 |
*
|
582 |
* @since 1.1.0
|
583 |
* @since 2.0.0 Change 'hide' key to 'view' now values can be [yes, no]
|
|
|
584 |
* @access public
|
585 |
* @return void
|
586 |
*/
|
@@ -593,6 +624,7 @@ class WhatsAppMe_Admin {
|
|
593 |
|
594 |
// Clean and delete empty/false fields
|
595 |
$metadata = array_filter( $this->clean_input( array(
|
|
|
596 |
'message_text' => $_POST['whatsappme_message'],
|
597 |
'message_send' => $_POST['whatsappme_message_send'],
|
598 |
'view' => $_POST['whatsappme_view'],
|
102 |
*
|
103 |
* @since 1.2.0
|
104 |
* @since 2.0.0 Added whatsappme-admin styles
|
105 |
+
* @since 2.2.0 Only register (not enqueue)
|
106 |
* @param string $hook The name of the page.
|
107 |
* @return void
|
108 |
*/
|
109 |
public function enqueue_styles($hook) {
|
110 |
|
111 |
+
wp_register_style( 'whatsappme-admin', plugin_dir_url( __FILE__ ) . 'css/whatsappme.css', array(), $this->version, 'all' );
|
112 |
+
|
113 |
+
if ( $this->enhanced_phone ) {
|
114 |
+
wp_register_style( 'intl-tel-input', 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/15.0.1/css/intlTelInput.css', array(), null, 'all' );
|
115 |
}
|
116 |
|
117 |
}
|
120 |
* Register the JavaScript for the admin area.
|
121 |
*
|
122 |
* @since 1.2.0
|
123 |
+
* @since 2.2.0 Only register (not enqueue)
|
124 |
* @param string $hook The id of the page.
|
125 |
* @return void
|
126 |
*/
|
127 |
public function enqueue_scripts($hook) {
|
128 |
|
129 |
+
if ( $this->enhanced_phone ) {
|
130 |
+
wp_register_script( 'intl-tel-input', 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/15.0.1/js/intlTelInput.min.js', array(), null, true );
|
131 |
+
wp_register_script( 'whatsappme-admin', plugin_dir_url( __FILE__ ) . 'js/whatsappme.js', array( 'jquery', 'intl-tel-input' ), $this->version, true );
|
132 |
+
} else {
|
133 |
+
wp_register_script( 'whatsappme-admin', plugin_dir_url( __FILE__ ) . 'js/whatsappme.js', array( 'jquery' ), $this->version, true );
|
134 |
}
|
135 |
|
136 |
}
|
276 |
$input['message_badge'] = isset( $input['message_badge'] ) ? 'yes' : 'no';
|
277 |
$input['message_send'] = $this->clean_input( $input['message_send'] );
|
278 |
$input['position'] = $input['position'] != 'left' ? 'right' : 'left';
|
279 |
+
if ( isset( $input['view'] ) ) {
|
280 |
+
$input['visibility'] = array_filter( $input['view'], function($v) { return $v == 'yes' || $v == 'no'; } );
|
281 |
+
unset( $input['view'] );
|
282 |
+
}
|
283 |
|
284 |
add_settings_error( 'whatsappme', 'settings_updated', __( 'Settings saved', 'creame-whatsapp-me' ), 'updated' );
|
285 |
|
332 |
* @return void
|
333 |
*/
|
334 |
public function field_telephone() {
|
335 |
+
echo '<input id="whatsappme_phone" ' . ( $this->enhanced_phone ? 'data-' : '') . 'name="whatsappme[telephone]" value="' . $this->settings['telephone'] . '" type="text" style="width:15em">' .
|
|
|
336 |
'<p class="description">' . __( "Contact phone number. <strong>The button will not be shown if it's empty.</strong>", 'creame-whatsapp-me' ) . '</p>';
|
337 |
}
|
338 |
|
355 |
* @return void
|
356 |
*/
|
357 |
public function field_message_delay() {
|
358 |
+
echo '<input name="whatsappme[message_delay]" value="' . $this->settings['message_delay'] . '" type="number" min="0" style="width:6em"> ' . __( 'milliseconds', 'creame-whatsapp-me' ) .
|
359 |
'<p class="description"> ' . __( 'The <strong>Call to action</strong> will be automatically displayed once when the user exceeds the estimated delay on a page.', 'creame-whatsapp-me' ) . '</p>';
|
360 |
}
|
361 |
|
479 |
* Generate the options page in the wordpress admin
|
480 |
*
|
481 |
* @since 1.0.0
|
482 |
+
* @since 2.2.0 Enqueue scripts/styles
|
483 |
* @access public
|
484 |
* @return void
|
485 |
*/
|
486 |
function options_page() {
|
487 |
+
|
488 |
+
// Enqueue assets
|
489 |
+
wp_enqueue_script( 'whatsappme-admin' );
|
490 |
+
wp_enqueue_style( 'whatsappme-admin' );
|
491 |
+
|
492 |
+
if ( $this->enhanced_phone ) {
|
493 |
+
wp_enqueue_style( 'intl-tel-input' );
|
494 |
+
}
|
495 |
?>
|
496 |
<div class="wrap">
|
497 |
<h1>WhatsApp me</h1>
|
540 |
*
|
541 |
* @since 1.1.0 (previously named "add_meta_box")
|
542 |
* @since 2.0.0 Now can set as [show, hide, default]
|
543 |
+
* @since 2.2.0 Enqueue scripts/styles. Added "telephone"
|
544 |
* @access public
|
545 |
* @return void
|
546 |
*/
|
547 |
public function meta_box( $post ) {
|
548 |
|
549 |
+
// Enqueue assets
|
550 |
+
wp_enqueue_script( 'whatsappme-admin' );
|
551 |
+
|
552 |
+
if ( $this->enhanced_phone ) {
|
553 |
+
wp_enqueue_style( 'intl-tel-input' );
|
554 |
+
}
|
555 |
+
|
556 |
$metadata = get_post_meta( $post->ID, '_whatsappme', true ) ?: array();
|
557 |
$metadata = array_merge( array(
|
558 |
+
'telephone' => '',
|
559 |
'message_text' => '',
|
560 |
'message_send' => '',
|
561 |
'hide' => false,
|
571 |
wp_nonce_field( 'whatsappme_data', 'whatsappme_nonce' );
|
572 |
?>
|
573 |
<div class="whatsappme-metabox">
|
574 |
+
<p>
|
575 |
+
<label for="whatsappme_phone"><?php _e( 'Telephone', 'creame-whatsapp-me' ); ?></label><br>
|
576 |
+
<input id="whatsappme_phone" <?php echo $this->enhanced_phone ? 'data-' : ''; ?>name="whatsappme_telephone" value="<?php echo $metadata['telephone']; ?>" type="text">
|
577 |
+
</p>
|
578 |
<p>
|
579 |
<label for="whatsappme_message"><?php _e( 'Call to action', 'creame-whatsapp-me' ); ?></label><br>
|
580 |
<textarea name="whatsappme_message" rows="2" class="large-text"><?php echo $metadata['message_text']; ?></textarea>
|
596 |
<style>
|
597 |
.whatsappme-metabox code { font-size:smaller; vertical-align:text-bottom; }
|
598 |
.whatsappme-metabox .dashicons { opacity:.5; }
|
599 |
+
.whatsappme-metabox input::placeholder { color:#dedfe0; }
|
600 |
+
.whatsappme-metabox input::-ms-input-placeholder { color:#dedfe0; }
|
601 |
.whatsappme-metabox input[type=radio] { margin-right:1px; }
|
602 |
.whatsappme-metabox input[type=radio]+span { margin-right:5px; transition:all 200ms; }
|
603 |
.whatsappme-metabox input[type=radio]:checked+span { color:#79ba49; opacity:1; }
|
611 |
*
|
612 |
* @since 1.1.0
|
613 |
* @since 2.0.0 Change 'hide' key to 'view' now values can be [yes, no]
|
614 |
+
* @since 2.2.0 Added "telephone"
|
615 |
* @access public
|
616 |
* @return void
|
617 |
*/
|
624 |
|
625 |
// Clean and delete empty/false fields
|
626 |
$metadata = array_filter( $this->clean_input( array(
|
627 |
+
'telephone' => $_POST['whatsappme_telephone'],
|
628 |
'message_text' => $_POST['whatsappme_message'],
|
629 |
'message_send' => $_POST['whatsappme_message_send'],
|
630 |
'view' => $_POST['whatsappme_view'],
|
admin/js/whatsappme.js
CHANGED
@@ -2,56 +2,37 @@
|
|
2 |
'use strict';
|
3 |
|
4 |
$(function () {
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
var countryCode = (resp && resp.country) ? resp.country : "";
|
19 |
-
localStorage.whatsappme_country_code = JSON.stringify({ code: countryCode, date: new Date().toDateString() });
|
20 |
-
callback(countryCode);
|
21 |
-
});
|
22 |
-
}
|
23 |
-
},
|
24 |
-
utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/12.1.9/js/utils.js"
|
25 |
-
});
|
26 |
-
|
27 |
-
$phone.on("keyup change", function () {
|
28 |
-
$phone.css('border-color', '');
|
29 |
-
});
|
30 |
-
$phone.on("blur", function () {
|
31 |
-
$phone.css('border-color', $.trim($phone.val()) && !$phone.intlTelInput("isValidNumber") ? '#ff0000' : '');
|
32 |
-
});
|
33 |
-
|
34 |
-
$('.nav-tab').click(function (e) {
|
35 |
-
var $tab = $(this);
|
36 |
-
e.preventDefault();
|
37 |
-
|
38 |
-
$('.nav-tab').removeClass('nav-tab-active');
|
39 |
-
$tab.addClass('nav-tab-active').blur();
|
40 |
-
$('.tab').removeClass('tab-active');
|
41 |
-
$($tab.attr('href')).addClass('tab-active');
|
42 |
-
});
|
43 |
-
|
44 |
-
var $tab_advanced = $('#tab-advanced');
|
45 |
-
var inheritance = {
|
46 |
-
'all': ['front_page', 'blog_page', '404_page', 'search', 'archive', 'singular', 'woocommerce', 'cpts'],
|
47 |
-
'archive': ['date', 'author'],
|
48 |
-
'singular': ['page', 'post'],
|
49 |
-
'woocommerce': ['product', 'cart', 'checkout', 'account_page']
|
50 |
-
};
|
51 |
-
|
52 |
-
$('input', $tab_advanced).change(function () {
|
53 |
-
propagate_inheritance();
|
54 |
-
});
|
55 |
|
56 |
function propagate_inheritance(field, show) {
|
57 |
field = field || 'all';
|
@@ -73,13 +54,37 @@
|
|
73 |
}
|
74 |
}
|
75 |
|
76 |
-
$('
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
});
|
85 |
})(jQuery);
|
2 |
'use strict';
|
3 |
|
4 |
$(function () {
|
5 |
+
if (typeof (intlTelInput) === 'function') {
|
6 |
+
var country_request = JSON.parse(localStorage.whatsappme_country_code || '{}');
|
7 |
+
var country_code = (country_request.code && country_request.date == new Date().toDateString()) ? country_request.code : false;
|
8 |
+
var $phone = $("#whatsappme_phone");
|
9 |
+
var iti = intlTelInput($phone.get(0), {
|
10 |
+
hiddenInput: $phone.data("name") || "whatsappme[telephone]",
|
11 |
+
initialCountry: "auto",
|
12 |
+
preferredCountries: [country_code || ''],
|
13 |
+
geoIpLookup: function (callback) {
|
14 |
+
if (country_code) {
|
15 |
+
callback(country_code);
|
16 |
+
} else {
|
17 |
+
$.getJSON('https://ipinfo.io').always(function (resp) {
|
18 |
+
var countryCode = (resp && resp.country) ? resp.country : "";
|
19 |
+
localStorage.whatsappme_country_code = JSON.stringify({ code: countryCode, date: new Date().toDateString() });
|
20 |
+
callback(countryCode);
|
21 |
+
});
|
22 |
+
}
|
23 |
+
},
|
24 |
+
utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/15.0.1/js/utils.js"
|
25 |
+
});
|
26 |
|
27 |
+
$phone.on("keyup change", function () {
|
28 |
+
$phone.css('border-color', '');
|
29 |
+
// Ensures number it's updated on AJAX save (Gutemberg)
|
30 |
+
iti.hiddenInput.value = iti.getNumber();
|
31 |
+
});
|
32 |
+
$phone.on("blur", function () {
|
33 |
+
$phone.css('border-color', $phone.val().trim() && !iti.isValidNumber() ? '#ff0000' : '');
|
34 |
+
});
|
35 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
function propagate_inheritance(field, show) {
|
38 |
field = field || 'all';
|
54 |
}
|
55 |
}
|
56 |
|
57 |
+
if ($('#whatsappme_form').length === 1) {
|
58 |
+
$('.nav-tab').click(function (e) {
|
59 |
+
var $tab = $(this);
|
60 |
+
e.preventDefault();
|
61 |
+
|
62 |
+
$('.nav-tab').removeClass('nav-tab-active');
|
63 |
+
$tab.addClass('nav-tab-active').blur();
|
64 |
+
$('.tab').removeClass('tab-active');
|
65 |
+
$($tab.attr('href')).addClass('tab-active');
|
66 |
+
});
|
67 |
+
|
68 |
+
var $tab_advanced = $('#tab-advanced');
|
69 |
+
var inheritance = {
|
70 |
+
'all': ['front_page', 'blog_page', '404_page', 'search', 'archive', 'singular', 'woocommerce', 'cpts'],
|
71 |
+
'archive': ['date', 'author'],
|
72 |
+
'singular': ['page', 'post'],
|
73 |
+
'woocommerce': ['product', 'cart', 'checkout', 'account_page']
|
74 |
+
};
|
75 |
+
|
76 |
+
$('input', $tab_advanced).change(function () {
|
77 |
+
propagate_inheritance();
|
78 |
+
});
|
79 |
|
80 |
+
$('.whatsappme_view_reset').click(function (e) {
|
81 |
+
e.preventDefault();
|
82 |
+
$('input[value=""]', $tab_advanced).prop('checked', true);
|
83 |
+
$('.whatsappme_view_all input', $tab_advanced).first().prop('checked', true);
|
84 |
+
propagate_inheritance();
|
85 |
+
});
|
86 |
+
|
87 |
+
propagate_inheritance();
|
88 |
+
}
|
89 |
});
|
90 |
})(jQuery);
|
public/class-whatsappme-public.php
CHANGED
@@ -71,6 +71,7 @@ class WhatsAppMe_Public {
|
|
71 |
*
|
72 |
* @since 1.0.0
|
73 |
* @since 2.0.0 Check visibility
|
|
|
74 |
* @return void
|
75 |
*/
|
76 |
public function get_settings() {
|
@@ -94,16 +95,19 @@ class WhatsAppMe_Public {
|
|
94 |
unset( $post_settings['hide'] );
|
95 |
}
|
96 |
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
$settings['mobile_only'] = $settings['mobile_only'] == 'yes';
|
101 |
if ( isset( $post_settings['message_text'] ) ) {
|
102 |
$settings['message_text'] = $post_settings['message_text'];
|
103 |
}
|
104 |
if ( isset( $post_settings['message_send'] ) ) {
|
105 |
$settings['message_send'] = $post_settings['message_send'];
|
106 |
}
|
|
|
|
|
|
|
|
|
107 |
$settings['message_badge'] = $settings['message_text'] && $settings['message_badge'] == 'yes';
|
108 |
$settings['message_send'] = $this->formated_message_send( $settings['message_send'] );
|
109 |
|
@@ -114,6 +118,9 @@ class WhatsAppMe_Public {
|
|
114 |
$this->check_visibility( $settings['visibility'] );
|
115 |
}
|
116 |
|
|
|
|
|
|
|
117 |
$this->settings = $settings;
|
118 |
}
|
119 |
|
@@ -162,20 +169,23 @@ class WhatsAppMe_Public {
|
|
162 |
// Clean unnecessary settings on front
|
163 |
$data = array_diff_key( $this->settings, array_flip( array( 'show', 'visibility', 'position' ) ) );
|
164 |
|
|
|
|
|
165 |
if ( $this->settings['show'] ) {
|
166 |
?>
|
167 |
<div class="whatsappme whatsappme--<?php echo $this->settings['position']; ?>" data-settings="<?php echo esc_attr( json_encode( $data ) ); ?>">
|
168 |
<div class="whatsappme__button">
|
169 |
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M.057 24l1.687-6.
|
170 |
<?php if ($this->settings['message_badge']): ?><div class="whatsappme__badge">1</div><?php endif; ?>
|
171 |
</div>
|
172 |
<?php if ($this->settings['message_text']): ?>
|
173 |
<div class="whatsappme__box">
|
174 |
<header class="whatsappme__header">
|
175 |
-
<svg xmlns="http://www.w3.org/2000/svg" width="120" height="28" viewBox="0 0 120 28"><path d="M117.2 17c0 .4-.2.7-.4 1-.1.3-.4.5-.7.7l-1 .2c-.5 0-.9 0-1.2-.2l-.7-.7a3 3 0 0 1-.4-1 5.4 5.4 0 0 1 0-2.3c0-.4.2-.7.4-1l.7-.7a2 2 0 0 1 1.1-.3 2 2 0 0 1 1.8 1l.4 1a5.3 5.3 0 0 1 0 2.3zm2.5-3c-.1-.7-.4-1.3-.8-1.7a4 4 0 0 0-1.3-1.2c-.6-.3-1.3-.4-2-.4-.6 0-1.2.1-1.7.4a3 3 0 0 0-1.2 1.1V11H110v13h2.7v-4.5c.4.4.8.8 1.3 1 .5.3 1 .4 1.6.4a4 4 0 0 0 3.2-1.5c.4-.5.7-1 .8-1.6.2-.6.3-1.2.3-1.9s0-1.3-.3-2zm-13.1 3c0 .4-.2.7-.4 1l-.7.7-1.1.2c-.4 0-.8 0-1-.2-.4-.2-.6-.4-.8-.7a3 3 0 0 1-.4-1 5.4 5.4 0 0 1 0-2.3c0-.4.2-.7.4-1 .1-.3.4-.5.7-.7a2 2 0 0 1 1-.3 2 2 0 0 1 1.9 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-.5A11.5 11.5 0 0 1 22.1 5.7 11.5 11.5 0 0 1 14 25.3zM14 0A13.8 13.8 0 0 0 2 20.7L0 28l7.3-2A13.8 13.8 0 1 0 14 0z"
|
176 |
<div class="whatsappme__close">×</div>
|
177 |
</header>
|
178 |
<div class="whatsappme__message"><?php echo $this->formated_message(); ?></div>
|
|
|
179 |
</div>
|
180 |
<?php endif; ?>
|
181 |
</div>
|
71 |
*
|
72 |
* @since 1.0.0
|
73 |
* @since 2.0.0 Check visibility
|
74 |
+
* @since 2.2.0 Post settings can also change "telephone". Added 'whastapp_web' setting
|
75 |
* @return void
|
76 |
*/
|
77 |
public function get_settings() {
|
95 |
unset( $post_settings['hide'] );
|
96 |
}
|
97 |
|
98 |
+
if ( isset( $post_settings['telephone'] ) ) {
|
99 |
+
$settings['telephone'] = $post_settings['telephone'];
|
100 |
+
}
|
|
|
101 |
if ( isset( $post_settings['message_text'] ) ) {
|
102 |
$settings['message_text'] = $post_settings['message_text'];
|
103 |
}
|
104 |
if ( isset( $post_settings['message_send'] ) ) {
|
105 |
$settings['message_send'] = $post_settings['message_send'];
|
106 |
}
|
107 |
+
// Prepare settings
|
108 |
+
$settings['telephone'] = preg_replace( '/^0+|\D/', '', $settings['telephone'] );
|
109 |
+
$settings['position'] = $settings['position'] != 'left' ? 'right' : 'left';
|
110 |
+
$settings['mobile_only'] = $settings['mobile_only'] == 'yes';
|
111 |
$settings['message_badge'] = $settings['message_text'] && $settings['message_badge'] == 'yes';
|
112 |
$settings['message_send'] = $this->formated_message_send( $settings['message_send'] );
|
113 |
|
118 |
$this->check_visibility( $settings['visibility'] );
|
119 |
}
|
120 |
|
121 |
+
// Set true to link http://web.whatsapp.com instead http://api.whatsapp.com
|
122 |
+
$settings['whastapp_web'] = apply_filters( 'whatsappme_whastapp_web', false );
|
123 |
+
|
124 |
$this->settings = $settings;
|
125 |
}
|
126 |
|
169 |
// Clean unnecessary settings on front
|
170 |
$data = array_diff_key( $this->settings, array_flip( array( 'show', 'visibility', 'position' ) ) );
|
171 |
|
172 |
+
$copy = apply_filters( 'whatsappme_copy', '<a href="https://wame.chat" rel="noopener" target="_blank">wame.chat</a>' );
|
173 |
+
|
174 |
if ( $this->settings['show'] ) {
|
175 |
?>
|
176 |
<div class="whatsappme whatsappme--<?php echo $this->settings['position']; ?>" data-settings="<?php echo esc_attr( json_encode( $data ) ); ?>">
|
177 |
<div class="whatsappme__button">
|
178 |
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M.057 24l1.687-6.163a11.867 11.867 0 0 1-1.587-5.946C.16 5.335 5.495 0 12.05 0a11.817 11.817 0 0 1 8.413 3.488 11.824 11.824 0 0 1 3.48 8.414c-.003 6.557-5.338 11.892-11.893 11.892a11.9 11.9 0 0 1-5.688-1.448L.057 24zm6.597-3.807c1.676.995 3.276 1.591 5.392 1.592 5.448 0 9.886-4.434 9.889-9.885.002-5.462-4.415-9.89-9.881-9.892-5.452 0-9.887 4.434-9.889 9.884-.001 2.225.651 3.891 1.746 5.634l-.999 3.648 3.742-.981zm11.387-5.464c-.074-.124-.272-.198-.57-.347-.297-.149-1.758-.868-2.031-.967-.272-.099-.47-.149-.669.149-.198.297-.768.967-.941 1.165-.173.198-.347.223-.644.074-.297-.149-1.255-.462-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.297-.347.446-.521.151-.172.2-.296.3-.495.099-.198.05-.372-.025-.521-.075-.148-.669-1.611-.916-2.206-.242-.579-.487-.501-.669-.51l-.57-.01c-.198 0-.52.074-.792.372s-1.04 1.016-1.04 2.479 1.065 2.876 1.213 3.074c.149.198 2.095 3.2 5.076 4.487.709.306 1.263.489 1.694.626.712.226 1.36.194 1.872.118.571-.085 1.758-.719 2.006-1.413.248-.695.248-1.29.173-1.414z"/></svg>
|
179 |
<?php if ($this->settings['message_badge']): ?><div class="whatsappme__badge">1</div><?php endif; ?>
|
180 |
</div>
|
181 |
<?php if ($this->settings['message_text']): ?>
|
182 |
<div class="whatsappme__box">
|
183 |
<header class="whatsappme__header">
|
184 |
+
<svg xmlns="http://www.w3.org/2000/svg" width="120" height="28" viewBox="0 0 120 28"><path fill="currentColor" fill-rule="evenodd" d="M117.2 17c0 .4-.2.7-.4 1-.1.3-.4.5-.7.7l-1 .2c-.5 0-.9 0-1.2-.2l-.7-.7a3 3 0 0 1-.4-1 5.4 5.4 0 0 1 0-2.3c0-.4.2-.7.4-1l.7-.7a2 2 0 0 1 1.1-.3 2 2 0 0 1 1.8 1l.4 1a5.3 5.3 0 0 1 0 2.3zm2.5-3c-.1-.7-.4-1.3-.8-1.7a4 4 0 0 0-1.3-1.2c-.6-.3-1.3-.4-2-.4-.6 0-1.2.1-1.7.4a3 3 0 0 0-1.2 1.1V11H110v13h2.7v-4.5c.4.4.8.8 1.3 1 .5.3 1 .4 1.6.4a4 4 0 0 0 3.2-1.5c.4-.5.7-1 .8-1.6.2-.6.3-1.2.3-1.9s0-1.3-.3-2zm-13.1 3c0 .4-.2.7-.4 1l-.7.7-1.1.2c-.4 0-.8 0-1-.2-.4-.2-.6-.4-.8-.7a3 3 0 0 1-.4-1 5.4 5.4 0 0 1 0-2.3c0-.4.2-.7.4-1 .1-.3.4-.5.7-.7a2 2 0 0 1 1-.3 2 2 0 0 1 1.9 1l.4 1a5.4 5.4 0 0 1 0 2.3zm1.7-4.7a4 4 0 0 0-3.3-1.6c-.6 0-1.2.1-1.7.4a3 3 0 0 0-1.2 1.1V11h-2.6v13h2.7v-4.5c.3.4.7.8 1.2 1 .6.3 1.1.4 1.7.4a4 4 0 0 0 3.2-1.5c.4-.5.6-1 .8-1.6.2-.6.3-1.2.3-1.9s-.1-1.3-.3-2c-.2-.6-.4-1.2-.8-1.6zm-17.5 3.2l1.7-5 1.7 5h-3.4zm.2-8.2l-5 13.4h3l1-3h5l1 3h3L94 7.3h-3zm-5.3 9.1l-.6-.8-1-.5a11.6 11.6 0 0 0-2.3-.5l-1-.3a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.6-.2 1-.5 1.5-1a4 4 0 0 0 .2 1H70l-.3-1v-1.2zm-11-6.7c-.2-.4-.6-.6-1-.8-.5-.2-1-.3-1.8-.3-.5 0-1 .1-1.5.4a3 3 0 0 0-1.3 1.2v-5h-2.7v13.4H53v-5.1c0-1 .2-1.7.5-2.2.3-.4.9-.6 1.6-.6.6 0 1 .2 1.3.6.3.4.4 1 .4 1.8v5.5h2.7v-6c0-.6 0-1.2-.2-1.6 0-.5-.3-1-.5-1.3zm-14 4.7l-2.3-9.2h-2.8l-2.3 9-2.2-9h-3l3.6 13.4h3l2.2-9.2 2.3 9.2h3l3.6-13.4h-3l-2.1 9.2zm-24.5.2L18 15.6c-.3-.1-.6-.2-.8.2A20 20 0 0 1 16 17c-.2.2-.4.3-.7.1-.4-.2-1.5-.5-2.8-1.7-1-1-1.7-2-2-2.4-.1-.4 0-.5.2-.7l.5-.6.4-.6v-.6L10.4 8c-.3-.6-.6-.5-.8-.6H9c-.2 0-.6.1-.9.5C7.8 8.2 7 9 7 10.7c0 1.7 1.3 3.4 1.4 3.6.2.3 2.5 3.7 6 5.2l1.9.8c.8.2 1.6.2 2.2.1.6-.1 2-.8 2.3-1.6.3-.9.3-1.5.2-1.7l-.7-.4zM14 25.3c-2 0-4-.5-5.8-1.6l-.4-.2-4.4 1.1 1.2-4.2-.3-.5A11.5 11.5 0 0 1 22.1 5.7 11.5 11.5 0 0 1 14 25.3zM14 0A13.8 13.8 0 0 0 2 20.7L0 28l7.3-2A13.8 13.8 0 1 0 14 0z"/></svg>
|
185 |
<div class="whatsappme__close">×</div>
|
186 |
</header>
|
187 |
<div class="whatsappme__message"><?php echo $this->formated_message(); ?></div>
|
188 |
+
<?php if ($copy): ?><div class="whatsappme__copy"><?php echo $copy; ?></div><?php endif; ?>
|
189 |
</div>
|
190 |
<?php endif; ?>
|
191 |
</div>
|
public/css/whatsappme.css
CHANGED
@@ -52,8 +52,8 @@
|
|
52 |
|
53 |
.whatsappme__button svg {
|
54 |
width: 36px;
|
55 |
-
height:
|
56 |
-
margin:
|
57 |
}
|
58 |
|
59 |
.whatsappme__badge {
|
@@ -86,6 +86,14 @@
|
|
86 |
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
|
87 |
}
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
.whatsappme__box {
|
90 |
position: absolute;
|
91 |
bottom: 0;
|
@@ -170,6 +178,26 @@
|
|
170 |
background-size: 100%;
|
171 |
}
|
172 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
/* Align left */
|
174 |
|
175 |
.whatsappme--left {
|
@@ -241,4 +269,4 @@
|
|
241 |
opacity: 0;
|
242 |
transform: translateY(-20px);
|
243 |
}
|
244 |
-
}
|
52 |
|
53 |
.whatsappme__button svg {
|
54 |
width: 36px;
|
55 |
+
height: 36px;
|
56 |
+
margin: 12px 12px;
|
57 |
}
|
58 |
|
59 |
.whatsappme__badge {
|
86 |
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
|
87 |
}
|
88 |
|
89 |
+
.whatsappme--dialog .whatsappme__button svg {
|
90 |
+
margin: 12px 10px 12px 14px;
|
91 |
+
}
|
92 |
+
|
93 |
+
.whatsappme--dialog .whatsappme__button svg path {
|
94 |
+
d: path("M1.101 21.757L23.8 12.028 1.101 2.3l.011 7.912 13.623 1.816-13.623 1.817-.011 7.912z");
|
95 |
+
}
|
96 |
+
|
97 |
.whatsappme__box {
|
98 |
position: absolute;
|
99 |
bottom: 0;
|
178 |
background-size: 100%;
|
179 |
}
|
180 |
|
181 |
+
.whatsappme__copy {
|
182 |
+
position: absolute;
|
183 |
+
bottom: 4px;
|
184 |
+
left: 40px;
|
185 |
+
color: #2e8c7d;
|
186 |
+
font-size: 11px;
|
187 |
+
letter-spacing: 0.2px;
|
188 |
+
}
|
189 |
+
|
190 |
+
.whatsappme__copy a {
|
191 |
+
font-weight: 600;
|
192 |
+
color: inherit;
|
193 |
+
text-decoration: none;
|
194 |
+
}
|
195 |
+
|
196 |
+
.whatsappme__copy a:hover {
|
197 |
+
color: inherit;
|
198 |
+
text-decoration: underline;
|
199 |
+
}
|
200 |
+
|
201 |
/* Align left */
|
202 |
|
203 |
.whatsappme--left {
|
269 |
opacity: 0;
|
270 |
transform: translateY(-20px);
|
271 |
}
|
272 |
+
}
|
public/js/whatsappme.js
CHANGED
@@ -39,7 +39,8 @@
|
|
39 |
function whatsappme_magic() {
|
40 |
var is_mobile = !!navigator.userAgent.match(/Android|iPhone|BlackBerry|IEMobile|Opera Mini/i);
|
41 |
var has_cta = wame_settings.message_text !== '';
|
42 |
-
var
|
|
|
43 |
|
44 |
// stored values
|
45 |
var messages_viewed = (store.getItem('whatsappme_hashes') || '').split(',').filter(Boolean);
|
@@ -58,9 +59,9 @@
|
|
58 |
|
59 |
if (has_cta && !is_viewed) {
|
60 |
if (wame_settings.message_badge) { // show badge
|
61 |
-
setTimeout(function () { $badge.addClass('whatsappme__badge--in'); }, delay_on_start + wame_settings.message_delay);
|
62 |
} else if (is_second_visit) { // show dialog
|
63 |
-
setTimeout(function () { $whatsappme.addClass('whatsappme--dialog'); }, delay_on_start + wame_settings.message_delay);
|
64 |
}
|
65 |
}
|
66 |
}
|
@@ -72,7 +73,7 @@
|
|
72 |
}
|
73 |
|
74 |
$('.whatsappme__button').click(function () {
|
75 |
-
var link = whatsapp_link(wame_settings.telephone, wame_settings.message_send);
|
76 |
|
77 |
if (has_cta && !$whatsappme.hasClass('whatsappme--dialog')) {
|
78 |
show_dialog();
|
@@ -92,6 +93,7 @@
|
|
92 |
|
93 |
function show_dialog() {
|
94 |
$whatsappme.addClass('whatsappme--dialog');
|
|
|
95 |
|
96 |
if (wame_settings.message_badge && $badge.hasClass('whatsappme__badge--in')) {
|
97 |
$badge.removeClass('whatsappme__badge--in').addClass('whatsappme__badge--out');
|
@@ -118,29 +120,35 @@
|
|
118 |
};
|
119 |
|
120 |
// Return WhatsApp link with optional message
|
121 |
-
function whatsapp_link(phone, message) {
|
122 |
-
var link = 'https://
|
123 |
-
if (typeof (message) == 'string' && message != '') {
|
124 |
-
link += '&text=' + encodeURIComponent(message);
|
125 |
-
}
|
126 |
|
127 |
-
return link;
|
128 |
}
|
129 |
|
130 |
// Trigger Google Analytics event
|
131 |
function send_event(link) {
|
132 |
-
if (typeof
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
gtag('event', 'click', {
|
134 |
'event_category': 'WhatsAppMe',
|
135 |
'event_label': link,
|
136 |
'transport_type': 'beacon'
|
137 |
});
|
138 |
-
} else if (typeof ga == 'function') {
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
'
|
144 |
});
|
145 |
}
|
146 |
}
|
39 |
function whatsappme_magic() {
|
40 |
var is_mobile = !!navigator.userAgent.match(/Android|iPhone|BlackBerry|IEMobile|Opera Mini/i);
|
41 |
var has_cta = wame_settings.message_text !== '';
|
42 |
+
var wa_web = wame_settings.whastapp_web && !is_mobile;
|
43 |
+
var message_hash, is_viewed, timeoutID, timeoutCTA;
|
44 |
|
45 |
// stored values
|
46 |
var messages_viewed = (store.getItem('whatsappme_hashes') || '').split(',').filter(Boolean);
|
59 |
|
60 |
if (has_cta && !is_viewed) {
|
61 |
if (wame_settings.message_badge) { // show badge
|
62 |
+
timeoutCTA = setTimeout(function () { $badge.addClass('whatsappme__badge--in'); }, delay_on_start + wame_settings.message_delay);
|
63 |
} else if (is_second_visit) { // show dialog
|
64 |
+
timeoutCTA = setTimeout(function () { $whatsappme.addClass('whatsappme--dialog'); }, delay_on_start + wame_settings.message_delay);
|
65 |
}
|
66 |
}
|
67 |
}
|
73 |
}
|
74 |
|
75 |
$('.whatsappme__button').click(function () {
|
76 |
+
var link = whatsapp_link(wa_web, wame_settings.telephone, wame_settings.message_send);
|
77 |
|
78 |
if (has_cta && !$whatsappme.hasClass('whatsappme--dialog')) {
|
79 |
show_dialog();
|
93 |
|
94 |
function show_dialog() {
|
95 |
$whatsappme.addClass('whatsappme--dialog');
|
96 |
+
clearTimeout(timeoutCTA);
|
97 |
|
98 |
if (wame_settings.message_badge && $badge.hasClass('whatsappme__badge--in')) {
|
99 |
$badge.removeClass('whatsappme__badge--in').addClass('whatsappme__badge--out');
|
120 |
};
|
121 |
|
122 |
// Return WhatsApp link with optional message
|
123 |
+
function whatsapp_link(wa_web, phone, message) {
|
124 |
+
var link = wa_web ? 'https://web.whatsapp.com/send' : 'https://api.whatsapp.com/send';
|
|
|
|
|
|
|
125 |
|
126 |
+
return link + '?phone=' + encodeURIComponent(phone) + '&text=' + encodeURIComponent(message || '');
|
127 |
}
|
128 |
|
129 |
// Trigger Google Analytics event
|
130 |
function send_event(link) {
|
131 |
+
if (typeof dataLayer == 'object') {
|
132 |
+
// Send Google Tag Manager Event
|
133 |
+
dataLayer.push({
|
134 |
+
'event': 'WhatsAppMe',
|
135 |
+
'eventAction': 'click',
|
136 |
+
'eventLabel': link
|
137 |
+
});
|
138 |
+
}
|
139 |
+
if (typeof gtag == 'function') {
|
140 |
+
// Send event (Global Site Tag - gtag.js)
|
141 |
gtag('event', 'click', {
|
142 |
'event_category': 'WhatsAppMe',
|
143 |
'event_label': link,
|
144 |
'transport_type': 'beacon'
|
145 |
});
|
146 |
+
} else if (typeof ga == 'function') {
|
147 |
+
// Send event (Universal Analtics - analytics.js)
|
148 |
+
ga('set', 'transport', 'beacon');
|
149 |
+
var trackers = ga.getAll();
|
150 |
+
trackers.forEach(function (tracker) {
|
151 |
+
tracker.send("event", 'WhatsAppMe', 'click', link);
|
152 |
});
|
153 |
}
|
154 |
}
|
whatsappme.php
CHANGED
@@ -7,9 +7,9 @@
|
|
7 |
*
|
8 |
* @wordpress-plugin
|
9 |
* Plugin Name: WhatsApp me
|
10 |
-
* Plugin URI:
|
11 |
* Description: Add support to your clients directly with WhatsApp.
|
12 |
-
* Version: 2.
|
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', '2.
|
31 |
|
32 |
/**
|
33 |
* The core plugin class that is used to define internationalization,
|
7 |
*
|
8 |
* @wordpress-plugin
|
9 |
* Plugin Name: WhatsApp me
|
10 |
+
* Plugin URI: https://wame.chat
|
11 |
* Description: Add support to your clients directly with WhatsApp.
|
12 |
+
* Version: 2.2.0
|
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', '2.2.0' );
|
31 |
|
32 |
/**
|
33 |
* The core plugin class that is used to define internationalization,
|