WhatsApp me - Version 2.1.0

Version Description

  • NEW: Button bagde option for a less intrusive mode.
  • CHANGED now each different Call to Action is marked as read separately.
  • CHANGED now first show Call to Action (if defined) before launch WhatsApp link.
Download this release

Release Info

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

Code changes from version 2.0.1 to 2.1.0

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: 2.0.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -28,10 +28,11 @@ Options:
28
  2. Mobile only: Select if you want the button to be visible only on mobile devices. WhatsApp Web/App will open on the desktop (if available).
29
  3. Call to action: Write a message to encourage users to contact you through WhatsApp.
30
  4. Delay: You can define a timeout to display the call-to-action message.
31
- 5. Message: You can define the first message to send.
32
- 6. Advanced: configure on which pages you want to show or hide your WhatsApp button.
33
- 7. If you have Google Analytics, an event is triggered when the user launches WhatsApp.
34
- 8. Can override call to action, message or visibility on every post, page or custom post.
 
35
 
36
  == Installation ==
37
 
@@ -60,6 +61,11 @@ WhatsApp me don't save any personal data and don't use cookies.
60
 
61
  == Changelog ==
62
 
 
 
 
 
 
63
  = 2.0.1 =
64
  * FIX removed array_filter function that requires PHP 5.6 min version.
65
 
5
  Requires at least: 3.0.1
6
  Tested up to: 4.9.4
7
  Requires PHP: 5.3
8
+ Stable tag: 2.1.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
28
  2. Mobile only: Select if you want the button to be visible only on mobile devices. WhatsApp Web/App will open on the desktop (if available).
29
  3. Call to action: Write a message to encourage users to contact you through WhatsApp.
30
  4. Delay: You can define a timeout to display the call-to-action message.
31
+ 5. Badge: Show a button badge for a less intrusive mode.
32
+ 6. Message: You can define the first message to send.
33
+ 7. Advanced: configure on which pages you want to show or hide your WhatsApp button.
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
 
61
 
62
  == Changelog ==
63
 
64
+ = 2.1.0 =
65
+ * **NEW:** Button bagde option for a less intrusive mode.
66
+ * CHANGED now each different Call to Action is marked as read separately.
67
+ * CHANGED now first show Call to Action (if defined) before launch WhatsApp link.
68
+
69
  = 2.0.1 =
70
  * FIX removed array_filter function that requires PHP 5.6 min version.
71
 
admin/class-whatsappme-admin.php CHANGED
@@ -71,6 +71,7 @@ class WhatsAppMe_Admin {
71
  *
72
  * @since 1.0.0
73
  * @since 2.0.0 Added visibility setting
 
74
  */
75
  private function get_settings() {
76
 
@@ -79,6 +80,7 @@ class WhatsAppMe_Admin {
79
  'mobile_only' => 'no',
80
  'message_text' => '',
81
  'message_delay' => 10000,
 
82
  'message_send' => '',
83
  'position' => 'right',
84
  'visibility' => array( 'all' => 'yes' ),
@@ -152,6 +154,7 @@ class WhatsAppMe_Admin {
152
  'mobile_only' => __( 'Mobile only', 'creame-whatsapp-me' ),
153
  'message_text' => __( 'Call to action', 'creame-whatsapp-me' ),
154
  'message_delay' => __( 'Delay', 'creame-whatsapp-me' ),
 
155
  'message_send' => __( 'Message', 'creame-whatsapp-me' ),
156
  'position' => __( 'Position on screen', 'creame-whatsapp-me' ),
157
  );
@@ -255,6 +258,7 @@ class WhatsAppMe_Admin {
255
  *
256
  * @since 1.0.0
257
  * @since 2.0.0 Added visibility setting
 
258
  * @param array $input contain keys 'id', 'title' and 'callback'.
259
  * @return array
260
  */
@@ -264,6 +268,7 @@ class WhatsAppMe_Admin {
264
  $input['telephone'] = $this->clean_input( $input['telephone'] );
265
  $input['message_text'] = $this->clean_input( $input['message_text'] );
266
  $input['message_delay'] = intval( $input['message_delay'] );
 
267
  $input['message_send'] = $this->clean_input( $input['message_send'] );
268
  $input['position'] = $input['position'] != 'left' ? 'right' : 'left';
269
  $input['visibility'] = array_filter( $input['view'], function($v) { return $v == 'yes' || $v == 'no'; } );
@@ -345,7 +350,19 @@ class WhatsAppMe_Admin {
345
  */
346
  public function field_message_delay() {
347
  echo '<input name="whatsappme[message_delay]" value="' . $this->settings['message_delay'] . '" class="small-text" type="number" min="0"> ' . __( 'milliseconds', 'creame-whatsapp-me' ) .
348
- '<p class="description"> ' . __( 'The <strong>Call to action</strong> will only be displayed once when the user exceeds the estimated delay on a page. It will also be displayed when the user stops the cursor over the WhatsApp button.', 'creame-whatsapp-me' ) . '</p>';
 
 
 
 
 
 
 
 
 
 
 
 
349
  }
350
 
351
  /**
71
  *
72
  * @since 1.0.0
73
  * @since 2.0.0 Added visibility setting
74
+ * @since 2.1.0 Added message_badge
75
  */
76
  private function get_settings() {
77
 
80
  'mobile_only' => 'no',
81
  'message_text' => '',
82
  'message_delay' => 10000,
83
+ 'message_badge' => 'no',
84
  'message_send' => '',
85
  'position' => 'right',
86
  'visibility' => array( 'all' => 'yes' ),
154
  'mobile_only' => __( 'Mobile only', 'creame-whatsapp-me' ),
155
  'message_text' => __( 'Call to action', 'creame-whatsapp-me' ),
156
  'message_delay' => __( 'Delay', 'creame-whatsapp-me' ),
157
+ 'message_badge' => __( 'Button Badge', 'creame-whatsapp-me' ),
158
  'message_send' => __( 'Message', 'creame-whatsapp-me' ),
159
  'position' => __( 'Position on screen', 'creame-whatsapp-me' ),
160
  );
258
  *
259
  * @since 1.0.0
260
  * @since 2.0.0 Added visibility setting
261
+ * @since 2.1.0 Added message_badge
262
  * @param array $input contain keys 'id', 'title' and 'callback'.
263
  * @return array
264
  */
268
  $input['telephone'] = $this->clean_input( $input['telephone'] );
269
  $input['message_text'] = $this->clean_input( $input['message_text'] );
270
  $input['message_delay'] = intval( $input['message_delay'] );
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
  $input['visibility'] = array_filter( $input['view'], function($v) { return $v == 'yes' || $v == 'no'; } );
350
  */
351
  public function field_message_delay() {
352
  echo '<input name="whatsappme[message_delay]" value="' . $this->settings['message_delay'] . '" class="small-text" type="number" min="0"> ' . __( 'milliseconds', 'creame-whatsapp-me' ) .
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
+
356
+ /**
357
+ * Field 'message_badge' output
358
+ *
359
+ * @since 2.1.0
360
+ * @return void
361
+ */
362
+ public function field_message_badge() {
363
+ echo '<fieldset><legend class="screen-reader-text"><span>' . __( 'Button Badge', 'creame-whatsapp-me' ) . '</span></legend>' .
364
+ '<label><input name="whatsappme[message_badge]" value="yes" type="checkbox"' . checked( 'yes', $this->settings['message_badge'], false ) . '> ' .
365
+ __('Display a button badge instead of opening the <strong>Call to action</strong> for a "less intrusive" mode', 'creame-whatsapp-me' ) . '</label></fieldset>';
366
  }
367
 
368
  /**
languages/creame-whatsapp-me.pot CHANGED
@@ -2,7 +2,7 @@
2
  msgid ""
3
  msgstr ""
4
  "Project-Id-Version: WhatsApp Me\n"
5
- "POT-Creation-Date: 2018-08-30 09:03+0000\n"
6
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
7
  "Last-Translator: Your Name <you@example.com>\n"
8
  "Language-Team: Creame <hola@crea.me>\n"
@@ -21,214 +21,223 @@ msgstr ""
21
  "X-Generator: Loco https://localise.biz/\n"
22
  "X-Poedit-SearchPath-0: ."
23
 
24
- #: admin/class-whatsappme-admin.php:151
25
  msgid "Telephone"
26
  msgstr ""
27
 
28
- #: admin/class-whatsappme-admin.php:152 admin/class-whatsappme-admin.php:370
29
  msgid "Mobile only"
30
  msgstr ""
31
 
32
- #: admin/class-whatsappme-admin.php:153 admin/class-whatsappme-admin.php:534
33
  msgid "Call to action"
34
  msgstr ""
35
 
36
- #: admin/class-whatsappme-admin.php:154
37
  msgid "Delay"
38
  msgstr ""
39
 
40
- #: admin/class-whatsappme-admin.php:155 admin/class-whatsappme-admin.php:538
 
 
 
 
41
  msgid "Message"
42
  msgstr ""
43
 
44
- #: admin/class-whatsappme-admin.php:156 admin/class-whatsappme-admin.php:382
45
  msgid "Position on screen"
46
  msgstr ""
47
 
48
- #: admin/class-whatsappme-admin.php:168
49
  msgid "Global"
50
  msgstr ""
51
 
52
- #: admin/class-whatsappme-admin.php:177
53
  msgid "Front Page"
54
  msgstr ""
55
 
56
- #: admin/class-whatsappme-admin.php:178
57
  msgid "Blog Page"
58
  msgstr ""
59
 
60
- #: admin/class-whatsappme-admin.php:179
61
  msgid "404 Page"
62
  msgstr ""
63
 
64
- #: admin/class-whatsappme-admin.php:180
65
  msgid "Search Results"
66
  msgstr ""
67
 
68
- #: admin/class-whatsappme-admin.php:181
69
  msgid "Archives"
70
  msgstr ""
71
 
72
- #: admin/class-whatsappme-admin.php:182
73
  msgid "Date Archives"
74
  msgstr ""
75
 
76
- #: admin/class-whatsappme-admin.php:183
77
  msgid "Author Archives"
78
  msgstr ""
79
 
80
- #: admin/class-whatsappme-admin.php:184
81
  msgid "Singular"
82
  msgstr ""
83
 
84
- #: admin/class-whatsappme-admin.php:185
85
  msgid "Page"
86
  msgstr ""
87
 
88
- #: admin/class-whatsappme-admin.php:186
89
  msgid "Post"
90
  msgstr ""
91
 
92
- #: admin/class-whatsappme-admin.php:207
93
  msgid "Shop"
94
  msgstr ""
95
 
96
- #: admin/class-whatsappme-admin.php:209
97
  msgid "Product Page"
98
  msgstr ""
99
 
100
- #: admin/class-whatsappme-admin.php:210
101
  msgid "Cart"
102
  msgstr ""
103
 
104
- #: admin/class-whatsappme-admin.php:211
105
  msgid "Checkout"
106
  msgstr ""
107
 
108
- #: admin/class-whatsappme-admin.php:212
109
  msgid "My Account"
110
  msgstr ""
111
 
112
- #: admin/class-whatsappme-admin.php:235
113
  msgid "Custom Post Types"
114
  msgstr ""
115
 
116
- #: admin/class-whatsappme-admin.php:272
117
  msgid "Settings saved"
118
  msgstr ""
119
 
120
- #: admin/class-whatsappme-admin.php:289
121
  msgid "General"
122
  msgstr ""
123
 
124
- #: admin/class-whatsappme-admin.php:290
125
  msgid "Advanced"
126
  msgstr ""
127
 
128
- #: admin/class-whatsappme-admin.php:294
129
  msgid ""
130
  "From here you can configure the behavior of the WhatsApp button on your site."
131
  msgstr ""
132
 
133
- #: admin/class-whatsappme-admin.php:299
134
  msgid ""
135
  "From here you can configure on which pages the WhatsApp button will be "
136
  "visible."
137
  msgstr ""
138
 
139
- #: admin/class-whatsappme-admin.php:300
140
  msgid "Restore default visibility"
141
  msgstr ""
142
 
143
- #: admin/class-whatsappme-admin.php:325
144
  msgid ""
145
  "Contact phone number. <strong>The button will not be shown if it's empty."
146
  "</strong>"
147
  msgstr ""
148
 
149
- #: admin/class-whatsappme-admin.php:335
150
  msgid ""
151
  "Hello 👋\n"
152
  "Can we help you?"
153
  msgstr ""
154
 
155
- #: admin/class-whatsappme-admin.php:336
156
  msgid ""
157
  "<strong>Optional.</strong> Text to invite the user to use the contact via "
158
  "WhatsApp."
159
  msgstr ""
160
 
161
- #: admin/class-whatsappme-admin.php:337
162
  msgid ""
163
  "You can use formatting styles like in WhatsApp: _<em>italic</em>_ *<strong>"
164
  "bold</strong>* ~<del>strikethrough</del>~"
165
  msgstr ""
166
 
167
- #: admin/class-whatsappme-admin.php:347
168
  msgid "milliseconds"
169
  msgstr ""
170
 
171
- #: admin/class-whatsappme-admin.php:348
 
 
 
 
 
 
172
  msgid ""
173
- "The <strong>Call to action</strong> will only be displayed once when the "
174
- "user exceeds the estimated delay on a page. It will also be displayed when "
175
- "the user stops the cursor over the WhatsApp button."
176
  msgstr ""
177
 
178
- #: admin/class-whatsappme-admin.php:358
179
  msgid "Hi {SITE}! I need more info about {TITLE}"
180
  msgstr ""
181
 
182
- #: admin/class-whatsappme-admin.php:359
183
  msgid "<strong>Optional.</strong> Default message to start the conversation."
184
  msgstr ""
185
 
186
- #: admin/class-whatsappme-admin.php:360
187
  msgid ""
188
  "You can use vars <code>{SITE} {URL} {TITLE}</code> that will be replaced "
189
  "with the values of the current page."
190
  msgstr ""
191
 
192
- #: admin/class-whatsappme-admin.php:372
193
  msgid "Only display the button on mobile devices"
194
  msgstr ""
195
 
196
- #: admin/class-whatsappme-admin.php:384
197
  msgid "Right"
198
  msgstr ""
199
 
200
- #: admin/class-whatsappme-admin.php:386
201
  msgid "Left"
202
  msgstr ""
203
 
204
- #: admin/class-whatsappme-admin.php:403 admin/class-whatsappme-admin.php:420
205
- #: admin/class-whatsappme-admin.php:544
206
  msgid "Show"
207
  msgstr ""
208
 
209
- #: admin/class-whatsappme-admin.php:405 admin/class-whatsappme-admin.php:422
210
- #: admin/class-whatsappme-admin.php:546
211
  msgid "Hide"
212
  msgstr ""
213
 
214
- #: admin/class-whatsappme-admin.php:424
215
  msgid "Inherit"
216
  msgstr ""
217
 
218
- #: admin/class-whatsappme-admin.php:449
219
  msgid "Settings"
220
  msgstr ""
221
 
222
  #. Name of the plugin
223
- #: admin/class-whatsappme-admin.php:497
224
  msgid "WhatsApp me"
225
  msgstr ""
226
 
227
- #: admin/class-whatsappme-admin.php:540
228
  msgid "You can use vars <code>{SITE} {URL} {TITLE}</code>"
229
  msgstr ""
230
 
231
- #: admin/class-whatsappme-admin.php:548
232
  msgid "Default visibility"
233
  msgstr ""
234
 
2
  msgid ""
3
  msgstr ""
4
  "Project-Id-Version: WhatsApp Me\n"
5
+ "POT-Creation-Date: 2018-09-13 08:06+0000\n"
6
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
7
  "Last-Translator: Your Name <you@example.com>\n"
8
  "Language-Team: Creame <hola@crea.me>\n"
21
  "X-Generator: Loco https://localise.biz/\n"
22
  "X-Poedit-SearchPath-0: ."
23
 
24
+ #: admin/class-whatsappme-admin.php:153
25
  msgid "Telephone"
26
  msgstr ""
27
 
28
+ #: admin/class-whatsappme-admin.php:154 admin/class-whatsappme-admin.php:387
29
  msgid "Mobile only"
30
  msgstr ""
31
 
32
+ #: admin/class-whatsappme-admin.php:155 admin/class-whatsappme-admin.php:551
33
  msgid "Call to action"
34
  msgstr ""
35
 
36
+ #: admin/class-whatsappme-admin.php:156
37
  msgid "Delay"
38
  msgstr ""
39
 
40
+ #: admin/class-whatsappme-admin.php:157 admin/class-whatsappme-admin.php:363
41
+ msgid "Button Badge"
42
+ msgstr ""
43
+
44
+ #: admin/class-whatsappme-admin.php:158 admin/class-whatsappme-admin.php:555
45
  msgid "Message"
46
  msgstr ""
47
 
48
+ #: admin/class-whatsappme-admin.php:159 admin/class-whatsappme-admin.php:399
49
  msgid "Position on screen"
50
  msgstr ""
51
 
52
+ #: admin/class-whatsappme-admin.php:171
53
  msgid "Global"
54
  msgstr ""
55
 
56
+ #: admin/class-whatsappme-admin.php:180
57
  msgid "Front Page"
58
  msgstr ""
59
 
60
+ #: admin/class-whatsappme-admin.php:181
61
  msgid "Blog Page"
62
  msgstr ""
63
 
64
+ #: admin/class-whatsappme-admin.php:182
65
  msgid "404 Page"
66
  msgstr ""
67
 
68
+ #: admin/class-whatsappme-admin.php:183
69
  msgid "Search Results"
70
  msgstr ""
71
 
72
+ #: admin/class-whatsappme-admin.php:184
73
  msgid "Archives"
74
  msgstr ""
75
 
76
+ #: admin/class-whatsappme-admin.php:185
77
  msgid "Date Archives"
78
  msgstr ""
79
 
80
+ #: admin/class-whatsappme-admin.php:186
81
  msgid "Author Archives"
82
  msgstr ""
83
 
84
+ #: admin/class-whatsappme-admin.php:187
85
  msgid "Singular"
86
  msgstr ""
87
 
88
+ #: admin/class-whatsappme-admin.php:188
89
  msgid "Page"
90
  msgstr ""
91
 
92
+ #: admin/class-whatsappme-admin.php:189
93
  msgid "Post"
94
  msgstr ""
95
 
96
+ #: admin/class-whatsappme-admin.php:210
97
  msgid "Shop"
98
  msgstr ""
99
 
100
+ #: admin/class-whatsappme-admin.php:212
101
  msgid "Product Page"
102
  msgstr ""
103
 
104
+ #: admin/class-whatsappme-admin.php:213
105
  msgid "Cart"
106
  msgstr ""
107
 
108
+ #: admin/class-whatsappme-admin.php:214
109
  msgid "Checkout"
110
  msgstr ""
111
 
112
+ #: admin/class-whatsappme-admin.php:215
113
  msgid "My Account"
114
  msgstr ""
115
 
116
+ #: admin/class-whatsappme-admin.php:238
117
  msgid "Custom Post Types"
118
  msgstr ""
119
 
120
+ #: admin/class-whatsappme-admin.php:277
121
  msgid "Settings saved"
122
  msgstr ""
123
 
124
+ #: admin/class-whatsappme-admin.php:294
125
  msgid "General"
126
  msgstr ""
127
 
128
+ #: admin/class-whatsappme-admin.php:295
129
  msgid "Advanced"
130
  msgstr ""
131
 
132
+ #: admin/class-whatsappme-admin.php:299
133
  msgid ""
134
  "From here you can configure the behavior of the WhatsApp button on your site."
135
  msgstr ""
136
 
137
+ #: admin/class-whatsappme-admin.php:304
138
  msgid ""
139
  "From here you can configure on which pages the WhatsApp button will be "
140
  "visible."
141
  msgstr ""
142
 
143
+ #: admin/class-whatsappme-admin.php:305
144
  msgid "Restore default visibility"
145
  msgstr ""
146
 
147
+ #: admin/class-whatsappme-admin.php:330
148
  msgid ""
149
  "Contact phone number. <strong>The button will not be shown if it's empty."
150
  "</strong>"
151
  msgstr ""
152
 
153
+ #: admin/class-whatsappme-admin.php:340
154
  msgid ""
155
  "Hello 👋\n"
156
  "Can we help you?"
157
  msgstr ""
158
 
159
+ #: admin/class-whatsappme-admin.php:341
160
  msgid ""
161
  "<strong>Optional.</strong> Text to invite the user to use the contact via "
162
  "WhatsApp."
163
  msgstr ""
164
 
165
+ #: admin/class-whatsappme-admin.php:342
166
  msgid ""
167
  "You can use formatting styles like in WhatsApp: _<em>italic</em>_ *<strong>"
168
  "bold</strong>* ~<del>strikethrough</del>~"
169
  msgstr ""
170
 
171
+ #: admin/class-whatsappme-admin.php:352
172
  msgid "milliseconds"
173
  msgstr ""
174
 
175
+ #: admin/class-whatsappme-admin.php:353
176
+ msgid ""
177
+ "The <strong>Call to action</strong> will be automatically displayed once "
178
+ "when the user exceeds the estimated delay on a page."
179
+ msgstr ""
180
+
181
+ #: admin/class-whatsappme-admin.php:365
182
  msgid ""
183
+ "Display a button badge instead of opening the <strong>Call to action</strong>"
184
+ " for a \"less intrusive\" mode"
 
185
  msgstr ""
186
 
187
+ #: admin/class-whatsappme-admin.php:375
188
  msgid "Hi {SITE}! I need more info about {TITLE}"
189
  msgstr ""
190
 
191
+ #: admin/class-whatsappme-admin.php:376
192
  msgid "<strong>Optional.</strong> Default message to start the conversation."
193
  msgstr ""
194
 
195
+ #: admin/class-whatsappme-admin.php:377
196
  msgid ""
197
  "You can use vars <code>{SITE} {URL} {TITLE}</code> that will be replaced "
198
  "with the values of the current page."
199
  msgstr ""
200
 
201
+ #: admin/class-whatsappme-admin.php:389
202
  msgid "Only display the button on mobile devices"
203
  msgstr ""
204
 
205
+ #: admin/class-whatsappme-admin.php:401
206
  msgid "Right"
207
  msgstr ""
208
 
209
+ #: admin/class-whatsappme-admin.php:403
210
  msgid "Left"
211
  msgstr ""
212
 
213
+ #: admin/class-whatsappme-admin.php:420 admin/class-whatsappme-admin.php:437
214
+ #: admin/class-whatsappme-admin.php:561
215
  msgid "Show"
216
  msgstr ""
217
 
218
+ #: admin/class-whatsappme-admin.php:422 admin/class-whatsappme-admin.php:439
219
+ #: admin/class-whatsappme-admin.php:563
220
  msgid "Hide"
221
  msgstr ""
222
 
223
+ #: admin/class-whatsappme-admin.php:441
224
  msgid "Inherit"
225
  msgstr ""
226
 
227
+ #: admin/class-whatsappme-admin.php:466
228
  msgid "Settings"
229
  msgstr ""
230
 
231
  #. Name of the plugin
232
+ #: admin/class-whatsappme-admin.php:514
233
  msgid "WhatsApp me"
234
  msgstr ""
235
 
236
+ #: admin/class-whatsappme-admin.php:557
237
  msgid "You can use vars <code>{SITE} {URL} {TITLE}</code>"
238
  msgstr ""
239
 
240
+ #: admin/class-whatsappme-admin.php:565
241
  msgid "Default visibility"
242
  msgstr ""
243
 
public/class-whatsappme-public.php CHANGED
@@ -44,6 +44,7 @@ class WhatsAppMe_Public {
44
  *
45
  * @since 1.0.0
46
  * @since 2.0.0 Added visibility setting
 
47
  * @param string $plugin_name The name of the plugin.
48
  * @param string $version The version of this plugin.
49
  */
@@ -56,6 +57,7 @@ class WhatsAppMe_Public {
56
  'telephone' => '',
57
  'message_text' => '',
58
  'message_delay' => 10000,
 
59
  'message_send' => '',
60
  'mobile_only' => false,
61
  'position' => 'right',
@@ -102,7 +104,8 @@ class WhatsAppMe_Public {
102
  if ( isset( $post_settings['message_send'] ) ) {
103
  $settings['message_send'] = $post_settings['message_send'];
104
  }
105
- $settings['message_send'] = $this->formated_message_send( $settings['message_send'] );
 
106
 
107
  $settings['show'] = $settings['telephone'] != '';
108
  if ( $settings['show'] ) {
@@ -164,6 +167,7 @@ class WhatsAppMe_Public {
164
  <div class="whatsappme whatsappme--<?php echo $this->settings['position']; ?>" data-settings="<?php echo esc_attr( json_encode( $data ) ); ?>">
165
  <div class="whatsappme__button">
166
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M.057 24l1.687-6.163c-1.041-1.804-1.588-3.849-1.587-5.946.003-6.556 5.338-11.891 11.893-11.891 3.181.001 6.167 1.24 8.413 3.488 2.245 2.248 3.481 5.236 3.48 8.414-.003 6.557-5.338 11.892-11.893 11.892-1.99-.001-3.951-.5-5.688-1.448l-6.305 1.654zm6.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" fill="currentColor"/></svg>
 
167
  </div>
168
  <?php if ($this->settings['message_text']): ?>
169
  <div class="whatsappme__box">
44
  *
45
  * @since 1.0.0
46
  * @since 2.0.0 Added visibility setting
47
+ * @since 2.1.0 Added message_badge
48
  * @param string $plugin_name The name of the plugin.
49
  * @param string $version The version of this plugin.
50
  */
57
  'telephone' => '',
58
  'message_text' => '',
59
  'message_delay' => 10000,
60
+ 'message_badge' => 'no',
61
  'message_send' => '',
62
  'mobile_only' => false,
63
  'position' => 'right',
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
 
110
  $settings['show'] = $settings['telephone'] != '';
111
  if ( $settings['show'] ) {
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.163c-1.041-1.804-1.588-3.849-1.587-5.946.003-6.556 5.338-11.891 11.893-11.891 3.181.001 6.167 1.24 8.413 3.488 2.245 2.248 3.481 5.236 3.48 8.414-.003 6.557-5.338 11.892-11.893 11.892-1.99-.001-3.951-.5-5.688-1.448l-6.305 1.654zm6.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" fill="currentColor"/></svg>
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">
public/css/whatsappme.css CHANGED
@@ -10,6 +10,9 @@
10
  transform: scale3d(0, 0, 0);
11
  transition: transform .3s ease-in-out;
12
  user-select: none;
 
 
 
13
  }
14
 
15
  .whatsappme--show {
@@ -30,7 +33,21 @@
30
  border-radius: 30px;
31
  box-shadow: 1px 6px 24px 0 rgba(7, 94, 84, .24);
32
  cursor: pointer;
33
- transition: background-color 500ms ease-in-out;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  }
35
 
36
  .whatsappme__button svg {
@@ -39,8 +56,34 @@
39
  margin: 0 12px;
40
  }
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  .whatsappme--dialog .whatsappme__button {
43
- box-shadow: 0 1px 2px 0 rgba(0,0,0,0.3);
44
  }
45
 
46
  .whatsappme__box {
@@ -59,13 +102,13 @@
59
  overflow: hidden;
60
  transform: scale3d(0, 0, 0);
61
  opacity: 0;
62
- transition: opacity 300ms ease-out, transform 0ms linear 300ms;
63
  }
64
 
65
  .whatsappme--dialog .whatsappme__box {
66
  opacity: 1;
67
  transform: scale3d(1, 1, 1);
68
- transition: opacity 100ms ease-out, transform 0ms linear;
69
  }
70
 
71
  .whatsappme__header {
@@ -99,6 +142,7 @@
99
  cursor: pointer;
100
  transition: opacity 300ms ease-out;
101
  }
 
102
  .whatsappme__close:hover {
103
  opacity: .6;
104
  }
@@ -175,4 +219,26 @@
175
  margin: 15px 21px 20px;
176
  line-height: 24px;
177
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  }
10
  transform: scale3d(0, 0, 0);
11
  transition: transform .3s ease-in-out;
12
  user-select: none;
13
+ -ms-user-select: none;
14
+ -moz-user-select: none;
15
+ -webkit-user-select: none;
16
  }
17
 
18
  .whatsappme--show {
33
  border-radius: 30px;
34
  box-shadow: 1px 6px 24px 0 rgba(7, 94, 84, .24);
35
  cursor: pointer;
36
+ transition: background-color 0.2s linear;
37
+ }
38
+
39
+ .whatsappme__button:hover {
40
+ background-color: #128C7E;
41
+ transition: background-color 1.5s linear;
42
+ }
43
+
44
+ .whatsappme--dialog .whatsappme__button {
45
+ transition: background-color 0.2s linear;
46
+ }
47
+
48
+ .whatsappme__button:active {
49
+ background-color: #075E54;
50
+ transition: none;
51
  }
52
 
53
  .whatsappme__button svg {
56
  margin: 0 12px;
57
  }
58
 
59
+ .whatsappme__badge {
60
+ position: absolute;
61
+ top: -4px;
62
+ right: -4px;
63
+ width: 20px;
64
+ height: 20px;
65
+ border: none;
66
+ border-radius: 50%;
67
+ background: #e82c0c;
68
+ font-size: 12px;
69
+ font-weight: 600;
70
+ line-height: 20px;
71
+ text-align: center;
72
+ box-shadow: none;
73
+ opacity: 0;
74
+ pointer-events: none;
75
+ }
76
+
77
+ .whatsappme__badge.whatsappme__badge--in {
78
+ animation: badge--in 500ms cubic-bezier(0.27, 0.9, 0.41, 1.28) 1 both;
79
+ }
80
+
81
+ .whatsappme__badge.whatsappme__badge--out {
82
+ animation: badge--out 400ms cubic-bezier(0.215, 0.61, 0.355, 1) 1 both;
83
+ }
84
+
85
  .whatsappme--dialog .whatsappme__button {
86
+ box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
87
  }
88
 
89
  .whatsappme__box {
102
  overflow: hidden;
103
  transform: scale3d(0, 0, 0);
104
  opacity: 0;
105
+ transition: opacity 400ms ease-out, transform 0ms linear 300ms;
106
  }
107
 
108
  .whatsappme--dialog .whatsappme__box {
109
  opacity: 1;
110
  transform: scale3d(1, 1, 1);
111
+ transition: opacity 200ms ease-out, transform 0ms linear;
112
  }
113
 
114
  .whatsappme__header {
142
  cursor: pointer;
143
  transition: opacity 300ms ease-out;
144
  }
145
+
146
  .whatsappme__close:hover {
147
  opacity: .6;
148
  }
219
  margin: 15px 21px 20px;
220
  line-height: 24px;
221
  }
222
+ }
223
+
224
+ @keyframes badge--in {
225
+ from {
226
+ opacity: 0;
227
+ transform: translateY(50px);
228
+ }
229
+ to {
230
+ opacity: 1;
231
+ transform: translateY(0);
232
+ }
233
+ }
234
+
235
+ @keyframes badge--out {
236
+ 0% {
237
+ opacity: 1;
238
+ transform: translateY(0);
239
+ }
240
+ 100% {
241
+ opacity: 0;
242
+ transform: translateY(-20px);
243
+ }
244
  }
public/js/whatsappme.js CHANGED
@@ -4,6 +4,7 @@
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
@@ -22,78 +23,111 @@
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';
29
- var views = wame_settings.message_text === '' ? 0 : parseInt(localStorage.whatsappme_views || 0) + 1;
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');
48
- }, 1600);
49
- }).mouseleave(function () {
50
- clearTimeout(timeoutID);
51
- });
52
  }
53
 
54
  $('.whatsappme__button').click(function () {
55
  var link = whatsapp_link(wame_settings.telephone, wame_settings.message_send);
56
 
57
- $whatsappme.removeClass('whatsappme--dialog');
58
- localStorage.whatsappme_click = 'yes';
59
-
60
- if (typeof gtag == 'function') {
61
- // Send event (Global Site Tag - gtag.js)
62
- gtag('event', 'click', {
63
- 'event_category': 'WhatsAppMe',
64
- 'event_label': link,
65
- 'transport_type': 'beacon'
66
- });
67
- } else if (typeof ga == 'function') {
68
- // Send event (Universal Analtics - analytics.js)
69
- ga('send', 'event', {
70
- 'eventCategory': 'WhatsAppMe',
71
- 'eventAction': 'click',
72
- 'eventLabel': link,
73
- 'transport': 'beacon'
74
- });
75
  }
76
-
77
- // Open WhatsApp link
78
- window.open(link, 'whatsappme');
79
  });
80
 
81
  $('.whatsappme__close').click(function () {
82
  $whatsappme.removeClass('whatsappme--dialog');
83
- localStorage.whatsappme_click = 'yes';
84
  });
85
- }
86
 
87
- // Return WhatsApp link with optional message
88
- function whatsapp_link(phone, message) {
89
- var link = 'https://api.whatsapp.com/send?phone=' + phone;
90
- if (typeof (message) == 'string' && message != '') {
91
- link += '&text=' + encodeURIComponent(message);
 
 
92
  }
93
 
94
- return link;
 
 
 
 
 
 
95
  }
96
-
97
  });
98
 
99
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  $(function () {
5
  var delay_on_start = 3000;
6
  var $whatsappme = $('.whatsappme');
7
+ var $badge = $whatsappme.find('.whatsappme__badge');
8
  var wame_settings = $whatsappme.data('settings');
9
 
10
  // In some strange cases data settings are empty
23
 
24
  function whatsappme_magic() {
25
  var is_mobile = !!navigator.userAgent.match(/Android|iPhone|BlackBerry|IEMobile|Opera Mini/i);
26
+ var has_cta = wame_settings.message_text !== '';
27
+ var message_hash, is_viewed, timeoutID;
28
 
29
  // stored values
30
+ var messages_viewed = (localStorage.whatsappme_hashes || '').split(',').filter(Boolean);
31
+ var is_second_visit = localStorage.whatsappme_visited == 'yes';
32
+
33
+ if (has_cta) {
34
+ message_hash = hash(wame_settings.message_text).toString();
35
+ is_viewed = messages_viewed.indexOf(message_hash) > -1;
36
+ }
37
+
38
+ localStorage.whatsappme_visited = 'yes';
39
 
 
40
  if (!wame_settings.mobile_only || is_mobile) {
41
+ // show button
42
+ setTimeout(function () { $whatsappme.addClass('whatsappme--show'); }, delay_on_start);
43
+
44
+ if (has_cta && !is_viewed) {
45
+ if (wame_settings.message_badge) { // show badge
46
+ setTimeout(function () { $badge.addClass('whatsappme__badge--in'); }, delay_on_start + wame_settings.message_delay);
47
+ } else if (is_second_visit) { // show dialog
48
+ setTimeout(function () { $whatsappme.addClass('whatsappme--dialog'); }, delay_on_start + wame_settings.message_delay);
49
+ }
50
  }
51
  }
52
 
53
+ if (has_cta && !is_mobile) {
54
+ $('.whatsappme__button')
55
+ .mouseenter(function () { timeoutID = setTimeout(show_dialog, 1500); })
56
+ .mouseleave(function () { clearTimeout(timeoutID); });
 
 
 
 
57
  }
58
 
59
  $('.whatsappme__button').click(function () {
60
  var link = whatsapp_link(wame_settings.telephone, wame_settings.message_send);
61
 
62
+ if (has_cta && !$whatsappme.hasClass('whatsappme--dialog')) {
63
+ show_dialog();
64
+ } else {
65
+ $whatsappme.removeClass('whatsappme--dialog');
66
+ save_message_viewed();
67
+ send_event(link);
68
+ // Open WhatsApp link
69
+ window.open(link, 'whatsappme');
 
 
 
 
 
 
 
 
 
 
70
  }
 
 
 
71
  });
72
 
73
  $('.whatsappme__close').click(function () {
74
  $whatsappme.removeClass('whatsappme--dialog');
75
+ save_message_viewed();
76
  });
 
77
 
78
+ function show_dialog() {
79
+ $whatsappme.addClass('whatsappme--dialog');
80
+
81
+ if (wame_settings.message_badge && $badge.hasClass('whatsappme__badge--in')) {
82
+ $badge.removeClass('whatsappme__badge--in').addClass('whatsappme__badge--out');
83
+ save_message_viewed();
84
+ }
85
  }
86
 
87
+ function save_message_viewed() {
88
+ if (has_cta && !is_viewed) {
89
+ messages_viewed.push(message_hash)
90
+ localStorage.whatsappme_hashes = messages_viewed.join(',');
91
+ is_viewed = true;
92
+ }
93
+ }
94
  }
 
95
  });
96
 
97
+ // Return a simple hash (source https://gist.github.com/iperelivskiy/4110988#gistcomment-2697447)
98
+ function hash(s) {
99
+ for (var i = 0, h = 1; i < s.length; i++) {
100
+ h = Math.imul(h + s.charCodeAt(i) | 0, 2654435761);
101
+ }
102
+ return (h ^ h >>> 17) >>> 0;
103
+ };
104
+
105
+ // Return WhatsApp link with optional message
106
+ function whatsapp_link(phone, message) {
107
+ var link = 'https://api.whatsapp.com/send?phone=' + phone;
108
+ if (typeof (message) == 'string' && message != '') {
109
+ link += '&text=' + encodeURIComponent(message);
110
+ }
111
+
112
+ return link;
113
+ }
114
+
115
+ // Trigger Google Analytics event
116
+ function send_event(link) {
117
+ if (typeof gtag == 'function') { // Send event (Global Site Tag - gtag.js)
118
+ gtag('event', 'click', {
119
+ 'event_category': 'WhatsAppMe',
120
+ 'event_label': link,
121
+ 'transport_type': 'beacon'
122
+ });
123
+ } else if (typeof ga == 'function') { // Send event (Universal Analtics - analytics.js)
124
+ ga('send', 'event', {
125
+ 'eventCategory': 'WhatsAppMe',
126
+ 'eventAction': 'click',
127
+ 'eventLabel': link,
128
+ 'transport': 'beacon'
129
+ });
130
+ }
131
+ }
132
+
133
+ }(jQuery));
whatsappme.php CHANGED
@@ -9,7 +9,7 @@
9
  * Plugin Name: WhatsApp me
10
  * Plugin URI: http://wame.chat
11
  * Description: Add support to your clients directly with WhatsApp.
12
- * Version: 2.0.1
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.0.1' );
31
 
32
  /**
33
  * The core plugin class that is used to define internationalization,
9
  * Plugin Name: WhatsApp me
10
  * Plugin URI: http://wame.chat
11
  * Description: Add support to your clients directly with WhatsApp.
12
+ * Version: 2.1.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.1.0' );
31
 
32
  /**
33
  * The core plugin class that is used to define internationalization,