Version Description
- NEW: Added the option to define the first message to send. You can include variables such as {SITE}, {URL} or {TITLE}.
- Fix PHP notice when global $post is null (e.g. search results or login page).
Download this release
Release Info
Developer | creapuntome |
Plugin | WhatsApp me |
Version | 1.4.0 |
Comparing to | |
See all releases |
Code changes from version 1.3.2 to 1.4.0
- README.txt +10 -4
- admin/class-whatsappme-admin.php +24 -3
- languages/creame-whatsapp-me.pot +45 -21
- public/class-whatsappme-public.php +52 -1
- public/js/whatsappme.js +11 -2
- 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.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -28,8 +28,9 @@ 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.
|
32 |
-
6.
|
|
|
33 |
|
34 |
== Installation ==
|
35 |
|
@@ -40,7 +41,8 @@ Options:
|
|
40 |
|
41 |
= I can't see the button or it's over / under another thing =
|
42 |
|
43 |
-
You can change the position of the button so that nothing covers it by adding this CSS in *Appearance > Customize > Custom CSS*:
|
|
|
44 |
Greater values of z-index are left over, the default value is 400.
|
45 |
|
46 |
== Screenshots ==
|
@@ -52,6 +54,10 @@ Greater values of z-index are left over, the default value is 400.
|
|
52 |
|
53 |
== Changelog ==
|
54 |
|
|
|
|
|
|
|
|
|
55 |
= 1.3.2 =
|
56 |
* Only set admin/public hooks when it corresponds to improve performance and fix a notice on admin.
|
57 |
|
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 |
|
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. If you have Google Analytics, an event is triggered when the user launches WhatsApp.
|
33 |
+
7. Can override call to action and message or hide button on every post, page or custom post.
|
34 |
|
35 |
== Installation ==
|
36 |
|
41 |
|
42 |
= I can't see the button or it's over / under another thing =
|
43 |
|
44 |
+
You can change the position of the button so that nothing covers it by adding this CSS in *Appearance > Customize > Custom CSS*:
|
45 |
+
`.whatsappme { z-index:9999; }`
|
46 |
Greater values of z-index are left over, the default value is 400.
|
47 |
|
48 |
== Screenshots ==
|
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).
|
60 |
+
|
61 |
= 1.3.2 =
|
62 |
* Only set admin/public hooks when it corresponds to improve performance and fix a notice on admin.
|
63 |
|
admin/class-whatsappme-admin.php
CHANGED
@@ -77,6 +77,7 @@ class WhatsAppMe_Admin {
|
|
77 |
'mobile_only' => 'no',
|
78 |
'message_text' => '',
|
79 |
'message_delay' => 10000,
|
|
|
80 |
'position' => 'right',
|
81 |
);
|
82 |
|
@@ -136,6 +137,7 @@ class WhatsAppMe_Admin {
|
|
136 |
'mobile_only' => __( 'Mobile only', 'creame-whatsapp-me' ),
|
137 |
'message_text' => __( 'Call to action', 'creame-whatsapp-me' ),
|
138 |
'message_delay' => __( 'Delay', 'creame-whatsapp-me' ),
|
|
|
139 |
'position' => __( 'Position on screen', 'creame-whatsapp-me' ),
|
140 |
);
|
141 |
|
@@ -160,6 +162,7 @@ class WhatsAppMe_Admin {
|
|
160 |
$input['telephone'] = sanitize_text_field($input['telephone']);
|
161 |
$input['message_text'] = trim($input['message_text']);
|
162 |
$input['message_delay'] = intval($input['message_delay']);
|
|
|
163 |
$input['position'] = $input['position'] != 'left' ? 'right' : 'left';
|
164 |
|
165 |
add_settings_error( 'whatsappme', 'settings_updated', __( 'Settings saved', 'creame-whatsapp-me' ), 'updated' );
|
@@ -196,8 +199,8 @@ class WhatsAppMe_Admin {
|
|
196 |
* @return void
|
197 |
*/
|
198 |
public function field_message_text() {
|
199 |
-
echo '<textarea name="whatsappme[message_text]" rows="
|
200 |
-
'<p class="description">' . __( 'Optional
|
201 |
'<p>' . __( 'You can use formatting styles like in WhatsApp: _<em>italic</em>_ *<strong>bold</strong>* ~<del>strikethrough</del>~', 'creame-whatsapp-me' ) . '</p>';
|
202 |
}
|
203 |
|
@@ -212,6 +215,18 @@ class WhatsAppMe_Admin {
|
|
212 |
'<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>';
|
213 |
}
|
214 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
/**
|
216 |
* Field 'mobile_only' output
|
217 |
*
|
@@ -329,6 +344,7 @@ class WhatsAppMe_Admin {
|
|
329 |
$metadata = get_post_meta( $post->ID, '_whatsappme', true ) ?: array();
|
330 |
$metadata = array_merge( array(
|
331 |
'message_text' => '',
|
|
|
332 |
'hide' => false
|
333 |
), $metadata );
|
334 |
|
@@ -341,7 +357,11 @@ class WhatsAppMe_Admin {
|
|
341 |
?>
|
342 |
<p>
|
343 |
<label for="whatsappme_message"><?php _e( 'Call to action', 'creame-whatsapp-me' ); ?></label><br>
|
344 |
-
<textarea name="whatsappme_message" rows="
|
|
|
|
|
|
|
|
|
345 |
</p>
|
346 |
<p>
|
347 |
<input type="checkbox" name="whatsappme_hide" id="whatsappme_hide" value="1" <?php echo $metadata['hide'] ? 'checked' : ''; ?>>
|
@@ -367,6 +387,7 @@ class WhatsAppMe_Admin {
|
|
367 |
// Delete empty/false fields
|
368 |
$metadata = array_filter( array(
|
369 |
'message_text' => trim( $_POST['whatsappme_message'] ),
|
|
|
370 |
'hide' => isset( $_POST['whatsappme_hide'] ) ? 1 : 0,
|
371 |
) );
|
372 |
|
77 |
'mobile_only' => 'no',
|
78 |
'message_text' => '',
|
79 |
'message_delay' => 10000,
|
80 |
+
'message_send' => '',
|
81 |
'position' => 'right',
|
82 |
);
|
83 |
|
137 |
'mobile_only' => __( 'Mobile only', 'creame-whatsapp-me' ),
|
138 |
'message_text' => __( 'Call to action', 'creame-whatsapp-me' ),
|
139 |
'message_delay' => __( 'Delay', 'creame-whatsapp-me' ),
|
140 |
+
'message_send' => __( 'Message', 'creame-whatsapp-me' ),
|
141 |
'position' => __( 'Position on screen', 'creame-whatsapp-me' ),
|
142 |
);
|
143 |
|
162 |
$input['telephone'] = sanitize_text_field($input['telephone']);
|
163 |
$input['message_text'] = trim($input['message_text']);
|
164 |
$input['message_delay'] = intval($input['message_delay']);
|
165 |
+
$input['message_send'] = trim($input['message_send']);
|
166 |
$input['position'] = $input['position'] != 'left' ? 'right' : 'left';
|
167 |
|
168 |
add_settings_error( 'whatsappme', 'settings_updated', __( 'Settings saved', 'creame-whatsapp-me' ), 'updated' );
|
199 |
* @return void
|
200 |
*/
|
201 |
public function field_message_text() {
|
202 |
+
echo '<textarea name="whatsappme[message_text]" rows="3" class="regular-text" placeholder="' . esc_attr__( "Hello 👋\nCan we help you?", 'creame-whatsapp-me' ) . '">' . $this->settings['message_text'] . '</textarea>' .
|
203 |
+
'<p class="description">' . __( '<strong>Optional.</strong> Text to invite the user to use the contact via WhatsApp.', 'creame-whatsapp-me' ) . '</p>' .
|
204 |
'<p>' . __( 'You can use formatting styles like in WhatsApp: _<em>italic</em>_ *<strong>bold</strong>* ~<del>strikethrough</del>~', 'creame-whatsapp-me' ) . '</p>';
|
205 |
}
|
206 |
|
215 |
'<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>';
|
216 |
}
|
217 |
|
218 |
+
/**
|
219 |
+
* Field 'message_send' output
|
220 |
+
*
|
221 |
+
* @since 1.4.0
|
222 |
+
* @return void
|
223 |
+
*/
|
224 |
+
public function field_message_send() {
|
225 |
+
echo '<textarea name="whatsappme[message_send]" rows="3" class="regular-text" placeholder="' . esc_attr__( "Hi {SITE}! I need more info about {TITLE}", 'creame-whatsapp-me' ) . '">' . $this->settings['message_send'] . '</textarea>' .
|
226 |
+
'<p class="description">' . __( '<strong>Optional.</strong> Default message to start the conversation.', 'creame-whatsapp-me' ) . '</p>' .
|
227 |
+
'<p>' . __( 'You can use vars <code>{SITE} {URL} {TITLE}</code> that will be replaced with the values of the current page.', 'creame-whatsapp-me' ) . '</p>';
|
228 |
+
}
|
229 |
+
|
230 |
/**
|
231 |
* Field 'mobile_only' output
|
232 |
*
|
344 |
$metadata = get_post_meta( $post->ID, '_whatsappme', true ) ?: array();
|
345 |
$metadata = array_merge( array(
|
346 |
'message_text' => '',
|
347 |
+
'message_send' => '',
|
348 |
'hide' => false
|
349 |
), $metadata );
|
350 |
|
357 |
?>
|
358 |
<p>
|
359 |
<label for="whatsappme_message"><?php _e( 'Call to action', 'creame-whatsapp-me' ); ?></label><br>
|
360 |
+
<textarea name="whatsappme_message" rows="2" class="large-text"><?php echo $metadata['message_text']; ?></textarea>
|
361 |
+
</p>
|
362 |
+
<p>
|
363 |
+
<label for="whatsappme_message_send"><?php _e( 'Message', 'creame-whatsapp-me' ); ?></label><br>
|
364 |
+
<textarea name="whatsappme_message_send" rows="2" class="large-text"><?php echo $metadata['message_send']; ?></textarea>
|
365 |
</p>
|
366 |
<p>
|
367 |
<input type="checkbox" name="whatsappme_hide" id="whatsappme_hide" value="1" <?php echo $metadata['hide'] ? 'checked' : ''; ?>>
|
387 |
// Delete empty/false fields
|
388 |
$metadata = array_filter( array(
|
389 |
'message_text' => trim( $_POST['whatsappme_message'] ),
|
390 |
+
'message_send' => trim( $_POST['whatsappme_message_send'] ),
|
391 |
'hide' => isset( $_POST['whatsappme_hide'] ) ? 1 : 0,
|
392 |
) );
|
393 |
|
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-
|
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,86 +21,110 @@ msgstr ""
|
|
21 |
"X-Generator: Loco https://localise.biz/\n"
|
22 |
"X-Poedit-SearchPath-0: ."
|
23 |
|
24 |
-
#: admin/class-whatsappme-admin.php:
|
25 |
msgid "Telephone"
|
26 |
msgstr ""
|
27 |
|
28 |
-
#: admin/class-whatsappme-admin.php:
|
29 |
msgid "Mobile only"
|
30 |
msgstr ""
|
31 |
|
32 |
-
#: admin/class-whatsappme-admin.php:
|
33 |
msgid "Call to action"
|
34 |
msgstr ""
|
35 |
|
36 |
-
#: admin/class-whatsappme-admin.php:
|
37 |
msgid "Delay"
|
38 |
msgstr ""
|
39 |
|
40 |
-
#: admin/class-whatsappme-admin.php:
|
|
|
|
|
|
|
|
|
41 |
msgid "Position on screen"
|
42 |
msgstr ""
|
43 |
|
44 |
-
#: admin/class-whatsappme-admin.php:
|
45 |
msgid "Settings saved"
|
46 |
msgstr ""
|
47 |
|
48 |
-
#: admin/class-whatsappme-admin.php:
|
49 |
msgid ""
|
50 |
"From here you can configure the behavior of the WhatsApp button on your site."
|
51 |
msgstr ""
|
52 |
|
53 |
-
#: admin/class-whatsappme-admin.php:
|
54 |
msgid ""
|
55 |
"Contact phone number. <strong>The button will not be shown if it's empty."
|
56 |
"</strong>"
|
57 |
msgstr ""
|
58 |
|
59 |
-
#: admin/class-whatsappme-admin.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
msgid ""
|
61 |
-
"Optional
|
62 |
-
"
|
63 |
msgstr ""
|
64 |
|
65 |
-
#: admin/class-whatsappme-admin.php:
|
66 |
msgid ""
|
67 |
"You can use formatting styles like in WhatsApp: _<em>italic</em>_ *<strong>"
|
68 |
"bold</strong>* ~<del>strikethrough</del>~"
|
69 |
msgstr ""
|
70 |
|
71 |
-
#: admin/class-whatsappme-admin.php:
|
72 |
msgid "milliseconds"
|
73 |
msgstr ""
|
74 |
|
75 |
-
#: admin/class-whatsappme-admin.php:
|
76 |
msgid ""
|
77 |
"The <strong>Call to action</strong> will only be displayed once when the "
|
78 |
"user exceeds the estimated delay on a page. It will also be displayed when "
|
79 |
"the user stops the cursor over the WhatsApp button."
|
80 |
msgstr ""
|
81 |
|
82 |
-
#: admin/class-whatsappme-admin.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
msgid "Only display the button on mobile devices"
|
84 |
msgstr ""
|
85 |
|
86 |
-
#: admin/class-whatsappme-admin.php:
|
87 |
msgid "Right"
|
88 |
msgstr ""
|
89 |
|
90 |
-
#: admin/class-whatsappme-admin.php:
|
91 |
msgid "Left"
|
92 |
msgstr ""
|
93 |
|
94 |
-
#: admin/class-whatsappme-admin.php:
|
95 |
msgid "Settings"
|
96 |
msgstr ""
|
97 |
|
98 |
#. Name of the plugin
|
99 |
-
#: admin/class-whatsappme-admin.php:
|
100 |
msgid "WhatsApp me"
|
101 |
msgstr ""
|
102 |
|
103 |
-
#: admin/class-whatsappme-admin.php:
|
104 |
#, php-format
|
105 |
msgid "Hide on this %s"
|
106 |
msgstr ""
|
2 |
msgid ""
|
3 |
msgstr ""
|
4 |
"Project-Id-Version: WhatsApp Me\n"
|
5 |
+
"POT-Creation-Date: 2018-04-16 11:42+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:136
|
25 |
msgid "Telephone"
|
26 |
msgstr ""
|
27 |
|
28 |
+
#: admin/class-whatsappme-admin.php:137 admin/class-whatsappme-admin.php:237
|
29 |
msgid "Mobile only"
|
30 |
msgstr ""
|
31 |
|
32 |
+
#: admin/class-whatsappme-admin.php:138 admin/class-whatsappme-admin.php:359
|
33 |
msgid "Call to action"
|
34 |
msgstr ""
|
35 |
|
36 |
+
#: admin/class-whatsappme-admin.php:139
|
37 |
msgid "Delay"
|
38 |
msgstr ""
|
39 |
|
40 |
+
#: admin/class-whatsappme-admin.php:140 admin/class-whatsappme-admin.php:363
|
41 |
+
msgid "Message"
|
42 |
+
msgstr ""
|
43 |
+
|
44 |
+
#: admin/class-whatsappme-admin.php:141 admin/class-whatsappme-admin.php:249
|
45 |
msgid "Position on screen"
|
46 |
msgstr ""
|
47 |
|
48 |
+
#: admin/class-whatsappme-admin.php:168
|
49 |
msgid "Settings saved"
|
50 |
msgstr ""
|
51 |
|
52 |
+
#: admin/class-whatsappme-admin.php:180
|
53 |
msgid ""
|
54 |
"From here you can configure the behavior of the WhatsApp button on your site."
|
55 |
msgstr ""
|
56 |
|
57 |
+
#: admin/class-whatsappme-admin.php:192
|
58 |
msgid ""
|
59 |
"Contact phone number. <strong>The button will not be shown if it's empty."
|
60 |
"</strong>"
|
61 |
msgstr ""
|
62 |
|
63 |
+
#: admin/class-whatsappme-admin.php:202
|
64 |
+
msgid ""
|
65 |
+
"Hello 👋\n"
|
66 |
+
"Can we help you?"
|
67 |
+
msgstr ""
|
68 |
+
|
69 |
+
#: admin/class-whatsappme-admin.php:203
|
70 |
msgid ""
|
71 |
+
"<strong>Optional.</strong> Text to invite the user to use the contact via "
|
72 |
+
"WhatsApp."
|
73 |
msgstr ""
|
74 |
|
75 |
+
#: admin/class-whatsappme-admin.php:204
|
76 |
msgid ""
|
77 |
"You can use formatting styles like in WhatsApp: _<em>italic</em>_ *<strong>"
|
78 |
"bold</strong>* ~<del>strikethrough</del>~"
|
79 |
msgstr ""
|
80 |
|
81 |
+
#: admin/class-whatsappme-admin.php:214
|
82 |
msgid "milliseconds"
|
83 |
msgstr ""
|
84 |
|
85 |
+
#: admin/class-whatsappme-admin.php:215
|
86 |
msgid ""
|
87 |
"The <strong>Call to action</strong> will only be displayed once when the "
|
88 |
"user exceeds the estimated delay on a page. It will also be displayed when "
|
89 |
"the user stops the cursor over the WhatsApp button."
|
90 |
msgstr ""
|
91 |
|
92 |
+
#: admin/class-whatsappme-admin.php:225
|
93 |
+
msgid "Hi {SITE}! I need more info about {TITLE}"
|
94 |
+
msgstr ""
|
95 |
+
|
96 |
+
#: admin/class-whatsappme-admin.php:226
|
97 |
+
msgid "<strong>Optional.</strong> Default message to start the conversation."
|
98 |
+
msgstr ""
|
99 |
+
|
100 |
+
#: admin/class-whatsappme-admin.php:227
|
101 |
+
msgid ""
|
102 |
+
"You can use vars <code>{SITE} {URL} {TITLE}</code> that will be replaced "
|
103 |
+
"with the values of the current page."
|
104 |
+
msgstr ""
|
105 |
+
|
106 |
+
#: admin/class-whatsappme-admin.php:239
|
107 |
msgid "Only display the button on mobile devices"
|
108 |
msgstr ""
|
109 |
|
110 |
+
#: admin/class-whatsappme-admin.php:251
|
111 |
msgid "Right"
|
112 |
msgstr ""
|
113 |
|
114 |
+
#: admin/class-whatsappme-admin.php:253
|
115 |
msgid "Left"
|
116 |
msgstr ""
|
117 |
|
118 |
+
#: admin/class-whatsappme-admin.php:278
|
119 |
msgid "Settings"
|
120 |
msgstr ""
|
121 |
|
122 |
#. Name of the plugin
|
123 |
+
#: admin/class-whatsappme-admin.php:326
|
124 |
msgid "WhatsApp me"
|
125 |
msgstr ""
|
126 |
|
127 |
+
#: admin/class-whatsappme-admin.php:368
|
128 |
#, php-format
|
129 |
msgid "Hide on this %s"
|
130 |
msgstr ""
|
public/class-whatsappme-public.php
CHANGED
@@ -55,6 +55,7 @@ class WhatsAppMe_Public {
|
|
55 |
'telephone' => '',
|
56 |
'message_text' => '',
|
57 |
'message_delay' => 10000,
|
|
|
58 |
'mobile_only' => false,
|
59 |
'position' => 'right',
|
60 |
);
|
@@ -79,7 +80,7 @@ class WhatsAppMe_Public {
|
|
79 |
$settings = array_merge( $this->settings, $settings );
|
80 |
|
81 |
// Post custom settings
|
82 |
-
$post_settings = get_post_meta( $post->ID, '_whatsappme', true )
|
83 |
|
84 |
// Prepare settings
|
85 |
$settings['telephone'] = preg_replace( '/^0+|\D/', '', $settings['telephone'] );
|
@@ -89,6 +90,10 @@ class WhatsAppMe_Public {
|
|
89 |
if ( isset( $post_settings['message_text'] ) ) {
|
90 |
$settings['message_text'] = $post_settings['message_text'];
|
91 |
}
|
|
|
|
|
|
|
|
|
92 |
|
93 |
$this->settings = $settings;
|
94 |
}
|
@@ -183,4 +188,50 @@ class WhatsAppMe_Public {
|
|
183 |
return implode( '<br>', $lines );
|
184 |
|
185 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
}
|
55 |
'telephone' => '',
|
56 |
'message_text' => '',
|
57 |
'message_delay' => 10000,
|
58 |
+
'message_send' => '',
|
59 |
'mobile_only' => false,
|
60 |
'position' => 'right',
|
61 |
);
|
80 |
$settings = array_merge( $this->settings, $settings );
|
81 |
|
82 |
// Post custom settings
|
83 |
+
$post_settings = is_object( $post ) ? get_post_meta( $post->ID, '_whatsappme', true ) : '';
|
84 |
|
85 |
// Prepare settings
|
86 |
$settings['telephone'] = preg_replace( '/^0+|\D/', '', $settings['telephone'] );
|
90 |
if ( isset( $post_settings['message_text'] ) ) {
|
91 |
$settings['message_text'] = $post_settings['message_text'];
|
92 |
}
|
93 |
+
if ( isset( $post_settings['message_send'] ) ) {
|
94 |
+
$settings['message_send'] = $post_settings['message_send'];
|
95 |
+
}
|
96 |
+
$settings['message_send'] = $this->formated_message_send( $settings['message_send'] );
|
97 |
|
98 |
$this->settings = $settings;
|
99 |
}
|
188 |
return implode( '<br>', $lines );
|
189 |
|
190 |
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Format message send, replace vars.
|
194 |
+
*
|
195 |
+
* @since 1.4.0
|
196 |
+
* @return string message formated string
|
197 |
+
*/
|
198 |
+
public function formated_message_send( $string ) {
|
199 |
+
global $wp;
|
200 |
+
|
201 |
+
$replacements = apply_filters( 'whatsappme_message_send_replacements', array(
|
202 |
+
'/\{SITE\}/i' => get_bloginfo( 'name' ),
|
203 |
+
'/\{URL\}/i' => home_url( $wp->request ),
|
204 |
+
'/\{TITLE\}/i'=> $this->get_title(),
|
205 |
+
) );
|
206 |
+
|
207 |
+
return preg_replace( array_keys( $replacements ), $replacements, $string );
|
208 |
+
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Get current page title
|
213 |
+
*
|
214 |
+
* @since 1.4.0
|
215 |
+
* @return string message formated string
|
216 |
+
*/
|
217 |
+
public function get_title() {
|
218 |
+
|
219 |
+
if ( is_home() || is_singular() ) {
|
220 |
+
$title = single_post_title( '', false );
|
221 |
+
} elseif ( is_tax() ) {
|
222 |
+
$title = single_term_title( '', false );
|
223 |
+
} elseif ( function_exists( 'wp_get_document_title' ) ) {
|
224 |
+
$title = wp_get_document_title();
|
225 |
+
|
226 |
+
// Try to remove sitename from $title for cleaner title
|
227 |
+
$sep = apply_filters( 'document_title_separator', '-' );
|
228 |
+
$site = get_bloginfo( 'name', 'display' );
|
229 |
+
$title = str_replace( esc_html( convert_chars( wptexturize( " $sep " . $site ) ) ), '', $title);
|
230 |
+
} else {
|
231 |
+
$title = get_bloginfo( 'name' );
|
232 |
+
}
|
233 |
+
|
234 |
+
return apply_filters( 'whatsappme_get_title', $title );
|
235 |
+
|
236 |
+
}
|
237 |
}
|
public/js/whatsappme.js
CHANGED
@@ -51,8 +51,7 @@
|
|
51 |
ga('send', 'event', 'WhatsAppMe', 'click');
|
52 |
}
|
53 |
|
54 |
-
|
55 |
-
window.open('https://api.whatsapp.com/send?phone=' + settings.telephone, 'whatsappme');
|
56 |
});
|
57 |
|
58 |
$('.whatsappme__close').click(function () {
|
@@ -61,6 +60,16 @@
|
|
61 |
});
|
62 |
}
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
});
|
65 |
|
66 |
})(jQuery);
|
51 |
ga('send', 'event', 'WhatsAppMe', 'click');
|
52 |
}
|
53 |
|
54 |
+
whatsapp_open(settings.telephone, settings.message_send);
|
|
|
55 |
});
|
56 |
|
57 |
$('.whatsappme__close').click(function () {
|
60 |
});
|
61 |
}
|
62 |
|
63 |
+
// Open WhatsApp link with optional message
|
64 |
+
function whatsapp_open(phone, message) {
|
65 |
+
var link = 'https://api.whatsapp.com/send?phone=' + phone;
|
66 |
+
if (typeof (message) == 'string' && message != '') {
|
67 |
+
link += '&text=' + encodeURIComponent(message);
|
68 |
+
}
|
69 |
+
|
70 |
+
window.open(link, 'whatsappme');
|
71 |
+
}
|
72 |
+
|
73 |
});
|
74 |
|
75 |
})(jQuery);
|
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.
|
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.
|
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.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', '1.4.0' );
|
31 |
|
32 |
/**
|
33 |
* The core plugin class that is used to define internationalization,
|