Version Description
- NEW: Better Integration with WooCommerce: CTA and Custom Message for product pages and new dynamic variables {SKU}, {PRICE} {PRODUCT}.
- NEW: Admin help tab with styles and dynamic varibles info.
- NEW: For developers: a lot of new hooks to change or extend WAme functions.
- NEW: Custom javascript document event 'whatsappme:open' that allow trigger other actions and/or change the link url.
- CHANGED Rebrand "WhatsApp me" to "WAme chat".
- CHANGED Code linted following WordPress standar.
- FIX when post visibility was set as "hidden", it used default global visibility.
- FIX javascript error when "ga" global object is defined but isn't Google Analytics.
- FIX rtl styles for chat.
Download this release
Release Info
Developer | creapuntome |
Plugin | WhatsApp me |
Version | 3.0.0 |
Comparing to | |
See all releases |
Code changes from version 2.3.3 to 3.0.0
- README.txt +27 -15
- admin/class-whatsappme-admin.php +412 -314
- admin/class-whatsappme-wooadmin.php +247 -0
- admin/css/whatsappme.css +52 -8
- admin/css/whatsappme.min.css +1 -1
- admin/index.php +1 -1
- admin/js/whatsappme.js +31 -11
- admin/js/whatsappme.min.js +1 -1
- includes/class-whatsappme-integrations.php +42 -0
- includes/class-whatsappme-loader.php +75 -17
- includes/class-whatsappme.php +41 -16
- includes/index.php +1 -1
- index.php +1 -1
- languages/creame-whatsapp-me.pot +208 -107
- public/class-whatsappme-public.php +126 -109
- public/class-whatsappme-woopublic.php +158 -0
- public/css/whatsappme.css +11 -0
- public/css/whatsappme.min.css +1 -1
- public/index.php +1 -1
- public/js/whatsappme.js +15 -5
- public/js/whatsappme.min.js +1 -1
- whatsappme.php +9 -7
README.txt
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
===
|
2 |
Contributors: creapuntome, pacotole, davidlillo, monillo
|
3 |
Donate link: https://www.paypal.me/creapuntome/
|
4 |
Tags: whatsapp business, whatsapp, click to chat, button, whatsapp support chat, support, contact, directly message whatsapp, floating whatsapp, whatsapp chat
|
5 |
Requires at least: 3.0.1
|
6 |
Tested up to: 5.2
|
7 |
Requires PHP: 5.3
|
8 |
-
Stable tag:
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -13,10 +13,14 @@ Connect a WordPress chat with WhatsApp. The best solution for marketing and supp
|
|
13 |
|
14 |
== Description ==
|
15 |
|
16 |
-
[wame.chat](https://wame.chat) | [
|
17 |
|
18 |
### Connect a WordPress chat with WhatsApp. The best solution for marketing and support. Stop losing customers and increase your sales.
|
19 |
|
|
|
|
|
|
|
|
|
20 |
### ⌁ What you can do with WAme ✅
|
21 |
|
22 |
#### 🛎 Insert a WhatsApp button on your website.
|
@@ -71,7 +75,7 @@ Having many options is not an advantage, the configuration of WAme is so easy th
|
|
71 |
|
72 |
= Open WhatsApp Web on desktop =
|
73 |
|
74 |
-
By default,
|
75 |
|
76 |
If you prefer always open WhatsApp Web on desktop you can add this code in your functions.php:
|
77 |
|
@@ -89,11 +93,11 @@ Greater values of z-index are left over, the default value is 400.
|
|
89 |
|
90 |
= What about GDPR? =
|
91 |
|
92 |
-
|
93 |
|
94 |
= Google Analytics integration =
|
95 |
|
96 |
-
|
97 |
|
98 |
If Global Site Tag (gtag.js) detected:
|
99 |
|
@@ -105,21 +109,29 @@ If Universal Analtics (analytics.js) detected:
|
|
105 |
|
106 |
= Google Tag Manager integration =
|
107 |
|
108 |
-
|
109 |
|
110 |
`dataLayer.push({ 'event': 'WhatsAppMe', 'eventAction': 'click', 'eventLabel': out_url });`
|
111 |
|
112 |
== Screenshots ==
|
113 |
|
114 |
-
1.
|
115 |
-
2.
|
116 |
-
3.
|
117 |
-
4. Button on desktop.
|
118 |
-
5. Call to action on desktop.
|
119 |
-
6. Button and call to action on mobile.
|
120 |
|
121 |
== Changelog ==
|
122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
= 2.3.3 =
|
124 |
* FIX javascript error when "ga" global object is defined but isn't Google Analytics.
|
125 |
|
@@ -172,7 +184,7 @@ WhatsApp me send an event (if GTM detected) when user click to launch WhatsApp:
|
|
172 |
* FIX removed array_filter function that requires PHP 5.6 min version.
|
173 |
|
174 |
= 2.0.0 =
|
175 |
-
* **NEW: Advanced visibility settings to define where to show
|
176 |
* **NEW:** WooCommerce integration.
|
177 |
* UPDATED International Telephone Input library to v.13.
|
178 |
* Minor fixes on fields cleanup and other improvements.
|
@@ -186,7 +198,7 @@ WhatsApp me send an event (if GTM detected) when user click to launch WhatsApp:
|
|
186 |
* FIX JavaScript error introduced on v1.4.1.
|
187 |
|
188 |
= 1.4.1 =
|
189 |
-
* Fix JS frontend sometimes can't load
|
190 |
* Fix better Google Analytics event tracking when leave page.
|
191 |
|
192 |
= 1.4.0 =
|
1 |
+
=== WAme chat ===
|
2 |
Contributors: creapuntome, pacotole, davidlillo, monillo
|
3 |
Donate link: https://www.paypal.me/creapuntome/
|
4 |
Tags: whatsapp business, whatsapp, click to chat, button, whatsapp support chat, support, contact, directly message whatsapp, floating whatsapp, whatsapp chat
|
5 |
Requires at least: 3.0.1
|
6 |
Tested up to: 5.2
|
7 |
Requires PHP: 5.3
|
8 |
+
Stable tag: 3.0.0
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
13 |
|
14 |
== Description ==
|
15 |
|
16 |
+
[wame.chat](https://wame.chat) | [Add-Ons](https://wame.chat/addons/) | [Plugin support](https://wordpress.org/support/plugin/creame-whatsapp-me/)
|
17 |
|
18 |
### Connect a WordPress chat with WhatsApp. The best solution for marketing and support. Stop losing customers and increase your sales.
|
19 |
|
20 |
+
### New in WAme 3.0 📍
|
21 |
+
|
22 |
+
🛒 **Better Integration with WooCommerce**. Define CTAs and Custom Messages for product pages, you can use dynamic variables such as {SKU}, {PRICE} or {PRODUCT}.
|
23 |
+
|
24 |
### ⌁ What you can do with WAme ✅
|
25 |
|
26 |
#### 🛎 Insert a WhatsApp button on your website.
|
75 |
|
76 |
= Open WhatsApp Web on desktop =
|
77 |
|
78 |
+
By default, WAme always opens api.whatsapp.com and try to launch the native application or if it doesn't exist redirects to WhatsApp Web. Depending on the browser and the operating system, sometimes it doesn't work.
|
79 |
|
80 |
If you prefer always open WhatsApp Web on desktop you can add this code in your functions.php:
|
81 |
|
93 |
|
94 |
= What about GDPR? =
|
95 |
|
96 |
+
WAme don't save any personal data and don't use cookies.
|
97 |
|
98 |
= Google Analytics integration =
|
99 |
|
100 |
+
WAme send an event when user click to launch WhatsApp.
|
101 |
|
102 |
If Global Site Tag (gtag.js) detected:
|
103 |
|
109 |
|
110 |
= Google Tag Manager integration =
|
111 |
|
112 |
+
WAme send an event (if GTM detected) when user click to launch WhatsApp:
|
113 |
|
114 |
`dataLayer.push({ 'event': 'WhatsAppMe', 'eventAction': 'click', 'eventLabel': out_url });`
|
115 |
|
116 |
== Screenshots ==
|
117 |
|
118 |
+
1. WAme general settings.
|
119 |
+
2. WAme advanced visibility settings.
|
120 |
+
3. WAme on post/page edition.
|
|
|
|
|
|
|
121 |
|
122 |
== Changelog ==
|
123 |
|
124 |
+
= 3.0.0 =
|
125 |
+
* **NEW:** Better Integration with WooCommerce: CTA and Custom Message for product pages and new dynamic variables {SKU}, {PRICE} {PRODUCT}.
|
126 |
+
* **NEW:** Admin help tab with styles and dynamic varibles info.
|
127 |
+
* **NEW:** For developers: a lot of new hooks to change or extend WAme functions.
|
128 |
+
* **NEW:** Custom javascript document event 'whatsappme:open' that allow trigger other actions and/or change the link url.
|
129 |
+
* CHANGED Rebrand "WhatsApp me" to "WAme chat".
|
130 |
+
* CHANGED Code linted following WordPress standar.
|
131 |
+
* FIX when post visibility was set as "hidden", it used default global visibility.
|
132 |
+
* FIX javascript error when "ga" global object is defined but isn't Google Analytics.
|
133 |
+
* FIX rtl styles for chat.
|
134 |
+
|
135 |
= 2.3.3 =
|
136 |
* FIX javascript error when "ga" global object is defined but isn't Google Analytics.
|
137 |
|
184 |
* FIX removed array_filter function that requires PHP 5.6 min version.
|
185 |
|
186 |
= 2.0.0 =
|
187 |
+
* **NEW: Advanced visibility settings to define where to show WAme button.**
|
188 |
* **NEW:** WooCommerce integration.
|
189 |
* UPDATED International Telephone Input library to v.13.
|
190 |
* Minor fixes on fields cleanup and other improvements.
|
198 |
* FIX JavaScript error introduced on v1.4.1.
|
199 |
|
200 |
= 1.4.1 =
|
201 |
+
* Fix JS frontend sometimes can't load WAme settings.
|
202 |
* Fix better Google Analytics event tracking when leave page.
|
203 |
|
204 |
= 1.4.0 =
|
admin/class-whatsappme-admin.php
CHANGED
@@ -8,6 +8,7 @@
|
|
8 |
*
|
9 |
* @since 1.0.0
|
10 |
* @since 2.0.0 Added advanced visibility settings
|
|
|
11 |
* @package WhatsAppMe
|
12 |
* @subpackage WhatsAppMe/admin
|
13 |
* @author Creame <hola@crea.me>
|
@@ -50,19 +51,32 @@ class WhatsAppMe_Admin {
|
|
50 |
*/
|
51 |
private $enhanced_phone;
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
/**
|
54 |
* Initialize the class and set its properties.
|
55 |
*
|
56 |
* @since 1.0.0
|
57 |
-
* @
|
58 |
-
* @param string
|
|
|
59 |
*/
|
60 |
public function __construct( $plugin_name, $version ) {
|
61 |
|
62 |
-
$this->plugin_name
|
63 |
-
$this->version
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
66 |
|
67 |
}
|
68 |
|
@@ -73,33 +87,51 @@ class WhatsAppMe_Admin {
|
|
73 |
* @since 2.0.0 Added visibility setting
|
74 |
* @since 2.1.0 Added message_badge
|
75 |
* @since 2.3.0 Added button_delay and whatsapp_web settings, message_delay in seconds
|
|
|
76 |
*/
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
'
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
);
|
91 |
|
92 |
$saved_settings = get_option( 'whatsappme' );
|
93 |
|
94 |
if ( is_array( $saved_settings ) ) {
|
95 |
// clean unused saved settings
|
96 |
-
$saved_settings = array_intersect_key( $saved_settings, $
|
97 |
// merge defaults with saved settings
|
98 |
-
$this->settings = array_merge( $
|
99 |
// miliseconds (<v2.3) to seconds
|
100 |
if ( $this->settings['message_delay'] > 120 ) {
|
101 |
$this->settings['message_delay'] = round( $this->settings['message_delay'] / 1000 );
|
102 |
}
|
|
|
|
|
103 |
}
|
104 |
|
105 |
}
|
@@ -107,20 +139,17 @@ class WhatsAppMe_Admin {
|
|
107 |
/**
|
108 |
* Register the stylesheets for the admin area.
|
109 |
*
|
110 |
-
* @since
|
111 |
-
* @
|
112 |
-
* @since 2.2.0 Only register (not enqueue)
|
113 |
-
* @since 2.2.2 minified
|
114 |
-
* @param string $hook The name of the page.
|
115 |
* @return void
|
116 |
*/
|
117 |
-
public function
|
118 |
|
119 |
$styles = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'whatsappme.css' : 'whatsappme.min.css';
|
120 |
wp_register_style( 'whatsappme-admin', plugin_dir_url( __FILE__ ) . 'css/' . $styles, array(), $this->version, 'all' );
|
121 |
|
122 |
if ( $this->enhanced_phone ) {
|
123 |
-
wp_register_style( 'intl-tel-input', 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/
|
124 |
}
|
125 |
|
126 |
}
|
@@ -128,19 +157,18 @@ class WhatsAppMe_Admin {
|
|
128 |
/**
|
129 |
* Register the JavaScript for the admin area.
|
130 |
*
|
131 |
-
* @since
|
132 |
-
* @
|
133 |
-
* @since 2.2.2 minified
|
134 |
-
* @param string $hook The id of the page.
|
135 |
* @return void
|
136 |
*/
|
137 |
-
public function
|
138 |
|
139 |
$script = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'whatsappme.js' : 'whatsappme.min.js';
|
140 |
|
141 |
if ( $this->enhanced_phone ) {
|
142 |
-
wp_register_script( 'intl-tel-input', 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/
|
143 |
wp_register_script( 'whatsappme-admin', plugin_dir_url( __FILE__ ) . 'js/' . $script, array( 'jquery', 'intl-tel-input' ), $this->version, true );
|
|
|
144 |
} else {
|
145 |
wp_register_script( 'whatsappme-admin', plugin_dir_url( __FILE__ ) . 'js/' . $script, array( 'jquery' ), $this->version, true );
|
146 |
}
|
@@ -148,140 +176,132 @@ class WhatsAppMe_Admin {
|
|
148 |
}
|
149 |
|
150 |
/**
|
151 |
-
* Initialize the settings for
|
152 |
* From v1.2.0 also set filter to disable enhanced phone input
|
153 |
*
|
154 |
* @since 1.0.0
|
155 |
* @since 2.0.0 Added tabs for general and Advanced settings
|
156 |
* @since 2.3.0 Split general settings in Button and Window Chat
|
|
|
157 |
* @access public
|
158 |
* @return void
|
159 |
*/
|
160 |
-
public function settings_init(){
|
161 |
|
|
|
162 |
register_setting( 'whatsappme', 'whatsappme', array( $this, 'settings_validate' ) );
|
163 |
|
164 |
-
|
165 |
-
* General Settings
|
166 |
-
*/
|
167 |
|
168 |
-
|
169 |
|
170 |
-
|
171 |
-
'telephone' => '<label for="whatsappme_phone">' . __( 'Telephone', 'creame-whatsapp-me' ) . '</label>',
|
172 |
-
'mobile_only' => __( 'Mobile Only', 'creame-whatsapp-me' ),
|
173 |
-
'position' => __( 'Position On Screen', 'creame-whatsapp-me' ),
|
174 |
-
'button_delay' => '<label for="whatsappme_button_delay">' . __( 'Button Delay', 'creame-whatsapp-me' ) . '</label>',
|
175 |
-
'whatsapp_web' => __( 'WhatsApp Web', 'creame-whatsapp-me' ),
|
176 |
-
);
|
177 |
|
178 |
-
|
|
|
179 |
|
180 |
-
|
181 |
-
add_settings_field( 'whatsappme_' . $key, $value, array( $this, 'field_' . $key ), 'whatsappme', 'whatsappme_section_general_btn' );
|
182 |
-
}
|
183 |
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
|
|
|
|
190 |
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
add_settings_field( 'whatsappme_' . $key, $value, array( $this, 'field_' . $key ), 'whatsappme', 'whatsappme_section_general_cta' );
|
195 |
-
}
|
196 |
-
|
197 |
-
/*
|
198 |
-
* Advanced Settings / All
|
199 |
-
*/
|
200 |
-
|
201 |
-
add_settings_section( 'whatsappme_section_advanced_all', null, array( $this, 'section_text' ), 'whatsappme' );
|
202 |
-
add_settings_field( 'whatsappme_view_all', __( 'Global', 'creame-whatsapp-me' ), array( $this, 'field_view_all' ), 'whatsappme', 'whatsappme_section_advanced_all' );
|
203 |
-
|
204 |
-
/*
|
205 |
-
* Advanced Settings / WP
|
206 |
-
*/
|
207 |
-
|
208 |
-
add_settings_section( 'whatsappme_section_advanced_wp', null, array( $this, 'section_text' ), 'whatsappme' );
|
209 |
-
|
210 |
-
$advanced_fields = array(
|
211 |
-
'front_page' => __( 'Front Page', 'creame-whatsapp-me' ),
|
212 |
-
'blog_page' => __( 'Blog Page', 'creame-whatsapp-me' ),
|
213 |
-
'404_page' => __( '404 Page', 'creame-whatsapp-me' ),
|
214 |
-
'search' => __( 'Search Results', 'creame-whatsapp-me' ),
|
215 |
-
'archive' => __( 'Archives', 'creame-whatsapp-me' ),
|
216 |
-
'date' => '— ' . __( 'Date Archives', 'creame-whatsapp-me' ),
|
217 |
-
'author' => '— ' . __( 'Author Archives', 'creame-whatsapp-me' ),
|
218 |
-
'singular' => __( 'Singular', 'creame-whatsapp-me' ),
|
219 |
-
'page' => '— ' . __( 'Page', 'creame-whatsapp-me' ),
|
220 |
-
'post' => '— ' . __( 'Post', 'creame-whatsapp-me' ),
|
221 |
-
);
|
222 |
-
|
223 |
-
// If isn't set Blog Page or is the same than Front Page unset blog_page option
|
224 |
-
if ( get_option( 'show_on_front' ) == 'posts' || get_option( 'page_for_posts' ) == 0 ) {
|
225 |
-
unset( $advanced_fields['blog_page'] );
|
226 |
-
}
|
227 |
|
228 |
-
|
229 |
-
add_settings_field( 'whatsappme_view_' . $key, $value, array( $this, 'field_view' ), 'whatsappme', 'whatsappme_section_advanced_wp', array( 'field' => $key ) );
|
230 |
}
|
231 |
|
232 |
-
|
233 |
-
* Advanced Settings / Woocommerce
|
234 |
-
*/
|
235 |
-
|
236 |
-
if ( class_exists( 'WooCommerce' ) ) {
|
237 |
|
238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
'
|
244 |
-
|
245 |
-
|
246 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
);
|
248 |
|
249 |
-
|
250 |
-
|
|
|
251 |
}
|
252 |
-
}
|
253 |
-
|
254 |
-
/*
|
255 |
-
* Advanced Settings / Custom Post Types
|
256 |
-
*/
|
257 |
-
|
258 |
-
$custom_post_types = array_keys( get_post_types( array( 'has_archive' => true ), 'names' ) );
|
259 |
-
// Product CPT already defined in WooCommerce section
|
260 |
-
if ( class_exists( 'WooCommerce' ) ) {
|
261 |
-
$custom_post_types = array_diff( $custom_post_types, array( 'product' ) );
|
262 |
-
}
|
263 |
|
264 |
-
|
265 |
-
|
|
|
|
|
|
|
266 |
|
267 |
-
|
|
|
268 |
|
269 |
-
|
|
|
|
|
|
|
|
|
270 |
|
271 |
-
|
|
|
|
|
|
|
272 |
|
273 |
-
|
274 |
-
$post_type_name = function_exists( 'mb_convert_case' ) ?
|
275 |
-
mb_convert_case( $post_type->labels->name, MB_CASE_TITLE ) :
|
276 |
-
strtolower( $post_type->labels->name );
|
277 |
|
278 |
-
add_settings_field( 'whatsappme_view_cpt_' . $custom_post_type, $post_type_name, array( $this, 'field_view' ), 'whatsappme', 'whatsappme_section_advanced_cpt', array( 'field' => 'cpt_' . $custom_post_type ) );
|
279 |
-
}
|
280 |
}
|
281 |
|
282 |
-
|
|
|
283 |
|
284 |
-
$this->enhanced_phone = apply_filters( 'whatsappme_enhanced_phone', $this->enhanced_phone );
|
285 |
}
|
286 |
|
287 |
/**
|
@@ -291,25 +311,33 @@ class WhatsAppMe_Admin {
|
|
291 |
* @since 2.0.0 Added visibility setting
|
292 |
* @since 2.1.0 Added message_badge
|
293 |
* @since 2.3.0 Added button_delay and whatsapp_web settings, WPML integration
|
294 |
-
* @
|
|
|
295 |
* @return array
|
296 |
*/
|
297 |
-
public function settings_validate($input) {
|
298 |
|
299 |
-
$input['telephone'] =
|
300 |
$input['mobile_only'] = isset( $input['mobile_only'] ) ? 'yes' : 'no';
|
301 |
$input['button_delay'] = intval( $input['button_delay'] );
|
302 |
$input['whatsapp_web'] = isset( $input['whatsapp_web'] ) ? 'yes' : 'no';
|
303 |
-
$input['message_text'] =
|
304 |
$input['message_delay'] = intval( $input['message_delay'] );
|
305 |
$input['message_badge'] = isset( $input['message_badge'] ) ? 'yes' : 'no';
|
306 |
-
$input['message_send'] =
|
307 |
$input['position'] = $input['position'] != 'left' ? 'right' : 'left';
|
308 |
if ( isset( $input['view'] ) ) {
|
309 |
-
$input['visibility']
|
|
|
|
|
|
|
|
|
310 |
unset( $input['view'] );
|
311 |
}
|
312 |
|
|
|
|
|
|
|
313 |
/**
|
314 |
* Register WPML/Polylang strings for translation
|
315 |
* https://wpml.org/wpml-hook/wpml_register_single_string/
|
@@ -320,218 +348,271 @@ class WhatsAppMe_Admin {
|
|
320 |
do_action( 'wpml_register_single_string', 'WhatsApp me', 'Call To Action', $input['message_text'] );
|
321 |
do_action( 'wpml_register_single_string', 'WhatsApp me', 'Message', $input['message_send'] );
|
322 |
|
|
|
|
|
|
|
323 |
add_settings_error( 'whatsappme', 'settings_updated', __( 'Settings saved', 'creame-whatsapp-me' ), 'updated' );
|
324 |
|
325 |
return $input;
|
326 |
}
|
327 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
328 |
/**
|
329 |
* Section HTML output
|
330 |
*
|
331 |
-
* @since
|
332 |
-
* @
|
333 |
-
* @param array $args Section info.
|
334 |
* @return void
|
335 |
*/
|
336 |
-
public function
|
337 |
-
|
338 |
-
case 'whatsappme_section_general':
|
339 |
-
echo '<h2 class="nav-tab-wrapper wp-clearfix">' .
|
340 |
-
'<a href="#tab-general" class="nav-tab nav-tab-active">' . __( 'General', 'creame-whatsapp-me' ) . '</a>' .
|
341 |
-
'<a href="#tab-advanced" class="nav-tab">' . __( 'Advanced', 'creame-whatsapp-me' ) . '</a>' .
|
342 |
-
'</h2>' .
|
343 |
-
'<div class="tabs">' .
|
344 |
-
'<div id="tab-general" class="tab tab-active">';
|
345 |
-
break;
|
346 |
|
347 |
-
|
348 |
-
|
|
|
349 |
'<p>' . __( 'Set the contact number and where you want the WhatsApp button to be displayed.', 'creame-whatsapp-me' ) . '</p>';
|
350 |
break;
|
351 |
|
352 |
-
case '
|
353 |
-
|
354 |
'<p>' .
|
355 |
__( 'Set the behavior of the chat window.', 'creame-whatsapp-me' ) . ' ' .
|
356 |
-
__(
|
357 |
-
|
358 |
'</p>';
|
359 |
break;
|
360 |
|
361 |
-
case '
|
362 |
-
|
363 |
-
'<h2 class="title">' . __( 'Advanced Visibility Settings', 'creame-whatsapp-me' ) . '</h2>' .
|
364 |
'<p>' . __( 'From here you can configure on which pages the WhatsApp button will be visible.', 'creame-whatsapp-me' ) .
|
365 |
' <a href="#" class="whatsappme_view_reset">' . __( 'Restore default visibility', 'creame-whatsapp-me' ) . '</a></p>';
|
366 |
break;
|
367 |
|
368 |
-
case '
|
369 |
-
|
370 |
break;
|
371 |
|
372 |
-
case '
|
373 |
-
|
374 |
break;
|
375 |
|
376 |
default:
|
|
|
377 |
break;
|
378 |
}
|
379 |
-
}
|
380 |
|
381 |
-
|
382 |
-
|
383 |
-
*
|
384 |
-
* @since 1.0.0
|
385 |
-
* @return void
|
386 |
-
*/
|
387 |
-
public function field_telephone() {
|
388 |
-
echo '<input id="whatsappme_phone" ' . ( $this->enhanced_phone ? 'data-' : '') . 'name="whatsappme[telephone]" value="' . $this->settings['telephone'] . '" type="text" style="width:15em">' .
|
389 |
-
'<p class="description">' . __( "Contact phone number <strong>(the button will not be shown if it's empty)</strong>", 'creame-whatsapp-me' ) . '</p>';
|
390 |
}
|
391 |
|
392 |
/**
|
393 |
-
* Field
|
394 |
*
|
395 |
-
* @since
|
396 |
* @return void
|
397 |
*/
|
398 |
-
public function
|
399 |
-
echo '<textarea id="whatsappme_message_text" name="whatsappme[message_text]" rows="4" class="regular-text" placeholder="' . esc_attr__( "Hello 👋\nCan we help you?", 'creame-whatsapp-me' ) . '">' . $this->settings['message_text'] . '</textarea>' .
|
400 |
-
'<p class="description">' . __( 'Define a text to encourage users to contact by WhatsApp <strong>(optional)</strong>', 'creame-whatsapp-me' ) . '</p>';
|
401 |
-
}
|
402 |
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
* @since 1.0.0
|
407 |
-
* @return void
|
408 |
-
*/
|
409 |
-
public function field_message_delay() {
|
410 |
-
echo '<input id="whatsappme_message_delay" name="whatsappme[message_delay]" value="' . $this->settings['message_delay'] . '" type="number" min="0" max="120" style="width:5em"> ' . __( 'seconds', 'creame-whatsapp-me' ) .
|
411 |
-
'<p class="description">' . __( 'Time since the WhatsApp button is displayed until the Chat Window opens', 'creame-whatsapp-me' ) . '</p>';
|
412 |
-
}
|
413 |
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
public function field_message_badge() {
|
421 |
-
echo '<fieldset><legend class="screen-reader-text"><span>' . __( 'Hide Chat', 'creame-whatsapp-me' ) . '</span></legend>' .
|
422 |
-
'<label><input name="whatsappme[message_badge]" value="yes" type="checkbox"' . checked( 'yes', $this->settings['message_badge'], false ) . '> ' .
|
423 |
-
__('Display a notification balloon instead of opening the Chat Window for a "less intrusive" mode', 'creame-whatsapp-me' ) . '</label></fieldset>';
|
424 |
-
}
|
425 |
|
426 |
-
|
427 |
-
* Field 'message_send' output
|
428 |
-
*
|
429 |
-
* @since 1.4.0
|
430 |
-
* @return void
|
431 |
-
*/
|
432 |
-
public function field_message_send() {
|
433 |
-
echo '<textarea id="whatsappme_message_send" 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>' .
|
434 |
-
'<p class="description">' . __( 'Predefined text with which user can start the conversation <strong>(optional)</strong>', 'creame-whatsapp-me' ) . '</p>';
|
435 |
-
}
|
436 |
-
|
437 |
-
/**
|
438 |
-
* Field 'mobile_only' output
|
439 |
-
*
|
440 |
-
* @since 1.0.0
|
441 |
-
* @return void
|
442 |
-
*/
|
443 |
-
public function field_mobile_only() {
|
444 |
-
echo '<fieldset><legend class="screen-reader-text"><span>' . __( 'Mobile Only', 'creame-whatsapp-me' ) . '</span></legend>' .
|
445 |
-
'<label><input id="whatsappme_mobile_only" name="whatsappme[mobile_only]" value="yes" type="checkbox"' . checked( 'yes', $this->settings['mobile_only'], false ) . '> ' .
|
446 |
-
__('Only display the button on mobile devices', 'creame-whatsapp-me' ) . '</label></fieldset>';
|
447 |
-
}
|
448 |
-
|
449 |
-
/**
|
450 |
-
* Field 'button_delay' output
|
451 |
-
*
|
452 |
-
* @since 2.3.0
|
453 |
-
* @return void
|
454 |
-
*/
|
455 |
-
public function field_button_delay() {
|
456 |
-
echo '<input id="whatsappme_button_delay" name="whatsappme[button_delay]" value="' . $this->settings['button_delay'] . '" type="number" min="0" max="120" style="width:5em"> ' . __( 'seconds', 'creame-whatsapp-me' ) .
|
457 |
-
'<p class="description">' . __( 'Time since the page is opened until the WhatsApp button is displayed', 'creame-whatsapp-me' ) . '</p>';
|
458 |
-
}
|
459 |
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
473 |
|
474 |
-
|
475 |
-
|
476 |
-
*
|
477 |
-
* @since 2.3.0
|
478 |
-
* @return void
|
479 |
-
*/
|
480 |
-
public function field_whatsapp_web() {
|
481 |
-
echo '<fieldset><legend class="screen-reader-text"><span>' . __( 'WhatsApp Web', 'creame-whatsapp-me' ) . '</span></legend>' .
|
482 |
-
'<label><input id="whatsappme_whatsapp_web" name="whatsappme[whatsapp_web]" value="yes" type="checkbox"' . checked( 'yes', $this->settings['whatsapp_web'], false ) . '> ' .
|
483 |
-
__('Open <em>WhatsApp Web</em> directly on desktop', 'creame-whatsapp-me' ) . '</label></fieldset>';
|
484 |
}
|
485 |
|
486 |
/**
|
487 |
* Field 'field_view_all' output
|
488 |
*
|
489 |
* @since 2.0.0
|
|
|
490 |
* @return void
|
491 |
*/
|
492 |
public function field_view_all() {
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
|
|
|
|
|
|
|
|
|
|
498 |
|
499 |
-
echo '<
|
|
|
500 |
'<span class="dashicons dashicons-visibility" title="' . __( 'Show', 'creame-whatsapp-me' ) . '"></span></label>' .
|
501 |
-
'<label
|
502 |
-
'<span class="dashicons dashicons-hidden" title="' . __( 'Hide', 'creame-whatsapp-me' ) . '"></span></label>';
|
503 |
}
|
504 |
|
505 |
/**
|
506 |
-
*
|
507 |
*
|
508 |
-
* @since
|
509 |
-
* @
|
510 |
* @return void
|
511 |
*/
|
512 |
-
public function
|
513 |
-
|
514 |
-
|
515 |
|
516 |
-
echo '<label><input type="radio" name="whatsappme[view][' . $field . ']" value="yes"' . checked( 'yes', $value, false ) . '> ' .
|
517 |
-
'<span class="dashicons dashicons-visibility" title="' . __( 'Show', 'creame-whatsapp-me' ) . '"></span></label>' .
|
518 |
-
'<label><input type="radio" name="whatsappme[view][' . $field . ']" value="no"' . checked( 'no', $value, false ) . '> ' .
|
519 |
-
'<span class="dashicons dashicons-hidden" title="' . __( 'Hide', 'creame-whatsapp-me' ) . '"></span></label>' .
|
520 |
-
'<label><input type="radio" name="whatsappme[view][' . $field . ']" value=""' . checked( '', $value, false ) . '> ' .
|
521 |
-
__( 'Inherit', 'creame-whatsapp-me' ) . ' <span class="dashicons dashicons-visibility view_inheritance_' . $field . '"></span></label>';
|
522 |
}
|
523 |
|
524 |
/**
|
525 |
-
* Add
|
526 |
*
|
527 |
-
* @since
|
528 |
* @access public
|
529 |
* @return void
|
530 |
*/
|
531 |
-
|
532 |
-
|
533 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
534 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
535 |
}
|
536 |
|
537 |
/**
|
@@ -550,7 +631,7 @@ class WhatsAppMe_Admin {
|
|
550 |
}
|
551 |
|
552 |
/**
|
553 |
-
* Generate the options page in the
|
554 |
*
|
555 |
* @since 1.0.0
|
556 |
* @since 2.2.0 Enqueue scripts/styles
|
@@ -566,16 +647,22 @@ class WhatsAppMe_Admin {
|
|
566 |
if ( $this->enhanced_phone ) {
|
567 |
wp_enqueue_style( 'intl-tel-input' );
|
568 |
}
|
|
|
569 |
?>
|
570 |
<div class="wrap">
|
571 |
-
<h1>
|
572 |
|
573 |
<form method="post" id="whatsappme_form" action="options.php">
|
574 |
-
<?php
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
|
|
|
|
|
|
|
|
|
|
579 |
</form>
|
580 |
</div>
|
581 |
<?php
|
@@ -594,13 +681,13 @@ class WhatsAppMe_Admin {
|
|
594 |
// Custom post types with public url
|
595 |
$custom_post_types = array_keys( get_post_types( array( 'has_archive' => true ), 'names' ) );
|
596 |
|
597 |
-
// Add/remove posts types for "
|
598 |
$post_types = apply_filters( 'whatsappme_post_types_meta_box', array_merge( $builtin_post_types, $custom_post_types ) );
|
599 |
|
600 |
foreach ( $post_types as $post_type ) {
|
601 |
add_meta_box(
|
602 |
'whatsappme',
|
603 |
-
__( '
|
604 |
array( $this, 'meta_box' ),
|
605 |
$post_type,
|
606 |
'side',
|
@@ -619,7 +706,7 @@ class WhatsAppMe_Admin {
|
|
619 |
* @return void
|
620 |
*/
|
621 |
public function meta_box( $post ) {
|
622 |
-
|
623 |
// Enqueue assets
|
624 |
wp_enqueue_script( 'whatsappme-admin' );
|
625 |
|
@@ -628,13 +715,15 @@ class WhatsAppMe_Admin {
|
|
628 |
}
|
629 |
|
630 |
$metadata = get_post_meta( $post->ID, '_whatsappme', true ) ?: array();
|
631 |
-
$metadata = array_merge(
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
|
|
|
|
638 |
|
639 |
// Move old 'hide' to new 'view' field
|
640 |
if ( $metadata['hide'] ) {
|
@@ -642,6 +731,8 @@ class WhatsAppMe_Admin {
|
|
642 |
}
|
643 |
unset( $metadata['hide'] );
|
644 |
|
|
|
|
|
645 |
wp_nonce_field( 'whatsappme_data', 'whatsappme_nonce' );
|
646 |
?>
|
647 |
<div class="whatsappme-metabox">
|
@@ -656,7 +747,9 @@ class WhatsAppMe_Admin {
|
|
656 |
<p>
|
657 |
<label for="whatsappme_message_send"><?php _e( 'Message', 'creame-whatsapp-me' ); ?></label><br>
|
658 |
<textarea name="whatsappme_message_send" rows="2" class="large-text"><?php echo $metadata['message_send']; ?></textarea>
|
659 |
-
|
|
|
|
|
660 |
</p>
|
661 |
<p>
|
662 |
<label><input type="radio" name="whatsappme_view" value="yes" <?php checked( 'yes', $metadata['view'] ); ?>>
|
@@ -668,7 +761,7 @@ class WhatsAppMe_Admin {
|
|
668 |
</p>
|
669 |
</div>
|
670 |
<style>
|
671 |
-
.whatsappme-metabox code { font-size:smaller; vertical-align:text-bottom; }
|
672 |
.whatsappme-metabox .dashicons { opacity:.5; }
|
673 |
.whatsappme-metabox input::placeholder { color:#dedfe0; }
|
674 |
.whatsappme-metabox input::-ms-input-placeholder { color:#dedfe0; }
|
@@ -681,7 +774,7 @@ class WhatsAppMe_Admin {
|
|
681 |
}
|
682 |
|
683 |
/**
|
684 |
-
* Save meta data from "
|
685 |
*
|
686 |
* @since 1.1.0
|
687 |
* @since 2.0.0 Change 'hide' key to 'view' now values can be [yes, no]
|
@@ -697,12 +790,16 @@ class WhatsAppMe_Admin {
|
|
697 |
}
|
698 |
|
699 |
// Clean and delete empty/false fields
|
700 |
-
$metadata = array_filter(
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
|
|
|
|
|
|
|
|
706 |
|
707 |
if ( count( $metadata ) ) {
|
708 |
update_post_meta( $post_id, '_whatsappme', $metadata );
|
@@ -715,13 +812,14 @@ class WhatsAppMe_Admin {
|
|
715 |
* Clean user input fields
|
716 |
*
|
717 |
* @since 2.0.0
|
718 |
-
* @
|
|
|
719 |
* @return mixed $value cleaned
|
720 |
*/
|
721 |
-
public function clean_input($value) {
|
722 |
if ( is_array( $value ) ) {
|
723 |
-
return array_map(
|
724 |
-
}
|
725 |
// Split lines, clean and re-join lines
|
726 |
return implode( "\n", array_map( 'sanitize_text_field', explode( "\n", trim( $value ) ) ) );
|
727 |
} else {
|
8 |
*
|
9 |
* @since 1.0.0
|
10 |
* @since 2.0.0 Added advanced visibility settings
|
11 |
+
* @since 3.0.0 More extendable admin via hooks
|
12 |
* @package WhatsAppMe
|
13 |
* @subpackage WhatsAppMe/admin
|
14 |
* @author Creame <hola@crea.me>
|
51 |
*/
|
52 |
private $enhanced_phone;
|
53 |
|
54 |
+
/**
|
55 |
+
* Admin page tabs
|
56 |
+
*
|
57 |
+
* @since 3.0.0
|
58 |
+
* @access private
|
59 |
+
* @var array $tabs Admin page tabs.
|
60 |
+
*/
|
61 |
+
private $tabs;
|
62 |
+
|
63 |
/**
|
64 |
* Initialize the class and set its properties.
|
65 |
*
|
66 |
* @since 1.0.0
|
67 |
+
* @since 3.0.0 Added $tabs initilization and removed get_settings()
|
68 |
+
* @param string $plugin_name The name of this plugin.
|
69 |
+
* @param string $version The version of this plugin.
|
70 |
*/
|
71 |
public function __construct( $plugin_name, $version ) {
|
72 |
|
73 |
+
$this->plugin_name = $plugin_name;
|
74 |
+
$this->version = $version;
|
75 |
+
|
76 |
+
// Updated in get_settings() at 'admin_init' hook
|
77 |
+
$this->enhanced_phone = '16.0.3'; // intl-tel-input version
|
78 |
+
$this->tabs = array();
|
79 |
+
$this->settings = array();
|
80 |
|
81 |
}
|
82 |
|
87 |
* @since 2.0.0 Added visibility setting
|
88 |
* @since 2.1.0 Added message_badge
|
89 |
* @since 2.3.0 Added button_delay and whatsapp_web settings, message_delay in seconds
|
90 |
+
* @since 3.0.0 Is public and added plugin enhanced_phone and tabs
|
91 |
*/
|
92 |
+
public function get_settings() {
|
93 |
+
|
94 |
+
// Use International Telephone Input library version or false to disable
|
95 |
+
$this->enhanced_phone = apply_filters( 'whatsappme_enhanced_phone', $this->enhanced_phone );
|
96 |
+
|
97 |
+
// Admin tabs
|
98 |
+
$this->tabs = apply_filters(
|
99 |
+
'whatsappme_admin_tabs', array(
|
100 |
+
'general' => __( 'General', 'creame-whatsapp-me' ),
|
101 |
+
'advanced' => __( 'Advanced', 'creame-whatsapp-me' ),
|
102 |
+
)
|
103 |
+
);
|
104 |
+
|
105 |
+
// Default settings
|
106 |
+
$default_settings = array_merge(
|
107 |
+
array(
|
108 |
+
'telephone' => '',
|
109 |
+
'mobile_only' => 'no',
|
110 |
+
'button_delay' => 3,
|
111 |
+
'whatsapp_web' => 'no',
|
112 |
+
'message_text' => '',
|
113 |
+
'message_delay' => 10,
|
114 |
+
'message_badge' => 'no',
|
115 |
+
'message_send' => '',
|
116 |
+
'position' => 'right',
|
117 |
+
'visibility' => array( 'all' => 'yes' ),
|
118 |
+
),
|
119 |
+
apply_filters( 'whatsappme_extra_settings', array() )
|
120 |
);
|
121 |
|
122 |
$saved_settings = get_option( 'whatsappme' );
|
123 |
|
124 |
if ( is_array( $saved_settings ) ) {
|
125 |
// clean unused saved settings
|
126 |
+
$saved_settings = array_intersect_key( $saved_settings, $default_settings );
|
127 |
// merge defaults with saved settings
|
128 |
+
$this->settings = array_merge( $default_settings, $saved_settings );
|
129 |
// miliseconds (<v2.3) to seconds
|
130 |
if ( $this->settings['message_delay'] > 120 ) {
|
131 |
$this->settings['message_delay'] = round( $this->settings['message_delay'] / 1000 );
|
132 |
}
|
133 |
+
} else {
|
134 |
+
$this->settings = $default_settings;
|
135 |
}
|
136 |
|
137 |
}
|
139 |
/**
|
140 |
* Register the stylesheets for the admin area.
|
141 |
*
|
142 |
+
* @since 3.0.0
|
143 |
+
* @param string $hook The id of the page.
|
|
|
|
|
|
|
144 |
* @return void
|
145 |
*/
|
146 |
+
public function register_styles( $hook ) {
|
147 |
|
148 |
$styles = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'whatsappme.css' : 'whatsappme.min.css';
|
149 |
wp_register_style( 'whatsappme-admin', plugin_dir_url( __FILE__ ) . 'css/' . $styles, array(), $this->version, 'all' );
|
150 |
|
151 |
if ( $this->enhanced_phone ) {
|
152 |
+
wp_register_style( 'intl-tel-input', 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/' . $this->enhanced_phone . '/css/intlTelInput.css', array(), null, 'all' );
|
153 |
}
|
154 |
|
155 |
}
|
157 |
/**
|
158 |
* Register the JavaScript for the admin area.
|
159 |
*
|
160 |
+
* @since 3.0.0
|
161 |
+
* @param string $hook The id of the page.
|
|
|
|
|
162 |
* @return void
|
163 |
*/
|
164 |
+
public function register_scripts( $hook ) {
|
165 |
|
166 |
$script = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'whatsappme.js' : 'whatsappme.min.js';
|
167 |
|
168 |
if ( $this->enhanced_phone ) {
|
169 |
+
wp_register_script( 'intl-tel-input', 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/' . $this->enhanced_phone . '/js/intlTelInput.min.js', array(), null, true );
|
170 |
wp_register_script( 'whatsappme-admin', plugin_dir_url( __FILE__ ) . 'js/' . $script, array( 'jquery', 'intl-tel-input' ), $this->version, true );
|
171 |
+
wp_localize_script( 'intl-tel-input', 'intl_tel_input_version', $this->enhanced_phone );
|
172 |
} else {
|
173 |
wp_register_script( 'whatsappme-admin', plugin_dir_url( __FILE__ ) . 'js/' . $script, array( 'jquery' ), $this->version, true );
|
174 |
}
|
176 |
}
|
177 |
|
178 |
/**
|
179 |
+
* Initialize the settings for WordPress admin
|
180 |
* From v1.2.0 also set filter to disable enhanced phone input
|
181 |
*
|
182 |
* @since 1.0.0
|
183 |
* @since 2.0.0 Added tabs for general and Advanced settings
|
184 |
* @since 2.3.0 Split general settings in Button and Window Chat
|
185 |
+
* @since 3.0.0 Admin organized by tabs and sections
|
186 |
* @access public
|
187 |
* @return void
|
188 |
*/
|
189 |
+
public function settings_init() {
|
190 |
|
191 |
+
// Register WordPress 'whatsappme' settings
|
192 |
register_setting( 'whatsappme', 'whatsappme', array( $this, 'settings_validate' ) );
|
193 |
|
194 |
+
foreach ( $this->tabs as $tab => $tab_name ) {
|
|
|
|
|
195 |
|
196 |
+
add_settings_section( "whatsappme_tab_{$tab}_open", null, array( $this, 'settings_tab_open' ), 'whatsappme' );
|
197 |
|
198 |
+
$sections = $this->get_tab_sections( $tab );
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
|
200 |
+
foreach ( $sections as $section => $fields ) {
|
201 |
+
$section_id = "whatsappme_tab_{$tab}__{$section}";
|
202 |
|
203 |
+
add_settings_section( $section_id, null, array( $this, 'section_output' ), 'whatsappme' );
|
|
|
|
|
204 |
|
205 |
+
foreach ( $fields as $field => $field_args ) {
|
206 |
+
if ( is_array( $field_args ) ) {
|
207 |
+
$field_name = $field_args['label'];
|
208 |
+
$field_callback = $field_args['callback'];
|
209 |
+
} else {
|
210 |
+
$field_name = $field_args;
|
211 |
+
$field_callback = array( $this, 'field_output' );
|
212 |
+
}
|
213 |
|
214 |
+
add_settings_field( "whatsappme_$field", $field_name, $field_callback, 'whatsappme', $section_id, $field );
|
215 |
+
}
|
216 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
|
218 |
+
add_settings_section( "whatsappme_tab_{$tab}_close", null, array( $this, 'settings_tab_close' ), 'whatsappme' );
|
|
|
219 |
}
|
220 |
|
221 |
+
}
|
|
|
|
|
|
|
|
|
222 |
|
223 |
+
/**
|
224 |
+
* Return an array of sections and fields for the admin tab
|
225 |
+
*
|
226 |
+
* @since 3.0.0
|
227 |
+
* @param string $tab The id of the admin tab.
|
228 |
+
* @return array
|
229 |
+
*/
|
230 |
+
private function get_tab_sections( $tab ) {
|
231 |
+
|
232 |
+
if ( 'general' == $tab ) {
|
233 |
+
|
234 |
+
$sections = array(
|
235 |
+
'button' => array(
|
236 |
+
'telephone' => '<label for="whatsappme_phone">' . __( 'Telephone', 'creame-whatsapp-me' ) . '</label>',
|
237 |
+
'mobile_only' => __( 'Mobile Only', 'creame-whatsapp-me' ),
|
238 |
+
'position' => __( 'Position On Screen', 'creame-whatsapp-me' ),
|
239 |
+
'button_delay' => '<label for="whatsappme_button_delay">' . __( 'Button Delay', 'creame-whatsapp-me' ) . '</label>',
|
240 |
+
'whatsapp_web' => __( 'WhatsApp Web', 'creame-whatsapp-me' ),
|
241 |
+
),
|
242 |
+
'chat' => array(
|
243 |
+
'message_text' => '<label for="whatsappme_message_text">' . __( 'Call To Action', 'creame-whatsapp-me' ) . '</label>',
|
244 |
+
'message_send' => '<label for="whatsappme_message_send">' . __( 'Message', 'creame-whatsapp-me' ) . '</label>',
|
245 |
+
'message_delay' => '<label for="whatsappme_message_delay">' . __( 'Chat Delay', 'creame-whatsapp-me' ) . '</label>',
|
246 |
+
'message_badge' => __( 'Hide Chat', 'creame-whatsapp-me' ),
|
247 |
+
),
|
248 |
+
);
|
249 |
|
250 |
+
} elseif ( 'advanced' == $tab ) {
|
251 |
+
|
252 |
+
$sections = array(
|
253 |
+
'global' => array(
|
254 |
+
'view__all' => array(
|
255 |
+
'label' => __( 'Global', 'creame-whatsapp-me' ),
|
256 |
+
'callback' => array( $this, 'field_view_all' ),
|
257 |
+
),
|
258 |
+
),
|
259 |
+
'wp' => array(
|
260 |
+
'view__front_page' => __( 'Front Page', 'creame-whatsapp-me' ),
|
261 |
+
'view__blog_page' => __( 'Blog Page', 'creame-whatsapp-me' ),
|
262 |
+
'view__404_page' => __( '404 Page', 'creame-whatsapp-me' ),
|
263 |
+
'view__search' => __( 'Search Results', 'creame-whatsapp-me' ),
|
264 |
+
'view__archive' => __( 'Archives', 'creame-whatsapp-me' ),
|
265 |
+
'view__date' => '— ' . __( 'Date Archives', 'creame-whatsapp-me' ),
|
266 |
+
'view__author' => '— ' . __( 'Author Archives', 'creame-whatsapp-me' ),
|
267 |
+
'view__singular' => __( 'Singular', 'creame-whatsapp-me' ),
|
268 |
+
'view__page' => '— ' . __( 'Page', 'creame-whatsapp-me' ),
|
269 |
+
'view__post' => '— ' . __( 'Post', 'creame-whatsapp-me' ),
|
270 |
+
),
|
271 |
);
|
272 |
|
273 |
+
// If isn't set Blog Page or is the same than Front Page unset blog_page option
|
274 |
+
if ( get_option( 'show_on_front' ) == 'posts' || get_option( 'page_for_posts' ) == 0 ) {
|
275 |
+
unset( $sections['wp']['view__blog_page'] );
|
276 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
|
278 |
+
// Custom Post Types
|
279 |
+
$custom_post_types = apply_filters(
|
280 |
+
'whatsappme_custom_post_types',
|
281 |
+
array_keys( get_post_types( array( 'has_archive' => true ), 'names' ) )
|
282 |
+
);
|
283 |
|
284 |
+
if ( count( $custom_post_types ) ) {
|
285 |
+
$sections['cpt'] = array();
|
286 |
|
287 |
+
foreach ( $custom_post_types as $custom_post_type ) {
|
288 |
+
$post_type = get_post_type_object( $custom_post_type );
|
289 |
+
$post_type_name = function_exists( 'mb_convert_case' ) ?
|
290 |
+
mb_convert_case( $post_type->labels->name, MB_CASE_TITLE ) :
|
291 |
+
strtolower( $post_type->labels->name );
|
292 |
|
293 |
+
$sections['cpt'][ "view__cpt_$custom_post_type" ] = $post_type_name;
|
294 |
+
}
|
295 |
+
}
|
296 |
+
} else {
|
297 |
|
298 |
+
$sections = array();
|
|
|
|
|
|
|
299 |
|
|
|
|
|
300 |
}
|
301 |
|
302 |
+
// Filter tab sections to add, remove or edit sections or fields
|
303 |
+
return apply_filters( "whatsappme_tab_{$tab}_sections", $sections );
|
304 |
|
|
|
305 |
}
|
306 |
|
307 |
/**
|
311 |
* @since 2.0.0 Added visibility setting
|
312 |
* @since 2.1.0 Added message_badge
|
313 |
* @since 2.3.0 Added button_delay and whatsapp_web settings, WPML integration
|
314 |
+
* @since 3.0.0 Added filter for extra settings and action for extra tasks
|
315 |
+
* @param array $input contain keys 'id', 'title' and 'callback'.
|
316 |
* @return array
|
317 |
*/
|
318 |
+
public function settings_validate( $input ) {
|
319 |
|
320 |
+
$input['telephone'] = self::clean_input( $input['telephone'] );
|
321 |
$input['mobile_only'] = isset( $input['mobile_only'] ) ? 'yes' : 'no';
|
322 |
$input['button_delay'] = intval( $input['button_delay'] );
|
323 |
$input['whatsapp_web'] = isset( $input['whatsapp_web'] ) ? 'yes' : 'no';
|
324 |
+
$input['message_text'] = self::clean_input( $input['message_text'] );
|
325 |
$input['message_delay'] = intval( $input['message_delay'] );
|
326 |
$input['message_badge'] = isset( $input['message_badge'] ) ? 'yes' : 'no';
|
327 |
+
$input['message_send'] = self::clean_input( $input['message_send'] );
|
328 |
$input['position'] = $input['position'] != 'left' ? 'right' : 'left';
|
329 |
if ( isset( $input['view'] ) ) {
|
330 |
+
$input['visibility'] = array_filter(
|
331 |
+
$input['view'], function( $v ) {
|
332 |
+
return 'yes' == $v || 'no' == $v;
|
333 |
+
}
|
334 |
+
);
|
335 |
unset( $input['view'] );
|
336 |
}
|
337 |
|
338 |
+
// Filter for other validations or extra settings
|
339 |
+
$input = apply_filters( 'whatsappme_settings_validate', $input );
|
340 |
+
|
341 |
/**
|
342 |
* Register WPML/Polylang strings for translation
|
343 |
* https://wpml.org/wpml-hook/wpml_register_single_string/
|
348 |
do_action( 'wpml_register_single_string', 'WhatsApp me', 'Call To Action', $input['message_text'] );
|
349 |
do_action( 'wpml_register_single_string', 'WhatsApp me', 'Message', $input['message_send'] );
|
350 |
|
351 |
+
// Action to register more WPML strings or other tasks
|
352 |
+
do_action( 'whatsappme_settings_validate', $input );
|
353 |
+
|
354 |
add_settings_error( 'whatsappme', 'settings_updated', __( 'Settings saved', 'creame-whatsapp-me' ), 'updated' );
|
355 |
|
356 |
return $input;
|
357 |
}
|
358 |
|
359 |
+
/**
|
360 |
+
* Tab open HTML output
|
361 |
+
*
|
362 |
+
* @since 3.0.0
|
363 |
+
* @param array $args Section info.
|
364 |
+
* @return void
|
365 |
+
*/
|
366 |
+
public function settings_tab_open( $args ) {
|
367 |
+
|
368 |
+
$tab_id = str_replace( '_open', '', $args['id'] );
|
369 |
+
|
370 |
+
echo '<div id="' . $tab_id . '" class="tab' . ( 'whatsappme_tab_general' == $tab_id ? ' tab-active' : '' ) . '">';
|
371 |
+
|
372 |
+
}
|
373 |
+
|
374 |
+
/**
|
375 |
+
* Tab close HTML output
|
376 |
+
*
|
377 |
+
* @since 3.0.0
|
378 |
+
* @param array $args Section info.
|
379 |
+
* @return void
|
380 |
+
*/
|
381 |
+
public function settings_tab_close( $args ) {
|
382 |
+
|
383 |
+
echo '</div>';
|
384 |
+
|
385 |
+
}
|
386 |
+
|
387 |
/**
|
388 |
* Section HTML output
|
389 |
*
|
390 |
+
* @since 3.0.0
|
391 |
+
* @param array $args Section info.
|
|
|
392 |
* @return void
|
393 |
*/
|
394 |
+
public function section_output( $args ) {
|
395 |
+
$section_id = $args['id'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
396 |
|
397 |
+
switch ( $section_id ) {
|
398 |
+
case 'whatsappme_tab_general__button':
|
399 |
+
$output = '<h2 class="title">' . __( 'Button', 'creame-whatsapp-me' ) . '</h2>' .
|
400 |
'<p>' . __( 'Set the contact number and where you want the WhatsApp button to be displayed.', 'creame-whatsapp-me' ) . '</p>';
|
401 |
break;
|
402 |
|
403 |
+
case 'whatsappme_tab_general__chat':
|
404 |
+
$output = '<h2 class="title">' . __( 'Chat Window', 'creame-whatsapp-me' ) . '</h2>' .
|
405 |
'<p>' .
|
406 |
__( 'Set the behavior of the chat window.', 'creame-whatsapp-me' ) . ' ' .
|
407 |
+
' <em>' . __( 'You can use styles and dynamic variables', 'creame-whatsapp-me' ) . '</em> ' .
|
408 |
+
'<a class="whatsappme-show-help" href="#" title="' . __( 'Show Help', 'creame-whatsapp-me' ) . '">?</a>' .
|
409 |
'</p>';
|
410 |
break;
|
411 |
|
412 |
+
case 'whatsappme_tab_advanced__global':
|
413 |
+
$output = '<h2 class="title">' . __( 'Advanced Visibility Settings', 'creame-whatsapp-me' ) . '</h2>' .
|
|
|
414 |
'<p>' . __( 'From here you can configure on which pages the WhatsApp button will be visible.', 'creame-whatsapp-me' ) .
|
415 |
' <a href="#" class="whatsappme_view_reset">' . __( 'Restore default visibility', 'creame-whatsapp-me' ) . '</a></p>';
|
416 |
break;
|
417 |
|
418 |
+
case 'whatsappme_tab_advanced__wp':
|
419 |
+
$output = '<hr>';
|
420 |
break;
|
421 |
|
422 |
+
case 'whatsappme_tab_advanced__cpt':
|
423 |
+
$output = '<h2 class="title">' . __( 'Custom Post Types', 'creame-whatsapp-me' ) . '</h2>';
|
424 |
break;
|
425 |
|
426 |
default:
|
427 |
+
$output = '';
|
428 |
break;
|
429 |
}
|
|
|
430 |
|
431 |
+
// Filter section opening ouput
|
432 |
+
echo apply_filters( 'whatsappme_section_output', $output, $section_id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
433 |
}
|
434 |
|
435 |
/**
|
436 |
+
* Field HTML output
|
437 |
*
|
438 |
+
* @since 3.0.0
|
439 |
* @return void
|
440 |
*/
|
441 |
+
public function field_output( $field_id ) {
|
|
|
|
|
|
|
442 |
|
443 |
+
if ( strpos( $field_id, 'view__' ) === 0 ) {
|
444 |
+
$field = substr( $field_id, 6 );
|
445 |
+
$value = isset( $this->settings['visibility'][ $field ] ) ? $this->settings['visibility'][ $field ] : '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
446 |
|
447 |
+
$output = '<label><input type="radio" name="whatsappme[view][' . $field . ']" value="yes"' . checked( 'yes', $value, false ) . '> ' .
|
448 |
+
'<span class="dashicons dashicons-visibility" title="' . __( 'Show', 'creame-whatsapp-me' ) . '"></span></label>' .
|
449 |
+
'<label><input type="radio" name="whatsappme[view][' . $field . ']" value="no"' . checked( 'no', $value, false ) . '> ' .
|
450 |
+
'<span class="dashicons dashicons-hidden" title="' . __( 'Hide', 'creame-whatsapp-me' ) . '"></span></label>' .
|
451 |
+
'<label><input type="radio" name="whatsappme[view][' . $field . ']" value=""' . checked( '', $value, false ) . '> ' .
|
452 |
+
__( 'Inherit', 'creame-whatsapp-me' ) . ' <span class="dashicons dashicons-visibility view_inheritance_' . $field . '"></span></label>';
|
|
|
|
|
|
|
|
|
|
|
453 |
|
454 |
+
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
455 |
|
456 |
+
$value = isset( $this->settings[ $field_id ] ) ? $this->settings[ $field_id ] : '';
|
457 |
+
|
458 |
+
switch ( $field_id ) {
|
459 |
+
case 'telephone':
|
460 |
+
$output = '<input id="whatsappme_phone" ' . ( $this->enhanced_phone ? 'data-' : '' ) . 'name="whatsappme[telephone]" value="' . $value . '" type="text" style="width:15em">' .
|
461 |
+
'<p class="description">' . __( "Contact phone number <strong>(the button will not be shown if it's empty)</strong>", 'creame-whatsapp-me' ) . '</p>' .
|
462 |
+
'<p class="whatsappme-addon">' . sprintf(
|
463 |
+
__( 'Add unlimited numbers with %s', 'creame-whatsapp-me' ),
|
464 |
+
'<a href="https://wame.chat/en/addons/random-phone-addon/" target="_blank">\'WAme Random Phone\'</a>'
|
465 |
+
) . '</p>';
|
466 |
+
break;
|
467 |
+
|
468 |
+
case 'mobile_only':
|
469 |
+
$output = '<fieldset><legend class="screen-reader-text"><span>' . __( 'Mobile Only', 'creame-whatsapp-me' ) . '</span></legend>' .
|
470 |
+
'<label><input id="whatsappme_mobile_only" name="whatsappme[mobile_only]" value="yes" type="checkbox"' . checked( 'yes', $value, false ) . '> ' .
|
471 |
+
__( 'Only display the button on mobile devices', 'creame-whatsapp-me' ) . '</label></fieldset>';
|
472 |
+
break;
|
473 |
+
|
474 |
+
case 'position':
|
475 |
+
$output = '<fieldset><legend class="screen-reader-text"><span>' . __( 'Position On Screen', 'creame-whatsapp-me' ) . '</span></legend>' .
|
476 |
+
'<label><input name="whatsappme[position]" value="left" type="radio"' . checked( 'left', $value, false ) . '> ' .
|
477 |
+
__( 'Left', 'creame-whatsapp-me' ) . '</label><br>' .
|
478 |
+
'<label><input name="whatsappme[position]" value="right" type="radio"' . checked( 'right', $value, false ) . '> ' .
|
479 |
+
__( 'Right', 'creame-whatsapp-me' ) . '</label></fieldset>';
|
480 |
+
break;
|
481 |
+
|
482 |
+
case 'button_delay':
|
483 |
+
$output = '<input id="whatsappme_button_delay" name="whatsappme[button_delay]" value="' . $value . '" type="number" min="0" max="120" style="width:5em"> ' . __( 'seconds', 'creame-whatsapp-me' ) .
|
484 |
+
'<p class="description">' . __( 'Time since the page is opened until the WhatsApp button is displayed', 'creame-whatsapp-me' ) . '</p>';
|
485 |
+
break;
|
486 |
+
|
487 |
+
case 'whatsapp_web':
|
488 |
+
$output = '<fieldset><legend class="screen-reader-text"><span>' . __( 'WhatsApp Web', 'creame-whatsapp-me' ) . '</span></legend>' .
|
489 |
+
'<label><input id="whatsappme_whatsapp_web" name="whatsappme[whatsapp_web]" value="yes" type="checkbox"' . checked( 'yes', $value, false ) . '> ' .
|
490 |
+
__( 'Open <em>WhatsApp Web</em> directly on desktop', 'creame-whatsapp-me' ) . '</label></fieldset>';
|
491 |
+
break;
|
492 |
+
|
493 |
+
case 'message_text':
|
494 |
+
$output = '<textarea id="whatsappme_message_text" name="whatsappme[message_text]" rows="4" class="regular-text" placeholder="' . esc_attr__( "Hello 👋\nCan we help you?", 'creame-whatsapp-me' ) . '">' . $value . '</textarea>' .
|
495 |
+
'<p class="description">' . __( 'Define a text to encourage users to contact by WhatsApp <strong>(optional)</strong>', 'creame-whatsapp-me' ) . '</p>';
|
496 |
+
break;
|
497 |
+
|
498 |
+
case 'message_send':
|
499 |
+
$output = '<textarea id="whatsappme_message_send" name="whatsappme[message_send]" rows="3" class="regular-text" placeholder="' . esc_attr__( 'Hi *{SITE}*! I need more info about {TITLE}', 'creame-whatsapp-me' ) . '">' . $value . '</textarea>' .
|
500 |
+
'<p class="description">' . __( 'Predefined text with which user can start the conversation <strong>(optional)</strong>', 'creame-whatsapp-me' ) . '</p>';
|
501 |
+
break;
|
502 |
+
|
503 |
+
case 'message_delay':
|
504 |
+
$output = '<input id="whatsappme_message_delay" name="whatsappme[message_delay]" value="' . $value . '" type="number" min="0" max="120" style="width:5em"> ' . __( 'seconds', 'creame-whatsapp-me' ) .
|
505 |
+
'<p class="description">' . __( 'Time since the WhatsApp button is displayed until the Chat Window opens', 'creame-whatsapp-me' ) . '</p>';
|
506 |
+
break;
|
507 |
+
|
508 |
+
case 'message_badge':
|
509 |
+
$output = '<fieldset><legend class="screen-reader-text"><span>' . __( 'Hide Chat', 'creame-whatsapp-me' ) . '</span></legend>' .
|
510 |
+
'<label><input name="whatsappme[message_badge]" value="yes" type="checkbox"' . checked( 'yes', $value, false ) . '> ' .
|
511 |
+
__( 'Display a notification balloon instead of opening the Chat Window for a "less intrusive" mode', 'creame-whatsapp-me' ) . '</label></fieldset>';
|
512 |
+
break;
|
513 |
+
|
514 |
+
default:
|
515 |
+
$output = '';
|
516 |
+
break;
|
517 |
+
}
|
518 |
+
}
|
519 |
|
520 |
+
// Filter field ouput
|
521 |
+
echo apply_filters( 'whatsappme_field_output', $output, $field_id, $this->settings );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
522 |
}
|
523 |
|
524 |
/**
|
525 |
* Field 'field_view_all' output
|
526 |
*
|
527 |
* @since 2.0.0
|
528 |
+
* @since 3.0.0 Added $inheritance data
|
529 |
* @return void
|
530 |
*/
|
531 |
public function field_view_all() {
|
532 |
+
$value = ( isset( $this->settings['visibility']['all'] ) && 'no' == $this->settings['visibility']['all'] ) ? 'no' : 'yes';
|
533 |
+
|
534 |
+
$inheritance = apply_filters(
|
535 |
+
'whatsappme_advanced_inheritance', array(
|
536 |
+
'all' => array( 'front_page', 'blog_page', '404_page', 'search', 'archive', 'singular', 'cpts' ),
|
537 |
+
'archive' => array( 'date', 'author' ),
|
538 |
+
'singular' => array( 'page', 'post' ),
|
539 |
+
// 'woocommerce': ['product', 'cart', 'checkout', 'account_page']
|
540 |
+
)
|
541 |
+
);
|
542 |
|
543 |
+
echo '<div class="whatsappme_view_all" data-inheritance="' . esc_attr( json_encode( $inheritance ) ) . '">' .
|
544 |
+
'<label><input type="radio" name="whatsappme[view][all]" value="yes"' . checked( 'yes', $value, false ) . '> ' .
|
545 |
'<span class="dashicons dashicons-visibility" title="' . __( 'Show', 'creame-whatsapp-me' ) . '"></span></label>' .
|
546 |
+
'<label><input type="radio" name="whatsappme[view][all]" value="no"' . checked( 'no', $value, false ) . '> ' .
|
547 |
+
'<span class="dashicons dashicons-hidden" title="' . __( 'Hide', 'creame-whatsapp-me' ) . '"></span></label></div>';
|
548 |
}
|
549 |
|
550 |
/**
|
551 |
+
* Add menu to the options page in the WordPress admin
|
552 |
*
|
553 |
+
* @since 1.0.0
|
554 |
+
* @access public
|
555 |
* @return void
|
556 |
*/
|
557 |
+
public function add_menu() {
|
558 |
+
|
559 |
+
add_options_page( 'WAme chat', 'WAme chat', 'manage_options', 'whatsappme', array( $this, 'options_page' ) );
|
560 |
|
|
|
|
|
|
|
|
|
|
|
|
|
561 |
}
|
562 |
|
563 |
/**
|
564 |
+
* Add a help tab to the options page in the WordPress admin
|
565 |
*
|
566 |
+
* @since 3.0.0
|
567 |
* @access public
|
568 |
* @return void
|
569 |
*/
|
570 |
+
function help_tab() {
|
571 |
+
$screen = get_current_screen();
|
572 |
+
|
573 |
+
$screen->add_help_tab(
|
574 |
+
array(
|
575 |
+
'id' => 'styles-and-vars',
|
576 |
+
'title' => __( 'Styles and Variables', 'creame-whatsapp-me' ),
|
577 |
+
'content' => apply_filters(
|
578 |
+
'whatsappme_styles_and_vars_help',
|
579 |
+
'<p>' . __( 'You can use formatting styles like in WhatsApp: _<em>italic</em>_ *<strong>bold</strong>* ~<del>strikethrough</del>~.', 'creame-whatsapp-me' ) . '</p>' .
|
580 |
+
'<p>' . __( 'You can use dynamic variables that will be replaced by the values of the page the user visits:', 'creame-whatsapp-me' ) .
|
581 |
+
'<p>' .
|
582 |
+
'<span><code>{SITE}</code> ➜ ' . get_bloginfo( 'name', 'display' ) . '</span>, ' .
|
583 |
+
'<span><code>{URL}</code> ➜ ' . home_url( 'example' ) . '</span>, ' .
|
584 |
+
'<span><code>{TITLE}</code> ➜ ' . __( 'Page Title', 'creame-whatsapp-me' ) . '</span>' .
|
585 |
+
'</p>'
|
586 |
+
),
|
587 |
+
)
|
588 |
+
);
|
589 |
|
590 |
+
$screen->add_help_tab(
|
591 |
+
array(
|
592 |
+
'id' => 'support',
|
593 |
+
'title' => __( 'Support and Help', 'creame-whatsapp-me' ),
|
594 |
+
'content' =>
|
595 |
+
'<p>' . sprintf(
|
596 |
+
__( 'If you need help, please check the <a href="%s" rel="external" target="_blank">plugin support forum</a>.', 'creame-whatsapp-me' ),
|
597 |
+
esc_url( 'https://wordpress.org/support/plugin/creame-whatsapp-me/' )
|
598 |
+
) . '</p>' .
|
599 |
+
'<p>' . __( 'If you like WAme 😍', 'creame-whatsapp-me' ) . '</p>' .
|
600 |
+
'<ul>' .
|
601 |
+
'<li>' . sprintf(
|
602 |
+
__( 'Subscribe to our newsletter and our blog at %s.', 'creame-whatsapp-me' ),
|
603 |
+
'<a href="https://wame.chat/blog/" rel="external" target="_blank">wame.chat</a>'
|
604 |
+
) . '</li>' .
|
605 |
+
'<li>' . sprintf(
|
606 |
+
__( 'Learn from our tutorials on %s.', 'creame-whatsapp-me' ),
|
607 |
+
'<a href="https://www.youtube.com/channel/UCqHiSNPBaQ918fpVnCU1wog/" rel="external" target="_blank">Youtube</a>'
|
608 |
+
) . '</li>' .
|
609 |
+
'<li>' . sprintf(
|
610 |
+
__( 'Or rate us on %s.', 'creame-whatsapp-me' ),
|
611 |
+
'<a href="https://wordpress.org/support/plugin/creame-whatsapp-me/reviews/#new-post" rel="external" target="_blank">WordPress.org</a>'
|
612 |
+
) . '</li>' .
|
613 |
+
'</ul>',
|
614 |
+
)
|
615 |
+
);
|
616 |
}
|
617 |
|
618 |
/**
|
631 |
}
|
632 |
|
633 |
/**
|
634 |
+
* Generate the options page in the WordPress admin
|
635 |
*
|
636 |
* @since 1.0.0
|
637 |
* @since 2.2.0 Enqueue scripts/styles
|
647 |
if ( $this->enhanced_phone ) {
|
648 |
wp_enqueue_style( 'intl-tel-input' );
|
649 |
}
|
650 |
+
|
651 |
?>
|
652 |
<div class="wrap">
|
653 |
+
<h1>WAme chat</h1>
|
654 |
|
655 |
<form method="post" id="whatsappme_form" action="options.php">
|
656 |
+
<?php settings_fields( 'whatsappme' ); ?>
|
657 |
+
<h2 class="nav-tab-wrapper wp-clearfix">
|
658 |
+
<?php foreach ( $this->tabs as $tab => $name ) : ?>
|
659 |
+
<a href="#whatsappme_tab_<?php echo $tab; ?>" class="nav-tab <?php echo 'general' == $tab ? 'nav-tab-active' : ''; ?>"><?php echo $name; ?></a>
|
660 |
+
<?php endforeach; ?>
|
661 |
+
</h2>
|
662 |
+
<div class="tabs">
|
663 |
+
<?php do_settings_sections( 'whatsappme' ); ?>
|
664 |
+
</div><!-- end tabs -->
|
665 |
+
<?php submit_button(); ?>
|
666 |
</form>
|
667 |
</div>
|
668 |
<?php
|
681 |
// Custom post types with public url
|
682 |
$custom_post_types = array_keys( get_post_types( array( 'has_archive' => true ), 'names' ) );
|
683 |
|
684 |
+
// Add/remove posts types for "WAme chat" meta box
|
685 |
$post_types = apply_filters( 'whatsappme_post_types_meta_box', array_merge( $builtin_post_types, $custom_post_types ) );
|
686 |
|
687 |
foreach ( $post_types as $post_type ) {
|
688 |
add_meta_box(
|
689 |
'whatsappme',
|
690 |
+
__( 'WAme chat', 'creame-whatsapp-me' ),
|
691 |
array( $this, 'meta_box' ),
|
692 |
$post_type,
|
693 |
'side',
|
706 |
* @return void
|
707 |
*/
|
708 |
public function meta_box( $post ) {
|
709 |
+
// TODO: add hooks for more extendable metabox
|
710 |
// Enqueue assets
|
711 |
wp_enqueue_script( 'whatsappme-admin' );
|
712 |
|
715 |
}
|
716 |
|
717 |
$metadata = get_post_meta( $post->ID, '_whatsappme', true ) ?: array();
|
718 |
+
$metadata = array_merge(
|
719 |
+
array(
|
720 |
+
'telephone' => '',
|
721 |
+
'message_text' => '',
|
722 |
+
'message_send' => '',
|
723 |
+
'hide' => false,
|
724 |
+
'view' => '',
|
725 |
+
), $metadata
|
726 |
+
);
|
727 |
|
728 |
// Move old 'hide' to new 'view' field
|
729 |
if ( $metadata['hide'] ) {
|
731 |
}
|
732 |
unset( $metadata['hide'] );
|
733 |
|
734 |
+
$metabox_vars = apply_filters( 'whatsappme_metabox_vars', array( 'SITE', 'URL', 'TITLE' ) );
|
735 |
+
|
736 |
wp_nonce_field( 'whatsappme_data', 'whatsappme_nonce' );
|
737 |
?>
|
738 |
<div class="whatsappme-metabox">
|
747 |
<p>
|
748 |
<label for="whatsappme_message_send"><?php _e( 'Message', 'creame-whatsapp-me' ); ?></label><br>
|
749 |
<textarea name="whatsappme_message_send" rows="2" class="large-text"><?php echo $metadata['message_send']; ?></textarea>
|
750 |
+
<?php if ( count( $metabox_vars ) ) : ?>
|
751 |
+
<small><?php _e( 'You can use vars:', 'creame-whatsapp-me' ); ?> <code>{<?php echo join( '}</code> <code>{', $metabox_vars ); ?>}</code></small>
|
752 |
+
<?php endif; ?>
|
753 |
</p>
|
754 |
<p>
|
755 |
<label><input type="radio" name="whatsappme_view" value="yes" <?php checked( 'yes', $metadata['view'] ); ?>>
|
761 |
</p>
|
762 |
</div>
|
763 |
<style>
|
764 |
+
.whatsappme-metabox code { -webkit-user-select:all; -moz-user-select:all; -ms-user-select:all; user-select:all; padding:2px 1px; font-size:smaller; vertical-align:text-bottom; }
|
765 |
.whatsappme-metabox .dashicons { opacity:.5; }
|
766 |
.whatsappme-metabox input::placeholder { color:#dedfe0; }
|
767 |
.whatsappme-metabox input::-ms-input-placeholder { color:#dedfe0; }
|
774 |
}
|
775 |
|
776 |
/**
|
777 |
+
* Save meta data from "WAme chat" Meta Box on post save
|
778 |
*
|
779 |
* @since 1.1.0
|
780 |
* @since 2.0.0 Change 'hide' key to 'view' now values can be [yes, no]
|
790 |
}
|
791 |
|
792 |
// Clean and delete empty/false fields
|
793 |
+
$metadata = array_filter(
|
794 |
+
self::clean_input(
|
795 |
+
array(
|
796 |
+
'telephone' => $_POST['whatsappme_telephone'],
|
797 |
+
'message_text' => $_POST['whatsappme_message'],
|
798 |
+
'message_send' => $_POST['whatsappme_message_send'],
|
799 |
+
'view' => $_POST['whatsappme_view'],
|
800 |
+
)
|
801 |
+
)
|
802 |
+
);
|
803 |
|
804 |
if ( count( $metadata ) ) {
|
805 |
update_post_meta( $post_id, '_whatsappme', $metadata );
|
812 |
* Clean user input fields
|
813 |
*
|
814 |
* @since 2.0.0
|
815 |
+
* @access public
|
816 |
+
* @param mixed $value to clean
|
817 |
* @return mixed $value cleaned
|
818 |
*/
|
819 |
+
public static function clean_input( $value ) {
|
820 |
if ( is_array( $value ) ) {
|
821 |
+
return array_map( 'self::clean_input', $value );
|
822 |
+
} elseif ( is_string( $value ) ) {
|
823 |
// Split lines, clean and re-join lines
|
824 |
return implode( "\n", array_map( 'sanitize_text_field', explode( "\n", trim( $value ) ) ) );
|
825 |
} else {
|
admin/class-whatsappme-wooadmin.php
ADDED
@@ -0,0 +1,247 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The admin-specific functionality of the WooCommerce integration.
|
5 |
+
*
|
6 |
+
* @since 3.0.0
|
7 |
+
* @package WhatsAppMe
|
8 |
+
* @subpackage WhatsAppMe/admin
|
9 |
+
* @author Creame <hola@crea.me>
|
10 |
+
*/
|
11 |
+
class WhatsAppMe_WooAdmin {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Initialize all hooks
|
15 |
+
*
|
16 |
+
* @since 3.0.0
|
17 |
+
* @param array $whatsappme WhatsAppMe object.
|
18 |
+
* @return void
|
19 |
+
*/
|
20 |
+
public function init( $whatsappme ) {
|
21 |
+
|
22 |
+
$loader = $whatsappme->get_loader();
|
23 |
+
|
24 |
+
$loader->add_filter( 'whatsappme_extra_settings', $this, 'extra_settings' );
|
25 |
+
$loader->add_filter( 'whatsappme_settings_validate', $this, 'settings_validate' );
|
26 |
+
$loader->add_filter( 'whatsappme_admin_tabs', $this, 'admin_tab' );
|
27 |
+
$loader->add_filter( 'whatsappme_custom_post_types', $this, 'custom_post_types' );
|
28 |
+
$loader->add_filter( 'whatsappme_tab_advanced_sections', $this, 'advanced_tab_section' );
|
29 |
+
$loader->add_filter( 'whatsappme_tab_woocommerce_sections', $this, 'woo_tab_sections' );
|
30 |
+
$loader->add_filter( 'whatsappme_section_output', $this, 'section_ouput', 10, 2 );
|
31 |
+
$loader->add_filter( 'whatsappme_field_output', $this, 'field_ouput', 10, 3 );
|
32 |
+
$loader->add_filter( 'whatsappme_advanced_inheritance', $this, 'advanced_inheritance' );
|
33 |
+
$loader->add_filter( 'whatsappme_styles_and_vars_help', $this, 'help_vars' );
|
34 |
+
$loader->add_filter( 'whatsappme_metabox_vars', $this, 'metabox_vars' );
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Add WooCommerce extra settings defaults
|
39 |
+
*
|
40 |
+
* @since 3.0.0
|
41 |
+
* @param array $settings current settings.
|
42 |
+
* @return array
|
43 |
+
*/
|
44 |
+
public function extra_settings( $settings ) {
|
45 |
+
|
46 |
+
$woo_settings = array(
|
47 |
+
'message_text_product' => '',
|
48 |
+
'message_send_product' => '',
|
49 |
+
);
|
50 |
+
|
51 |
+
return array_merge( $settings, $woo_settings );
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* WooCommerce settings validation
|
56 |
+
*
|
57 |
+
* @since 3.0.0
|
58 |
+
* @param array $input form input.
|
59 |
+
* @return array
|
60 |
+
*/
|
61 |
+
public function settings_validate( $input ) {
|
62 |
+
|
63 |
+
$input['message_text_product'] = WhatsAppMe_Admin::clean_input( $input['message_text_product'] );
|
64 |
+
$input['message_send_product'] = WhatsAppMe_Admin::clean_input( $input['message_send_product'] );
|
65 |
+
|
66 |
+
return $input;
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Add WooCommerce admin tab
|
72 |
+
*
|
73 |
+
* @since 3.0.0
|
74 |
+
* @param array $tabs current admin tabs.
|
75 |
+
* @return array
|
76 |
+
*/
|
77 |
+
public function admin_tab( $tabs ) {
|
78 |
+
|
79 |
+
$tabs['woocommerce'] = 'WooCommerce';
|
80 |
+
|
81 |
+
return $tabs;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Remove WooCommerce product custom post type
|
86 |
+
*
|
87 |
+
* @since 3.0.0
|
88 |
+
* @param array $custom_post_types current tab sections and fields.
|
89 |
+
* @return array
|
90 |
+
*/
|
91 |
+
public function custom_post_types( $custom_post_types ) {
|
92 |
+
|
93 |
+
$custom_post_types = array_diff( $custom_post_types, array( 'product' ) );
|
94 |
+
|
95 |
+
return $custom_post_types;
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Woocommerce sections and fields for 'whatsappme_tab_advanced'
|
100 |
+
*
|
101 |
+
* @since 3.0.0
|
102 |
+
* @param array $sections current tab sections and fields.
|
103 |
+
* @return array
|
104 |
+
*/
|
105 |
+
public function advanced_tab_section( $sections ) {
|
106 |
+
|
107 |
+
$sections['woo'] = array(
|
108 |
+
'view__woocommerce' => __( 'Shop', 'creame-whatsapp-me' ),
|
109 |
+
'view__product' => '— ' . __( 'Product Page', 'creame-whatsapp-me' ),
|
110 |
+
'view__cart' => '— ' . __( 'Cart', 'creame-whatsapp-me' ),
|
111 |
+
'view__checkout' => '— ' . __( 'Checkout', 'creame-whatsapp-me' ),
|
112 |
+
'view__account_page' => '— ' . __( 'My Account', 'creame-whatsapp-me' ),
|
113 |
+
);
|
114 |
+
|
115 |
+
return $sections;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Woocommerce sections and fields for 'whatsappme_tab_woocommerce'
|
120 |
+
*
|
121 |
+
* @since 3.0.0
|
122 |
+
* @param array $sections current tab sections and fields.
|
123 |
+
* @return array
|
124 |
+
*/
|
125 |
+
public function woo_tab_sections( $sections ) {
|
126 |
+
|
127 |
+
$sections['chat'] = array(
|
128 |
+
'message_text_product' => '<label for="whatsappme_message_text_product">' . __( 'Call To Action', 'creame-whatsapp-me' ) . '</label>',
|
129 |
+
'message_send_product' => '<label for="whatsappme_message_send_product">' . __( 'Message', 'creame-whatsapp-me' ) . '</label>',
|
130 |
+
);
|
131 |
+
|
132 |
+
return $sections;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Woocommerce sections HTML output
|
137 |
+
*
|
138 |
+
* @since 3.0.0
|
139 |
+
* @param string $output current section output.
|
140 |
+
* @param string $section_id current section id.
|
141 |
+
* @return string
|
142 |
+
*/
|
143 |
+
public function section_ouput( $output, $section_id ) {
|
144 |
+
|
145 |
+
if ( 'whatsappme_tab_advanced__woo' == $section_id ) {
|
146 |
+
|
147 |
+
$output = '<h2 class="title">' . __( 'WooCommerce', 'creame-whatsapp-me' ) . '</h2>';
|
148 |
+
|
149 |
+
} elseif ( 'whatsappme_tab_woocommerce__chat' == $section_id ) {
|
150 |
+
|
151 |
+
$output = '<h2 class="title">' . __( 'Product Chat Window', 'creame-whatsapp-me' ) . '</h2>' .
|
152 |
+
'<p>' .
|
153 |
+
__( 'You can define other different texts for the Chat Window on the product pages.', 'creame-whatsapp-me' ) .
|
154 |
+
' <em>' . __( 'You can use styles and dynamic variables', 'creame-whatsapp-me' ) . '</em> ' .
|
155 |
+
'<a class="whatsappme-show-help" href="#" title="' . __( 'Show Help', 'creame-whatsapp-me' ) . '">?</a>' .
|
156 |
+
'</p>';
|
157 |
+
|
158 |
+
}
|
159 |
+
|
160 |
+
return $output;
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Woocommerce fields HTML output
|
165 |
+
*
|
166 |
+
* @since 3.0.0
|
167 |
+
* @param string $output current field output.
|
168 |
+
* @param string $field_id current field id.
|
169 |
+
* @param array $settings current whatsappme settings.
|
170 |
+
* @return string
|
171 |
+
*/
|
172 |
+
public function field_ouput( $output, $field_id, $settings ) {
|
173 |
+
|
174 |
+
$value = isset( $settings[ $field_id ] ) ? $settings[ $field_id ] : '';
|
175 |
+
|
176 |
+
switch ( $field_id ) {
|
177 |
+
case 'message_text_product':
|
178 |
+
$output = '<textarea id="whatsappme_message_text_product" name="whatsappme[message_text_product]" rows="4" class="regular-text" ' .
|
179 |
+
'placeholder="' . esc_attr__( "This *{PRODUCT}* can be yours for only *{PRICE}*!\nIf you have any questions, ask us.", 'creame-whatsapp-me' ) . '">' .
|
180 |
+
$value . '</textarea>' .
|
181 |
+
'<p class="description">' . __( 'Define a text to encourage clients to contact by WhatsApp <strong>(optional)</strong>', 'creame-whatsapp-me' ) . '</p>';
|
182 |
+
break;
|
183 |
+
|
184 |
+
case 'message_send_product':
|
185 |
+
$output = '<textarea id="whatsappme_message_send_product" name="whatsappme[message_send_product]" rows="3" class="regular-text" ' .
|
186 |
+
'placeholder="' . esc_attr__( "*Hi {SITE}!*\nI have a question about *{PRODUCT} ({SKU})*", 'creame-whatsapp-me' ) . '">' . $value . '</textarea>' .
|
187 |
+
'<p class="description">' . __( 'Predefined text with which client can start the conversation <strong>(optional)</strong>', 'creame-whatsapp-me' ) . '</p>';
|
188 |
+
break;
|
189 |
+
}
|
190 |
+
|
191 |
+
return $output;
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Modify $inheritance array to properly inherit
|
196 |
+
* WooCommerce fields on advanced visibily admin tab.
|
197 |
+
*
|
198 |
+
* @since 3.0.0
|
199 |
+
* @param array $inheritance current section output.
|
200 |
+
* @return array
|
201 |
+
*/
|
202 |
+
public function advanced_inheritance( $inheritance ) {
|
203 |
+
|
204 |
+
// 'woocommerce' inherit from 'all' (Global)
|
205 |
+
$inheritance['all'][] = 'woocommerce';
|
206 |
+
// WooCommerce pages inherit from 'woocommerce'
|
207 |
+
$inheritance['woocommerce'] = array( 'product', 'cart', 'checkout', 'account_page' );
|
208 |
+
|
209 |
+
return $inheritance;
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Add WooCommerce variables info for help tab.
|
214 |
+
*
|
215 |
+
* @since 3.0.0
|
216 |
+
* @param string $text current help tab content.
|
217 |
+
* @return string
|
218 |
+
*/
|
219 |
+
public function help_vars( $text ) {
|
220 |
+
|
221 |
+
return $text .
|
222 |
+
'<p> ' . __( '<strong>WooCommerce</strong>, in product pages you can also use:', 'creame-whatsapp-me' ) . '</p>' .
|
223 |
+
'<p>' .
|
224 |
+
'<span><code>{PRODUCT}</code> ➜ ' . __( 'Product Name', 'creame-whatsapp-me' ) . '</span>, ' .
|
225 |
+
'<span><code>{PRICE}</code> ➜ ' . strip_tags( wc_price( 9.95 ) ) . '</span>, ' .
|
226 |
+
'<span><code>{SKU}</code> ➜ ABC98798</span>' .
|
227 |
+
'</p>';
|
228 |
+
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Add Product metabox variables info.
|
233 |
+
*
|
234 |
+
* @since 3.0.0
|
235 |
+
* @param array $vars current default vars.
|
236 |
+
* @return array
|
237 |
+
*/
|
238 |
+
public function metabox_vars( $vars ) {
|
239 |
+
global $post;
|
240 |
+
|
241 |
+
if ( 'product' == $post->post_type ) {
|
242 |
+
$vars = array_merge( $vars, array( 'PRODUCT', 'PRICE', 'SKU' ) );
|
243 |
+
}
|
244 |
+
|
245 |
+
return $vars;
|
246 |
+
}
|
247 |
+
}
|
admin/css/whatsappme.css
CHANGED
@@ -1,3 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
1 |
.tab {
|
2 |
display: none;
|
3 |
}
|
@@ -6,32 +11,71 @@
|
|
6 |
display: block;
|
7 |
}
|
8 |
|
9 |
-
#
|
10 |
background: rgba(0, 0, 0, .05);
|
11 |
}
|
12 |
|
13 |
-
#
|
14 |
-
#
|
15 |
padding: 7px 15px;
|
16 |
}
|
17 |
|
18 |
-
#
|
19 |
margin-right: 15px;
|
20 |
}
|
21 |
|
22 |
-
#
|
23 |
opacity: .5;
|
24 |
}
|
25 |
|
26 |
-
#
|
27 |
transition: all 200ms;
|
28 |
}
|
29 |
|
30 |
-
#
|
31 |
color: #79ba49;
|
32 |
opacity: 1;
|
33 |
}
|
34 |
|
35 |
-
#
|
36 |
color: #ca4a1f;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
}
|
1 |
+
.js #whatsappme_form textarea {
|
2 |
+
overflow: hidden;
|
3 |
+
min-height: 100px;
|
4 |
+
}
|
5 |
+
|
6 |
.tab {
|
7 |
display: none;
|
8 |
}
|
11 |
display: block;
|
12 |
}
|
13 |
|
14 |
+
#whatsappme_tab_advanced tr:hover {
|
15 |
background: rgba(0, 0, 0, .05);
|
16 |
}
|
17 |
|
18 |
+
#whatsappme_tab_advanced th,
|
19 |
+
#whatsappme_tab_advanced td {
|
20 |
padding: 7px 15px;
|
21 |
}
|
22 |
|
23 |
+
#whatsappme_tab_advanced label {
|
24 |
margin-right: 15px;
|
25 |
}
|
26 |
|
27 |
+
#whatsappme_tab_advanced .dashicons {
|
28 |
opacity: .5;
|
29 |
}
|
30 |
|
31 |
+
#whatsappme_tab_advanced input[type=radio]+span {
|
32 |
transition: all 200ms;
|
33 |
}
|
34 |
|
35 |
+
#whatsappme_tab_advanced input[type=radio]:checked+span {
|
36 |
color: #79ba49;
|
37 |
opacity: 1;
|
38 |
}
|
39 |
|
40 |
+
#whatsappme_tab_advanced input[type=radio]:checked+.dashicons-hidden {
|
41 |
color: #ca4a1f;
|
42 |
+
}
|
43 |
+
|
44 |
+
.whatsappme-show-help {
|
45 |
+
display: inline-block;
|
46 |
+
width: 1.1em;
|
47 |
+
height: 1.1em;
|
48 |
+
line-height: 1.1em;
|
49 |
+
border-radius: 50%;
|
50 |
+
background: #999;
|
51 |
+
color: #fff;
|
52 |
+
font-weight: bold;
|
53 |
+
text-decoration: none;
|
54 |
+
text-align: center;
|
55 |
+
}
|
56 |
+
|
57 |
+
.whatsappme-show-help:hover,
|
58 |
+
.whatsappme-show-help:active,
|
59 |
+
.whatsappme-show-help:focus {
|
60 |
+
background: #444;
|
61 |
+
color: #fff;
|
62 |
+
}
|
63 |
+
|
64 |
+
#tab-panel-styles-and-vars span {
|
65 |
+
white-space: nowrap;
|
66 |
+
}
|
67 |
+
|
68 |
+
#tab-panel-styles-and-vars code {
|
69 |
+
-webkit-user-select: all;
|
70 |
+
-moz-user-select: all;
|
71 |
+
-ms-user-select: all;
|
72 |
+
user-select: all;
|
73 |
+
}
|
74 |
+
|
75 |
+
.form-table td p.whatsappme-addon {
|
76 |
+
font-size: 13px;
|
77 |
+
}
|
78 |
+
|
79 |
+
.iti--allow-dropdown input {
|
80 |
+
padding-left: 52px !important;
|
81 |
}
|
admin/css/whatsappme.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.tab{display:none}.tab-active{display:block}#
|
1 |
+
.js #whatsappme_form textarea{overflow:hidden;min-height:100px}.tab{display:none}.tab-active{display:block}#whatsappme_tab_advanced tr:hover{background:rgba(0,0,0,.05)}#whatsappme_tab_advanced td,#whatsappme_tab_advanced th{padding:7px 15px}#whatsappme_tab_advanced label{margin-right:15px}#whatsappme_tab_advanced .dashicons{opacity:.5}#whatsappme_tab_advanced input[type=radio]+span{transition:all .2s}#whatsappme_tab_advanced input[type=radio]:checked+span{color:#79ba49;opacity:1}#whatsappme_tab_advanced input[type=radio]:checked+.dashicons-hidden{color:#ca4a1f}.whatsappme-show-help{display:inline-block;width:1.1em;height:1.1em;line-height:1.1em;border-radius:50%;background:#999;color:#fff;font-weight:700;text-decoration:none;text-align:center}.whatsappme-show-help:active,.whatsappme-show-help:focus,.whatsappme-show-help:hover{background:#444;color:#fff}#tab-panel-styles-and-vars span{white-space:nowrap}#tab-panel-styles-and-vars code{-webkit-user-select:all;-moz-user-select:all;-ms-user-select:all;user-select:all}.form-table td p.whatsappme-addon{font-size:13px}.iti--allow-dropdown input{padding-left:52px!important}
|
admin/index.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php // Silence is golden
|
1 |
+
<?php // Silence is golden
|
admin/js/whatsappme.js
CHANGED
@@ -5,31 +5,31 @@
|
|
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 = $(
|
9 |
var iti = intlTelInput($phone.get(0), {
|
10 |
-
hiddenInput: $phone.data(
|
11 |
-
initialCountry:
|
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:
|
25 |
});
|
26 |
|
27 |
-
$phone.on(
|
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(
|
33 |
$phone.css('border-color', $phone.val().trim() && !iti.isValidNumber() ? '#ff0000' : '');
|
34 |
});
|
35 |
}
|
@@ -54,7 +54,12 @@
|
|
54 |
}
|
55 |
}
|
56 |
|
|
|
|
|
|
|
|
|
57 |
if ($('#whatsappme_form').length === 1) {
|
|
|
58 |
$('.nav-tab').click(function (e) {
|
59 |
var $tab = $(this);
|
60 |
e.preventDefault();
|
@@ -65,16 +70,31 @@
|
|
65 |
$($tab.attr('href')).addClass('tab-active');
|
66 |
});
|
67 |
|
|
|
68 |
$('#whatsappme_mobile_only').change(function () {
|
69 |
$('#whatsappme_whatsapp_web').closest('tr').toggleClass('hide-if-js', this.checked);
|
70 |
}).change();
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
'archive': ['date', 'author'],
|
76 |
'singular': ['page', 'post'],
|
77 |
-
'woocommerce': ['product', 'cart', 'checkout', 'account_page']
|
78 |
};
|
79 |
|
80 |
$('input', $tab_advanced).change(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/' + intl_tel_input_version + '/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 |
}
|
54 |
}
|
55 |
}
|
56 |
|
57 |
+
function textarea_autoheight() {
|
58 |
+
$(this).height(0).height(this.scrollHeight);
|
59 |
+
}
|
60 |
+
|
61 |
if ($('#whatsappme_form').length === 1) {
|
62 |
+
// Tabs
|
63 |
$('.nav-tab').click(function (e) {
|
64 |
var $tab = $(this);
|
65 |
e.preventDefault();
|
70 |
$($tab.attr('href')).addClass('tab-active');
|
71 |
});
|
72 |
|
73 |
+
// Toggle WhatsApp web option
|
74 |
$('#whatsappme_mobile_only').change(function () {
|
75 |
$('#whatsappme_whatsapp_web').closest('tr').toggleClass('hide-if-js', this.checked);
|
76 |
}).change();
|
77 |
|
78 |
+
// Show help
|
79 |
+
$('.whatsappme-show-help').click(function (e) {
|
80 |
+
e.preventDefault();
|
81 |
+
if ($('#contextual-help-wrap').is(':visible')) {
|
82 |
+
$("html, body").animate({ scrollTop: 0 });
|
83 |
+
} else {
|
84 |
+
$('#contextual-help-link').click();
|
85 |
+
}
|
86 |
+
$('#tab-link-styles-and-vars a').click();
|
87 |
+
});
|
88 |
+
|
89 |
+
// Texarea auto height
|
90 |
+
$('textarea', '#whatsappme_form').on('input', textarea_autoheight).each(textarea_autoheight);
|
91 |
+
|
92 |
+
// Advanced view inheritance
|
93 |
+
var $tab_advanced = $('#whatsappme_tab_advanced');
|
94 |
+
var inheritance = $('.whatsappme_view_all').data('inheritance') || {
|
95 |
+
'all': ['front_page', 'blog_page', '404_page', 'search', 'archive', 'singular', 'cpts'],
|
96 |
'archive': ['date', 'author'],
|
97 |
'singular': ['page', 'post'],
|
|
|
98 |
};
|
99 |
|
100 |
$('input', $tab_advanced).change(function () {
|
admin/js/whatsappme.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e){"use strict";e(function(){if("function"==typeof intlTelInput){var t=JSON.parse(localStorage.whatsappme_country_code||"{}"),a=!(!t.code||t.date!=(new Date).toDateString())&&t.code,
|
1 |
+
!function(e){"use strict";e(function(){if("function"==typeof intlTelInput){var t=JSON.parse(localStorage.whatsappme_country_code||"{}"),a=!(!t.code||t.date!=(new Date).toDateString())&&t.code,i=e("#whatsappme_phone"),n=intlTelInput(i.get(0),{hiddenInput:i.data("name")||"whatsappme[telephone]",initialCountry:"auto",preferredCountries:[a||""],geoIpLookup:function(t){a?t(a):e.getJSON("https://ipinfo.io").always(function(e){var a=e&&e.country?e.country:"";localStorage.whatsappme_country_code=JSON.stringify({code:a,date:(new Date).toDateString()}),t(a)})},utilsScript:"https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/"+intl_tel_input_version+"/js/utils.js"});i.on("keyup change",function(){i.css("border-color",""),n.hiddenInput.value=n.getNumber()}),i.on("blur",function(){i.css("border-color",i.val().trim()&&!n.isValidNumber()?"#ff0000":"")})}function s(t,a){if(t=t||"all",a=a||e('input[name="whatsappme[view]['+t+']"]:checked').val(),e(".view_inheritance_"+t).toggleClass("dashicons-visibility","yes"==a).toggleClass("dashicons-hidden","no"==a),"cpts"==t)e("[class*=view_inheritance_cpt_]").toggleClass("dashicons-visibility","yes"==a).toggleClass("dashicons-hidden","no"==a);else if(t in o){var i=e('input[name="whatsappme[view]['+t+']"]:checked').val();i=""===i?a:i,e.each(o[t],function(){s(this,i)})}}function c(){e(this).height(0).height(this.scrollHeight)}if(1===e("#whatsappme_form").length){e(".nav-tab").click(function(t){var a=e(this);t.preventDefault(),e(".nav-tab").removeClass("nav-tab-active"),a.addClass("nav-tab-active").blur(),e(".tab").removeClass("tab-active"),e(a.attr("href")).addClass("tab-active")}),e("#whatsappme_mobile_only").change(function(){e("#whatsappme_whatsapp_web").closest("tr").toggleClass("hide-if-js",this.checked)}).change(),e(".whatsappme-show-help").click(function(t){t.preventDefault(),e("#contextual-help-wrap").is(":visible")?e("html, body").animate({scrollTop:0}):e("#contextual-help-link").click(),e("#tab-link-styles-and-vars a").click()}),e("textarea","#whatsappme_form").on("input",c).each(c);var l=e("#whatsappme_tab_advanced"),o=e(".whatsappme_view_all").data("inheritance")||{all:["front_page","blog_page","404_page","search","archive","singular","cpts"],archive:["date","author"],singular:["page","post"]};e("input",l).change(function(){s()}),e(".whatsappme_view_reset").click(function(t){t.preventDefault(),e('input[value=""]',l).prop("checked",!0),e(".whatsappme_view_all input",l).first().prop("checked",!0),s()}),s()}})}(jQuery);
|
includes/class-whatsappme-integrations.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Define the third party plugins integration functionality.
|
5 |
+
*
|
6 |
+
* @since 3.0.0
|
7 |
+
* @package WhatsAppMe
|
8 |
+
* @subpackage WhatsAppMe/includes
|
9 |
+
* @author Creame <hola@crea.me>
|
10 |
+
*/
|
11 |
+
class WhatsAppMe_Integrations {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Load third party plugins integrations.
|
15 |
+
*
|
16 |
+
* @since 3.0.0
|
17 |
+
*/
|
18 |
+
public function load_integrations() {
|
19 |
+
|
20 |
+
// Integration with WooCommerce
|
21 |
+
if ( class_exists( 'WooCommerce' ) ) {
|
22 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-whatsappme-wooadmin.php';
|
23 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-whatsappme-woopublic.php';
|
24 |
+
|
25 |
+
if ( is_admin() ) {
|
26 |
+
|
27 |
+
$plugin_wooadmin = new WhatsAppMe_WooAdmin();
|
28 |
+
|
29 |
+
add_action( 'whatsappme_run_pre', array( $plugin_wooadmin, 'init' ) );
|
30 |
+
|
31 |
+
} else {
|
32 |
+
|
33 |
+
$plugin_woopublic = new WhatsAppMe_WooPublic();
|
34 |
+
|
35 |
+
add_action( 'whatsappme_run_pre', array( $plugin_woopublic, 'init' ) );
|
36 |
+
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
}
|
41 |
+
|
42 |
+
}
|
includes/class-whatsappme-loader.php
CHANGED
@@ -48,11 +48,11 @@ class WhatsAppMe_Loader {
|
|
48 |
* Add a new action to the collection to be registered with WordPress.
|
49 |
*
|
50 |
* @since 1.0.0
|
51 |
-
* @param string
|
52 |
-
* @param object
|
53 |
-
* @param string
|
54 |
-
* @param int
|
55 |
-
* @param int
|
56 |
*/
|
57 |
public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
58 |
$this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
|
@@ -62,11 +62,11 @@ class WhatsAppMe_Loader {
|
|
62 |
* Add a new filter to the collection to be registered with WordPress.
|
63 |
*
|
64 |
* @since 1.0.0
|
65 |
-
* @param string
|
66 |
-
* @param object
|
67 |
-
* @param string
|
68 |
-
* @param int
|
69 |
-
* @param int
|
70 |
*/
|
71 |
public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
72 |
$this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
|
@@ -78,12 +78,12 @@ class WhatsAppMe_Loader {
|
|
78 |
*
|
79 |
* @since 1.0.0
|
80 |
* @access private
|
81 |
-
* @param array
|
82 |
-
* @param string
|
83 |
-
* @param object
|
84 |
-
* @param string
|
85 |
-
* @param int
|
86 |
-
* @param int
|
87 |
* @return array The collection of actions and filters registered with WordPress.
|
88 |
*/
|
89 |
private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
|
@@ -93,13 +93,71 @@ class WhatsAppMe_Loader {
|
|
93 |
'component' => $component,
|
94 |
'callback' => $callback,
|
95 |
'priority' => $priority,
|
96 |
-
'accepted_args' => $accepted_args
|
97 |
);
|
98 |
|
99 |
return $hooks;
|
100 |
|
101 |
}
|
102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
/**
|
104 |
* Register the filters and actions with WordPress.
|
105 |
*
|
48 |
* Add a new action to the collection to be registered with WordPress.
|
49 |
*
|
50 |
* @since 1.0.0
|
51 |
+
* @param string $hook The name of the WordPress action that is being registered.
|
52 |
+
* @param object $component A reference to the instance of the object on which the action is defined.
|
53 |
+
* @param string $callback The name of the function definition on the $component.
|
54 |
+
* @param int $priority Optional. The priority at which the function should be fired. Default is 10.
|
55 |
+
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
|
56 |
*/
|
57 |
public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
58 |
$this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
|
62 |
* Add a new filter to the collection to be registered with WordPress.
|
63 |
*
|
64 |
* @since 1.0.0
|
65 |
+
* @param string $hook The name of the WordPress filter that is being registered.
|
66 |
+
* @param object $component A reference to the instance of the object on which the filter is defined.
|
67 |
+
* @param string $callback The name of the function definition on the $component.
|
68 |
+
* @param int $priority Optional. The priority at which the function should be fired. Default is 10.
|
69 |
+
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1
|
70 |
*/
|
71 |
public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
72 |
$this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
|
78 |
*
|
79 |
* @since 1.0.0
|
80 |
* @access private
|
81 |
+
* @param array $hooks The collection of hooks that is being registered (that is, actions or filters).
|
82 |
+
* @param string $hook The name of the WordPress filter that is being registered.
|
83 |
+
* @param object $component A reference to the instance of the object on which the filter is defined.
|
84 |
+
* @param string $callback The name of the function definition on the $component.
|
85 |
+
* @param int $priority The priority at which the function should be fired.
|
86 |
+
* @param int $accepted_args The number of arguments that should be passed to the $callback.
|
87 |
* @return array The collection of actions and filters registered with WordPress.
|
88 |
*/
|
89 |
private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
|
93 |
'component' => $component,
|
94 |
'callback' => $callback,
|
95 |
'priority' => $priority,
|
96 |
+
'accepted_args' => $accepted_args,
|
97 |
);
|
98 |
|
99 |
return $hooks;
|
100 |
|
101 |
}
|
102 |
|
103 |
+
/**
|
104 |
+
* Remove one or more actions to the collection to be registered with WordPress.
|
105 |
+
* It can be very specific or remove several hooks. Empty call remove all action hooks.
|
106 |
+
*
|
107 |
+
* @since 3.0.0
|
108 |
+
* @param string $hook Optional. The name of the WordPress action that is being removed.
|
109 |
+
* @param object $component Optional. A reference to the instance or name of the object on which the action is defined.
|
110 |
+
* @param string $callback Optional. The name of the function definition on the $component.
|
111 |
+
* @param int $priority Optional. The priority at which the function should be fired. Default is 10.
|
112 |
+
*/
|
113 |
+
public function remove_action( $hook = null, $component = null, $callback = null, $priority = 10 ) {
|
114 |
+
$this->actions = $this->remove( $this->actions, $hook, $component, $callback, $priority );
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Remove one or more filters to the collection to be registered with WordPress.
|
119 |
+
* It can be very specific or remove several hooks. Empty call remove all filter hooks.
|
120 |
+
*
|
121 |
+
* @since 3.0.0
|
122 |
+
* @param string $hook Optional. The name of the WordPress filter that is being removed.
|
123 |
+
* @param object $component Optional. A reference to the instance or name of the object on which the filter is defined.
|
124 |
+
* @param string $callback Optional. The name of the function definition on the $component.
|
125 |
+
* @param int $priority Optional. The priority at which the function should be fired. Default is 10.
|
126 |
+
*/
|
127 |
+
public function remove_filter( $hook = null, $component = null, $callback = null, $priority = 10 ) {
|
128 |
+
$this->filters = $this->remove( $this->filters, $hook, $component, $callback, $priority );
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* A utility function that is used to remove the actions and hooks from a single
|
133 |
+
* collection.
|
134 |
+
*
|
135 |
+
* @since 3.0.0
|
136 |
+
* @access private
|
137 |
+
* @param array $hooks The collection of hooks that is being removed (that is, actions or filters).
|
138 |
+
* @param string $hook The name of the WordPress filter that is being removed.
|
139 |
+
* @param object $component A reference to the instance or name of the object on which the filter is defined.
|
140 |
+
* @param string $callback The name of the function definition on the $component.
|
141 |
+
* @param int $priority The priority at which the function should be fired.
|
142 |
+
* @return array The collection of actions and filters registered with WordPress.
|
143 |
+
*/
|
144 |
+
private function remove( $hooks, $hook, $component, $callback, $priority ) {
|
145 |
+
|
146 |
+
foreach ( $hooks as $key => $value ) {
|
147 |
+
if (
|
148 |
+
( is_null( $hook ) || $value['hook'] == $hook ) &&
|
149 |
+
( is_null( $component ) || $value['component'] == $component || $value['component'] instanceof $component ) &&
|
150 |
+
( is_null( $callback ) || $value['callback'] == $callback ) &&
|
151 |
+
( is_null( $priority ) || $value['priority'] == $priority )
|
152 |
+
) {
|
153 |
+
unset( $hooks[ $key ] );
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
return $hooks;
|
158 |
+
|
159 |
+
}
|
160 |
+
|
161 |
/**
|
162 |
* Register the filters and actions with WordPress.
|
163 |
*
|
includes/class-whatsappme.php
CHANGED
@@ -54,15 +54,12 @@ class WhatsAppMe {
|
|
54 |
* @since 1.0.0
|
55 |
*/
|
56 |
public function __construct() {
|
57 |
-
|
58 |
-
$this->version = WHATSAPPME_VERSION;
|
59 |
-
} else {
|
60 |
-
$this->version = '1.0.0';
|
61 |
-
}
|
62 |
$this->plugin_name = 'whatsappme';
|
63 |
|
64 |
$this->load_dependencies();
|
65 |
$this->set_locale();
|
|
|
66 |
is_admin() ? $this->define_admin_hooks() : $this->define_public_hooks();
|
67 |
|
68 |
}
|
@@ -87,6 +84,7 @@ class WhatsAppMe {
|
|
87 |
|
88 |
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-whatsappme-loader.php';
|
89 |
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-whatsappme-i18n.php';
|
|
|
90 |
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-whatsappme-admin.php';
|
91 |
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-whatsappme-public.php';
|
92 |
|
@@ -107,10 +105,28 @@ class WhatsAppMe {
|
|
107 |
|
108 |
$plugin_i18n = new WhatsAppMe_i18n();
|
109 |
|
110 |
-
$this->loader
|
|
|
111 |
|
112 |
}
|
113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
/**
|
115 |
* Register all of the hooks related to the admin area functionality
|
116 |
* of the plugin.
|
@@ -122,12 +138,14 @@ class WhatsAppMe {
|
|
122 |
|
123 |
$plugin_admin = new WhatsAppMe_Admin( $this->get_plugin_name(), $this->get_version() );
|
124 |
|
125 |
-
$this->loader->add_action( 'admin_init',
|
126 |
-
$this->loader->add_action( '
|
127 |
-
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, '
|
128 |
-
$this->loader->add_action( '
|
129 |
-
$this->loader->add_action( '
|
130 |
-
$this->loader->add_action( '
|
|
|
|
|
131 |
|
132 |
$this->loader->add_filter( "plugin_action_links_creame-whatsapp-me/{$this->plugin_name}.php", $plugin_admin, 'settings_link' );
|
133 |
|
@@ -144,10 +162,10 @@ class WhatsAppMe {
|
|
144 |
|
145 |
$plugin_public = new WhatsAppMe_Public( $this->get_plugin_name(), $this->get_version() );
|
146 |
|
147 |
-
$this->loader->add_action( 'wp',
|
148 |
-
$this->loader->add_action( 'wp_enqueue_scripts',
|
149 |
-
$this->loader->add_action( 'wp_enqueue_scripts',
|
150 |
-
$this->loader->add_action( 'wp_footer',
|
151 |
$this->loader->add_action( 'elementor/preview/init', $plugin_public, 'elementor_preview_disable' );
|
152 |
|
153 |
}
|
@@ -156,9 +174,16 @@ class WhatsAppMe {
|
|
156 |
* Run the loader to execute all of the hooks with WordPress.
|
157 |
*
|
158 |
* @since 1.0.0
|
|
|
159 |
*/
|
160 |
public function run() {
|
|
|
|
|
|
|
161 |
$this->loader->run();
|
|
|
|
|
|
|
162 |
}
|
163 |
|
164 |
/**
|
54 |
* @since 1.0.0
|
55 |
*/
|
56 |
public function __construct() {
|
57 |
+
$this->version = defined( 'WHATSAPPME_VERSION' ) ? WHATSAPPME_VERSION : '1.0.0';
|
|
|
|
|
|
|
|
|
58 |
$this->plugin_name = 'whatsappme';
|
59 |
|
60 |
$this->load_dependencies();
|
61 |
$this->set_locale();
|
62 |
+
$this->load_integrations();
|
63 |
is_admin() ? $this->define_admin_hooks() : $this->define_public_hooks();
|
64 |
|
65 |
}
|
84 |
|
85 |
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-whatsappme-loader.php';
|
86 |
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-whatsappme-i18n.php';
|
87 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-whatsappme-integrations.php';
|
88 |
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-whatsappme-admin.php';
|
89 |
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-whatsappme-public.php';
|
90 |
|
105 |
|
106 |
$plugin_i18n = new WhatsAppMe_i18n();
|
107 |
|
108 |
+
// No delegate to $this->loader, use WordPress add_action
|
109 |
+
add_action( 'plugins_loaded', array( $plugin_i18n, 'load_plugin_textdomain' ) );
|
110 |
|
111 |
}
|
112 |
|
113 |
+
/**
|
114 |
+
* Load third party plugins integrations
|
115 |
+
*
|
116 |
+
* @since 3.0.0
|
117 |
+
* @access private
|
118 |
+
*/
|
119 |
+
private function load_integrations() {
|
120 |
+
|
121 |
+
$plugin_integrations = new WhatsAppMe_Integrations();
|
122 |
+
|
123 |
+
// No delegate to $this->loader, use WordPress add_action.
|
124 |
+
// At 'plugins_loaded' hook can determine if other plugins are present.
|
125 |
+
add_action( 'plugins_loaded', array( $plugin_integrations, 'load_integrations' ) );
|
126 |
+
|
127 |
+
}
|
128 |
+
|
129 |
+
|
130 |
/**
|
131 |
* Register all of the hooks related to the admin area functionality
|
132 |
* of the plugin.
|
138 |
|
139 |
$plugin_admin = new WhatsAppMe_Admin( $this->get_plugin_name(), $this->get_version() );
|
140 |
|
141 |
+
$this->loader->add_action( 'admin_init', $plugin_admin, 'get_settings', 5 );
|
142 |
+
$this->loader->add_action( 'admin_init', $plugin_admin, 'settings_init' );
|
143 |
+
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'register_styles' );
|
144 |
+
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'register_scripts' );
|
145 |
+
$this->loader->add_action( 'admin_menu', $plugin_admin, 'add_menu' );
|
146 |
+
$this->loader->add_action( 'add_meta_boxes', $plugin_admin, 'add_meta_boxes' );
|
147 |
+
$this->loader->add_action( 'save_post', $plugin_admin, 'save_post' );
|
148 |
+
$this->loader->add_action( 'load-settings_page_whatsappme', $plugin_admin, 'help_tab' );
|
149 |
|
150 |
$this->loader->add_filter( "plugin_action_links_creame-whatsapp-me/{$this->plugin_name}.php", $plugin_admin, 'settings_link' );
|
151 |
|
162 |
|
163 |
$plugin_public = new WhatsAppMe_Public( $this->get_plugin_name(), $this->get_version() );
|
164 |
|
165 |
+
$this->loader->add_action( 'wp', $plugin_public, 'get_settings' );
|
166 |
+
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
|
167 |
+
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
|
168 |
+
$this->loader->add_action( 'wp_footer', $plugin_public, 'footer_html' );
|
169 |
$this->loader->add_action( 'elementor/preview/init', $plugin_public, 'elementor_preview_disable' );
|
170 |
|
171 |
}
|
174 |
* Run the loader to execute all of the hooks with WordPress.
|
175 |
*
|
176 |
* @since 1.0.0
|
177 |
+
* @since 3.0.0 Added actions
|
178 |
*/
|
179 |
public function run() {
|
180 |
+
|
181 |
+
do_action( 'whatsappme_run_pre', $this );
|
182 |
+
|
183 |
$this->loader->run();
|
184 |
+
|
185 |
+
do_action( 'whatsappme_run_pos', $this );
|
186 |
+
|
187 |
}
|
188 |
|
189 |
/**
|
includes/index.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php // Silence is golden
|
1 |
+
<?php // Silence is golden
|
index.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php // Silence is golden
|
1 |
+
<?php // Silence is golden
|
languages/creame-whatsapp-me.pot
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
#, fuzzy
|
2 |
msgid ""
|
3 |
msgstr ""
|
4 |
-
"Project-Id-Version:
|
5 |
-
"POT-Creation-Date: 2019-
|
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"
|
@@ -15,265 +15,366 @@ msgstr ""
|
|
15 |
"X-Poedit-SourceCharset: UTF-8\n"
|
16 |
"X-Poedit-KeywordsList: __;_e;esc_html_e;esc_html_x:1,2c;esc_html__;"
|
17 |
"esc_attr_e;esc_attr_x:1,2c;esc_attr__;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;"
|
18 |
-
"_x:1,2c;_n:1,2;_n_noop:1,2;__ngettext:1,2;__ngettext_noop:1,2;_c,
|
|
|
19 |
"X-Poedit-Basepath: ..\n"
|
20 |
"X-Generator: Poedit 1.8.7.1\n"
|
21 |
"X-Poedit-SearchPath-0: .\n"
|
22 |
|
23 |
-
#: admin/class-whatsappme-admin.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
msgid "Telephone"
|
25 |
msgstr ""
|
26 |
|
27 |
-
#: admin/class-whatsappme-admin.php:
|
28 |
msgid "Mobile Only"
|
29 |
msgstr ""
|
30 |
|
31 |
-
#: admin/class-whatsappme-admin.php:
|
32 |
msgid "Position On Screen"
|
33 |
msgstr ""
|
34 |
|
35 |
-
#: admin/class-whatsappme-admin.php:
|
36 |
msgid "Button Delay"
|
37 |
msgstr ""
|
38 |
|
39 |
-
#: admin/class-whatsappme-admin.php:
|
40 |
msgid "WhatsApp Web"
|
41 |
msgstr ""
|
42 |
|
43 |
-
#: admin/class-whatsappme-admin.php:
|
|
|
44 |
msgid "Call To Action"
|
45 |
msgstr ""
|
46 |
|
47 |
-
#: admin/class-whatsappme-admin.php:
|
|
|
48 |
msgid "Message"
|
49 |
msgstr ""
|
50 |
|
51 |
-
#: admin/class-whatsappme-admin.php:
|
52 |
msgid "Chat Delay"
|
53 |
msgstr ""
|
54 |
|
55 |
-
#: admin/class-whatsappme-admin.php:
|
56 |
msgid "Hide Chat"
|
57 |
msgstr ""
|
58 |
|
59 |
-
#: admin/class-whatsappme-admin.php:
|
60 |
msgid "Global"
|
61 |
msgstr ""
|
62 |
|
63 |
-
#: admin/class-whatsappme-admin.php:
|
64 |
msgid "Front Page"
|
65 |
msgstr ""
|
66 |
|
67 |
-
#: admin/class-whatsappme-admin.php:
|
68 |
msgid "Blog Page"
|
69 |
msgstr ""
|
70 |
|
71 |
-
#: admin/class-whatsappme-admin.php:
|
72 |
msgid "404 Page"
|
73 |
msgstr ""
|
74 |
|
75 |
-
#: admin/class-whatsappme-admin.php:
|
76 |
msgid "Search Results"
|
77 |
msgstr ""
|
78 |
|
79 |
-
#: admin/class-whatsappme-admin.php:
|
80 |
msgid "Archives"
|
81 |
msgstr ""
|
82 |
|
83 |
-
#: admin/class-whatsappme-admin.php:
|
84 |
msgid "Date Archives"
|
85 |
msgstr ""
|
86 |
|
87 |
-
#: admin/class-whatsappme-admin.php:
|
88 |
msgid "Author Archives"
|
89 |
msgstr ""
|
90 |
|
91 |
-
#: admin/class-whatsappme-admin.php:
|
92 |
msgid "Singular"
|
93 |
msgstr ""
|
94 |
|
95 |
-
#: admin/class-whatsappme-admin.php:
|
96 |
msgid "Page"
|
97 |
msgstr ""
|
98 |
|
99 |
-
#: admin/class-whatsappme-admin.php:
|
100 |
msgid "Post"
|
101 |
msgstr ""
|
102 |
|
103 |
-
#: admin/class-whatsappme-admin.php:
|
104 |
-
msgid "
|
105 |
msgstr ""
|
106 |
|
107 |
-
#: admin/class-whatsappme-admin.php:
|
108 |
-
msgid "
|
109 |
msgstr ""
|
110 |
|
111 |
-
#: admin/class-whatsappme-admin.php:
|
112 |
-
msgid "
|
|
|
|
|
113 |
msgstr ""
|
114 |
|
115 |
-
#: admin/class-whatsappme-admin.php:
|
116 |
-
msgid "
|
117 |
msgstr ""
|
118 |
|
119 |
-
#: admin/class-whatsappme-admin.php:
|
120 |
-
msgid "
|
121 |
msgstr ""
|
122 |
|
123 |
-
#: admin/class-whatsappme-admin.php:
|
124 |
-
|
|
|
125 |
msgstr ""
|
126 |
|
127 |
-
#: admin/class-whatsappme-admin.php:
|
128 |
-
|
|
|
129 |
msgstr ""
|
130 |
|
131 |
-
#: admin/class-whatsappme-admin.php:
|
132 |
-
msgid "
|
133 |
msgstr ""
|
134 |
|
135 |
-
#: admin/class-whatsappme-admin.php:
|
136 |
-
msgid "
|
|
|
|
|
137 |
msgstr ""
|
138 |
|
139 |
-
#: admin/class-whatsappme-admin.php:
|
140 |
-
msgid "
|
141 |
msgstr ""
|
142 |
|
143 |
-
#: admin/class-whatsappme-admin.php:
|
144 |
-
msgid ""
|
145 |
-
"Set the contact number and where you want the WhatsApp button to be "
|
146 |
-
"displayed."
|
147 |
msgstr ""
|
148 |
|
149 |
-
#: admin/class-whatsappme-admin.php:
|
150 |
-
|
|
|
151 |
msgstr ""
|
152 |
|
153 |
-
#: admin/class-whatsappme-admin.php:
|
154 |
-
|
|
|
155 |
msgstr ""
|
156 |
|
157 |
-
#: admin/class-whatsappme-admin.php:
|
158 |
-
msgid ""
|
159 |
-
"You can use the dynamic variables <code>{SITE}</code>, <code>{URL}</code> "
|
160 |
-
"and <code>{TITLE}</code> which will be replaced by the values of the user's "
|
161 |
-
"current page."
|
162 |
msgstr ""
|
163 |
|
164 |
-
#: admin/class-whatsappme-admin.php:
|
165 |
msgid ""
|
166 |
-
"
|
167 |
-
"
|
168 |
msgstr ""
|
169 |
|
170 |
-
#: admin/class-whatsappme-admin.php:
|
171 |
-
|
|
|
172 |
msgstr ""
|
173 |
|
174 |
-
#: admin/class-whatsappme-admin.php:
|
175 |
-
msgid ""
|
176 |
-
"From here you can configure on which pages the WhatsApp button will be "
|
177 |
-
"visible."
|
178 |
msgstr ""
|
179 |
|
180 |
-
#: admin/class-whatsappme-admin.php:
|
181 |
-
msgid "
|
182 |
msgstr ""
|
183 |
|
184 |
-
#: admin/class-whatsappme-admin.php:
|
185 |
-
msgid ""
|
186 |
-
"Contact phone number <strong>(the button will not be shown if it's empty)</"
|
187 |
-
"strong>"
|
188 |
msgstr ""
|
189 |
|
190 |
-
#: admin/class-whatsappme-admin.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
msgid ""
|
192 |
"Hello 👋\n"
|
193 |
"Can we help you?"
|
194 |
msgstr ""
|
195 |
|
196 |
-
#: admin/class-whatsappme-admin.php:
|
197 |
msgid ""
|
198 |
"Define a text to encourage users to contact by WhatsApp <strong>(optional)</"
|
199 |
"strong>"
|
200 |
msgstr ""
|
201 |
|
202 |
-
#: admin/class-whatsappme-admin.php:
|
203 |
-
msgid "
|
204 |
msgstr ""
|
205 |
|
206 |
-
#: admin/class-whatsappme-admin.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
msgid ""
|
208 |
"Time since the WhatsApp button is displayed until the Chat Window opens"
|
209 |
msgstr ""
|
210 |
|
211 |
-
#: admin/class-whatsappme-admin.php:
|
212 |
msgid ""
|
213 |
"Display a notification balloon instead of opening the Chat Window for a "
|
214 |
"\"less intrusive\" mode"
|
215 |
msgstr ""
|
216 |
|
217 |
-
#: admin/class-whatsappme-admin.php:
|
218 |
-
msgid "
|
219 |
msgstr ""
|
220 |
|
221 |
-
#: admin/class-whatsappme-admin.php:
|
222 |
msgid ""
|
223 |
-
"
|
224 |
-
"
|
225 |
msgstr ""
|
226 |
|
227 |
-
#: admin/class-whatsappme-admin.php:
|
228 |
-
msgid "
|
|
|
|
|
229 |
msgstr ""
|
230 |
|
231 |
-
#: admin/class-whatsappme-admin.php:
|
232 |
-
msgid "
|
233 |
msgstr ""
|
234 |
|
235 |
-
#: admin/class-whatsappme-admin.php:
|
236 |
-
msgid "
|
237 |
msgstr ""
|
238 |
|
239 |
-
#: admin/class-whatsappme-admin.php:
|
240 |
-
|
|
|
|
|
|
|
241 |
msgstr ""
|
242 |
|
243 |
-
#: admin/class-whatsappme-admin.php:
|
244 |
-
msgid "
|
245 |
msgstr ""
|
246 |
|
247 |
-
#: admin/class-whatsappme-admin.php:
|
248 |
-
|
249 |
-
msgid "
|
250 |
msgstr ""
|
251 |
|
252 |
-
#: admin/class-whatsappme-admin.php:
|
253 |
-
|
254 |
-
msgid "
|
255 |
msgstr ""
|
256 |
|
257 |
-
#: admin/class-whatsappme-admin.php:
|
258 |
-
|
|
|
259 |
msgstr ""
|
260 |
|
261 |
-
#: admin/class-whatsappme-admin.php:
|
262 |
msgid "Settings"
|
263 |
msgstr ""
|
264 |
|
265 |
-
#: admin/class-whatsappme-admin.php:
|
266 |
-
msgid "
|
267 |
msgstr ""
|
268 |
|
269 |
-
#: admin/class-whatsappme-admin.php:
|
270 |
-
msgid "You can use vars
|
271 |
msgstr ""
|
272 |
|
273 |
-
#: admin/class-whatsappme-admin.php:
|
274 |
msgid "Default visibility"
|
275 |
msgstr ""
|
276 |
|
277 |
-
#:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
msgid "Powered by"
|
279 |
msgstr ""
|
1 |
#, fuzzy
|
2 |
msgid ""
|
3 |
msgstr ""
|
4 |
+
"Project-Id-Version: WAme chat\n"
|
5 |
+
"POT-Creation-Date: 2019-09-18 14:00+0200\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"
|
15 |
"X-Poedit-SourceCharset: UTF-8\n"
|
16 |
"X-Poedit-KeywordsList: __;_e;esc_html_e;esc_html_x:1,2c;esc_html__;"
|
17 |
"esc_attr_e;esc_attr_x:1,2c;esc_attr__;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;"
|
18 |
+
"_x:1,2c;_n:1,2;_n_noop:1,2;__ngettext:1,2;__ngettext_noop:1,2;_c,"
|
19 |
+
"_nc:4c,1,2\n"
|
20 |
"X-Poedit-Basepath: ..\n"
|
21 |
"X-Generator: Poedit 1.8.7.1\n"
|
22 |
"X-Poedit-SearchPath-0: .\n"
|
23 |
|
24 |
+
#: admin/class-whatsappme-admin.php:100
|
25 |
+
msgid "General"
|
26 |
+
msgstr ""
|
27 |
+
|
28 |
+
#: admin/class-whatsappme-admin.php:101
|
29 |
+
msgid "Advanced"
|
30 |
+
msgstr ""
|
31 |
+
|
32 |
+
#: admin/class-whatsappme-admin.php:235 admin/class-whatsappme-admin.php:739
|
33 |
msgid "Telephone"
|
34 |
msgstr ""
|
35 |
|
36 |
+
#: admin/class-whatsappme-admin.php:236 admin/class-whatsappme-admin.php:468
|
37 |
msgid "Mobile Only"
|
38 |
msgstr ""
|
39 |
|
40 |
+
#: admin/class-whatsappme-admin.php:237 admin/class-whatsappme-admin.php:474
|
41 |
msgid "Position On Screen"
|
42 |
msgstr ""
|
43 |
|
44 |
+
#: admin/class-whatsappme-admin.php:238
|
45 |
msgid "Button Delay"
|
46 |
msgstr ""
|
47 |
|
48 |
+
#: admin/class-whatsappme-admin.php:239 admin/class-whatsappme-admin.php:487
|
49 |
msgid "WhatsApp Web"
|
50 |
msgstr ""
|
51 |
|
52 |
+
#: admin/class-whatsappme-admin.php:242 admin/class-whatsappme-admin.php:743
|
53 |
+
#: admin/class-whatsappme-wooadmin.php:128
|
54 |
msgid "Call To Action"
|
55 |
msgstr ""
|
56 |
|
57 |
+
#: admin/class-whatsappme-admin.php:243 admin/class-whatsappme-admin.php:747
|
58 |
+
#: admin/class-whatsappme-wooadmin.php:129
|
59 |
msgid "Message"
|
60 |
msgstr ""
|
61 |
|
62 |
+
#: admin/class-whatsappme-admin.php:244
|
63 |
msgid "Chat Delay"
|
64 |
msgstr ""
|
65 |
|
66 |
+
#: admin/class-whatsappme-admin.php:245 admin/class-whatsappme-admin.php:508
|
67 |
msgid "Hide Chat"
|
68 |
msgstr ""
|
69 |
|
70 |
+
#: admin/class-whatsappme-admin.php:254
|
71 |
msgid "Global"
|
72 |
msgstr ""
|
73 |
|
74 |
+
#: admin/class-whatsappme-admin.php:259
|
75 |
msgid "Front Page"
|
76 |
msgstr ""
|
77 |
|
78 |
+
#: admin/class-whatsappme-admin.php:260
|
79 |
msgid "Blog Page"
|
80 |
msgstr ""
|
81 |
|
82 |
+
#: admin/class-whatsappme-admin.php:261
|
83 |
msgid "404 Page"
|
84 |
msgstr ""
|
85 |
|
86 |
+
#: admin/class-whatsappme-admin.php:262
|
87 |
msgid "Search Results"
|
88 |
msgstr ""
|
89 |
|
90 |
+
#: admin/class-whatsappme-admin.php:263
|
91 |
msgid "Archives"
|
92 |
msgstr ""
|
93 |
|
94 |
+
#: admin/class-whatsappme-admin.php:264
|
95 |
msgid "Date Archives"
|
96 |
msgstr ""
|
97 |
|
98 |
+
#: admin/class-whatsappme-admin.php:265
|
99 |
msgid "Author Archives"
|
100 |
msgstr ""
|
101 |
|
102 |
+
#: admin/class-whatsappme-admin.php:266
|
103 |
msgid "Singular"
|
104 |
msgstr ""
|
105 |
|
106 |
+
#: admin/class-whatsappme-admin.php:267
|
107 |
msgid "Page"
|
108 |
msgstr ""
|
109 |
|
110 |
+
#: admin/class-whatsappme-admin.php:268
|
111 |
msgid "Post"
|
112 |
msgstr ""
|
113 |
|
114 |
+
#: admin/class-whatsappme-admin.php:353
|
115 |
+
msgid "Settings saved"
|
116 |
msgstr ""
|
117 |
|
118 |
+
#: admin/class-whatsappme-admin.php:398
|
119 |
+
msgid "Button"
|
120 |
msgstr ""
|
121 |
|
122 |
+
#: admin/class-whatsappme-admin.php:399
|
123 |
+
msgid ""
|
124 |
+
"Set the contact number and where you want the WhatsApp button to be "
|
125 |
+
"displayed."
|
126 |
msgstr ""
|
127 |
|
128 |
+
#: admin/class-whatsappme-admin.php:403
|
129 |
+
msgid "Chat Window"
|
130 |
msgstr ""
|
131 |
|
132 |
+
#: admin/class-whatsappme-admin.php:405
|
133 |
+
msgid "Set the behavior of the chat window."
|
134 |
msgstr ""
|
135 |
|
136 |
+
#: admin/class-whatsappme-admin.php:406
|
137 |
+
#: admin/class-whatsappme-wooadmin.php:154
|
138 |
+
msgid "You can use styles and dynamic variables"
|
139 |
msgstr ""
|
140 |
|
141 |
+
#: admin/class-whatsappme-admin.php:407
|
142 |
+
#: admin/class-whatsappme-wooadmin.php:155
|
143 |
+
msgid "Show Help"
|
144 |
msgstr ""
|
145 |
|
146 |
+
#: admin/class-whatsappme-admin.php:412
|
147 |
+
msgid "Advanced Visibility Settings"
|
148 |
msgstr ""
|
149 |
|
150 |
+
#: admin/class-whatsappme-admin.php:413
|
151 |
+
msgid ""
|
152 |
+
"From here you can configure on which pages the WhatsApp button will be "
|
153 |
+
"visible."
|
154 |
msgstr ""
|
155 |
|
156 |
+
#: admin/class-whatsappme-admin.php:414
|
157 |
+
msgid "Restore default visibility"
|
158 |
msgstr ""
|
159 |
|
160 |
+
#: admin/class-whatsappme-admin.php:422
|
161 |
+
msgid "Custom Post Types"
|
|
|
|
|
162 |
msgstr ""
|
163 |
|
164 |
+
#: admin/class-whatsappme-admin.php:447 admin/class-whatsappme-admin.php:544
|
165 |
+
#: admin/class-whatsappme-admin.php:755
|
166 |
+
msgid "Show"
|
167 |
msgstr ""
|
168 |
|
169 |
+
#: admin/class-whatsappme-admin.php:449 admin/class-whatsappme-admin.php:546
|
170 |
+
#: admin/class-whatsappme-admin.php:757
|
171 |
+
msgid "Hide"
|
172 |
msgstr ""
|
173 |
|
174 |
+
#: admin/class-whatsappme-admin.php:451
|
175 |
+
msgid "Inherit"
|
|
|
|
|
|
|
176 |
msgstr ""
|
177 |
|
178 |
+
#: admin/class-whatsappme-admin.php:460
|
179 |
msgid ""
|
180 |
+
"Contact phone number <strong>(the button will not be shown if it's empty)</"
|
181 |
+
"strong>"
|
182 |
msgstr ""
|
183 |
|
184 |
+
#: admin/class-whatsappme-admin.php:462
|
185 |
+
#, php-format
|
186 |
+
msgid "Add unlimited numbers with %s"
|
187 |
msgstr ""
|
188 |
|
189 |
+
#: admin/class-whatsappme-admin.php:470
|
190 |
+
msgid "Only display the button on mobile devices"
|
|
|
|
|
191 |
msgstr ""
|
192 |
|
193 |
+
#: admin/class-whatsappme-admin.php:476
|
194 |
+
msgid "Left"
|
195 |
msgstr ""
|
196 |
|
197 |
+
#: admin/class-whatsappme-admin.php:478
|
198 |
+
msgid "Right"
|
|
|
|
|
199 |
msgstr ""
|
200 |
|
201 |
+
#: admin/class-whatsappme-admin.php:482 admin/class-whatsappme-admin.php:503
|
202 |
+
msgid "seconds"
|
203 |
+
msgstr ""
|
204 |
+
|
205 |
+
#: admin/class-whatsappme-admin.php:483
|
206 |
+
msgid "Time since the page is opened until the WhatsApp button is displayed"
|
207 |
+
msgstr ""
|
208 |
+
|
209 |
+
#: admin/class-whatsappme-admin.php:489
|
210 |
+
msgid "Open <em>WhatsApp Web</em> directly on desktop"
|
211 |
+
msgstr ""
|
212 |
+
|
213 |
+
#: admin/class-whatsappme-admin.php:493
|
214 |
msgid ""
|
215 |
"Hello 👋\n"
|
216 |
"Can we help you?"
|
217 |
msgstr ""
|
218 |
|
219 |
+
#: admin/class-whatsappme-admin.php:494
|
220 |
msgid ""
|
221 |
"Define a text to encourage users to contact by WhatsApp <strong>(optional)</"
|
222 |
"strong>"
|
223 |
msgstr ""
|
224 |
|
225 |
+
#: admin/class-whatsappme-admin.php:498
|
226 |
+
msgid "Hi *{SITE}*! I need more info about {TITLE}"
|
227 |
msgstr ""
|
228 |
|
229 |
+
#: admin/class-whatsappme-admin.php:499
|
230 |
+
msgid ""
|
231 |
+
"Predefined text with which user can start the conversation "
|
232 |
+
"<strong>(optional)</strong>"
|
233 |
+
msgstr ""
|
234 |
+
|
235 |
+
#: admin/class-whatsappme-admin.php:504
|
236 |
msgid ""
|
237 |
"Time since the WhatsApp button is displayed until the Chat Window opens"
|
238 |
msgstr ""
|
239 |
|
240 |
+
#: admin/class-whatsappme-admin.php:510
|
241 |
msgid ""
|
242 |
"Display a notification balloon instead of opening the Chat Window for a "
|
243 |
"\"less intrusive\" mode"
|
244 |
msgstr ""
|
245 |
|
246 |
+
#: admin/class-whatsappme-admin.php:575
|
247 |
+
msgid "Styles and Variables"
|
248 |
msgstr ""
|
249 |
|
250 |
+
#: admin/class-whatsappme-admin.php:578
|
251 |
msgid ""
|
252 |
+
"You can use formatting styles like in WhatsApp: _<em>italic</em>_ "
|
253 |
+
"*<strong>bold</strong>* ~<del>strikethrough</del>~."
|
254 |
msgstr ""
|
255 |
|
256 |
+
#: admin/class-whatsappme-admin.php:579
|
257 |
+
msgid ""
|
258 |
+
"You can use dynamic variables that will be replaced by the values of the "
|
259 |
+
"page the user visits:"
|
260 |
msgstr ""
|
261 |
|
262 |
+
#: admin/class-whatsappme-admin.php:583
|
263 |
+
msgid "Page Title"
|
264 |
msgstr ""
|
265 |
|
266 |
+
#: admin/class-whatsappme-admin.php:592
|
267 |
+
msgid "Support and Help"
|
268 |
msgstr ""
|
269 |
|
270 |
+
#: admin/class-whatsappme-admin.php:595
|
271 |
+
#, php-format
|
272 |
+
msgid ""
|
273 |
+
"If you need help, please check the <a href=\"%s\" rel=\"external\" target="
|
274 |
+
"\"_blank\">plugin support forum</a>."
|
275 |
msgstr ""
|
276 |
|
277 |
+
#: admin/class-whatsappme-admin.php:598
|
278 |
+
msgid "If you like WAme 😍"
|
279 |
msgstr ""
|
280 |
|
281 |
+
#: admin/class-whatsappme-admin.php:601
|
282 |
+
#, php-format
|
283 |
+
msgid "Subscribe to our newsletter and our blog at %s."
|
284 |
msgstr ""
|
285 |
|
286 |
+
#: admin/class-whatsappme-admin.php:605
|
287 |
+
#, php-format
|
288 |
+
msgid "Learn from our tutorials on %s."
|
289 |
msgstr ""
|
290 |
|
291 |
+
#: admin/class-whatsappme-admin.php:609
|
292 |
+
#, php-format
|
293 |
+
msgid "Or rate us on %s."
|
294 |
msgstr ""
|
295 |
|
296 |
+
#: admin/class-whatsappme-admin.php:626
|
297 |
msgid "Settings"
|
298 |
msgstr ""
|
299 |
|
300 |
+
#: admin/class-whatsappme-admin.php:689
|
301 |
+
msgid "WAme chat"
|
302 |
msgstr ""
|
303 |
|
304 |
+
#: admin/class-whatsappme-admin.php:750
|
305 |
+
msgid "You can use vars:"
|
306 |
msgstr ""
|
307 |
|
308 |
+
#: admin/class-whatsappme-admin.php:759
|
309 |
msgid "Default visibility"
|
310 |
msgstr ""
|
311 |
|
312 |
+
#: admin/class-whatsappme-wooadmin.php:108
|
313 |
+
msgid "Shop"
|
314 |
+
msgstr ""
|
315 |
+
|
316 |
+
#: admin/class-whatsappme-wooadmin.php:109
|
317 |
+
msgid "Product Page"
|
318 |
+
msgstr ""
|
319 |
+
|
320 |
+
#: admin/class-whatsappme-wooadmin.php:110
|
321 |
+
msgid "Cart"
|
322 |
+
msgstr ""
|
323 |
+
|
324 |
+
#: admin/class-whatsappme-wooadmin.php:111
|
325 |
+
msgid "Checkout"
|
326 |
+
msgstr ""
|
327 |
+
|
328 |
+
#: admin/class-whatsappme-wooadmin.php:112
|
329 |
+
msgid "My Account"
|
330 |
+
msgstr ""
|
331 |
+
|
332 |
+
#: admin/class-whatsappme-wooadmin.php:147
|
333 |
+
msgid "WooCommerce"
|
334 |
+
msgstr ""
|
335 |
+
|
336 |
+
#: admin/class-whatsappme-wooadmin.php:151
|
337 |
+
msgid "Product Chat Window"
|
338 |
+
msgstr ""
|
339 |
+
|
340 |
+
#: admin/class-whatsappme-wooadmin.php:153
|
341 |
+
msgid ""
|
342 |
+
"You can define other different texts for the Chat Window on the product "
|
343 |
+
"pages."
|
344 |
+
msgstr ""
|
345 |
+
|
346 |
+
#: admin/class-whatsappme-wooadmin.php:179
|
347 |
+
msgid ""
|
348 |
+
"This *{PRODUCT}* can be yours for only *{PRICE}*!\n"
|
349 |
+
"If you have any questions, ask us."
|
350 |
+
msgstr ""
|
351 |
+
|
352 |
+
#: admin/class-whatsappme-wooadmin.php:181
|
353 |
+
msgid ""
|
354 |
+
"Define a text to encourage clients to contact by WhatsApp "
|
355 |
+
"<strong>(optional)</strong>"
|
356 |
+
msgstr ""
|
357 |
+
|
358 |
+
#: admin/class-whatsappme-wooadmin.php:186
|
359 |
+
msgid ""
|
360 |
+
"*Hi {SITE}!*\n"
|
361 |
+
"I have a question about *{PRODUCT} ({SKU})*"
|
362 |
+
msgstr ""
|
363 |
+
|
364 |
+
#: admin/class-whatsappme-wooadmin.php:187
|
365 |
+
msgid ""
|
366 |
+
"Predefined text with which client can start the conversation "
|
367 |
+
"<strong>(optional)</strong>"
|
368 |
+
msgstr ""
|
369 |
+
|
370 |
+
#: admin/class-whatsappme-wooadmin.php:222
|
371 |
+
msgid "<strong>WooCommerce</strong>, in product pages you can also use:"
|
372 |
+
msgstr ""
|
373 |
+
|
374 |
+
#: admin/class-whatsappme-wooadmin.php:224
|
375 |
+
msgid "Product Name"
|
376 |
+
msgstr ""
|
377 |
+
|
378 |
+
#: public/class-whatsappme-public.php:219
|
379 |
msgid "Powered by"
|
380 |
msgstr ""
|
public/class-whatsappme-public.php
CHANGED
@@ -6,6 +6,8 @@
|
|
6 |
* Defines the plugin name, version, and two examples hooks for how to
|
7 |
* enqueue the public-facing stylesheet and JavaScript.
|
8 |
*
|
|
|
|
|
9 |
* @package WhatsAppMe
|
10 |
* @subpackage WhatsAppMe/public
|
11 |
* @author Creame <hola@crea.me>
|
@@ -39,6 +41,15 @@ class WhatsAppMe_Public {
|
|
39 |
*/
|
40 |
private $settings;
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
/**
|
43 |
* Initialize the class and set its properties.
|
44 |
*
|
@@ -46,26 +57,17 @@ class WhatsAppMe_Public {
|
|
46 |
* @since 2.0.0 Added visibility setting
|
47 |
* @since 2.1.0 Added message_badge
|
48 |
* @since 2.3.0 Added button_delay and whatsapp_web settings, message_delay in seconds
|
49 |
-
* @param string
|
50 |
-
* @param string
|
51 |
*/
|
52 |
public function __construct( $plugin_name, $version ) {
|
53 |
|
54 |
$this->plugin_name = $plugin_name;
|
55 |
-
$this->version
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
'button_delay' => 3,
|
61 |
-
'whatsapp_web' => false,
|
62 |
-
'message_text' => '',
|
63 |
-
'message_delay' => 10,
|
64 |
-
'message_badge' => 'no',
|
65 |
-
'message_send' => '',
|
66 |
-
'position' => 'right',
|
67 |
-
'visibility' => array( 'all' => 'yes' ),
|
68 |
-
);
|
69 |
|
70 |
}
|
71 |
|
@@ -76,21 +78,37 @@ class WhatsAppMe_Public {
|
|
76 |
* @since 2.0.0 Check visibility
|
77 |
* @since 2.2.0 Post settings can also change "telephone". Added 'whastapp_web' setting
|
78 |
* @since 2.3.0 Fix global $post incorrect post id on loops. WPML integration.
|
|
|
79 |
* @return void
|
80 |
*/
|
81 |
public function get_settings() {
|
82 |
|
83 |
// If use "global $post;" take first post in loop on archive pages
|
84 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
-
$
|
87 |
|
88 |
-
if ( is_array( $
|
89 |
// Clean unused saved settings
|
90 |
-
$settings = array_intersect_key( $
|
91 |
// Merge defaults with saved settings
|
92 |
-
$settings = array_merge( $
|
93 |
-
|
94 |
// miliseconds (<v2.3) to seconds
|
95 |
if ( $settings['message_delay'] > 120 ) {
|
96 |
$settings['message_delay'] = round( $settings['message_delay'] / 1000 );
|
@@ -100,8 +118,12 @@ class WhatsAppMe_Public {
|
|
100 |
$settings['message_text'] = apply_filters( 'wpml_translate_single_string', $settings['message_text'], 'WhatsApp me', 'Call To Action' );
|
101 |
$settings['message_send'] = apply_filters( 'wpml_translate_single_string', $settings['message_send'], 'WhatsApp me', 'Message' );
|
102 |
|
103 |
-
//
|
104 |
-
|
|
|
|
|
|
|
|
|
105 |
|
106 |
if ( is_array( $post_settings ) ) {
|
107 |
// Move old 'hide' to new 'view' field
|
@@ -115,31 +137,38 @@ class WhatsAppMe_Public {
|
|
115 |
|
116 |
// Prepare settings
|
117 |
$settings['telephone'] = preg_replace( '/^0+|\D/', '', $settings['telephone'] );
|
118 |
-
$settings['
|
119 |
-
$settings['
|
120 |
-
$settings['message_badge'] = $settings['
|
|
|
121 |
$settings['message_send'] = $this->replace_message_variables( $settings['message_send'] );
|
122 |
-
|
123 |
-
$settings['
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
}
|
|
|
129 |
unset( $settings['view'] );
|
130 |
|
131 |
-
// Set true to link http://web.whatsapp.com instead http://api.whatsapp.com
|
132 |
-
$settings['whatsapp_web'] = apply_filters( 'whatsappme_whatsapp_web', $settings['whatsapp_web'] == 'yes' );
|
133 |
-
|
134 |
$this->settings = $settings;
|
135 |
}
|
136 |
|
137 |
-
// Apply
|
138 |
-
$this->settings = apply_filters( 'whatsappme_get_settings', $this->settings, $
|
|
|
|
|
139 |
|
140 |
// Ensure not show if not phone
|
141 |
-
if (
|
142 |
-
$this->
|
143 |
}
|
144 |
}
|
145 |
|
@@ -151,7 +180,7 @@ class WhatsAppMe_Public {
|
|
151 |
*/
|
152 |
public function enqueue_styles() {
|
153 |
|
154 |
-
if ( $this->
|
155 |
$styles = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'whatsappme.css' : 'whatsappme.min.css';
|
156 |
wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/' . $styles, array(), $this->version, 'all' );
|
157 |
}
|
@@ -166,7 +195,7 @@ class WhatsAppMe_Public {
|
|
166 |
*/
|
167 |
public function enqueue_scripts() {
|
168 |
|
169 |
-
if ( $this->
|
170 |
$script = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'whatsappme.js' : 'whatsappme.min.js';
|
171 |
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/' . $script, array( 'jquery' ), $this->version, true );
|
172 |
}
|
@@ -181,16 +210,17 @@ class WhatsAppMe_Public {
|
|
181 |
public function footer_html() {
|
182 |
global $wp;
|
183 |
|
184 |
-
if ( $this->
|
185 |
|
186 |
// Clean unnecessary settings on front
|
187 |
-
$
|
|
|
188 |
|
189 |
$copy = apply_filters( 'whatsappme_copy', __( 'Powered by', 'creame-whatsapp-me' ) );
|
190 |
|
191 |
-
$
|
192 |
-
$
|
193 |
-
$
|
194 |
|
195 |
?>
|
196 |
<div class="whatsappme <?php echo apply_filters( 'whatsappme_classes', "whatsappme--{$this->settings['position']}" ); ?>" data-settings="<?php echo esc_attr( json_encode( $data ) ); ?>">
|
@@ -200,16 +230,20 @@ class WhatsAppMe_Public {
|
|
200 |
<path class="wame_plain" stroke-dasharray="1096.67" stroke-dashoffset="1096.67" d="M168.83 200.504H79.218L33.04 44.284a1 1 0 0 1 1.386-1.188L365.083 199.04a1 1 0 0 1 .003 1.808L34.432 357.903a1 1 0 0 1-1.388-1.187l29.42-99.427"/>
|
201 |
<path class="wame_chat" stroke-dasharray="1019.22" stroke-dashoffset="1019.22" d="M318.087 318.087c-52.982 52.982-132.708 62.922-195.725 29.82l-80.449 10.18 10.358-80.112C18.956 214.905 28.836 134.99 81.913 81.913c65.218-65.217 170.956-65.217 236.174 0 42.661 42.661 57.416 102.661 44.265 157.316"/>
|
202 |
</svg>
|
203 |
-
<?php if ($this->settings['message_badge']):
|
|
|
|
|
204 |
</div>
|
205 |
-
<?php if ($this->settings['message_text']): ?>
|
206 |
<div class="whatsappme__box">
|
207 |
<div class="whatsappme__header">
|
208 |
<svg viewBox="0 0 120 28"><path fill="#fff" 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-.3a2 2 0 0 1-.6-.3.7.7 0 0 1-.3-.6c0-.2 0-.4.2-.5l.3-.3h.5l.5-.1c.5 0 .9 0 1.2.3.4.1.6.5.6 1h2.5c0-.6-.2-1.1-.4-1.5a3 3 0 0 0-1-1 4 4 0 0 0-1.3-.5 7.7 7.7 0 0 0-3 0c-.6.1-1 .3-1.4.5l-1 1a3 3 0 0 0-.4 1.5 2 2 0 0 0 1 1.8l1 .5 1.1.3 2.2.6c.6.2.8.5.8 1l-.1.5-.4.4a2 2 0 0 1-.6.2 2.8 2.8 0 0 1-1.4 0 2 2 0 0 1-.6-.3l-.5-.5-.2-.8H77c0 .7.2 1.2.5 1.6.2.5.6.8 1 1 .4.3.9.5 1.4.6a8 8 0 0 0 3.3 0c.5 0 1-.2 1.4-.5a3 3 0 0 0 1-1c.3-.5.4-1 .4-1.6 0-.5 0-.9-.3-1.2zM74.7 8h-2.6v3h-1.7v1.7h1.7v5.8c0 .5 0 .9.2 1.2l.7.7 1 .3a7.8 7.8 0 0 0 2 0h.7v-2.1a3.4 3.4 0 0 1-.8 0l-1-.1-.2-1v-4.8h2V11h-2V8zm-7.6 9v.5l-.3.8-.7.6c-.2.2-.7.2-1.2.2h-.6l-.5-.2a1 1 0 0 1-.4-.4l-.1-.6.1-.6.4-.4.5-.3a4.8 4.8 0 0 1 1.2-.2 8.3 8.3 0 0 0 1.2-.2l.4-.3v1zm2.6 1.5v-5c0-.6 0-1.1-.3-1.5l-1-.8-1.4-.4a10.9 10.9 0 0 0-3.1 0l-1.5.6c-.4.2-.7.6-1 1a3 3 0 0 0-.5 1.5h2.7c0-.5.2-.9.5-1a2 2 0 0 1 1.3-.4h.6l.6.2.3.4.2.7c0 .3 0 .5-.3.6-.1.2-.4.3-.7.4l-1 .1a21.9 21.9 0 0 0-2.4.4l-1 .5c-.3.2-.6.5-.8.9-.2.3-.3.8-.3 1.3s.1 1 .3 1.3c.1.4.4.7.7 1l1 .4c.4.2.9.2 1.3.2a6 6 0 0 0 1.8-.2c.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>
|
209 |
<div class="whatsappme__close"><svg viewBox="0 0 24 24"><path fill="#fff" d="M24 2.4L21.6 0 12 9.6 2.4 0 0 2.4 9.6 12 0 21.6 2.4 24l9.6-9.6 9.6 9.6 2.4-2.4-9.6-9.6L24 2.4z"/></svg></div>
|
210 |
</div>
|
211 |
<div class="whatsappme__message"><?php echo $this->formated_message(); ?></div>
|
212 |
-
<?php if (
|
|
|
|
|
213 |
</div>
|
214 |
<?php endif; ?>
|
215 |
</div>
|
@@ -229,18 +263,20 @@ class WhatsAppMe_Public {
|
|
229 |
*/
|
230 |
public function formated_message() {
|
231 |
|
232 |
-
$replacements = apply_filters(
|
233 |
-
'
|
234 |
-
|
235 |
-
|
236 |
-
|
|
|
|
|
237 |
|
238 |
$replacements_keys = array_keys( $replacements );
|
239 |
|
240 |
// Split text into lines and apply replacements line by line
|
241 |
$lines = explode( "\n", $this->settings['message_text'] );
|
242 |
-
foreach ($lines as $key => $line) {
|
243 |
-
$lines[$key] = preg_replace( $replacements_keys, $replacements, esc_html( $line ) );
|
244 |
}
|
245 |
|
246 |
return $this->replace_message_variables( implode( '<br>', $lines ) );
|
@@ -257,11 +293,13 @@ class WhatsAppMe_Public {
|
|
257 |
public function replace_message_variables( $string ) {
|
258 |
global $wp;
|
259 |
|
260 |
-
$replacements = apply_filters(
|
261 |
-
'
|
262 |
-
|
263 |
-
|
264 |
-
|
|
|
|
|
265 |
|
266 |
return preg_replace( array_keys( $replacements ), $replacements, $string );
|
267 |
|
@@ -280,12 +318,12 @@ class WhatsAppMe_Public {
|
|
280 |
} elseif ( is_tax() ) {
|
281 |
$title = single_term_title( '', false );
|
282 |
} elseif ( function_exists( 'wp_get_document_title' ) ) {
|
283 |
-
$title
|
284 |
|
285 |
// Try to remove sitename from $title for cleaner title
|
286 |
$sep = apply_filters( 'document_title_separator', '-' );
|
287 |
$site = get_bloginfo( 'name', 'display' );
|
288 |
-
$title = str_replace( esc_html( convert_chars( wptexturize( " $sep " . $site ) ) ), '', $title);
|
289 |
} else {
|
290 |
$title = get_bloginfo( 'name' );
|
291 |
}
|
@@ -298,55 +336,33 @@ class WhatsAppMe_Public {
|
|
298 |
* Check visibility on current page
|
299 |
*
|
300 |
* @since 2.0.0
|
301 |
-
* @
|
|
|
302 |
* @return boolean is visible or not on current page
|
303 |
*/
|
304 |
-
public function check_visibility($options) {
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
|
306 |
-
$global = isset( $options['all'] ) ? $options['all']
|
307 |
|
308 |
// Check front page
|
309 |
if ( is_front_page() ) {
|
310 |
-
return isset( $options['front_page'] ) ? $options['front_page']
|
311 |
}
|
312 |
|
313 |
// Check blog page
|
314 |
if ( is_home() ) {
|
315 |
-
return isset( $options['blog_page'] ) ? $options['blog_page']
|
316 |
}
|
317 |
|
318 |
// Check 404 page
|
319 |
if ( is_404() ) {
|
320 |
-
return isset( $options['404_page'] ) ? $options['404_page']
|
321 |
-
}
|
322 |
-
|
323 |
-
// Check WooCommerce
|
324 |
-
if ( class_exists( 'WooCommerce' ) ) {
|
325 |
-
$woo = isset( $options['woocommerce'] ) ? $options['woocommerce'] == 'yes' : $global;
|
326 |
-
|
327 |
-
// Product page
|
328 |
-
if ( is_product() ) {
|
329 |
-
return isset( $options['product'] ) ? $options['product'] == 'yes' : $woo;
|
330 |
-
}
|
331 |
-
|
332 |
-
// Cart page
|
333 |
-
if ( is_cart() ) {
|
334 |
-
return isset( $options['cart'] ) ? $options['cart'] == 'yes' : $woo;
|
335 |
-
}
|
336 |
-
|
337 |
-
// Checkout page
|
338 |
-
if ( is_checkout() ) {
|
339 |
-
return isset( $options['checkout'] ) ? $options['checkout'] == 'yes' : $woo;
|
340 |
-
}
|
341 |
-
|
342 |
-
// Customer account pages
|
343 |
-
if ( is_account_page() ) {
|
344 |
-
return isset( $options['account_page'] ) ? $options['account_page'] == 'yes': $woo;
|
345 |
-
}
|
346 |
-
|
347 |
-
if ( is_woocommerce() ) {
|
348 |
-
return $woo;
|
349 |
-
}
|
350 |
}
|
351 |
|
352 |
// Check Custom Post Types
|
@@ -355,7 +371,7 @@ class WhatsAppMe_Public {
|
|
355 |
if ( substr( $cpt, 0, 4 ) == 'cpt_' ) {
|
356 |
$cpt = substr( $cpt, 4 );
|
357 |
if ( is_singular( $cpt ) || is_post_type_archive( $cpt ) ) {
|
358 |
-
return
|
359 |
}
|
360 |
}
|
361 |
}
|
@@ -363,7 +379,7 @@ class WhatsAppMe_Public {
|
|
363 |
|
364 |
// Search results
|
365 |
if ( is_search() ) {
|
366 |
-
return isset( $options['search'] ) ? $options['search']
|
367 |
}
|
368 |
|
369 |
// Check archives
|
@@ -371,15 +387,15 @@ class WhatsAppMe_Public {
|
|
371 |
|
372 |
// Date archive
|
373 |
if ( isset( $options['date'] ) && is_date() ) {
|
374 |
-
return $options['date']
|
375 |
}
|
376 |
|
377 |
// Author archive
|
378 |
if ( isset( $options['author'] ) && is_author() ) {
|
379 |
-
return $options['author']
|
380 |
}
|
381 |
|
382 |
-
return isset( $options['archive'] ) ? $options['archive']
|
383 |
}
|
384 |
|
385 |
// Check singular
|
@@ -387,15 +403,15 @@ class WhatsAppMe_Public {
|
|
387 |
|
388 |
// Page
|
389 |
if ( isset( $options['page'] ) && is_page() ) {
|
390 |
-
return $options['page']
|
391 |
}
|
392 |
|
393 |
// Post (or other custom posts)
|
394 |
if ( isset( $options['post'] ) && is_single() ) {
|
395 |
-
return $options['post']
|
396 |
}
|
397 |
|
398 |
-
return isset( $options['singular'] ) ? $options['singular']
|
399 |
}
|
400 |
|
401 |
return $global;
|
@@ -408,9 +424,10 @@ class WhatsAppMe_Public {
|
|
408 |
* @since 2.2.3
|
409 |
* @param object /Elementor/Preview instance
|
410 |
*/
|
411 |
-
public function elementor_preview_disable($elementor_preview) {
|
412 |
|
413 |
-
$this->
|
414 |
|
415 |
}
|
|
|
416 |
}
|
6 |
* Defines the plugin name, version, and two examples hooks for how to
|
7 |
* enqueue the public-facing stylesheet and JavaScript.
|
8 |
*
|
9 |
+
* @since 1.0.0
|
10 |
+
* @since 3.0.0 Added $show property and more hooks
|
11 |
* @package WhatsAppMe
|
12 |
* @subpackage WhatsAppMe/public
|
13 |
* @author Creame <hola@crea.me>
|
41 |
*/
|
42 |
private $settings;
|
43 |
|
44 |
+
/**
|
45 |
+
* Show WhatsApp button in front.
|
46 |
+
*
|
47 |
+
* @since 3.0.0
|
48 |
+
* @access private
|
49 |
+
* @var bool $show Show button on front.
|
50 |
+
*/
|
51 |
+
private $show;
|
52 |
+
|
53 |
/**
|
54 |
* Initialize the class and set its properties.
|
55 |
*
|
57 |
* @since 2.0.0 Added visibility setting
|
58 |
* @since 2.1.0 Added message_badge
|
59 |
* @since 2.3.0 Added button_delay and whatsapp_web settings, message_delay in seconds
|
60 |
+
* @param string $plugin_name The name of the plugin.
|
61 |
+
* @param string $version The version of this plugin.
|
62 |
*/
|
63 |
public function __construct( $plugin_name, $version ) {
|
64 |
|
65 |
$this->plugin_name = $plugin_name;
|
66 |
+
$this->version = $version;
|
67 |
+
|
68 |
+
// Updated in get_settings() at 'wp' hook
|
69 |
+
$this->show = false;
|
70 |
+
$this->settings = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
}
|
73 |
|
78 |
* @since 2.0.0 Check visibility
|
79 |
* @since 2.2.0 Post settings can also change "telephone". Added 'whastapp_web' setting
|
80 |
* @since 2.3.0 Fix global $post incorrect post id on loops. WPML integration.
|
81 |
+
* @since 3.0.0 New filters.
|
82 |
* @return void
|
83 |
*/
|
84 |
public function get_settings() {
|
85 |
|
86 |
// If use "global $post;" take first post in loop on archive pages
|
87 |
+
$obj = get_queried_object();
|
88 |
+
|
89 |
+
$default_settings = array_merge(
|
90 |
+
array(
|
91 |
+
'telephone' => '',
|
92 |
+
'mobile_only' => 'no',
|
93 |
+
'button_delay' => 3,
|
94 |
+
'whatsapp_web' => 'no',
|
95 |
+
'message_text' => '',
|
96 |
+
'message_delay' => 10,
|
97 |
+
'message_badge' => 'no',
|
98 |
+
'message_send' => '',
|
99 |
+
'position' => 'right',
|
100 |
+
'visibility' => array( 'all' => 'yes' ),
|
101 |
+
),
|
102 |
+
apply_filters( 'whatsappme_extra_settings', array() )
|
103 |
+
);
|
104 |
|
105 |
+
$site_settings = get_option( 'whatsappme' );
|
106 |
|
107 |
+
if ( is_array( $site_settings ) ) {
|
108 |
// Clean unused saved settings
|
109 |
+
$settings = array_intersect_key( $site_settings, $default_settings );
|
110 |
// Merge defaults with saved settings
|
111 |
+
$settings = array_merge( $default_settings, $settings );
|
|
|
112 |
// miliseconds (<v2.3) to seconds
|
113 |
if ( $settings['message_delay'] > 120 ) {
|
114 |
$settings['message_delay'] = round( $settings['message_delay'] / 1000 );
|
118 |
$settings['message_text'] = apply_filters( 'wpml_translate_single_string', $settings['message_text'], 'WhatsApp me', 'Call To Action' );
|
119 |
$settings['message_send'] = apply_filters( 'wpml_translate_single_string', $settings['message_send'], 'WhatsApp me', 'Message' );
|
120 |
|
121 |
+
// Filter for site settings (can be overriden by post settings)
|
122 |
+
// You can translate more WPML strings or add/change other settings
|
123 |
+
$settings = apply_filters( 'whatsappme_get_settings_site', $settings, $obj );
|
124 |
+
|
125 |
+
// Post custom settings override site settings
|
126 |
+
$post_settings = is_a( $obj, 'WP_Post' ) ? get_post_meta( $obj->ID, '_whatsappme', true ) : '';
|
127 |
|
128 |
if ( is_array( $post_settings ) ) {
|
129 |
// Move old 'hide' to new 'view' field
|
137 |
|
138 |
// Prepare settings
|
139 |
$settings['telephone'] = preg_replace( '/^0+|\D/', '', $settings['telephone'] );
|
140 |
+
$settings['mobile_only'] = 'yes' == $settings['mobile_only'];
|
141 |
+
$settings['whatsapp_web'] = 'yes' == $settings['whatsapp_web'];
|
142 |
+
$settings['message_badge'] = 'yes' == $settings['message_badge'] && '' != $settings['message_text'];
|
143 |
+
$settings['position'] = 'right' == $settings['position'] ? 'right' : 'left';
|
144 |
$settings['message_send'] = $this->replace_message_variables( $settings['message_send'] );
|
145 |
+
// Set true to link http://web.whatsapp.com instead http://api.whatsapp.com
|
146 |
+
$settings['whatsapp_web'] = apply_filters( 'whatsappme_whatsapp_web', 'yes' == $settings['whatsapp_web'] );
|
147 |
+
|
148 |
+
// Only show if there is a phone number
|
149 |
+
if ( '' != $settings['telephone'] ) {
|
150 |
+
if ( isset( $settings['view'] ) && 'yes' == $settings['view'] ) {
|
151 |
+
$this->show = true;
|
152 |
+
} elseif ( isset( $settings['view'] ) && 'no' == $settings['view'] ) {
|
153 |
+
$this->show = false;
|
154 |
+
} else {
|
155 |
+
$this->show = $this->check_visibility( $settings['visibility'] );
|
156 |
+
}
|
157 |
}
|
158 |
+
// Unset post 'view' setting
|
159 |
unset( $settings['view'] );
|
160 |
|
|
|
|
|
|
|
161 |
$this->settings = $settings;
|
162 |
}
|
163 |
|
164 |
+
// Apply filters to final settings after site and post settings
|
165 |
+
$this->settings = apply_filters( 'whatsappme_get_settings', $this->settings, $obj );
|
166 |
+
// Apply filters to alter 'show' value
|
167 |
+
$this->show = apply_filters( 'whatsappme_show', $this->show, $this->settings, $obj );
|
168 |
|
169 |
// Ensure not show if not phone
|
170 |
+
if ( '' == $this->settings['telephone'] ) {
|
171 |
+
$this->show = false;
|
172 |
}
|
173 |
}
|
174 |
|
180 |
*/
|
181 |
public function enqueue_styles() {
|
182 |
|
183 |
+
if ( $this->show ) {
|
184 |
$styles = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'whatsappme.css' : 'whatsappme.min.css';
|
185 |
wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/' . $styles, array(), $this->version, 'all' );
|
186 |
}
|
195 |
*/
|
196 |
public function enqueue_scripts() {
|
197 |
|
198 |
+
if ( $this->show ) {
|
199 |
$script = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'whatsappme.js' : 'whatsappme.min.js';
|
200 |
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/' . $script, array( 'jquery' ), $this->version, true );
|
201 |
}
|
210 |
public function footer_html() {
|
211 |
global $wp;
|
212 |
|
213 |
+
if ( $this->show ) {
|
214 |
|
215 |
// Clean unnecessary settings on front
|
216 |
+
$excluded_fields = apply_filters( 'whatsappme_excluded_fields', array( 'visibility', 'position' ) );
|
217 |
+
$data = array_diff_key( $this->settings, array_flip( $excluded_fields ) );
|
218 |
|
219 |
$copy = apply_filters( 'whatsappme_copy', __( 'Powered by', 'creame-whatsapp-me' ) );
|
220 |
|
221 |
+
$powered_url = urlencode( home_url( $wp->request ) );
|
222 |
+
$powered_site = urlencode( get_bloginfo( 'name' ) );
|
223 |
+
$powered_link = "https://wame.chat/powered/?site={$powered_site}&url={$powered_url}";
|
224 |
|
225 |
?>
|
226 |
<div class="whatsappme <?php echo apply_filters( 'whatsappme_classes', "whatsappme--{$this->settings['position']}" ); ?>" data-settings="<?php echo esc_attr( json_encode( $data ) ); ?>">
|
230 |
<path class="wame_plain" stroke-dasharray="1096.67" stroke-dashoffset="1096.67" d="M168.83 200.504H79.218L33.04 44.284a1 1 0 0 1 1.386-1.188L365.083 199.04a1 1 0 0 1 .003 1.808L34.432 357.903a1 1 0 0 1-1.388-1.187l29.42-99.427"/>
|
231 |
<path class="wame_chat" stroke-dasharray="1019.22" stroke-dashoffset="1019.22" d="M318.087 318.087c-52.982 52.982-132.708 62.922-195.725 29.82l-80.449 10.18 10.358-80.112C18.956 214.905 28.836 134.99 81.913 81.913c65.218-65.217 170.956-65.217 236.174 0 42.661 42.661 57.416 102.661 44.265 157.316"/>
|
232 |
</svg>
|
233 |
+
<?php if ( $this->settings['message_badge'] ) : ?>
|
234 |
+
<div class="whatsappme__badge">1</div>
|
235 |
+
<?php endif; ?>
|
236 |
</div>
|
237 |
+
<?php if ( $this->settings['message_text'] ) : ?>
|
238 |
<div class="whatsappme__box">
|
239 |
<div class="whatsappme__header">
|
240 |
<svg viewBox="0 0 120 28"><path fill="#fff" 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-.3a2 2 0 0 1-.6-.3.7.7 0 0 1-.3-.6c0-.2 0-.4.2-.5l.3-.3h.5l.5-.1c.5 0 .9 0 1.2.3.4.1.6.5.6 1h2.5c0-.6-.2-1.1-.4-1.5a3 3 0 0 0-1-1 4 4 0 0 0-1.3-.5 7.7 7.7 0 0 0-3 0c-.6.1-1 .3-1.4.5l-1 1a3 3 0 0 0-.4 1.5 2 2 0 0 0 1 1.8l1 .5 1.1.3 2.2.6c.6.2.8.5.8 1l-.1.5-.4.4a2 2 0 0 1-.6.2 2.8 2.8 0 0 1-1.4 0 2 2 0 0 1-.6-.3l-.5-.5-.2-.8H77c0 .7.2 1.2.5 1.6.2.5.6.8 1 1 .4.3.9.5 1.4.6a8 8 0 0 0 3.3 0c.5 0 1-.2 1.4-.5a3 3 0 0 0 1-1c.3-.5.4-1 .4-1.6 0-.5 0-.9-.3-1.2zM74.7 8h-2.6v3h-1.7v1.7h1.7v5.8c0 .5 0 .9.2 1.2l.7.7 1 .3a7.8 7.8 0 0 0 2 0h.7v-2.1a3.4 3.4 0 0 1-.8 0l-1-.1-.2-1v-4.8h2V11h-2V8zm-7.6 9v.5l-.3.8-.7.6c-.2.2-.7.2-1.2.2h-.6l-.5-.2a1 1 0 0 1-.4-.4l-.1-.6.1-.6.4-.4.5-.3a4.8 4.8 0 0 1 1.2-.2 8.3 8.3 0 0 0 1.2-.2l.4-.3v1zm2.6 1.5v-5c0-.6 0-1.1-.3-1.5l-1-.8-1.4-.4a10.9 10.9 0 0 0-3.1 0l-1.5.6c-.4.2-.7.6-1 1a3 3 0 0 0-.5 1.5h2.7c0-.5.2-.9.5-1a2 2 0 0 1 1.3-.4h.6l.6.2.3.4.2.7c0 .3 0 .5-.3.6-.1.2-.4.3-.7.4l-1 .1a21.9 21.9 0 0 0-2.4.4l-1 .5c-.3.2-.6.5-.8.9-.2.3-.3.8-.3 1.3s.1 1 .3 1.3c.1.4.4.7.7 1l1 .4c.4.2.9.2 1.3.2a6 6 0 0 0 1.8-.2c.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>
|
241 |
<div class="whatsappme__close"><svg viewBox="0 0 24 24"><path fill="#fff" d="M24 2.4L21.6 0 12 9.6 2.4 0 0 2.4 9.6 12 0 21.6 2.4 24l9.6-9.6 9.6 9.6 2.4-2.4-9.6-9.6L24 2.4z"/></svg></div>
|
242 |
</div>
|
243 |
<div class="whatsappme__message"><?php echo $this->formated_message(); ?></div>
|
244 |
+
<?php if ( $copy ) : ?>
|
245 |
+
<div class="whatsappme__copy"><?php echo $copy; ?> <a href="<?php echo $powered_link; ?>" rel="nofollow noopener" target="_blank"><svg viewBox="0 0 72 17"><path fill="#fff" fill-rule="evenodd" d="M25.371 10.429l2.122-6.239h.045l2.054 6.239h-4.22zm32.2 2.397c-.439.495-.88.953-1.325 1.375-.797.755-1.332 1.232-1.604 1.43-.622.438-1.156.706-1.604.805-.447.1-.787.13-1.02.09a3.561 3.561 0 0 1-.7-.239c-.66-.318-1.02-.864-1.079-1.64-.058-.774.03-1.619.263-2.533.35-1.987 1.108-4.133 2.274-6.438a73.481 73.481 0 0 0-2.8 3.04c-.816.954-1.7 2.096-2.653 3.428a44.068 44.068 0 0 0-2.77 4.441c-.738 0-1.341-.159-1.808-.477-.427-.278-.748-.695-.962-1.252-.214-.556-.165-1.41.146-2.563l.204-.626c.097-.298.204-.606.32-.924.117-.318.234-.626.35-.924.117-.298.195-.507.234-.626v.06c.272-.756.603-1.56.991-2.415a56.92 56.92 0 0 1 1.4-2.832 62.832 62.832 0 0 0-3.266 3.875 61.101 61.101 0 0 0-2.945 3.995 57.072 57.072 0 0 0-2.886 4.71c-.387 0-.736-.044-1.048-.131l.195.545h-3.72l-1.23-3.786h-6.093L23.158 17h-3.605l6.16-17h3.674l4.357 12.16c.389-1.35.97-2.736 1.74-4.16a41.336 41.336 0 0 0 2.013-4.232.465.465 0 0 0 .058-.18c0-.039.02-.098.058-.178.04-.08.078-.199.117-.358.039-.159.097-.337.175-.536.039-.12.078-.219.117-.298a.465.465 0 0 0 .058-.18c.078-.277.175-.575.292-.893.116-.318.194-.597.233-.835V.25c-.039-.04-.039-.08 0-.119l.233-.12c.117-.039.292.02.525.18.156.08.292.179.408.298.272.199.564.427.875.685.311.259.583.557.816.895a2.9 2.9 0 0 1 .467 1.043c.078.358.039.735-.117 1.133a8.127 8.127 0 0 1-.35.775c0 .08-.038.159-.116.238a2.93 2.93 0 0 1-.175.298 7.05 7.05 0 0 0-.35.656c-.039.04-.058.07-.058.09 0 .02-.02.05-.059.089a61.988 61.988 0 0 1-1.633 2.385c-.544.755-.913 1.35-1.108 1.788a79.39 79.39 0 0 1 3.5-4.233 101.59 101.59 0 0 1 3.12-3.398C45.651 1.82 46.612.986 47.468.43c.739.278 1.341.596 1.808.954.428.318.768.676 1.02 1.073.253.398.244.835-.029 1.312l-1.4 2.325a36.928 36.928 0 0 0-1.749 3.279 53.748 53.748 0 0 1 1.633-1.848 46.815 46.815 0 0 1 4.024-3.875c.7-.597 1.38-1.113 2.041-1.55.739.278 1.341.596 1.808.953.428.318.768.676 1.02 1.073.253.398.243.835-.029 1.312-.155.318-.408.795-.758 1.43a152.853 152.853 0 0 0-2.04 3.846 97.87 97.87 0 0 0-.467.924c-.35.835-.632 1.55-.846 2.146-.214.597-.282.934-.204 1.014a.63.63 0 0 0 .291-.06c.234-.119.564-.348.992-.685.428-.338.875-.736 1.341-1.193.467-.457.914-.914 1.341-1.37.217-.232.409-.45.575-.657a15.4 15.4 0 0 1 .957-2.514c.34-.696.708-1.333 1.108-1.91.399-.576.778-1.044 1.137-1.402a19.553 19.553 0 0 1 1.796-1.7 32.727 32.727 0 0 1 1.497-1.164 8.821 8.821 0 0 1 1.317-.835C66.292.989 66.83.83 67.269.83c.32 0 .649.11.988.328.34.22.649.478.928.776.28.299.519.607.718.925.2.318.3.557.3.716.04.597-.06 1.253-.3 1.97a7.14 7.14 0 0 1-1.107 2.058 8.534 8.534 0 0 1-1.826 1.76 6.522 6.522 0 0 1-2.395 1.074c-.2.08-.36.06-.48-.06a.644.644 0 0 1-.179-.477c0-.358.14-.616.42-.776.837-.318 1.536-.735 2.095-1.253.559-.517.998-1.034 1.317-1.551.4-.597.699-1.213.898-1.85 0-.199-.09-.308-.27-.328a4.173 4.173 0 0 0-.448-.03 4.83 4.83 0 0 0-1.318.597c-.399.239-.848.577-1.347 1.014-.499.438-1.028 1.015-1.586 1.73-.918 1.154-1.587 2.298-2.006 3.432-.42 1.134-.629 1.979-.629 2.536 0 .915.19 1.482.569 1.7.38.22.728.329 1.048.329.638 0 1.347-.15 2.125-.448a16.248 16.248 0 0 0 2.305-1.104 30.05 30.05 0 0 0 2.126-1.342 27.256 27.256 0 0 0 1.646-1.224c.08-.04.18-.1.3-.179l.24-.12a.54.54 0 0 1 .239-.059c.08 0 .16.02.24.06.08.04.119.16.119.358 0 .239-.08.457-.24.656a19.115 19.115 0 0 1-2.245 1.82 35.445 35.445 0 0 1-2.185 1.403c-.759.437-1.497.855-2.215 1.253a8.461 8.461 0 0 1-1.647.387c-.499.06-.968.09-1.407.09-.998 0-1.796-.16-2.395-.477-.599-.319-1.048-.706-1.347-1.164a4.113 4.113 0 0 1-.599-1.372c-.1-.457-.15-.843-.15-1.161zm-42.354-1.111L17.887 0h3.514L17.02 17h-3.56L10.7 5.428h-.046L7.94 17H4.312L0 0h3.582L6.16 11.571h.045L9.035 0h3.354l2.783 11.715h.045z"/></svg></a></div>
|
246 |
+
<?php endif; ?>
|
247 |
</div>
|
248 |
<?php endif; ?>
|
249 |
</div>
|
263 |
*/
|
264 |
public function formated_message() {
|
265 |
|
266 |
+
$replacements = apply_filters(
|
267 |
+
'whatsappme_message_replacements', array(
|
268 |
+
'/_(\S[^_]*\S)_/mu' => '<em>$1</em>',
|
269 |
+
'/\*(\S[^\*]*\S)\*/mu' => '<strong>$1</strong>',
|
270 |
+
'/~(\S[^~]*\S)~/mu' => '<del>$1</del>',
|
271 |
+
)
|
272 |
+
);
|
273 |
|
274 |
$replacements_keys = array_keys( $replacements );
|
275 |
|
276 |
// Split text into lines and apply replacements line by line
|
277 |
$lines = explode( "\n", $this->settings['message_text'] );
|
278 |
+
foreach ( $lines as $key => $line ) {
|
279 |
+
$lines[ $key ] = preg_replace( $replacements_keys, $replacements, esc_html( $line ) );
|
280 |
}
|
281 |
|
282 |
return $this->replace_message_variables( implode( '<br>', $lines ) );
|
293 |
public function replace_message_variables( $string ) {
|
294 |
global $wp;
|
295 |
|
296 |
+
$replacements = apply_filters(
|
297 |
+
'whatsappme_message_send_replacements', array(
|
298 |
+
'/\{SITE\}/i' => get_bloginfo( 'name' ),
|
299 |
+
'/\{URL\}/i' => home_url( $wp->request ),
|
300 |
+
'/\{TITLE\}/i' => $this->get_title(),
|
301 |
+
)
|
302 |
+
);
|
303 |
|
304 |
return preg_replace( array_keys( $replacements ), $replacements, $string );
|
305 |
|
318 |
} elseif ( is_tax() ) {
|
319 |
$title = single_term_title( '', false );
|
320 |
} elseif ( function_exists( 'wp_get_document_title' ) ) {
|
321 |
+
$title = wp_get_document_title();
|
322 |
|
323 |
// Try to remove sitename from $title for cleaner title
|
324 |
$sep = apply_filters( 'document_title_separator', '-' );
|
325 |
$site = get_bloginfo( 'name', 'display' );
|
326 |
+
$title = str_replace( esc_html( convert_chars( wptexturize( " $sep " . $site ) ) ), '', $title );
|
327 |
} else {
|
328 |
$title = get_bloginfo( 'name' );
|
329 |
}
|
336 |
* Check visibility on current page
|
337 |
*
|
338 |
* @since 2.0.0
|
339 |
+
* @since 3.0.0 Added filter to 'whatsappme_visibility'
|
340 |
+
* @param array $options array of visibility settings
|
341 |
* @return boolean is visible or not on current page
|
342 |
*/
|
343 |
+
public function check_visibility( $options ) {
|
344 |
+
|
345 |
+
// Custom visibility, bypass all checks if not null
|
346 |
+
$visibility = apply_filters( 'whatsappme_visibility', null, $options );
|
347 |
+
if ( ! is_null( $visibility ) ) {
|
348 |
+
return $visibility;
|
349 |
+
}
|
350 |
|
351 |
+
$global = isset( $options['all'] ) ? 'yes' == $options['all'] : true;
|
352 |
|
353 |
// Check front page
|
354 |
if ( is_front_page() ) {
|
355 |
+
return isset( $options['front_page'] ) ? 'yes' == $options['front_page'] : $global;
|
356 |
}
|
357 |
|
358 |
// Check blog page
|
359 |
if ( is_home() ) {
|
360 |
+
return isset( $options['blog_page'] ) ? 'yes' == $options['blog_page'] : $global;
|
361 |
}
|
362 |
|
363 |
// Check 404 page
|
364 |
if ( is_404() ) {
|
365 |
+
return isset( $options['404_page'] ) ? 'yes' == $options['404_page'] : $global;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
366 |
}
|
367 |
|
368 |
// Check Custom Post Types
|
371 |
if ( substr( $cpt, 0, 4 ) == 'cpt_' ) {
|
372 |
$cpt = substr( $cpt, 4 );
|
373 |
if ( is_singular( $cpt ) || is_post_type_archive( $cpt ) ) {
|
374 |
+
return 'yes' == $view;
|
375 |
}
|
376 |
}
|
377 |
}
|
379 |
|
380 |
// Search results
|
381 |
if ( is_search() ) {
|
382 |
+
return isset( $options['search'] ) ? 'yes' == $options['search'] : $global;
|
383 |
}
|
384 |
|
385 |
// Check archives
|
387 |
|
388 |
// Date archive
|
389 |
if ( isset( $options['date'] ) && is_date() ) {
|
390 |
+
return 'yes' == $options['date'];
|
391 |
}
|
392 |
|
393 |
// Author archive
|
394 |
if ( isset( $options['author'] ) && is_author() ) {
|
395 |
+
return 'yes' == $options['author'];
|
396 |
}
|
397 |
|
398 |
+
return isset( $options['archive'] ) ? 'yes' == $options['archive'] : $global;
|
399 |
}
|
400 |
|
401 |
// Check singular
|
403 |
|
404 |
// Page
|
405 |
if ( isset( $options['page'] ) && is_page() ) {
|
406 |
+
return 'yes' == $options['page'];
|
407 |
}
|
408 |
|
409 |
// Post (or other custom posts)
|
410 |
if ( isset( $options['post'] ) && is_single() ) {
|
411 |
+
return 'yes' == $options['post'];
|
412 |
}
|
413 |
|
414 |
+
return isset( $options['singular'] ) ? 'yes' == $options['singular'] : $global;
|
415 |
}
|
416 |
|
417 |
return $global;
|
424 |
* @since 2.2.3
|
425 |
* @param object /Elementor/Preview instance
|
426 |
*/
|
427 |
+
public function elementor_preview_disable( $elementor_preview ) {
|
428 |
|
429 |
+
$this->show = apply_filters( 'whatsappme_elementor_preview_show', false );
|
430 |
|
431 |
}
|
432 |
+
|
433 |
}
|
public/class-whatsappme-woopublic.php
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The public-facing functionality of the WooCommerce integration.
|
5 |
+
*
|
6 |
+
* @since 3.0.0
|
7 |
+
* @package WhatsAppMe
|
8 |
+
* @subpackage WhatsAppMe/admin
|
9 |
+
* @author Creame <hola@crea.me>
|
10 |
+
*/
|
11 |
+
class WhatsAppMe_WooPublic {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Initialize all hooks
|
15 |
+
*
|
16 |
+
* @since 3.0.0
|
17 |
+
* @param array $whatsappme WhatsAppMe object.
|
18 |
+
* @return void
|
19 |
+
*/
|
20 |
+
public function init( $whatsappme ) {
|
21 |
+
|
22 |
+
$loader = $whatsappme->get_loader();
|
23 |
+
|
24 |
+
$loader->add_filter( 'whatsappme_extra_settings', $this, 'woo_settings' );
|
25 |
+
$loader->add_filter( 'whatsappme_get_settings_site', $this, 'product_settings' );
|
26 |
+
$loader->add_filter( 'whatsappme_visibility', $this, 'visibility', 10, 2 );
|
27 |
+
$loader->add_filter( 'whatsappme_message_send_replacements', $this, 'replacements' );
|
28 |
+
$loader->add_filter( 'whatsappme_excluded_fields', $this, 'excluded_fields' );
|
29 |
+
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Add WooCommerce settings defaults
|
34 |
+
*
|
35 |
+
* @since 3.0.0
|
36 |
+
* @param array $settings current settings.
|
37 |
+
* @return array
|
38 |
+
*/
|
39 |
+
public function woo_settings( $settings ) {
|
40 |
+
|
41 |
+
$woo_settings = array(
|
42 |
+
'message_text_product' => '',
|
43 |
+
'message_send_product' => '',
|
44 |
+
);
|
45 |
+
|
46 |
+
return array_merge( $settings, $woo_settings );
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Replace general site CTA and send messages with the product ones
|
51 |
+
*
|
52 |
+
* @since 3.0.0
|
53 |
+
* @param array $settings current site settings.
|
54 |
+
* @return array
|
55 |
+
*/
|
56 |
+
public function product_settings( $settings ) {
|
57 |
+
|
58 |
+
// Only applies to product pages
|
59 |
+
if ( is_product() ) {
|
60 |
+
if ( '' != $settings['message_text_product'] ) {
|
61 |
+
$settings['message_text'] = apply_filters(
|
62 |
+
'wpml_translate_single_string', $settings['message_text_product'],
|
63 |
+
'WhatsApp me', 'Call To Action for Products'
|
64 |
+
);
|
65 |
+
}
|
66 |
+
if ( '' != $settings['message_send_product'] ) {
|
67 |
+
$settings['message_send'] = apply_filters(
|
68 |
+
'wpml_translate_single_string', $settings['message_send_product'],
|
69 |
+
'WhatsApp me', 'Message for Products'
|
70 |
+
);
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
return $settings;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Return visibility for Woocommerce pages
|
79 |
+
*
|
80 |
+
* @since 3.0.0
|
81 |
+
* @param null $visibility by default $visibility is null.
|
82 |
+
* @return mixed true or false if WooCommerce page apply else return $visibility.
|
83 |
+
*/
|
84 |
+
public function visibility( $visibility, $options ) {
|
85 |
+
|
86 |
+
$global = isset( $options['all'] ) ? 'yes' == $options['all'] : true;
|
87 |
+
$woo = isset( $options['woocommerce'] ) ? 'yes' == $options['woocommerce'] : $global;
|
88 |
+
|
89 |
+
// Product page
|
90 |
+
if ( is_product() ) {
|
91 |
+
return isset( $options['product'] ) ? 'yes' == $options['product'] : $woo;
|
92 |
+
}
|
93 |
+
|
94 |
+
// Cart page
|
95 |
+
if ( is_cart() ) {
|
96 |
+
return isset( $options['cart'] ) ? 'yes' == $options['cart'] : $woo;
|
97 |
+
}
|
98 |
+
|
99 |
+
// Checkout page
|
100 |
+
if ( is_checkout() ) {
|
101 |
+
return isset( $options['checkout'] ) ? 'yes' == $options['checkout'] : $woo;
|
102 |
+
}
|
103 |
+
|
104 |
+
// Customer account pages
|
105 |
+
if ( is_account_page() ) {
|
106 |
+
return isset( $options['account_page'] ) ? 'yes' == $options['account_page'] : $woo;
|
107 |
+
}
|
108 |
+
|
109 |
+
if ( is_woocommerce() ) {
|
110 |
+
return $woo;
|
111 |
+
}
|
112 |
+
|
113 |
+
return $visibility;
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Woocommerce product replacement for messages
|
118 |
+
*
|
119 |
+
* @since 3.0.0
|
120 |
+
* @param array $replacements current replacements.
|
121 |
+
* @return array
|
122 |
+
*/
|
123 |
+
public function replacements( $replacements ) {
|
124 |
+
|
125 |
+
// Only applies to product pages
|
126 |
+
if ( is_product() ) {
|
127 |
+
$product = wc_get_product();
|
128 |
+
|
129 |
+
$replacements = array_merge(
|
130 |
+
$replacements, array(
|
131 |
+
'/\{PRODUCT\}/i' => $product->get_name(),
|
132 |
+
'/\{SKU\}/i' => $product->get_sku(),
|
133 |
+
'/\{PRICE\}/i' => strip_tags( wc_price( $product->get_price() ) ),
|
134 |
+
)
|
135 |
+
);
|
136 |
+
}
|
137 |
+
|
138 |
+
return $replacements;
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Exclude unnecessary Woocommerce settings in front
|
143 |
+
*
|
144 |
+
* @since 3.0.0
|
145 |
+
* @param array $fields current excluded fields.
|
146 |
+
* @return array
|
147 |
+
*/
|
148 |
+
public function excluded_fields( $fields ) {
|
149 |
+
|
150 |
+
$excluded = array(
|
151 |
+
'message_text_product',
|
152 |
+
'message_send_product',
|
153 |
+
);
|
154 |
+
|
155 |
+
return array_merge( $fields, $excluded );
|
156 |
+
}
|
157 |
+
|
158 |
+
}
|
public/css/whatsappme.css
CHANGED
@@ -195,6 +195,11 @@
|
|
195 |
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
196 |
}
|
197 |
|
|
|
|
|
|
|
|
|
|
|
198 |
.whatsappme__close:hover {
|
199 |
opacity: .6;
|
200 |
}
|
@@ -229,6 +234,12 @@
|
|
229 |
background-size: 100%;
|
230 |
}
|
231 |
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
.whatsappme__copy {
|
233 |
position: absolute;
|
234 |
bottom: 4px;
|
195 |
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
196 |
}
|
197 |
|
198 |
+
[dir=rtl] .whatsappme__close {
|
199 |
+
right: auto;
|
200 |
+
left: 24px;
|
201 |
+
}
|
202 |
+
|
203 |
.whatsappme__close:hover {
|
204 |
opacity: .6;
|
205 |
}
|
234 |
background-size: 100%;
|
235 |
}
|
236 |
|
237 |
+
[dir=rtl] .whatsappme__message:before {
|
238 |
+
left: auto;
|
239 |
+
right: -18px;
|
240 |
+
transform: rotateY(180deg);
|
241 |
+
}
|
242 |
+
|
243 |
.whatsappme__copy {
|
244 |
position: absolute;
|
245 |
bottom: 4px;
|
public/css/whatsappme.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.whatsappme{position:fixed;z-index:400;right:20px;bottom:20px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Open Sans","Helvetica Neue",sans-serif;font-size:16px;line-height:26px;color:#262626;transform:scale3d(0,0,0);transition:transform .3s ease-in-out;user-select:none;-ms-user-select:none;-moz-user-select:none;-webkit-user-select:none}.whatsappme svg path{fill:currentColor!important}.whatsappme--show{transform:scale3d(1,1,1);transition:transform .5s cubic-bezier(.18,.89,.32,1.28)}.whatsappme__button{position:absolute;z-index:2;bottom:8px;right:8px;height:60px;min-width:60px;max-width:95vw;background-color:#25d366;color:#fff;border-radius:30px;box-shadow:1px 6px 24px 0 rgba(7,94,84,.24);cursor:pointer;transition:background-color .2s linear;-webkit-tap-highlight-color:transparent}.whatsappme__button:hover{background-color:#128c7e;transition:background-color 1.5s linear}.whatsappme--dialog .whatsappme__button{background-color:#128c7e;transition:background-color .2s linear}.whatsappme--dialog .whatsappme__button:hover{background-color:#075e54}.whatsappme__button:active{background-color:#075e54;transition:none}@supports (-webkit-overflow-scrolling:touch){.whatsappme--dialog .whatsappme__button{background-color:#34b7f1}.whatsappme--dialog .whatsappme__button:hover,.whatsappme__button:active{background-color:#228bb9}}.whatsappme__button svg{width:36px;height:36px;margin:12px 12px}.whatsappme__badge{position:absolute;top:-4px;right:-4px;width:20px;height:20px;border:none;border-radius:50%;background:#e82c0c;font-size:12px;font-weight:600;line-height:20px;text-align:center;box-shadow:none;opacity:0;pointer-events:none}.whatsappme__badge.whatsappme__badge--in{animation:badge--in .5s cubic-bezier(.27,.9,.41,1.28) 1 both}.whatsappme__badge.whatsappme__badge--out{animation:badge--out .4s cubic-bezier(.215,.61,.355,1) 1 both}.whatsappme--dialog .whatsappme__button{box-shadow:0 1px 2px 0 rgba(0,0,0,.3)}.whatsappme--dialog .whatsappme__button svg{margin:12px 11px 12px 13px}.whatsappme .whatsappme__button__send path{fill:none!important;stroke:#fff!important;animation:wame_plain 6s 0s ease-in-out infinite}.whatsappme .whatsappme__button__send path.wame_chat{animation-name:wame_chat}.whatsappme--dialog .whatsappme__button__send,.whatsappme__button__open{display:block}.whatsappme--dialog .whatsappme__button__open,.whatsappme__button__send{display:none}.whatsappme__box{position:absolute;bottom:0;right:0;z-index:1;width:calc(100vw - 40px);max-width:400px;min-height:280px;padding-bottom:60px;border-radius:32px;background:#ede4dd url(../images/background.webp) center repeat-y;background-size:100% auto;box-shadow:0 2px 6px 0 rgba(0,0,0,.5);overflow:hidden;transform:scale3d(0,0,0);opacity:0;transition:opacity .4s ease-out,transform 0s linear .3s}.nowebp .whatsappme__box{background-image:url(../images/background.png)}.whatsappme--dialog .whatsappme__box{opacity:1;transform:scale3d(1,1,1);transition:opacity .2s ease-out,transform 0s linear}.whatsappme__header{float:none;display:block;position:static;width:100%;height:70px;padding:0 26px;margin:0;background-color:#2e8c7d;color:rgba(255,255,255,.5)}.whatsappme__header svg{width:120px;height:100%}.whatsappme__close{display:flex;position:absolute;top:18px;right:24px;width:34px;height:34px;border-radius:50%;background:#000;color:#fff;text-align:center;opacity:.4;cursor:pointer;transition:opacity .3s ease-out;-webkit-tap-highlight-color:transparent}.whatsappme__close:hover{opacity:.6}.whatsappme__close svg{display:block;width:12px;height:12px;margin:auto}.whatsappme__message{position:relative;min-height:80px;padding:20px 22px;margin:34px 26px;border-radius:32px;background-color:#fff;color:#4a4a4a;box-shadow:0 1px 2px 0 rgba(0,0,0,.3)}.whatsappme__message:before{content:'';display:block;position:absolute;bottom:30px;left:-18px;width:18px;height:18px;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADcAAAA1CAYAAADlE3NNAAAEr0lEQVRo3t2aT0gjVxzHf++9mcn8zWhW6bpELWzcogFNaRar7a4tBNy2WATbHpacpdZ6redeZE+9CL02B1ktXsRD/xwsilhoSwsqag/xYK09hCQlmCiTf28vGRnGmZhE183MFx5vmGQy7zO/P/P7PYLAHUIAQCqDAwDPxMREG3IpHL+zs/MZcgkYAgAMAIwOl8lkYm6xGgYAFgAEAGgZHx9/vVwun7nJJTkAEAGgdW9v73NKKXWLSzIA4AEAGQDazs/P/3ALnNEl1a2trY9oRW6wmu6SEgC0ZrPZn9wCp2dIHgCU1dXVtymlZafDIatEksvlfqYGueG9xgOAcnBw8JSa5GR3vIi1aDTaUSwWj5wOZ3RHPUN6U6nUN9RCTnZHDwDI+/v745TSkpPhrOpHcWlpqbdcLieojZwGpseZMDo66svn87/RKnIaGAsAfCAQ8J6dnX1Pr5DjwABAzmazMVqDHAd2enr6La1RjgGLRCJqLpeL0TrUjFDGrMgCAD8/P38vn8//QutUs1pLT/fC5ubmQKFQOKANqNmspbuhBwDEZDL5BaX0lDaoZoK62NxZXFzs1DRthV5TrxrKGFue/v5+KZ1Of1kul5P0BtQUUAAgxOPx9wuFwl/0BvWq3O8C6vDw8F1N036gL0G3ZaVLUEdHRxFN036kL1E3DWMHxAEAPzc3dyedTk+XSqUdegu6CRijy5mBPLOzs2oikfhU07RFSmmG3qKuaxkdxuhy/MzMjDeRSHyiadrz2wYyClUBMh9bzRfAu7u7PX6//z1RFB9zHBcBALUZKoRqUMgEgyvHeHt7+353d/cjQRBGWJZ9jBDqaMYKHKpYBAEAXltbawsGg2FFUd7iOO4hIeQhQuiOEzpdOzCSTCaftLS0fEUIGXbiHiBjU5njVCr1sc/nW6wkDcduS1u1HKRUKv2KMR4ABwvbAWKMA+BwYbsasFgs/uMWuEtxd3x8/J3b4C4Ag8Hg83g8/iyfz//n5IRi1eZzla00HgA8oijyDMNwlFJCCGH0axiGQQAAXq+XyLLMeL1eRlEURpZlRpIkhud5oigK297eLvl8Prm1tVVSFEWSJEkWRVESBMGrqupriqLcFQThLsaYu612n6vUip4KMFv5HJssjhooEi5laoZh0NjYWNvw8PC9np6ejkAg8MDv9w+oqnrfxsNqhgNTh2wE1MGYChyyWGA9RYJVFWTM3MhwjMPhsDw9PT0QDocHOjs731RV9Y1rv+cMlb4Oiy3garWW1b2sPMfceZgHmZqa6pycnPywr6/vA47jfPXAWbU0xOCOqE44u2K8Wl9oBUfMa+rq6hIWFhbGBwcHn9pBohogcRWwRiCRTUiACQ6ZYpxY9JAkFAopy8vLM4FAYKyRrgA1GGf1JperLGgEM4cNG4vF3olGo18TQkT9JsRmAdQw66NsGlbn7Ibdd0um2XzOblz6/ZWVlX8JIb8PDQ090gFJDU+e2sBeZ1hBU9NcqvIQzDMFALq+vp7GGP85MjLyBCHE1tPO1LP4eq4FG/hqnlGyeSiwsbHxfygUOu7t7Y00059JUY3ZHFm8k1lT0cGfnJw8c0ojepWFzd6CMpnM3y8AJPEkZ9khO4IAAAAASUVORK5CYII=);background-size:100%}.whatsappme__copy{position:absolute;bottom:4px;left:40px;color:#2e8c7d;font-size:11px;letter-spacing:.2px;opacity:.4;transition:opacity .25s}.whatsappme--left .whatsappme__copy{left:auto;right:40px}.whatsappme__copy:hover{opacity:.8;transition:opacity .5s ease-out .5s}.whatsappme__copy a,.whatsappme__copy a:active,.whatsappme__copy a:hover{color:inherit;text-decoration:none}.whatsappme__copy svg{width:40px;height:10px;vertical-align:inherit}.whatsappme--left{right:auto;left:20px}.whatsappme--left .whatsappme__button{right:auto;left:8px}.whatsappme--left .whatsappme__box{right:auto;left:0}@media (max-width:480px){.whatsappme{bottom:6px;right:6px}.whatsappme--left{right:auto;left:6px}.whatsappme__box{width:calc(100vw - 12px);min-height:0}.whatsappme__header{height:55px}.whatsappme__close{top:13px;width:28px;height:28px}.whatsappme__message{padding:14px 20px;margin:15px 21px 20px;line-height:24px}}@keyframes badge--in{from{opacity:0;transform:translateY(50px)}to{opacity:1;transform:translateY(0)}}@keyframes badge--out{from{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-20px)}}@keyframes wame_plain{5%{stroke-dashoffset:0}45%{stroke-dashoffset:0}50%{stroke-dashoffset:1096.67}100%{stroke-dashoffset:1096.67}}@keyframes wame_chat{50%{stroke-dashoffset:1019.22}55%{stroke-dashoffset:0}95%{stroke-dashoffset:0}}
|
1 |
+
.whatsappme{position:fixed;z-index:400;right:20px;bottom:20px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Open Sans","Helvetica Neue",sans-serif;font-size:16px;line-height:26px;color:#262626;transform:scale3d(0,0,0);transition:transform .3s ease-in-out;user-select:none;-ms-user-select:none;-moz-user-select:none;-webkit-user-select:none}.whatsappme svg path{fill:currentColor!important}.whatsappme--show{transform:scale3d(1,1,1);transition:transform .5s cubic-bezier(.18,.89,.32,1.28)}.whatsappme__button{position:absolute;z-index:2;bottom:8px;right:8px;height:60px;min-width:60px;max-width:95vw;background-color:#25d366;color:#fff;border-radius:30px;box-shadow:1px 6px 24px 0 rgba(7,94,84,.24);cursor:pointer;transition:background-color .2s linear;-webkit-tap-highlight-color:transparent}.whatsappme__button:hover{background-color:#128c7e;transition:background-color 1.5s linear}.whatsappme--dialog .whatsappme__button{background-color:#128c7e;transition:background-color .2s linear}.whatsappme--dialog .whatsappme__button:hover{background-color:#075e54}.whatsappme__button:active{background-color:#075e54;transition:none}@supports (-webkit-overflow-scrolling:touch){.whatsappme--dialog .whatsappme__button{background-color:#34b7f1}.whatsappme--dialog .whatsappme__button:hover,.whatsappme__button:active{background-color:#228bb9}}.whatsappme__button svg{width:36px;height:36px;margin:12px 12px}.whatsappme__badge{position:absolute;top:-4px;right:-4px;width:20px;height:20px;border:none;border-radius:50%;background:#e82c0c;font-size:12px;font-weight:600;line-height:20px;text-align:center;box-shadow:none;opacity:0;pointer-events:none}.whatsappme__badge.whatsappme__badge--in{animation:badge--in .5s cubic-bezier(.27,.9,.41,1.28) 1 both}.whatsappme__badge.whatsappme__badge--out{animation:badge--out .4s cubic-bezier(.215,.61,.355,1) 1 both}.whatsappme--dialog .whatsappme__button{box-shadow:0 1px 2px 0 rgba(0,0,0,.3)}.whatsappme--dialog .whatsappme__button svg{margin:12px 11px 12px 13px}.whatsappme .whatsappme__button__send path{fill:none!important;stroke:#fff!important;animation:wame_plain 6s 0s ease-in-out infinite}.whatsappme .whatsappme__button__send path.wame_chat{animation-name:wame_chat}.whatsappme--dialog .whatsappme__button__send,.whatsappme__button__open{display:block}.whatsappme--dialog .whatsappme__button__open,.whatsappme__button__send{display:none}.whatsappme__box{position:absolute;bottom:0;right:0;z-index:1;width:calc(100vw - 40px);max-width:400px;min-height:280px;padding-bottom:60px;border-radius:32px;background:#ede4dd url(../images/background.webp) center repeat-y;background-size:100% auto;box-shadow:0 2px 6px 0 rgba(0,0,0,.5);overflow:hidden;transform:scale3d(0,0,0);opacity:0;transition:opacity .4s ease-out,transform 0s linear .3s}.nowebp .whatsappme__box{background-image:url(../images/background.png)}.whatsappme--dialog .whatsappme__box{opacity:1;transform:scale3d(1,1,1);transition:opacity .2s ease-out,transform 0s linear}.whatsappme__header{float:none;display:block;position:static;width:100%;height:70px;padding:0 26px;margin:0;background-color:#2e8c7d;color:rgba(255,255,255,.5)}.whatsappme__header svg{width:120px;height:100%}.whatsappme__close{display:flex;position:absolute;top:18px;right:24px;width:34px;height:34px;border-radius:50%;background:#000;color:#fff;text-align:center;opacity:.4;cursor:pointer;transition:opacity .3s ease-out;-webkit-tap-highlight-color:transparent}[dir=rtl] .whatsappme__close{right:auto;left:24px}.whatsappme__close:hover{opacity:.6}.whatsappme__close svg{display:block;width:12px;height:12px;margin:auto}.whatsappme__message{position:relative;min-height:80px;padding:20px 22px;margin:34px 26px;border-radius:32px;background-color:#fff;color:#4a4a4a;box-shadow:0 1px 2px 0 rgba(0,0,0,.3)}.whatsappme__message:before{content:'';display:block;position:absolute;bottom:30px;left:-18px;width:18px;height:18px;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADcAAAA1CAYAAADlE3NNAAAEr0lEQVRo3t2aT0gjVxzHf++9mcn8zWhW6bpELWzcogFNaRar7a4tBNy2WATbHpacpdZ6redeZE+9CL02B1ktXsRD/xwsilhoSwsqag/xYK09hCQlmCiTf28vGRnGmZhE183MFx5vmGQy7zO/P/P7PYLAHUIAQCqDAwDPxMREG3IpHL+zs/MZcgkYAgAMAIwOl8lkYm6xGgYAFgAEAGgZHx9/vVwun7nJJTkAEAGgdW9v73NKKXWLSzIA4AEAGQDazs/P/3ALnNEl1a2trY9oRW6wmu6SEgC0ZrPZn9wCp2dIHgCU1dXVtymlZafDIatEksvlfqYGueG9xgOAcnBw8JSa5GR3vIi1aDTaUSwWj5wOZ3RHPUN6U6nUN9RCTnZHDwDI+/v745TSkpPhrOpHcWlpqbdcLieojZwGpseZMDo66svn87/RKnIaGAsAfCAQ8J6dnX1Pr5DjwABAzmazMVqDHAd2enr6La1RjgGLRCJqLpeL0TrUjFDGrMgCAD8/P38vn8//QutUs1pLT/fC5ubmQKFQOKANqNmspbuhBwDEZDL5BaX0lDaoZoK62NxZXFzs1DRthV5TrxrKGFue/v5+KZ1Of1kul5P0BtQUUAAgxOPx9wuFwl/0BvWq3O8C6vDw8F1N036gL0G3ZaVLUEdHRxFN036kL1E3DWMHxAEAPzc3dyedTk+XSqUdegu6CRijy5mBPLOzs2oikfhU07RFSmmG3qKuaxkdxuhy/MzMjDeRSHyiadrz2wYyClUBMh9bzRfAu7u7PX6//z1RFB9zHBcBALUZKoRqUMgEgyvHeHt7+353d/cjQRBGWJZ9jBDqaMYKHKpYBAEAXltbawsGg2FFUd7iOO4hIeQhQuiOEzpdOzCSTCaftLS0fEUIGXbiHiBjU5njVCr1sc/nW6wkDcduS1u1HKRUKv2KMR4ABwvbAWKMA+BwYbsasFgs/uMWuEtxd3x8/J3b4C4Ag8Hg83g8/iyfz//n5IRi1eZzla00HgA8oijyDMNwlFJCCGH0axiGQQAAXq+XyLLMeL1eRlEURpZlRpIkhud5oigK297eLvl8Prm1tVVSFEWSJEkWRVESBMGrqupriqLcFQThLsaYu612n6vUip4KMFv5HJssjhooEi5laoZh0NjYWNvw8PC9np6ejkAg8MDv9w+oqnrfxsNqhgNTh2wE1MGYChyyWGA9RYJVFWTM3MhwjMPhsDw9PT0QDocHOjs731RV9Y1rv+cMlb4Oiy3garWW1b2sPMfceZgHmZqa6pycnPywr6/vA47jfPXAWbU0xOCOqE44u2K8Wl9oBUfMa+rq6hIWFhbGBwcHn9pBohogcRWwRiCRTUiACQ6ZYpxY9JAkFAopy8vLM4FAYKyRrgA1GGf1JperLGgEM4cNG4vF3olGo18TQkT9JsRmAdQw66NsGlbn7Ibdd0um2XzOblz6/ZWVlX8JIb8PDQ090gFJDU+e2sBeZ1hBU9NcqvIQzDMFALq+vp7GGP85MjLyBCHE1tPO1LP4eq4FG/hqnlGyeSiwsbHxfygUOu7t7Y00059JUY3ZHFm8k1lT0cGfnJw8c0ojepWFzd6CMpnM3y8AJPEkZ9khO4IAAAAASUVORK5CYII=);background-size:100%}[dir=rtl] .whatsappme__message:before{left:auto;right:-18px;transform:rotateY(180deg)}.whatsappme__copy{position:absolute;bottom:4px;left:40px;color:#2e8c7d;font-size:11px;letter-spacing:.2px;opacity:.4;transition:opacity .25s}.whatsappme--left .whatsappme__copy{left:auto;right:40px}.whatsappme__copy:hover{opacity:.8;transition:opacity .5s ease-out .5s}.whatsappme__copy a,.whatsappme__copy a:active,.whatsappme__copy a:hover{color:inherit;text-decoration:none}.whatsappme__copy svg{width:40px;height:10px;vertical-align:inherit}.whatsappme--left{right:auto;left:20px}.whatsappme--left .whatsappme__button{right:auto;left:8px}.whatsappme--left .whatsappme__box{right:auto;left:0}@media (max-width:480px){.whatsappme{bottom:6px;right:6px}.whatsappme--left{right:auto;left:6px}.whatsappme__box{width:calc(100vw - 12px);min-height:0}.whatsappme__header{height:55px}.whatsappme__close{top:13px;width:28px;height:28px}.whatsappme__message{padding:14px 20px;margin:15px 21px 20px;line-height:24px}}@keyframes badge--in{from{opacity:0;transform:translateY(50px)}to{opacity:1;transform:translateY(0)}}@keyframes badge--out{from{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-20px)}}@keyframes wame_plain{5%{stroke-dashoffset:0}45%{stroke-dashoffset:0}50%{stroke-dashoffset:1096.67}100%{stroke-dashoffset:1096.67}}@keyframes wame_chat{50%{stroke-dashoffset:1019.22}55%{stroke-dashoffset:0}95%{stroke-dashoffset:0}}
|
public/index.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php // Silence is golden
|
1 |
+
<?php // Silence is golden
|
public/js/whatsappme.js
CHANGED
@@ -80,16 +80,26 @@
|
|
80 |
}
|
81 |
|
82 |
$('.whatsappme__button', $whatsappme).click(function () {
|
83 |
-
var link = whatsapp_link(wa_web, wame_settings.telephone, wame_settings.message_send);
|
84 |
-
|
85 |
if (has_cta && !$whatsappme.hasClass('whatsappme--dialog')) {
|
86 |
show_dialog();
|
87 |
} else {
|
|
|
|
|
|
|
88 |
$whatsappme.removeClass('whatsappme--dialog');
|
89 |
save_message_viewed();
|
90 |
-
|
91 |
-
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
}
|
94 |
});
|
95 |
|
80 |
}
|
81 |
|
82 |
$('.whatsappme__button', $whatsappme).click(function () {
|
|
|
|
|
83 |
if (has_cta && !$whatsappme.hasClass('whatsappme--dialog')) {
|
84 |
show_dialog();
|
85 |
} else {
|
86 |
+
var args = { link: whatsapp_link(wa_web, wame_settings.telephone, wame_settings.message_send) };
|
87 |
+
var secure_link = new RegExp("^https?:\/\/(wa\.me|(api|web|chat)\.whatsapp\.com|" + location.hostname.replace('.', '\.') + ")\/.*", 'i');
|
88 |
+
|
89 |
$whatsappme.removeClass('whatsappme--dialog');
|
90 |
save_message_viewed();
|
91 |
+
// Trigger custom event (args obj allow edit link by third party scripts)
|
92 |
+
$(document).trigger('whatsappme:open', [args, wame_settings]);
|
93 |
+
|
94 |
+
// Ensure the link is safe
|
95 |
+
if (secure_link.test(args.link)) {
|
96 |
+
// Send analytics events
|
97 |
+
send_event(args.link);
|
98 |
+
// Open WhatsApp link
|
99 |
+
window.open(args.link, 'whatsappme');
|
100 |
+
} else {
|
101 |
+
console.error("WAme: the link doesn't seem safe, it must point to the current domain or whatsapp.com")
|
102 |
+
}
|
103 |
}
|
104 |
});
|
105 |
|
public/js/whatsappme.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e){"use strict";e(function(){var
|
1 |
+
!function(e){"use strict";function t(e,t,a){return(e?"https://web.whatsapp.com/send":"https://api.whatsapp.com/send")+"?phone="+encodeURIComponent(t)+"&text="+encodeURIComponent(a||"")}e(function(){var a,s=e(".whatsappme"),n=s.find(".whatsappme__badge"),o=s.data("settings");try{localStorage.setItem("test",1),localStorage.removeItem("test"),a=localStorage}catch(e){a={_data:{},setItem:function(e,t){this._data[e]=String(t)},getItem:function(e){return this._data.hasOwnProperty(e)?this._data[e]:null}}}if(void 0===o)try{o=JSON.parse(s.attr("data-settings"))}catch(e){o=void 0}s.length&&o&&o.telephone&&function(){var i,p,l,m,c=!!navigator.userAgent.match(/Android|iPhone|BlackBerry|IEMobile|Opera Mini/i),r=1e3*o.button_delay,h=""!==o.message_text,d=o.whatsapp_web&&!c,g=new Image;g.src="data:image/webp;base64,UklGRi4AAABXRUJQVlA4TCEAAAAvAUAAEB8wAiMwAgSSNtse/cXjxyCCmrYNWPwmHRH9jwMA",g.onload=g.onerror=function(){2!==g.height&&s.addClass("nowebp")};var u=(a.getItem("whatsappme_hashes")||"").split(",").filter(Boolean),w="yes"==a.getItem("whatsappme_visited");h&&(i=function(e){for(var t=0,a=1;t<e.length;t++)a=Math.imul(a+e.charCodeAt(t)|0,2654435761);return(a^a>>>17)>>>0}(o.message_text).toString(),p=u.indexOf(i)>-1);a.setItem("whatsappme_visited","yes"),(!o.mobile_only||c)&&(setTimeout(function(){s.addClass("whatsappme--show")},r),h&&!p&&(o.message_badge?m=setTimeout(function(){n.addClass("whatsappme__badge--in")},r+1e3*o.message_delay):w&&(m=setTimeout(function(){s.addClass("whatsappme--dialog")},r+1e3*o.message_delay))));h&&!c&&e(".whatsappme__button",s).mouseenter(function(){l=setTimeout(f,1500)}).mouseleave(function(){clearTimeout(l)});function f(){s.addClass("whatsappme--dialog"),clearTimeout(m),o.message_badge&&n.hasClass("whatsappme__badge--in")&&(n.removeClass("whatsappme__badge--in").addClass("whatsappme__badge--out"),_())}function _(){h&&!p&&(u.push(i),a.setItem("whatsappme_hashes",u.join(",")),p=!0)}e(".whatsappme__button",s).click(function(){if(h&&!s.hasClass("whatsappme--dialog"))f();else{var a={link:t(d,o.telephone,o.message_send)},n=new RegExp("^https?://(wa.me|(api|web|chat).whatsapp.com|"+location.hostname.replace(".",".")+")/.*","i");s.removeClass("whatsappme--dialog"),_(),e(document).trigger("whatsappme:open",[a,o]),n.test(a.link)?(!function(e){"object"==typeof dataLayer&&dataLayer.push({event:"WhatsAppMe",eventAction:"click",eventLabel:e});if("function"==typeof gtag)gtag("event","click",{event_category:"WhatsAppMe",event_label:e,transport_type:"beacon"});else if("function"==typeof ga&&"function"==typeof ga.getAll){ga("set","transport","beacon");var t=ga.getAll();t.forEach(function(t){t.send("event","WhatsAppMe","click",e)})}}(a.link),window.open(a.link,"whatsappme")):console.error("WAme: the link doesn't seem safe, it must point to the current domain or whatsapp.com")}}),e(".whatsappme__close",s).click(function(){s.removeClass("whatsappme--dialog"),_()})}()}),Math.imul=Math.imul||function(e,t){var a=65535&e,s=65535&t;return a*s+((e>>>16&65535)*s+a*(t>>>16&65535)<<16>>>0)|0}}(jQuery);
|
whatsappme.php
CHANGED
@@ -6,10 +6,10 @@
|
|
6 |
* @package WhatsAppMe
|
7 |
*
|
8 |
* @wordpress-plugin
|
9 |
-
* Plugin Name:
|
10 |
* Plugin URI: https://wame.chat
|
11 |
* Description: Connect a WordPress chat with WhatsApp. The best solution for marketing and support. Stop losing customers and increase your sales.
|
12 |
-
* Version:
|
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', '
|
31 |
|
32 |
/**
|
33 |
* The core plugin class that is used to define internationalization,
|
@@ -38,16 +38,18 @@ require plugin_dir_path( __FILE__ ) . 'includes/class-whatsappme.php';
|
|
38 |
/**
|
39 |
* Begins execution of the plugin.
|
40 |
*
|
41 |
-
*
|
42 |
-
*
|
43 |
-
*
|
44 |
*
|
45 |
* @since 1.0.0
|
|
|
46 |
*/
|
47 |
function run_whatsappme() {
|
48 |
|
49 |
$plugin = new WhatsAppMe();
|
50 |
-
|
|
|
51 |
|
52 |
}
|
53 |
run_whatsappme();
|
6 |
* @package WhatsAppMe
|
7 |
*
|
8 |
* @wordpress-plugin
|
9 |
+
* Plugin Name: WAme chat
|
10 |
* Plugin URI: https://wame.chat
|
11 |
* Description: Connect a WordPress chat with WhatsApp. The best solution for marketing and support. Stop losing customers and increase your sales.
|
12 |
+
* Version: 3.0.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', '3.0.0' );
|
31 |
|
32 |
/**
|
33 |
* The core plugin class that is used to define internationalization,
|
38 |
/**
|
39 |
* Begins execution of the plugin.
|
40 |
*
|
41 |
+
* Everything within the plugin is registered via hooks,
|
42 |
+
* but initiation is delayed to 'init' hook to allow extensions
|
43 |
+
* or third party plugins to change WAme behavior.
|
44 |
*
|
45 |
* @since 1.0.0
|
46 |
+
* @since 3.0.0 Replaced direct run() to launch via 'init' hook
|
47 |
*/
|
48 |
function run_whatsappme() {
|
49 |
|
50 |
$plugin = new WhatsAppMe();
|
51 |
+
|
52 |
+
add_action( 'init', array( $plugin, 'run' ) );
|
53 |
|
54 |
}
|
55 |
run_whatsappme();
|