WhatsApp me - Version 4.0.0

Version Description

  • NEW: Join.chat brand.
  • NEW: Widget theme color.
  • NEW: CSS class triggers to open chat window.
  • CHANGED for SEO: All analytics events change from WhatsAppMe to JoinChat
  • CHANGED for devs: All css styles change from wame or whatsappmeto joinchat and all actions and filters change from wame_ or whatsappme_to joinchat_.
  • Lighter, reduced assets size and deleted images.
Download this release

Release Info

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

Code changes from version 3.2.3 to 4.0.0

Files changed (33) hide show
  1. README.txt +79 -47
  2. admin/{class-whatsappme-admin.php → class-joinchat-admin.php} +234 -161
  3. admin/{class-whatsappme-wooadmin.php → class-joinchat-wooadmin.php} +38 -38
  4. admin/css/{whatsappme.css → joinchat.css} +60 -46
  5. admin/css/joinchat.min.css +1 -0
  6. admin/css/whatsappme.min.css +0 -1
  7. admin/js/{whatsappme.js → joinchat.js} +47 -39
  8. admin/js/joinchat.min.js +1 -0
  9. admin/js/whatsappme.min.js +0 -1
  10. includes/{class-whatsappme-i18n.php → class-joinchat-i18n.php} +3 -3
  11. includes/{class-whatsappme-integrations.php → class-joinchat-integrations.php} +9 -9
  12. includes/{class-whatsappme-loader.php → class-joinchat-loader.php} +3 -3
  13. includes/{class-whatsappme-util.php → class-joinchat-util.php} +7 -12
  14. includes/{class-whatsappme.php → class-joinchat.php} +110 -27
  15. whatsappme.php → joinchat.php +12 -10
  16. languages/creame-whatsapp-me-fr_FR.mo +0 -0
  17. languages/creame-whatsapp-me-fr_FR.po +0 -549
  18. languages/creame-whatsapp-me.pot +240 -139
  19. public/class-joinchat-public.php +431 -0
  20. public/{class-whatsappme-woopublic.php → class-joinchat-woopublic.php} +13 -12
  21. public/class-whatsappme-public.php +0 -428
  22. public/css/joinchat.css +601 -0
  23. public/css/joinchat.min.css +1 -0
  24. public/css/whatsappme.css +0 -638
  25. public/css/whatsappme.min.css +0 -1
  26. public/images/background.png +0 -0
  27. public/images/background.webp +0 -0
  28. public/images/svgs.php +0 -6
  29. public/js/joinchat.js +268 -0
  30. public/js/joinchat.min.js +1 -0
  31. public/js/whatsappme.js +0 -246
  32. public/js/whatsappme.min.js +0 -1
  33. uninstall.php +12 -8
README.txt CHANGED
@@ -1,27 +1,30 @@
1
- === VVAme 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.4
7
Requires PHP: 5.3
8
- Stable tag: 3.2.3
9
License: GPLv2 or later
10
License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
12
- Connects a WordPress chat with WhatsApp. The best solution for marketing and support. Stop losing customers and increase your sales.
13
14
== Description ==
15
16
- [wame.chat](https://wame.chat?utm_source=wporg&utm_medium=web&utm_campaign=v3_2) | [Add-Ons](https://wame.chat/en/addons/?utm_source=wporg&utm_medium=web&utm_campaign=v3_2) | [Docs](https://wame.chat/en/docs/?utm_source=wporg&utm_medium=web&utm_campaign=v3_2) | [Support](https://wame.chat/en/support/?utm_source=wporg&utm_medium=web&utm_campaign=v3_2)
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.2 📍
21
22
- 🌚 **Discover the new Dark Mode.** Great news for all those who prefer white text on a black background. Now you will find an option to activate it in your settings.
23
24
- ### What you can do with WAme
25
26
#### 🛎 Insert a WhatsApp button on your website.
27
Define in which pages or zones it should appear, the delay time, if you want it to the right or to the left, only on mobile phones or also on the desktop.
@@ -36,7 +39,7 @@ You can serve users in different terminals, you can insert a different one in ea
36
Use a balloon on the button to get the user's attention. In this way, you ensure that you do not miss any important message you want to give them, surprise them in a less intrusive way.
37
38
#### 📯 Create call-to-action messages.
39
- For users to click on the button, use custom CTAs on each page, product or section. Welcome them, help them and offer them offers or promotions. [You can read more about this topic here](https://wame.chat/es/whatsapp-me-mucho-mas-que-un-click-to-chat/).
40
41
#### 💬 Customize conversation start messages.
42
So that the user does not waste time in writing. This way you will be able to know from which page it comes or what product is being consulted when you start the first conversation.
@@ -45,31 +48,33 @@ So that the user does not waste time in writing. This way you will be able to kn
45
Define CTAs and Custom Messages for product pages, you can use dynamic variables such as {SKU}, {PRICE} or {PRODUCT}.
46
47
#### 🏁 Analyze the conversion data in Google Analytics and Facebook Pixel.
48
- Remember, you do not have to do anything, the plugin already creates and computes the events by itself. [You can read more about this topic here](https://wame.chat/es/wame-mide-los-eventos-de-whatsapp-en-google-analytics/).
49
50
#### 💱 Customize different languages.
51
To be able to support all your users, wherever they are. Our plugin is compatible with WPML and Polylang.
52
53
- ### What you can´t do with WAme ⛔️
54
55
#### 👨‍🎨 Modify the appearance of the button.
56
Users recognize it instantly because it is in thousands of web pages and they know what it is for, it generates trust. If you modify it, you lose these important values.
57
58
#### 😡 Wasting time configuring other similar plugins.
59
- Having many options is not an advantage, the configuration of WAme is so easy that in less than 2 minutes you will be ‘wasapeando’ with your clients.
60
-
61
- ### ⌁ Translations 🇦🇶
62
- -[English (US)](https://wordpress.org/plugins/creame-whatsapp-me/)
63
- -[Portuguese (Brazil)](https://br.wordpress.org/plugins/creame-whatsapp-me/)
64
- -[Spanish (Spain)](https://es.wordpress.org/plugins/creame-whatsapp-me/)
65
- -[Translate into your language](https://translate.wordpress.org/projects/wp-plugins/creame-whatsapp-me)
66
67
- ### ⌁ If you like WAme 😍
68
1. Please leave us a [★★★★★](https://wordpress.org/support/plugin/creame-whatsapp-me/reviews/#new-post) rating. We'll thank you.
69
- 2. Subscribe to our newsletter and visit our blog at [wame.chat](https://wame.chat/?utm_source=wporg&utm_medium=web&utm_campaign=v3_2).
70
- 3. Follow [@wamechat](https://twitter.com/wamechat) on twitter.
71
72
- *WhatsApp and WhatsApp Logo are brand assets and trademark of Facebook, Inc. WAme is not in partnership, sponsored or endorsed by Facebook, Inc.*
73
74
== Installation ==
75
@@ -78,60 +83,68 @@ Having many options is not an advantage, the configuration of WAme is so easy th
78
79
== Frequently Asked Questions ==
80
81
= I can't see the button or it's over / under another thing =
82
83
You can change the position of the button so that nothing covers it by adding this CSS in *Appearance > Customize > Custom CSS*:
84
85
- `.whatsappme { z-index:9999; }`
86
87
Greater values of z-index are left over, the default value is 400.
88
89
= What about GDPR? =
90
91
- WAme don't use cookies.
92
-
93
- WAme save two localStorage variables for proper operation:
94
95
- - `whatsappme_visited` to know if is the first time on site or is a returning user.
96
- - `whatsappme_hashes` if you set a Call To Action (CTA), when user launch WhatsApp or close Chat Window the CTA hashed is saved to prevent show automatically that CTA again.
97
98
= Google Analytics integration =
99
100
- WAme send a custom event when user click to launch WhatsApp.
101
102
If Global Site Tag (gtag.js) detected:
103
104
- `gtag('event', 'click', { 'event_category': 'WhatsAppMe', 'event_label': out_url })`
105
106
If Universal Analtics (analytics.js) detected:
107
108
- `ga('send', 'event', 'WhatsAppMe', 'click', out_url })`
109
110
If your tracker doesn't have the standard name 'ga' you can set your custom name with 'ga_tracker' setting:
111
112
- `add_filter( 'whatsappme_get_settings', function( $settings ){
113
$settings['ga_tracker'] = 'my_custom_GA_name';
114
return $settings;
115
} );`
116
117
= Google Tag Manager integration =
118
119
- WAme send an event (if GTM detected) when user click to launch WhatsApp:
120
121
- `dataLayer.push({ 'event': 'WhatsAppMe', 'eventAction': 'click', 'eventLabel': out_url });`
122
123
= Facebook Pixel integration =
124
125
- WAme send a custom event if Facebook Pixel is detected when user click to launch WhatsApp:
126
127
- `fbq('trackCustom', 'WhatsAppMe', { eventAction: 'click', eventLabel: out_url });`
128
129
= Other integrations =
130
131
- There is a Javascript event that WAme triggers automatically before launch WhatsApp, which can be used to add your custom tracking code (or other needs).
132
133
`jQuery(document).ready(function($){
134
- $(document).on('whatsappme:open', function (event, args, settings) {
135
// Your staff
136
// Note: args.link is the link to open, you can change it
137
// but only wa.me, whastapp.com or current domain are allowed.
@@ -140,17 +153,19 @@ There is a Javascript event that WAme triggers automatically before launch Whats
140
141
= WPML/Polylang change Telephone by language =
142
143
- WAme general text settings can be translated with the strings translation of WPML/Polylang. You only need to save WAme settings to register strings and make them ready for translation. But "Telephone" is not translatable by default. If you need different phone numbers for every language add the following php code in your theme functions.php and save WAme settings.
144
145
- `add_filter( 'whatsappme_settings_i18n', function( $settings ) {
146
$settings['telephone'] = 'Telephone';
147
return $settings;
148
} );`
149
150
- = Emojis are not saved =
151
152
- To save emojis the site database must use utf8mb4 encoding.
153
- If your database enconding is utf8 you can use emojis converting them to html entities with a tool [like this](https://mothereff.in/html-entities).
154
155
== Screenshots ==
156
@@ -158,13 +173,21 @@ If your database enconding is utf8 you can use emojis converting them to html en
158
2. Button with tooltip and custom image.
159
3. Call to action on desktop.
160
4. Button and call to action on mobile.
161
- 5. WAme general settings.
162
- 6. WAme advanced visibility settings.
163
- 7. WAme WooCommerce settings.
164
- 8. WAme on post/page edition.
165
166
== Changelog ==
167
168
= 3.2.3 =
169
* FIX svg in safari < 13.
170
@@ -345,6 +368,15 @@ If your database enconding is utf8 you can use emojis converting them to html en
345
346
== Upgrade Notice ==
347
348
= 2.3.0 =
349
WPML and Polylang integration.
350
Added new settings to control delay and launch WhatsApp Web on desktop.
1
+ === Join.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.4
7
Requires PHP: 5.3
8
+ Stable tag: 4.0.0
9
License: GPLv2 or later
10
License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
12
+ (formerly WAme) We help you capture users with WhatsApp and turn them into clients.
13
14
== Description ==
15
16
+ [join.chat](https://join.chat?utm_source=wporg&utm_medium=web&utm_campaign=v4_0) | [Add-ons](https://join.chat/en/addons/?utm_source=wporg&utm_medium=web&utm_campaign=v4_0) | [Documentation](https://join.chat/en/docs/?utm_source=wporg&utm_medium=web&utm_campaign=v4_0) | [Support](https://join.chat/en/support/?utm_source=wporg&utm_medium=web&utm_campaign=v4_0)
17
18
+ ### The best WhatsApp plugin for WordPress.
19
+ > We help more than 200,000 businesses worldwide to attract users and convert them into clients.
20
21
+ ### New in Join.chat 4.0 📍
22
23
+ 🌈 **Say hello to the colors.** We've redesigned the entire interface of the chat window, now you choose a color, and we customize all the visual theme of the Widget.
24
25
+ 🍾 **Triggers.** Your pages can interact with Join.chat and show the chat window or launch WhatsApp when user clicks or an item appears when scrolling. You just need to add a few css classes.
26
+
27
+ ### ⌁ What you can do with Join.chat ✅
28
29
#### 🛎 Insert a WhatsApp button on your website.
30
Define in which pages or zones it should appear, the delay time, if you want it to the right or to the left, only on mobile phones or also on the desktop.
39
Use a balloon on the button to get the user's attention. In this way, you ensure that you do not miss any important message you want to give them, surprise them in a less intrusive way.
40
41
#### 📯 Create call-to-action messages.
42
+ For users to click on the button, use custom CTAs on each page, product or section. Welcome them, help them and offer them offers or promotions. [You can read more about this topic here](https://join.chat/es/whatsapp-me-mucho-mas-que-un-click-to-chat/).
43
44
#### 💬 Customize conversation start messages.
45
So that the user does not waste time in writing. This way you will be able to know from which page it comes or what product is being consulted when you start the first conversation.
48
Define CTAs and Custom Messages for product pages, you can use dynamic variables such as {SKU}, {PRICE} or {PRODUCT}.
49
50
#### 🏁 Analyze the conversion data in Google Analytics and Facebook Pixel.
51
+ Remember, you do not have to do anything, the plugin already creates and computes the events by itself. [You can read more about this topic here](https://join.chat/es/wame-mide-los-eventos-de-whatsapp-en-google-analytics/).
52
53
#### 💱 Customize different languages.
54
To be able to support all your users, wherever they are. Our plugin is compatible with WPML and Polylang.
55
56
+ ### 🌚 Dark Mode.
57
+ Display the chat window with dark colors and white text. From settings you can activate it or leave it automatic so that it detects the configuration of devices in dark mode.
58
+
59
+ https://www.youtube.com/watch?v=1Gma1Wvt6gU
60
+
61
+ ### ⌁ What you can´t do with Join.chat ⛔️
62
63
#### 👨‍🎨 Modify the appearance of the button.
64
Users recognize it instantly because it is in thousands of web pages and they know what it is for, it generates trust. If you modify it, you lose these important values.
65
66
#### 😡 Wasting time configuring other similar plugins.
67
+ Having many options is not an advantage, the configuration of Join.chat is so easy that in less than 2 minutes you will be ‘wasapeando’ with your clients.
68
69
+ ### ⌁ If you like Join.chat 😍
70
1. Please leave us a [★★★★★](https://wordpress.org/support/plugin/creame-whatsapp-me/reviews/#new-post) rating. We'll thank you.
71
+ 2. Help us with the [translation in your language](https://translate.wordpress.org/projects/wp-plugins/creame-whatsapp-me)
72
+ 3. Subscribe to our newsletter and visit our blog at [join.chat](https://join.chat/?utm_source=wporg&utm_medium=web&utm_campaign=v4_0).
73
+ 4. Follow [@joinchat](https://twitter.com/wamechat) on twitter.
74
75
+ Name history: *WhatsApp me > WAme > VVAme > **Join.chat***
76
+
77
+ *WhatsApp and WhatsApp Logo are brand assets and trademark of Facebook, Inc. Join.chat is not in partnership, sponsored or endorsed by Facebook, Inc.*
78
79
== Installation ==
80
83
84
== Frequently Asked Questions ==
85
86
+ = WAme now is Join.chat =
87
+
88
+ From version 4.0 we change our name to Join.chat.
89
+ To avoid using several prefixes from old and new versions we have decided to rename all them to the new `joinchat`.
90
+
91
+ * All analytics events change from `WhatsAppMe` to `JoinChat`
92
+ * All css styles change from `wame` or `whatsappme` to `joinchat`.
93
+ * All actions and filters change from `wame_` or `whatsappme_` to `joinchat_`.
94
+
95
= I can't see the button or it's over / under another thing =
96
97
You can change the position of the button so that nothing covers it by adding this CSS in *Appearance > Customize > Custom CSS*:
98
99
+ `.joinchat { z-index:9999; }`
100
101
Greater values of z-index are left over, the default value is 400.
102
103
= What about GDPR? =
104
105
+ Join.chat don't use cookies.
106
107
+ Join.chat save two localStorage variables for proper operation:
108
+ * `joinchat_visited` to know if is the first time on site or is a returning user.
109
+ * `joinchat_hashes` if you set a Call To Action (CTA), when user launch WhatsApp or close Chat Window the CTA hashed is saved to prevent show automatically that CTA again.
110
111
= Google Analytics integration =
112
113
+ Join.chat send a custom event when user click to launch WhatsApp.
114
115
If Global Site Tag (gtag.js) detected:
116
117
+ `gtag('event', 'click', { 'event_category': 'JoinChat', 'event_label': out_url })`
118
119
If Universal Analtics (analytics.js) detected:
120
121
+ `ga('send', 'event', 'JoinChat', 'click', out_url })`
122
123
If your tracker doesn't have the standard name 'ga' you can set your custom name with 'ga_tracker' setting:
124
125
+ `add_filter( 'joinchat_get_settings', function( $settings ){
126
$settings['ga_tracker'] = 'my_custom_GA_name';
127
return $settings;
128
} );`
129
130
= Google Tag Manager integration =
131
132
+ Join.chat send an event (if GTM detected) when user click to launch WhatsApp:
133
134
+ `dataLayer.push({ 'event': 'JoinChat', 'eventAction': 'click', 'eventLabel': out_url });`
135
136
= Facebook Pixel integration =
137
138
+ Join.chat send a custom event if Facebook Pixel is detected when user click to launch WhatsApp:
139
140
+ `fbq('trackCustom', 'JoinChat', { eventAction: 'click', eventLabel: out_url });`
141
142
= Other integrations =
143
144
+ There is a Javascript event that Join.chat triggers automatically before launch WhatsApp, which can be used to add your custom tracking code (or other needs).
145
146
`jQuery(document).ready(function($){
147
+ $(document).on('joinchat:open', function (event, args, settings) {
148
// Your staff
149
// Note: args.link is the link to open, you can change it
150
// but only wa.me, whastapp.com or current domain are allowed.
153
154
= WPML/Polylang change Telephone by language =
155
156
+ Join.chat general text settings can be translated with the strings translation of WPML/Polylang. You only need to save Join.chat settings to register strings and make them ready for translation. But "Telephone" is not translateable by default. If you need different phone numbers for every language add the following php code in your theme functions.php and save Join.chat settings.
157
158
+ `add_filter( 'joinchat_settings_i18n', function( $settings ) {
159
$settings['telephone'] = 'Telephone';
160
return $settings;
161
} );`
162
163
+ = Settings are not saved when using emojis =
164
+
165
+ To save emojis site database must use utf8mb4 encoding.
166
+ If settings are not saved when using emojis, add this code in your theme functions.php:
167
168
+ `add_filter( 'sanitize_text_field', 'wp_encode_emoji' );`
169
170
== Screenshots ==
171
173
2. Button with tooltip and custom image.
174
3. Call to action on desktop.
175
4. Button and call to action on mobile.
176
+ 5. Join.chat general settings.
177
+ 6. Join.chat advanced visibility settings.
178
+ 7. Join.chat WooCommerce settings.
179
+ 8. Join.chat on post/page edition.
180
181
== Changelog ==
182
183
+ = 4.0.0 =
184
+ * **NEW:** Join.chat brand.
185
+ * **NEW:** Widget theme color.
186
+ * **NEW:** CSS class triggers to open chat window.
187
+ * **CHANGED for SEO:** All analytics events change from `WhatsAppMe` to `JoinChat`
188
+ * **CHANGED for devs:** All css styles change from `wame` or `whatsappme`to `joinchat` and all actions and filters change from `wame_` or `whatsappme_`to `joinchat_`.
189
+ * Lighter, reduced assets size and deleted images.
190
+
191
= 3.2.3 =
192
* FIX svg in safari < 13.
193
368
369
== Upgrade Notice ==
370
371
+ = 4.0.0 =
372
+ **Join.chat rebrand.**
373
+ To avoid using several prefixes from old and new versions we have decided to rename all them to the new `joinchat`.
374
+
375
+ **WARNING**
376
+ * **For SEO:** All analytics events change from `WhatsAppMe` to `JoinChat`
377
+ * **For Devs:** All css styles change from `wame` or `whatsappme`to `joinchat`.
378
+ * **For Devs:** All actions and filters change from `wame_` or `whatsappme_`to `joinchat_`.
379
+
380
= 2.3.0 =
381
WPML and Polylang integration.
382
Added new settings to control delay and launch WhatsApp Web on desktop.
admin/{class-whatsappme-admin.php → class-joinchat-admin.php} RENAMED
@@ -4,13 +4,13 @@
4
* The admin-specific functionality of the plugin.
5
*
6
* @since 1.0.0
7
- * @since 2.0.0 Added advanced visibility settings
8
* @since 3.0.0 More extendable admin via hooks
9
- * @package WhatsAppMe
10
- * @subpackage WhatsAppMe/admin
11
* @author Creame <hola@crea.me>
12
*/
13
- class WhatsAppMe_Admin {
14
15
/**
16
* The ID of this plugin.
@@ -71,7 +71,7 @@ class WhatsAppMe_Admin {
71
$this->version = $version;
72
73
// Updated in get_settings() at 'admin_init' hook
74
- $this->enhanced_phone = '16.0.8'; // intl-tel-input version
75
$this->tabs = array();
76
$this->settings = array();
77
@@ -86,18 +86,19 @@ class WhatsAppMe_Admin {
86
* @since 2.3.0 Added button_delay and whatsapp_web settings, message_delay in seconds
87
* @since 3.0.0 Is public and added plugin enhanced_phone and tabs
88
* @since 3.1.0 Added tooltip and image
89
*/
90
public function get_settings() {
91
92
// Use International Telephone Input library version or false to disable
93
- $this->enhanced_phone = apply_filters( 'whatsappme_enhanced_phone', $this->enhanced_phone );
94
95
// Admin tabs
96
$this->tabs = apply_filters(
97
- 'whatsappme_admin_tabs',
98
array(
99
- 'general' => __( 'General', 'creame-whatsapp-me' ),
100
- 'advanced' => __( 'Advanced', 'creame-whatsapp-me' ),
101
)
102
);
103
@@ -112,17 +113,19 @@ class WhatsAppMe_Admin {
112
'whatsapp_web' => 'no',
113
'message_text' => '',
114
'message_delay' => 10,
115
'message_badge' => 'no',
116
'message_send' => '',
117
'message_start' => __( 'Open chat', 'creame-whatsapp-me' ),
118
'position' => 'right',
119
'visibility' => array( 'all' => 'yes' ),
120
'dark_mode' => 'no',
121
),
122
- apply_filters( 'whatsappme_extra_settings', array() )
123
);
124
125
- $saved_settings = get_option( 'whatsappme' );
126
127
if ( is_array( $saved_settings ) ) {
128
// clean unused saved settings
@@ -148,8 +151,8 @@ class WhatsAppMe_Admin {
148
*/
149
public function register_styles( $hook ) {
150
151
- $styles = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'whatsappme.css' : 'whatsappme.min.css';
152
- wp_register_style( 'whatsappme-admin', plugin_dir_url( __FILE__ ) . 'css/' . $styles, array(), $this->version, 'all' );
153
154
if ( $this->enhanced_phone ) {
155
wp_register_style( 'intl-tel-input', 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/' . $this->enhanced_phone . '/css/intlTelInput.css', array(), null, 'all' );
@@ -166,14 +169,14 @@ class WhatsAppMe_Admin {
166
*/
167
public function register_scripts( $hook ) {
168
169
- $script = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'whatsappme.js' : 'whatsappme.min.js';
170
171
if ( $this->enhanced_phone ) {
172
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 );
173
- wp_register_script( 'whatsappme-admin', plugin_dir_url( __FILE__ ) . 'js/' . $script, array( 'jquery', 'intl-tel-input' ), $this->version, true );
174
wp_localize_script( 'intl-tel-input', 'intl_tel_input_version', $this->enhanced_phone );
175
} else {
176
- wp_register_script( 'whatsappme-admin', plugin_dir_url( __FILE__ ) . 'js/' . $script, array( 'jquery' ), $this->version, true );
177
}
178
179
}
@@ -183,7 +186,7 @@ class WhatsAppMe_Admin {
183
* From v1.2.0 also set filter to disable enhanced phone input
184
*
185
* @since 1.0.0
186
- * @since 2.0.0 Added tabs for general and Advanced settings
187
* @since 2.3.0 Split general settings in Button and Window Chat
188
* @since 3.0.0 Admin organized by tabs and sections
189
* @access public
@@ -191,19 +194,19 @@ class WhatsAppMe_Admin {
191
*/
192
public function settings_init() {
193
194
- // Register WordPress 'whatsappme' settings
195
- register_setting( 'whatsappme', 'whatsappme', array( $this, 'settings_validate' ) );
196
197
foreach ( $this->tabs as $tab => $tab_name ) {
198
199
- add_settings_section( "whatsappme_tab_{$tab}_open", null, array( $this, 'settings_tab_open' ), 'whatsappme' );
200
201
$sections = $this->get_tab_sections( $tab );
202
203
foreach ( $sections as $section => $fields ) {
204
- $section_id = "whatsappme_tab_{$tab}__{$section}";
205
206
- add_settings_section( $section_id, null, array( $this, 'section_output' ), 'whatsappme' );
207
208
foreach ( $fields as $field => $field_args ) {
209
if ( is_array( $field_args ) ) {
@@ -214,11 +217,11 @@ class WhatsAppMe_Admin {
214
$field_callback = array( $this, 'field_output' );
215
}
216
217
- add_settings_field( "whatsappme_$field", $field_name, $field_callback, 'whatsappme', $section_id, $field );
218
}
219
}
220
221
- add_settings_section( "whatsappme_tab_{$tab}_close", null, array( $this, 'settings_tab_close' ), 'whatsappme' );
222
}
223
224
}
@@ -236,26 +239,31 @@ class WhatsAppMe_Admin {
236
if ( 'general' == $tab ) {
237
238
$sections = array(
239
- 'button' => array(
240
- 'telephone' => '<label for="whatsappme_phone">' . __( 'Telephone', 'creame-whatsapp-me' ) . '</label>',
241
- 'message_send' => '<label for="whatsappme_message_send">' . __( 'Message', 'creame-whatsapp-me' ) . '</label>' . self::vars_help( 'message_send' ),
242
- 'mobile_only' => __( 'Mobile Only', 'creame-whatsapp-me' ),
243
'position' => __( 'Position on Screen', 'creame-whatsapp-me' ),
244
'button_image' => __( 'Image', 'creame-whatsapp-me' ),
245
- 'button_tip' => __( 'Tooltip', 'creame-whatsapp-me' ),
246
- 'button_delay' => '<label for="whatsappme_button_delay">' . __( 'Button Delay', 'creame-whatsapp-me' ) . '</label>',
247
'whatsapp_web' => __( 'WhatsApp Web', 'creame-whatsapp-me' ),
248
),
249
- 'chat' => array(
250
- 'message_text' => '<label for="whatsappme_message_text">' . __( 'Call to Action', 'creame-whatsapp-me' ) . '</label>' . self::vars_help( 'message_text' ),
251
- 'message_start' => '<label for="whatsappme_message_start">' . __( 'Start WhatsApp Button', 'creame-whatsapp-me' ) . '</label>',
252
- 'message_delay' => '<label for="whatsappme_message_delay">' . __( 'Chat Delay', 'creame-whatsapp-me' ) . '</label>',
253
- 'message_badge' => __( 'Notification Balloon', 'creame-whatsapp-me' ),
254
'dark_mode' => __( 'Dark Mode', 'creame-whatsapp-me' ),
255
),
256
);
257
258
- } elseif ( 'advanced' == $tab ) {
259
260
$sections = array(
261
'global' => array(
@@ -285,7 +293,7 @@ class WhatsAppMe_Admin {
285
286
// Custom Post Types
287
$custom_post_types = apply_filters(
288
- 'whatsappme_custom_post_types',
289
array_keys( get_post_types( array( 'has_archive' => true ), 'names' ) )
290
);
291
@@ -308,7 +316,7 @@ class WhatsAppMe_Admin {
308
}
309
310
// Filter tab sections to add, remove or edit sections or fields
311
- return apply_filters( "whatsappme_tab_{$tab}_sections", $sections );
312
313
}
314
@@ -328,11 +336,11 @@ class WhatsAppMe_Admin {
328
329
// Prevent bad behavior when validate twice on first save
330
// bug https://core.trac.wordpress.org/ticket/21989
331
- if ( count( get_settings_errors( 'whatsappme' ) ) ) {
332
return $input;
333
}
334
335
- $util = new WhatsAppMe_Util(); // Shortcut
336
337
$input['telephone'] = $util::clean_input( $input['telephone'] );
338
$input['mobile_only'] = isset( $input['mobile_only'] ) ? 'yes' : 'no';
@@ -345,7 +353,9 @@ class WhatsAppMe_Admin {
345
$input['message_send'] = $util::clean_input( $input['message_send'] );
346
$input['message_start'] = $util::substr( $util::clean_input( $input['message_start'] ), 0, 20 );
347
$input['message_delay'] = intval( $input['message_delay'] );
348
$input['position'] = $input['position'] != 'left' ? 'right' : 'left';
349
$input['dark_mode'] = in_array( $input['dark_mode'], array( 'no', 'yes', 'auto' ) ) ? $input['dark_mode'] : 'no';
350
if ( isset( $input['view'] ) ) {
351
$input['visibility'] = array_filter(
@@ -358,22 +368,22 @@ class WhatsAppMe_Admin {
358
}
359
360
// Filter for other validations or extra settings
361
- $input = apply_filters( 'whatsappme_settings_validate', $input );
362
363
/**
364
* Register WPML/Polylang strings for translation
365
* https://wpml.org/wpml-hook/wpml_register_single_string/
366
*/
367
- $settings_i18n = WhatsAppMe_Util::settings_i18n();
368
369
foreach ( $settings_i18n as $setting_key => $setting_name ) {
370
- do_action( 'wpml_register_single_string', 'WhatsApp me', $setting_name, $input[ $setting_key ] );
371
}
372
373
// Extra actions on save
374
- do_action( 'whatsappme_settings_validate', $input );
375
376
- add_settings_error( 'whatsappme', 'settings_updated', __( 'Settings saved', 'creame-whatsapp-me' ), 'updated' );
377
378
return $input;
379
}
@@ -387,10 +397,11 @@ class WhatsAppMe_Admin {
387
*/
388
public function settings_tab_open( $args ) {
389
390
- $tab_id = str_replace( array( 'whatsappme_tab_', '_open' ), '', $args['id'] );
391
- $active = 'general' == $tab_id ? 'wametab-active' : '';
392
393
- echo "<div id=\"whatsappme_tab_$tab_id\" class=\"wametab $active\" role=\"tabpanel\" aria-labelledby=\"navtab_$tab_id\" >";
394
395
}
396
@@ -418,12 +429,12 @@ class WhatsAppMe_Admin {
418
$section_id = $args['id'];
419
420
switch ( $section_id ) {
421
- case 'whatsappme_tab_general__button':
422
$output = '<h2 class="title">' . __( 'Button', 'creame-whatsapp-me' ) . '</h2>' .
423
'<p>' . __( 'Set the contact number and where you want the WhatsApp button to be displayed.', 'creame-whatsapp-me' ) . '</p>';
424
break;
425
426
- case 'whatsappme_tab_general__chat':
427
$output = '<hr><h2 class="title">' . __( 'Chat Window', 'creame-whatsapp-me' ) . '</h2>' .
428
'<p>' .
429
__( 'If you define a "Call to Action" a window will be displayed simulating a chat before launching WhatsApp.', 'creame-whatsapp-me' ) . ' ' .
@@ -431,17 +442,24 @@ class WhatsAppMe_Admin {
431
'</p>';
432
break;
433
434
- case 'whatsappme_tab_advanced__global':
435
- $output = '<h2 class="title">' . __( 'Advanced Visibility Settings', 'creame-whatsapp-me' ) . '</h2>' .
436
'<p>' . __( 'From here you can configure on which pages the WhatsApp button will be visible.', 'creame-whatsapp-me' ) .
437
- ' <a href="#" class="whatsappme_view_reset">' . __( 'Restore default visibility', 'creame-whatsapp-me' ) . '</a></p>';
438
break;
439
440
- case 'whatsappme_tab_advanced__wp':
441
$output = '<hr>';
442
break;
443
444
- case 'whatsappme_tab_advanced__cpt':
445
$output = '<h2 class="title">' . __( 'Custom Post Types', 'creame-whatsapp-me' ) . '</h2>';
446
break;
447
@@ -451,7 +469,7 @@ class WhatsAppMe_Admin {
451
}
452
453
// Filter section opening ouput
454
- echo apply_filters( 'whatsappme_section_output', $output, $section_id );
455
}
456
457
/**
@@ -467,112 +485,133 @@ class WhatsAppMe_Admin {
467
$field = substr( $field_id, 6 );
468
$value = isset( $this->settings['visibility'][ $field ] ) ? $this->settings['visibility'][ $field ] : '';
469
470
- $output = '<label><input type="radio" name="whatsappme[view][' . $field . ']" value="yes"' . checked( 'yes', $value, false ) . '> ' .
471
'<span class="dashicons dashicons-visibility" title="' . __( 'Show', 'creame-whatsapp-me' ) . '"></span></label>' .
472
- '<label><input type="radio" name="whatsappme[view][' . $field . ']" value="no"' . checked( 'no', $value, false ) . '> ' .
473
'<span class="dashicons dashicons-hidden" title="' . __( 'Hide', 'creame-whatsapp-me' ) . '"></span></label>' .
474
- '<label><input type="radio" name="whatsappme[view][' . $field . ']" value=""' . checked( '', $value, false ) . '> ' .
475
__( 'Inherit', 'creame-whatsapp-me' ) . ' <span class="dashicons dashicons-visibility view_inheritance_' . $field . '"></span></label>';
476
477
} else {
478
479
$value = isset( $this->settings[ $field_id ] ) ? $this->settings[ $field_id ] : '';
480
- $utm = '?utm_source=wpadmin&utm_medium=settings&utm_campaign=v' . str_replace( '.', '_', $this->version );
481
482
switch ( $field_id ) {
483
case 'telephone':
484
- $output = '<input id="whatsappme_phone" ' . ( $this->enhanced_phone ? 'data-' : '' ) . 'name="whatsappme[telephone]" value="' . $value . '" type="text" style="width:15em">' .
485
'<p class="description">' . __( "Contact phone number <strong>(the button will not be shown if it's empty)</strong>", 'creame-whatsapp-me' ) . '</p>' .
486
- '<p class="whatsappme-addon">' . sprintf(
487
__( 'Add unlimited numbers with %1$s or multiple contacts with %2$s', 'creame-whatsapp-me' ),
488
- '<a href="https://wame.chat/en/addons/wame-random-phone/' . $utm . '" target="_blank">\'WAme Random Phone\'</a>',
489
- '<a href="https://wame.chat/en/addons/support-agents/' . $utm . '" target="_blank">\'WAme Agents\'</a>'
490
) . '</p>';
491
break;
492
493
case 'mobile_only':
494
$output = '<fieldset><legend class="screen-reader-text"><span>' . __( 'Mobile Only', 'creame-whatsapp-me' ) . '</span></legend>' .
495
- '<label><input id="whatsappme_mobile_only" name="whatsappme[mobile_only]" value="yes" type="checkbox"' . checked( 'yes', $value, false ) . '> ' .
496
__( 'Only display the button on mobile devices', 'creame-whatsapp-me' ) . '</label></fieldset>';
497
break;
498
499
case 'position':
500
$output = '<fieldset><legend class="screen-reader-text"><span>' . __( 'Position on Screen', 'creame-whatsapp-me' ) . '</span></legend>' .
501
- '<label><input name="whatsappme[position]" value="left" type="radio"' . checked( 'left', $value, false ) . '> ' .
502
__( 'Left', 'creame-whatsapp-me' ) . '</label><br>' .
503
- '<label><input name="whatsappme[position]" value="right" type="radio"' . checked( 'right', $value, false ) . '> ' .
504
__( 'Right', 'creame-whatsapp-me' ) . '</label></fieldset>';
505
break;
506
507
case 'button_image':
508
- $thumb = intval( $value ) > 0 ? WhatsAppMe_Util::thumb( $value, 116, 116 ) : false;
509
$image = is_array( $thumb ) ? $thumb['url'] : false;
510
511
- $output = '<div id="whatsappme_button_image_wrapper">' .
512
- '<div id="whatsappme_button_image_holder" ' . ( $image ? "style=\"background-size:cover; background-image:url('$image');\"" : '' ) . '></div>' .
513
- '<input id="whatsappme_button_image" name="whatsappme[button_image]" type="hidden" value="' . $value . '">' .
514
- '<input id="whatsappme_button_image_add" type="button" value="' . esc_attr__( 'Select an image', 'creame-whatsapp-me' ) . '" class="button-primary" ' .
515
'data-title="' . esc_attr__( 'Select button image', 'creame-whatsapp-me' ) . '" data-button="' . esc_attr__( 'Use image', 'creame-whatsapp-me' ) . '"> ' .
516
- '<input id="whatsappme_button_image_remove" type="button" value="' . esc_attr__( 'Remove', 'creame-whatsapp-me' ) . '" class="button-secondary' . ( $image ? '' : ' wame-hidden' ) . '">' .
517
'<p class="description">' . __( 'The image will alternate with WhatsApp logo', 'creame-whatsapp-me' ) . '</p></div>';
518
break;
519
520
case 'button_tip':
521
- $output = '<input id="whatsappme_button_tip" name="whatsappme[button_tip]" value="' . $value . '" type="text" maxlength="40" class="regular-text" placeholder="' . esc_attr__( '💬 Need help?', 'creame-whatsapp-me' ) . '"> ' .
522
'<p class="description">' . __( 'Short text shown next to WhatsApp button', 'creame-whatsapp-me' ) . '</p>';
523
break;
524
525
case 'button_delay':
526
- $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' ) .
527
'<p class="description">' . __( 'Time since the page is opened until the WhatsApp button is displayed', 'creame-whatsapp-me' ) . '</p>';
528
break;
529
530
case 'whatsapp_web':
531
$output = '<fieldset><legend class="screen-reader-text"><span>' . __( 'WhatsApp Web', 'creame-whatsapp-me' ) . '</span></legend>' .
532
- '<label><input id="whatsappme_whatsapp_web" name="whatsappme[whatsapp_web]" value="yes" type="checkbox"' . checked( 'yes', $value, false ) . '> ' .
533
__( 'Open <em>WhatsApp Web</em> directly on desktop', 'creame-whatsapp-me' ) . '</label></fieldset>';
534
break;
535
536
case 'message_text':
537
- $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>' .
538
'<p class="description">' . __( 'Define a text to encourage users to contact by WhatsApp', 'creame-whatsapp-me' ) . '</p>' .
539
- '<p class="whatsappme-addon">' . sprintf(
540
__( 'Add links, images, videos and more with %s', 'creame-whatsapp-me' ),
541
- '<a href="https://wame.chat/en/addons/cta-extras/' . $utm . '" target="_blank">\'WAme CTA Extras\'</a>'
542
) . '</p>';
543
break;
544
545
case 'message_send':
546
- $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} {URL}', 'creame-whatsapp-me' ) . '">' . $value . '</textarea>' .
547
'<p class="description">' . __( 'Predefined text for the first message the user will send you', 'creame-whatsapp-me' ) . '</p>';
548
break;
549
550
case 'message_start':
551
- $output = '<input id="whatsappme_message_start" name="whatsappme[message_start]" value="' . $value . '" type="text" maxlength="20" class="regular-text" placeholder="' . esc_attr__( 'Open chat', 'creame-whatsapp-me' ) . '"> ' .
552
'<p class="description">' . __( 'Text of the start WhatsApp button on Chat Window', 'creame-whatsapp-me' ) . '</p>';
553
break;
554
555
case 'message_delay':
556
- $output = '<input id="whatsappme_message_delay" name="whatsappme[message_delay]" value="' . $value . '" type="number" min="0" max="120" style="width:5em"> ' . __( 'seconds (0 disabled)', 'creame-whatsapp-me' ) .
557
- '<p class="description">' . __( 'Chat Window is automatically displayed after delay', 'creame-whatsapp-me' ) . '</p>';
558
break;
559
560
case 'message_badge':
561
$output = '<fieldset><legend class="screen-reader-text"><span>' . __( 'Notification Balloon', 'creame-whatsapp-me' ) . '</span></legend>' .
562
- '<label><input id="whatsappme_message_badge" name="whatsappme[message_badge]" value="yes" type="checkbox"' . checked( 'yes', $value, false ) . '> ' .
563
__( 'Display a notification balloon instead of opening the Chat Window for a "less intrusive" mode', 'creame-whatsapp-me' ) . '</label></fieldset>';
564
break;
565
566
case 'dark_mode':
567
$output = '<fieldset><legend class="screen-reader-text"><span>' . __( 'Dark Mode', 'creame-whatsapp-me' ) . '</span></legend>' .
568
- '<label><input name="whatsappme[dark_mode]" value="no" type="radio"' . checked( 'no', $value, false ) . '> ' .
569
__( 'No', 'creame-whatsapp-me' ) . '</label><br>' .
570
- '<label><input name="whatsappme[dark_mode]" value="yes" type="radio"' . checked( 'yes', $value, false ) . '> ' .
571
__( 'Yes', 'creame-whatsapp-me' ) . '</label><br>' .
572
- '<label><input name="whatsappme[dark_mode]" value="auto" type="radio"' . checked( 'auto', $value, false ) . '> ' .
573
__( 'Auto (detects device dark mode)', 'creame-whatsapp-me' ) . '</label></fieldset>';
574
break;
575
576
default:
577
$output = '';
578
break;
@@ -580,7 +619,7 @@ class WhatsAppMe_Admin {
580
}
581
582
// Filter field ouput
583
- echo apply_filters( 'whatsappme_field_output', $output, $field_id, $this->settings );
584
}
585
586
/**
@@ -594,7 +633,7 @@ class WhatsAppMe_Admin {
594
$value = ( isset( $this->settings['visibility']['all'] ) && 'no' == $this->settings['visibility']['all'] ) ? 'no' : 'yes';
595
596
$inheritance = apply_filters(
597
- 'whatsappme_advanced_inheritance',
598
array(
599
'all' => array( 'front_page', 'blog_page', '404_page', 'search', 'archive', 'singular', 'cpts' ),
600
'archive' => array( 'date', 'author' ),
@@ -602,10 +641,10 @@ class WhatsAppMe_Admin {
602
)
603
);
604
605
- echo '<div class="whatsappme_view_all" data-inheritance="' . esc_attr( json_encode( $inheritance ) ) . '">' .
606
- '<label><input type="radio" name="whatsappme[view][all]" value="yes"' . checked( 'yes', $value, false ) . '> ' .
607
'<span class="dashicons dashicons-visibility" title="' . __( 'Show', 'creame-whatsapp-me' ) . '"></span></label>' .
608
- '<label><input type="radio" name="whatsappme[view][all]" value="no"' . checked( 'no', $value, false ) . '> ' .
609
'<span class="dashicons dashicons-hidden" title="' . __( 'Hide', 'creame-whatsapp-me' ) . '"></span></label></div>';
610
}
611
@@ -618,7 +657,7 @@ class WhatsAppMe_Admin {
618
*/
619
public function add_menu() {
620
621
- add_options_page( 'WAme chat', 'WAme chat', 'manage_options', 'whatsappme', array( $this, 'options_page' ) );
622
623
}
624
@@ -631,7 +670,8 @@ class WhatsAppMe_Admin {
631
*/
632
function help_tab() {
633
$screen = get_current_screen();
634
- $utm = '?utm_source=wpadmin&utm_medium=helptab&utm_campaign=v' . str_replace( '.', '_', $this->version );
635
636
$help_tabs = array(
637
array(
@@ -639,29 +679,24 @@ class WhatsAppMe_Admin {
639
'title' => __( 'Support and Help', 'creame-whatsapp-me' ),
640
'content' =>
641
'<p>' . sprintf(
642
- __(
643
- 'If you need help, first review our <a href="%1$s" rel="external" target="_blank">documentation</a> ' .
644
- 'and if you don\'t find a solution check the <a href="%2$s" rel="external" target="_blank">free plugin support forum</a> ' .
645
- 'or buy our <a href="%3$s" rel="external" target="_blank">premium support</a>.',
646
- 'creame-whatsapp-me'
647
- ),
648
- esc_url( 'https://wame.chat/en/docs/' . $utm ),
649
esc_url( 'https://wordpress.org/support/plugin/creame-whatsapp-me/' ),
650
- esc_url( 'https://my.wame.chat/' . $utm )
651
) . '</p>' .
652
- '<p>' . __( 'If you like WAme 😍', 'creame-whatsapp-me' ) . '</p>' .
653
'<ul>' .
654
'<li>' . sprintf(
655
__( "Please leave us a %s rating. We'll thank you.", 'creame-whatsapp-me' ),
656
- '<a href="https://wordpress.org/support/plugin/creame-whatsapp-me/reviews/#new-post" rel="external" target="_blank">★★★★★</a>'
657
) . '</li>' .
658
'<li>' . sprintf(
659
__( 'Subscribe to our newsletter and visit our blog at %s.', 'creame-whatsapp-me' ),
660
- '<a href="https://wame.chat/' . $utm . '" rel="external" target="_blank">wame.chat</a>'
661
) . '</li>' .
662
'<li>' . sprintf(
663
__( 'Follow %s on twitter.', 'creame-whatsapp-me' ),
664
- '<a href="https://twitter.com/wamechat" rel="external" target="_blank">@wamechat</a>'
665
) . '</li>' .
666
'</ul>',
667
),
@@ -677,10 +712,27 @@ class WhatsAppMe_Admin {
677
'<span><code>{TITLE}</code> ➜ ' . __( 'Page Title', 'creame-whatsapp-me' ) . '</span>' .
678
'</p>',
679
),
680
);
681
682
foreach ( $help_tabs as $tab_data ) {
683
- $screen->add_help_tab( apply_filters( 'whatsappme_help_tab_' . str_replace( '-', '_', $tab_data['id'] ), $tab_data ) );
684
}
685
686
}
@@ -690,16 +742,42 @@ class WhatsAppMe_Admin {
690
*
691
* @since 1.0.0
692
* @access public
693
- * @return void
694
*/
695
public function settings_link( $links ) {
696
697
$settings_link = '<a href="options-general.php?page=' . $this->plugin_name . '">' . __( 'Settings', 'creame-whatsapp-me' ) . '</a>';
698
array_unshift( $links, $settings_link );
699
return $links;
700
701
}
702
703
/**
704
* Generate the options page in the WordPress admin
705
*
@@ -713,30 +791,32 @@ class WhatsAppMe_Admin {
713
// Enqueue WordPress media scripts
714
wp_enqueue_media();
715
// Enqueue assets
716
- wp_enqueue_script( 'whatsappme-admin' );
717
- wp_enqueue_style( 'whatsappme-admin' );
718
719
if ( $this->enhanced_phone ) {
720
wp_enqueue_style( 'intl-tel-input' );
721
}
722
723
?>
724
<div class="wrap">
725
- <h1>WAme chat</h1>
726
727
- <form method="post" id="whatsappme_form" action="options.php" autocomplete="off">
728
- <?php settings_fields( 'whatsappme' ); ?>
729
<h2 class="nav-tab-wrapper wp-clearfix" role="tablist">
730
<?php foreach ( $this->tabs as $tab => $name ) : ?>
731
- <?php if ( 'general' === $tab ) : ?>
732
- <a id="navtab_<?php echo $tab; ?>" href="#whatsappme_tab_<?php echo $tab; ?>" class="nav-tab nav-tab-active" role="tab" aria-controls="whatsappme_tab_<?php echo $tab; ?>" aria-selected="true"><?php echo $name; ?></a>
733
<?php else : ?>
734
- <a id="navtab_<?php echo $tab; ?>" href="#whatsappme_tab_<?php echo $tab; ?>" class="nav-tab" role="tab" aria-controls="whatsappme_tab_<?php echo $tab; ?>" aria-selected="false"><?php echo $name; ?></a>
735
<?php endif; ?>
736
<?php endforeach; ?>
737
</h2>
738
- <div class="wametabs">
739
- <?php do_settings_sections( 'whatsappme' ); ?>
740
</div><!-- end tabs -->
741
<?php submit_button(); ?>
742
</form>
@@ -757,13 +837,13 @@ class WhatsAppMe_Admin {
757
// Custom post types with public url
758
$custom_post_types = array_keys( get_post_types( array( 'has_archive' => true ), 'names' ) );
759
760
- // Add/remove posts types for "WAme chat" meta box
761
- $post_types = apply_filters( 'whatsappme_post_types_meta_box', array_merge( $builtin_post_types, $custom_post_types ) );
762
763
foreach ( $post_types as $post_type ) {
764
add_meta_box(
765
- 'whatsappme',
766
- __( 'WAme chat', 'creame-whatsapp-me' ),
767
array( $this, 'meta_box' ),
768
$post_type,
769
'side',
@@ -779,40 +859,33 @@ class WhatsAppMe_Admin {
779
* @since 2.0.0 Now can set as [show, hide, default]
780
* @since 2.2.0 Enqueue scripts/styles. Added "telephone"
781
* @since 3.0.3 Capture and filter output
782
- * @since 3.2.0 Added filter 'whatsappme_metabox_placeholders'
783
* @access public
784
* @return void
785
*/
786
public function meta_box( $post ) {
787
788
// Enqueue assets
789
- wp_enqueue_script( 'whatsappme-admin' );
790
- wp_enqueue_style( 'whatsappme-admin' );
791
792
if ( $this->enhanced_phone ) {
793
wp_enqueue_style( 'intl-tel-input' );
794
}
795
796
- $metadata = get_post_meta( $post->ID, '_whatsappme', true ) ?: array();
797
$metadata = array_merge(
798
array(
799
'telephone' => '',
800
'message_text' => '',
801
'message_send' => '',
802
- 'hide' => false,
803
'view' => '',
804
),
805
$metadata
806
);
807
808
- // Move old 'hide' to new 'view' field
809
- if ( $metadata['hide'] ) {
810
- $metadata['view'] = 'no';
811
- }
812
- unset( $metadata['hide'] );
813
-
814
$placeholders = apply_filters(
815
- 'whatsappme_metabox_placeholders',
816
array(
817
'telephone' => $this->settings['telephone'],
818
'message_text' => $this->settings['message_text'],
@@ -822,45 +895,45 @@ class WhatsAppMe_Admin {
822
$this->settings
823
);
824
825
- $metabox_vars = apply_filters( 'whatsappme_metabox_vars', array( 'SITE', 'URL', 'TITLE' ), $post );
826
827
ob_start();
828
?>
829
- <div class="whatsappme-metabox">
830
- <?php wp_nonce_field( 'whatsappme_data', 'whatsappme_nonce' ); ?>
831
<p>
832
- <label for="whatsappme_phone"><?php _e( 'Telephone', 'creame-whatsapp-me' ); ?></label><br>
833
- <input id="whatsappme_phone" <?php echo $this->enhanced_phone ? 'data-' : ''; ?>name="whatsappme_telephone" value="<?php echo $metadata['telephone']; ?>" type="text" placeholder="<?php echo $placeholders['telephone']; ?>">
834
</p>
835
<p>
836
- <label for="whatsappme_message"><?php _e( 'Call to Action', 'creame-whatsapp-me' ); ?></label><br>
837
- <textarea id="whatsappme_message" name="whatsappme_message" rows="2" placeholder="<?php echo $placeholders['message_text']; ?>" class="large-text"><?php echo $metadata['message_text']; ?></textarea>
838
</p>
839
<p>
840
- <label for="whatsappme_message_send"><?php _e( 'Message', 'creame-whatsapp-me' ); ?></label><br>
841
- <textarea id="whatsappme_message_send" name="whatsappme_message_send" rows="2" placeholder="<?php echo $placeholders['message_send']; ?>" class="large-text"><?php echo $metadata['message_send']; ?></textarea>
842
<?php if ( count( $metabox_vars ) ) : ?>
843
<small><?php _e( 'Can use vars', 'creame-whatsapp-me' ); ?> <code>{<?php echo join( '}</code> <code>{', $metabox_vars ); ?>}</code></small>
844
<?php endif; ?>
845
<small><?php _e( 'to leave it blank use', 'creame-whatsapp-me' ); ?> <code>{}</code></small>
846
</p>
847
<p>
848
- <label><input type="radio" name="whatsappme_view" value="yes" <?php checked( 'yes', $metadata['view'] ); ?>>
849
<span class="dashicons dashicons-visibility" title="<?php echo __( 'Show', 'creame-whatsapp-me' ); ?>"></span></label>
850
- <label><input type="radio" name="whatsappme_view" value="no" <?php checked( 'no', $metadata['view'] ); ?>>
851
<span class="dashicons dashicons-hidden" title="<?php echo __( 'Hide', 'creame-whatsapp-me' ); ?>"></span></label>
852
- <label><input type="radio" name="whatsappme_view" value="" <?php checked( '', $metadata['view'] ); ?>>
853
<?php echo __( 'Default visibility', 'creame-whatsapp-me' ); ?></label>
854
</p>
855
</div>
856
<?php
857
$metabox_output = ob_get_clean();
858
859
- echo apply_filters( 'whatsappme_metabox_output', $metabox_output, $post, $metadata );
860
}
861
862
/**
863
- * Save meta data from "WAme chat" Meta Box on post save
864
*
865
* @since 1.1.0
866
* @since 2.0.0 Change 'hide' key to 'view' now values can be [yes, no]
@@ -871,29 +944,29 @@ class WhatsAppMe_Admin {
871
*/
872
public function save_post( $post_id ) {
873
if ( wp_is_post_autosave( $post_id ) ||
874
- ! isset( $_POST['whatsappme_nonce'] ) ||
875
- ! wp_verify_nonce( $_POST['whatsappme_nonce'], 'whatsappme_data' ) ) {
876
return;
877
}
878
879
// Clean and delete empty/false fields
880
$metadata = array_filter(
881
- WhatsAppMe_Util::clean_input(
882
array(
883
- 'telephone' => $_POST['whatsappme_telephone'],
884
- 'message_text' => $_POST['whatsappme_message'],
885
- 'message_send' => $_POST['whatsappme_message_send'],
886
- 'view' => $_POST['whatsappme_view'],
887
)
888
)
889
);
890
891
- $metadata = apply_filters( 'whatsappme_metabox_save', $metadata, $post_id );
892
893
if ( count( $metadata ) ) {
894
- update_post_meta( $post_id, '_whatsappme', $metadata );
895
} else {
896
- delete_post_meta( $post_id, '_whatsappme' );
897
}
898
}
899
@@ -907,10 +980,10 @@ class WhatsAppMe_Admin {
907
*/
908
public static function vars_help( $field ) {
909
910
- $vars = apply_filters( 'whatsappme_vars_help', array( 'SITE', 'URL', 'TITLE' ), $field );
911
912
- return count( $vars ) ? '<div class="whatsappme_vars_help">' . __( 'You can use vars', 'creame-whatsapp-me' ) . ' ' .
913
- '<a class="whatsappme-show-help" href="#" title="' . __( 'Show Help', 'creame-whatsapp-me' ) . '">?</a><br> ' .
914
'<code>{' . join( '}</code> <code>{', $vars ) . '}</code></div>' : '';
915
916
}
4
* The admin-specific functionality of the plugin.
5
*
6
* @since 1.0.0
7
+ * @since 2.0.0 Added visibility settings
8
* @since 3.0.0 More extendable admin via hooks
9
+ * @package JoinChat
10
+ * @subpackage JoinChat/admin
11
* @author Creame <hola@crea.me>
12
*/
13
+ class JoinChatAdmin {
14
15
/**
16
* The ID of this plugin.
71
$this->version = $version;
72
73
// Updated in get_settings() at 'admin_init' hook
74
+ $this->enhanced_phone = '16.0.11'; // intl-tel-input version
75
$this->tabs = array();
76
$this->settings = array();
77
86
* @since 2.3.0 Added button_delay and whatsapp_web settings, message_delay in seconds
87
* @since 3.0.0 Is public and added plugin enhanced_phone and tabs
88
* @since 3.1.0 Added tooltip and image
89
+ * @since 4.0.0 Added message_views and color
90
*/
91
public function get_settings() {
92
93
// Use International Telephone Input library version or false to disable
94
+ $this->enhanced_phone = apply_filters( 'joinchat_enhanced_phone', $this->enhanced_phone );
95
96
// Admin tabs
97
$this->tabs = apply_filters(
98
+ 'joinchat_admin_tabs',
99
array(
100
+ 'general' => __( 'General', 'creame-whatsapp-me' ),
101
+ 'visibility' => __( 'Visibility', 'creame-whatsapp-me' ),
102
)
103
);
104
113
'whatsapp_web' => 'no',
114
'message_text' => '',
115
'message_delay' => 10,
116
+ 'message_views' => 2,
117
'message_badge' => 'no',
118
'message_send' => '',
119
'message_start' => __( 'Open chat', 'creame-whatsapp-me' ),
120
'position' => 'right',
121
'visibility' => array( 'all' => 'yes' ),
122
+ 'color' => '#25d366',
123
'dark_mode' => 'no',
124
),
125
+ apply_filters( 'joinchat_extra_settings', array() )
126
);
127
128
+ $saved_settings = get_option( 'joinchat' );
129
130
if ( is_array( $saved_settings ) ) {
131
// clean unused saved settings
151
*/
152
public function register_styles( $hook ) {
153
154
+ $styles = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'joinchat.css' : 'joinchat.min.css';
155
+ wp_register_style( 'joinchat-admin', plugin_dir_url( __FILE__ ) . 'css/' . $styles, array(), $this->version, 'all' );
156
157
if ( $this->enhanced_phone ) {
158
wp_register_style( 'intl-tel-input', 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/' . $this->enhanced_phone . '/css/intlTelInput.css', array(), null, 'all' );
169
*/
170
public function register_scripts( $hook ) {
171
172
+ $script = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'joinchat.js' : 'joinchat.min.js';
173
174
if ( $this->enhanced_phone ) {
175
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 );
176
+ wp_register_script( 'joinchat-admin', plugin_dir_url( __FILE__ ) . 'js/' . $script, array( 'jquery', 'wp-color-picker', 'intl-tel-input' ), $this->version, true );
177
wp_localize_script( 'intl-tel-input', 'intl_tel_input_version', $this->enhanced_phone );
178
} else {
179
+ wp_register_script( 'joinchat-admin', plugin_dir_url( __FILE__ ) . 'js/' . $script, array( 'jquery', 'wp-color-picker' ), $this->version, true );
180
}
181
182
}
186
* From v1.2.0 also set filter to disable enhanced phone input
187
*
188
* @since 1.0.0
189
+ * @since 2.0.0 Added tabs for general and Visibility settings
190
* @since 2.3.0 Split general settings in Button and Window Chat
191
* @since 3.0.0 Admin organized by tabs and sections
192
* @access public
194
*/
195
public function settings_init() {
196
197
+ // Register WordPress 'joinchat' settings
198
+ register_setting( 'joinchat', 'joinchat', array( $this, 'settings_validate' ) );
199
200
foreach ( $this->tabs as $tab => $tab_name ) {
201
202
+ add_settings_section( "joinchat_tab_{$tab}_open", null, array( $this, 'settings_tab_open' ), 'joinchat' );
203
204
$sections = $this->get_tab_sections( $tab );
205
206
foreach ( $sections as $section => $fields ) {
207
+ $section_id = "joinchat_tab_{$tab}__{$section}";
208
209
+ add_settings_section( $section_id, null, array( $this, 'section_output' ), 'joinchat' );
210
211
foreach ( $fields as $field => $field_args ) {
212
if ( is_array( $field_args ) ) {
217
$field_callback = array( $this, 'field_output' );
218
}
219
220
+ add_settings_field( "joinchat_$field", $field_name, $field_callback, 'joinchat', $section_id, $field );
221
}
222
}
223
224
+ add_settings_section( "joinchat_tab_{$tab}_close", null, array( $this, 'settings_tab_close' ), 'joinchat' );
225
}
226
227
}
239
if ( 'general' == $tab ) {
240
241
$sections = array(
242
+ 'button' => array(
243
+ 'telephone' => '<label for="joinchat_phone">' . __( 'Telephone', 'creame-whatsapp-me' ) . '</label>',
244
+ 'message_send' => '<label for="joinchat_message_send">' . __( 'Message', 'creame-whatsapp-me' ) . '</label>' . self::vars_help( 'message_send' ),
245
'position' => __( 'Position on Screen', 'creame-whatsapp-me' ),
246
'button_image' => __( 'Image', 'creame-whatsapp-me' ),
247
+ 'button_tip' => '<label for="joinchat_button_tip">' . __( 'Tooltip', 'creame-whatsapp-me' ) . '</label>',
248
+ 'button_delay' => '<label for="joinchat_button_delay">' . __( 'Button Delay', 'creame-whatsapp-me' ) . '</label>',
249
+ 'mobile_only' => __( 'Mobile Only', 'creame-whatsapp-me' ),
250
'whatsapp_web' => __( 'WhatsApp Web', 'creame-whatsapp-me' ),
251
),
252
+ 'chat' => array(
253
+ 'message_text' => '<label for="joinchat_message_text">' . __( 'Call to Action', 'creame-whatsapp-me' ) . '</label>' . self::vars_help( 'message_text' ),
254
+ 'message_start' => '<label for="joinchat_message_start">' . __( 'Start WhatsApp Button', 'creame-whatsapp-me' ) . '</label>',
255
+ 'color' => __( 'Theme Color', 'creame-whatsapp-me' ),
256
'dark_mode' => __( 'Dark Mode', 'creame-whatsapp-me' ),
257
+ 'remove_brand' => __( 'Logo', 'creame-whatsapp-me' ),
258
+ ),
259
+ 'chat_open' => array(
260
+ 'message_delay' => '<label for="joinchat_message_delay">' . __( 'Chat Delay', 'creame-whatsapp-me' ) . '</label>',
261
+ 'message_views' => '<label for="joinchat_message_views">' . __( 'Page Views', 'creame-whatsapp-me' ) . '</label>',
262
+ 'message_badge' => __( 'Notification Balloon', 'creame-whatsapp-me' ),
263
),
264
);
265
266
+ } elseif ( 'visibility' == $tab ) {
267
268
$sections = array(
269
'global' => array(
293
294
// Custom Post Types
295
$custom_post_types = apply_filters(
296
+ 'joinchat_custom_post_types',
297
array_keys( get_post_types( array( 'has_archive' => true ), 'names' ) )
298
);
299
316
}
317
318
// Filter tab sections to add, remove or edit sections or fields
319
+ return apply_filters( "joinchat_tab_{$tab}_sections", $sections );
320
321
}
322
336
337
// Prevent bad behavior when validate twice on first save
338
// bug https://core.trac.wordpress.org/ticket/21989
339
+ if ( count( get_settings_errors( 'joinchat' ) ) ) {
340
return $input;
341
}
342
343
+ $util = new JoinChatUtil(); // Shortcut
344
345
$input['telephone'] = $util::clean_input( $input['telephone'] );
346
$input['mobile_only'] = isset( $input['mobile_only'] ) ? 'yes' : 'no';
353
$input['message_send'] = $util::clean_input( $input['message_send'] );
354
$input['message_start'] = $util::substr( $util::clean_input( $input['message_start'] ), 0, 20 );
355
$input['message_delay'] = intval( $input['message_delay'] );
356
+ $input['message_views'] = intval( $input['message_views'] ) ?: 1;
357
$input['position'] = $input['position'] != 'left' ? 'right' : 'left';
358
+ $input['color'] = preg_match( '/^#[a-f0-9]{6}#x2F;i', $input['color'] ) ? $input['color'] : '#25d366';
359
$input['dark_mode'] = in_array( $input['dark_mode'], array( 'no', 'yes', 'auto' ) ) ? $input['dark_mode'] : 'no';
360
if ( isset( $input['view'] ) ) {
361
$input['visibility'] = array_filter(
368
}
369
370
// Filter for other validations or extra settings
371
+ $input = apply_filters( 'joinchat_settings_validate', $input );
372
373
/**
374
* Register WPML/Polylang strings for translation
375
* https://wpml.org/wpml-hook/wpml_register_single_string/
376
*/
377
+ $settings_i18n = JoinChatUtil::settings_i18n();
378
379
foreach ( $settings_i18n as $setting_key => $setting_name ) {
380
+ do_action( 'wpml_register_single_string', 'Join.chat', $setting_name, $input[ $setting_key ] );
381
}
382
383
// Extra actions on save
384
+ do_action( 'joinchat_settings_validate', $input );
385
386
+ add_settings_error( 'joinchat', 'settings_updated', __( 'Settings saved', 'creame-whatsapp-me' ), 'updated' );
387
388
return $input;
389
}
397
*/
398
public function settings_tab_open( $args ) {
399
400
+ $tab_id = str_replace( array( 'joinchat_tab_', '_open' ), '', $args['id'] );
401
+ $active_tab = isset( $_GET['tab'] ) && in_array( $_GET['tab'], array_keys( $this->tabs ) ) ? $_GET['tab'] : 'general';
402
+ $active = $active_tab == $tab_id ? 'joinchat-tab-active' : '';
403
404
+ echo "<div id=\"joinchat_tab_$tab_id\" class=\"joinchat-tab $active\" role=\"tabpanel\" aria-labelledby=\"navtab_$tab_id\" >";
405
406
}
407
429
$section_id = $args['id'];
430
431
switch ( $section_id ) {
432
+ case 'joinchat_tab_general__button':
433
$output = '<h2 class="title">' . __( 'Button', 'creame-whatsapp-me' ) . '</h2>' .
434
'<p>' . __( 'Set the contact number and where you want the WhatsApp button to be displayed.', 'creame-whatsapp-me' ) . '</p>';
435
break;
436
437
+ case 'joinchat_tab_general__chat':
438
$output = '<hr><h2 class="title">' . __( 'Chat Window', 'creame-whatsapp-me' ) . '</h2>' .
439
'<p>' .
440
__( 'If you define a "Call to Action" a window will be displayed simulating a chat before launching WhatsApp.', 'creame-whatsapp-me' ) . ' ' .
442
'</p>';
443
break;
444
445
+ case 'joinchat_tab_general__chat_open':
446
+ $output = '<p>' .
447
+ __( 'If it\'s defined a "Call to Action", the Chat Window can be displayed automatically if conditions are met.', 'creame-whatsapp-me' ) .
448
+ ' <a class="joinchat-show-help" href="#tab-link-triggers" title="' . __( 'Show Help', 'creame-whatsapp-me' ) . '">?</a>' .
449
+ '</p>';
450
+ break;
451
+
452
+ case 'joinchat_tab_visibility__global':
453
+ $output = '<h2 class="title">' . __( 'Visibility Settings', 'creame-whatsapp-me' ) . '</h2>' .
454
'<p>' . __( 'From here you can configure on which pages the WhatsApp button will be visible.', 'creame-whatsapp-me' ) .
455
+ ' <a href="#" class="joinchat_view_reset">' . __( 'Restore default visibility', 'creame-whatsapp-me' ) . '</a></p>';
456
break;
457
458
+ case 'joinchat_tab_visibility__wp':
459
$output = '<hr>';
460
break;
461
462
+ case 'joinchat_tab_visibility__cpt':
463
$output = '<h2 class="title">' . __( 'Custom Post Types', 'creame-whatsapp-me' ) . '</h2>';
464
break;
465
469
}
470
471
// Filter section opening ouput
472
+ echo apply_filters( 'joinchat_section_output', $output, $section_id );
473
}
474
475
/**
485
$field = substr( $field_id, 6 );
486
$value = isset( $this->settings['visibility'][ $field ] ) ? $this->settings['visibility'][ $field ] : '';
487
488
+ $output = '<label><input type="radio" name="joinchat[view][' . $field . ']" value="yes"' . checked( 'yes', $value, false ) . '> ' .
489
'<span class="dashicons dashicons-visibility" title="' . __( 'Show', 'creame-whatsapp-me' ) . '"></span></label>' .
490
+ '<label><input type="radio" name="joinchat[view][' . $field . ']" value="no"' . checked( 'no', $value, false ) . '> ' .
491
'<span class="dashicons dashicons-hidden" title="' . __( 'Hide', 'creame-whatsapp-me' ) . '"></span></label>' .
492
+ '<label><input type="radio" name="joinchat[view][' . $field . ']" value=""' . checked( '', $value, false ) . '> ' .
493
__( 'Inherit', 'creame-whatsapp-me' ) . ' <span class="dashicons dashicons-visibility view_inheritance_' . $field . '"></span></label>';
494
495
} else {
496
497
$value = isset( $this->settings[ $field_id ] ) ? $this->settings[ $field_id ] : '';
498
+ $utm = '?utm_source=settings&utm_medium=wpadmin&utm_campaign=v' . str_replace( '.', '_', $this->version );
499
+ $lang = _x( 'en', 'url lang slug (only avaible for spanish "es")', 'creame-whatsapp-me' );
500
501
switch ( $field_id ) {
502
case 'telephone':
503
+ $output = '<input id="joinchat_phone" ' . ( $this->enhanced_phone ? 'data-' : '' ) . 'name="joinchat[telephone]" value="' . $value . '" type="text" style="width:15em">' .
504
'<p class="description">' . __( "Contact phone number <strong>(the button will not be shown if it's empty)</strong>", 'creame-whatsapp-me' ) . '</p>' .
505
+ '<p class="joinchat-addon">' . sprintf(
506
__( 'Add unlimited numbers with %1$s or multiple contacts with %2$s', 'creame-whatsapp-me' ),
507
+ '<a href="https://join.chat/' . $lang . '/addons/random-phone/' . $utm . '" target="_blank">\'Random Phone\'</a>',
508
+ '<a href="https://join.chat/' . $lang . '/addons/support-agents/' . $utm . '" target="_blank">\'Support Agents\'</a>'
509
) . '</p>';
510
break;
511
512
case 'mobile_only':
513
$output = '<fieldset><legend class="screen-reader-text"><span>' . __( 'Mobile Only', 'creame-whatsapp-me' ) . '</span></legend>' .
514
+ '<label><input id="joinchat_mobile_only" name="joinchat[mobile_only]" value="yes" type="checkbox"' . checked( 'yes', $value, false ) . '> ' .
515
__( 'Only display the button on mobile devices', 'creame-whatsapp-me' ) . '</label></fieldset>';
516
break;
517
518
case 'position':
519
$output = '<fieldset><legend class="screen-reader-text"><span>' . __( 'Position on Screen', 'creame-whatsapp-me' ) . '</span></legend>' .
520
+ '<label><input name="joinchat[position]" value="left" type="radio"' . checked( 'left', $value, false ) . '> ' .
521
__( 'Left', 'creame-whatsapp-me' ) . '</label><br>' .
522
+ '<label><input name="joinchat[position]" value="right" type="radio"' . checked( 'right', $value, false ) . '> ' .
523
__( 'Right', 'creame-whatsapp-me' ) . '</label></fieldset>';
524
break;
525
526
case 'button_image':
527
+ $thumb = intval( $value ) > 0 ? JoinChatUtil::thumb( $value, 116, 116 ) : false;
528
$image = is_array( $thumb ) ? $thumb['url'] : false;
529
530
+ $output = '<div id="joinchat_button_image_wrapper">' .
531
+ '<div id="joinchat_button_image_holder" ' . ( $image ? "style=\"background-size:cover; background-image:url('$image');\"" : '' ) . '></div>' .
532
+ '<input id="joinchat_button_image" name="joinchat[button_image]" type="hidden" value="' . $value . '">' .
533
+ '<input id="joinchat_button_image_add" type="button" value="' . esc_attr__( 'Select an image', 'creame-whatsapp-me' ) . '" class="button-primary" ' .
534
'data-title="' . esc_attr__( 'Select button image', 'creame-whatsapp-me' ) . '" data-button="' . esc_attr__( 'Use image', 'creame-whatsapp-me' ) . '"> ' .
535
+ '<input id="joinchat_button_image_remove" type="button" value="' . esc_attr__( 'Remove', 'creame-whatsapp-me' ) . '" class="button-secondary' . ( $image ? '' : ' joinchat-hidden' ) . '">' .
536
'<p class="description">' . __( 'The image will alternate with WhatsApp logo', 'creame-whatsapp-me' ) . '</p></div>';
537
break;
538
539
case 'button_tip':
540
+ $output = '<input id="joinchat_button_tip" name="joinchat[button_tip]" value="' . $value . '" type="text" maxlength="40" class="regular-text" placeholder="' . esc_attr__( '💬 Need help?', 'creame-whatsapp-me' ) . '"> ' .
541
'<p class="description">' . __( 'Short text shown next to WhatsApp button', 'creame-whatsapp-me' ) . '</p>';
542
break;
543
544
case 'button_delay':
545
+ $output = '<input id="joinchat_button_delay" name="joinchat[button_delay]" value="' . $value . '" type="number" min="0" max="120" style="width:5em"> ' . __( 'seconds', 'creame-whatsapp-me' ) .
546
'<p class="description">' . __( 'Time since the page is opened until the WhatsApp button is displayed', 'creame-whatsapp-me' ) . '</p>';
547
break;
548
549
case 'whatsapp_web':
550
$output = '<fieldset><legend class="screen-reader-text"><span>' . __( 'WhatsApp Web', 'creame-whatsapp-me' ) . '</span></legend>' .
551
+ '<label><input id="joinchat_whatsapp_web" name="joinchat[whatsapp_web]" value="yes" type="checkbox"' . checked( 'yes', $value, false ) . '> ' .
552
__( 'Open <em>WhatsApp Web</em> directly on desktop', 'creame-whatsapp-me' ) . '</label></fieldset>';
553
break;
554
555
case 'message_text':
556
+ $output = '<textarea id="joinchat_message_text" name="joinchat[message_text]" rows="4" class="regular-text" placeholder="' . esc_attr__( "Hello 👋\nCan we help you?", 'creame-whatsapp-me' ) . '">' . $value . '</textarea>' .
557
'<p class="description">' . __( 'Define a text to encourage users to contact by WhatsApp', 'creame-whatsapp-me' ) . '</p>' .
558
+ '<p class="joinchat-addon">' . sprintf(
559
__( 'Add links, images, videos and more with %s', 'creame-whatsapp-me' ),
560
+ '<a href="https://join.chat/' . $lang . '/addons/cta-extras/' . $utm . '" target="_blank">\'CTA Extras\'</a>'
561
) . '</p>';
562
break;
563
564
case 'message_send':
565
+ $output = '<textarea id="joinchat_message_send" name="joinchat[message_send]" rows="3" class="regular-text" placeholder="' . esc_attr__( 'Hi *{SITE}*! I need more info about {TITLE} {URL}', 'creame-whatsapp-me' ) . '">' . $value . '</textarea>' .
566
'<p class="description">' . __( 'Predefined text for the first message the user will send you', 'creame-whatsapp-me' ) . '</p>';
567
break;
568
569
case 'message_start':
570
+ $output = '<input id="joinchat_message_start" name="joinchat[message_start]" value="' . $value . '" type="text" maxlength="20" class="regular-text" placeholder="' . esc_attr__( 'Open chat', 'creame-whatsapp-me' ) . '"> ' .
571
'<p class="description">' . __( 'Text of the start WhatsApp button on Chat Window', 'creame-whatsapp-me' ) . '</p>';
572
break;
573
574
case 'message_delay':
575
+ $output = '<input id="joinchat_message_delay" name="joinchat[message_delay]" value="' . $value . '" type="number" min="0" max="120" style="width:5em"> ' . __( 'seconds (0 disabled)', 'creame-whatsapp-me' ) .
576
+ '<p class="description">' . __( 'Chat Window auto displays after delay', 'creame-whatsapp-me' ) . '</p>';
577
+ break;
578
+
579
+ case 'message_views':
580
+ $output = '<input id="joinchat_message_views" name="joinchat[message_views]" value="' . $value . '" type="number" min="1" max="120" style="width:5em"> ' .
581
+ '<p class="description">' . __( 'Chat Window auto displays from this number of page views', 'creame-whatsapp-me' ) . '</p>';
582
break;
583
584
case 'message_badge':
585
$output = '<fieldset><legend class="screen-reader-text"><span>' . __( 'Notification Balloon', 'creame-whatsapp-me' ) . '</span></legend>' .
586
+ '<label><input id="joinchat_message_badge" name="joinchat[message_badge]" value="yes" type="checkbox"' . checked( 'yes', $value, false ) . '> ' .
587
__( 'Display a notification balloon instead of opening the Chat Window for a "less intrusive" mode', 'creame-whatsapp-me' ) . '</label></fieldset>';
588
break;
589
590
+ case 'color':
591
+ $output = '<input id="joinchat_color" name="joinchat[color]" value="' . $value . '" type="text" data-default-color="#25d366"> ';
592
+ break;
593
+
594
case 'dark_mode':
595
$output = '<fieldset><legend class="screen-reader-text"><span>' . __( 'Dark Mode', 'creame-whatsapp-me' ) . '</span></legend>' .
596
+ '<label><input name="joinchat[dark_mode]" value="no" type="radio"' . checked( 'no', $value, false ) . '> ' .
597
__( 'No', 'creame-whatsapp-me' ) . '</label><br>' .
598
+ '<label><input name="joinchat[dark_mode]" value="yes" type="radio"' . checked( 'yes', $value, false ) . '> ' .
599
__( 'Yes', 'creame-whatsapp-me' ) . '</label><br>' .
600
+ '<label><input name="joinchat[dark_mode]" value="auto" type="radio"' . checked( 'auto', $value, false ) . '> ' .
601
__( 'Auto (detects device dark mode)', 'creame-whatsapp-me' ) . '</label></fieldset>';
602
break;
603
604
+ case 'remove_brand':
605
+ $output = '<fieldset><legend class="screen-reader-text"><span>' . __( 'Logo', 'creame-whatsapp-me' ) . '</span></legend>' .
606
+ '<label><input id="joinchat_remove_brand" type="checkbox" disabled> ' .
607
+ __( 'Remove "Powered by Join.chat" link', 'creame-whatsapp-me' ) . '</label></fieldset>' .
608
+ '<p class="joinchat-addon">' . sprintf(
609
+ __( 'Included with all our %1$sadd-ons%2$s', 'creame-whatsapp-me' ),
610
+ '<a target="_blank" href="https://join.chat/' . $lang . '/addons/' . $utm . '">',
611
+ '</a>'
612
+ ) . '</p>';
613
+ break;
614
+
615
default:
616
$output = '';
617
break;
619
}
620
621
// Filter field ouput
622
+ echo apply_filters( 'joinchat_field_output', $output, $field_id, $this->settings );
623
}
624
625
/**
633
$value = ( isset( $this->settings['visibility']['all'] ) && 'no' == $this->settings['visibility']['all'] ) ? 'no' : 'yes';
634
635
$inheritance = apply_filters(
636
+ 'joinchat_visibility_inheritance',
637
array(
638
'all' => array( 'front_page', 'blog_page', '404_page', 'search', 'archive', 'singular', 'cpts' ),
639
'archive' => array( 'date', 'author' ),
641
)
642
);
643
644
+ echo '<div class="joinchat_view_all" data-inheritance="' . esc_attr( json_encode( $inheritance ) ) . '">' .
645
+ '<label><input type="radio" name="joinchat[view][all]" value="yes"' . checked( 'yes', $value, false ) . '> ' .
646
'<span class="dashicons dashicons-visibility" title="' . __( 'Show', 'creame-whatsapp-me' ) . '"></span></label>' .
647
+ '<label><input type="radio" name="joinchat[view][all]" value="no"' . checked( 'no', $value, false ) . '> ' .
648
'<span class="dashicons dashicons-hidden" title="' . __( 'Hide', 'creame-whatsapp-me' ) . '"></span></label></div>';
649
}
650
657
*/
658
public function add_menu() {
659
660
+ add_options_page( 'Join.chat', 'Join.chat', 'manage_options', 'joinchat', array( $this, 'options_page' ) );
661
662
}
663
670
*/
671
function help_tab() {
672
$screen = get_current_screen();
673
+ $utm = '?utm_source=helptab&utm_medium=wpadmin&utm_campaign=v' . str_replace( '.', '_', $this->version );
674
+ $lang = _x( 'en', 'url lang slug (only avaible for spanish "es")', 'creame-whatsapp-me' );
675
676
$help_tabs = array(
677
array(
679
'title' => __( 'Support and Help', 'creame-whatsapp-me' ),
680
'content' =>
681
'<p>' . sprintf(
682
+ __( 'If you need help, first review our <a href="%1$s" target="_blank">documentation</a> and if you don\'t find a solution check the <a href="%2$s" target="_blank">free plugin support forum</a> or buy our <a href="%3$s" target="_blank">premium support</a>.', 'creame-whatsapp-me' ),
683
+ esc_url( 'https://join.chat/' . $lang . '/docs/' . $utm ),
684
esc_url( 'https://wordpress.org/support/plugin/creame-whatsapp-me/' ),
685
+ esc_url( 'https://my.join.chat/' . $utm )
686
) . '</p>' .
687
+ '<p>' . __( 'If you like Join.chat 😍', 'creame-whatsapp-me' ) . '</p>' .
688
'<ul>' .
689
'<li>' . sprintf(
690
__( "Please leave us a %s rating. We'll thank you.", 'creame-whatsapp-me' ),
691
+ '<a href="https://wordpress.org/support/plugin/creame-whatsapp-me/reviews/#new-post" target="_blank">★★★★★</a>'
692
) . '</li>' .
693
'<li>' . sprintf(
694
__( 'Subscribe to our newsletter and visit our blog at %s.', 'creame-whatsapp-me' ),
695
+ '<a href="https://join.chat/' . $utm . '" target="_blank">join.chat</a>'
696
) . '</li>' .
697
'<li>' . sprintf(
698
__( 'Follow %s on twitter.', 'creame-whatsapp-me' ),
699
+ '<a href="https://twitter.com/joinchatnow" target="_blank">@joinchatnow</a>'
700
) . '</li>' .
701
'</ul>',
702
),
712
'<span><code>{TITLE}</code> ➜ ' . __( 'Page Title', 'creame-whatsapp-me' ) . '</span>' .
713
'</p>',
714
),
715
+ array(
716
+ 'id' => 'triggers',
717
+ 'title' => __( 'Triggers', 'creame-whatsapp-me' ),
718
+ 'content' =>
719
+ '<p>' . __( 'Chat Window with a Call to Action (CTA) can be displayed automatically after a defined delay time and from a number of page views.', 'creame-whatsapp-me' ) . ' ' .
720
+ __( 'When the user close Chat Window or open WhatsApp, that CTA will not automatically show again.', 'creame-whatsapp-me' ) . '</p>' .
721
+ '<p>' . __( 'You can also interact with Join.chat in your pages adding some CSS classes to your HTML:', 'creame-whatsapp-me' ) . '</p>' .
722
+ '<ul>' .
723
+ '<li><code>joinchat_open</code> ' . __( 'to show Chat Window or open WhatsApp on click.', 'creame-whatsapp-me' ) . '</li>' .
724
+ '<li><code>joinchat_close</code> ' . __( 'to hide Chat Window on click.', 'creame-whatsapp-me' ) . '</li>' .
725
+ '<li>' . __( 'To show Chat Window when an HTML element appears on screen when user scrolls:', 'creame-whatsapp-me' ) .
726
+ '<ul>' .
727
+ '<li><code>joinchat_show</code> ' . __( 'only show if it\'s an not seen CTA.', 'creame-whatsapp-me' ) . '</li>' .
728
+ '<li><code>joinchat_force_show</code> ' . __( 'to show allways.', 'creame-whatsapp-me' ) . '</li>' .
729
+ '</ul></li>' .
730
+ '</ul>',
731
+ ),
732
);
733
734
foreach ( $help_tabs as $tab_data ) {
735
+ $screen->add_help_tab( apply_filters( 'joinchat_help_tab_' . str_replace( '-', '_', $tab_data['id'] ), $tab_data ) );
736
}
737
738
}
742
*
743
* @since 1.0.0
744
* @access public
745
+ * @param array $links current plugin links.
746
+ * @return array
747
*/
748
public function settings_link( $links ) {
749
750
$settings_link = '<a href="options-general.php?page=' . $this->plugin_name . '">' . __( 'Settings', 'creame-whatsapp-me' ) . '</a>';
751
array_unshift( $links, $settings_link );
752
+
753
return $links;
754
755
}
756
757
+ /**
758
+ * Add plugin meta links
759
+ *
760
+ * @since 4.0.0
761
+ * @access public
762
+ * @param array $plugin_meta current plugin row meta.
763
+ * @param string $plugin_file plugin file.
764
+ * @return array
765
+ */
766
+ public function plugin_links( $plugin_meta, $plugin_file ) {
767
+
768
+ if ( 'creame-whatsapp-me/joinchat.php' == $plugin_file ) {
769
+ $utm = '?utm_source=plugins&utm_medium=wpadmin&utm_campaign=v' . str_replace( '.', '_', $this->version );
770
+ $lang = _x( 'en', 'url lang slug (only avaible for spanish "es")', 'creame-whatsapp-me' );
771
+
772
+ $plugin_meta[] = '<a target="_blank" href="https://join.chat/' . $lang . '/docs/' . $utm . '">' . __( 'Documentation', 'creame-whatsapp-me' ) . '</a>';
773
+ $plugin_meta[] = '<a target="_blank" href="https://join.chat/' . $lang . '/addons/' . $utm . '">' . __( 'Add-ons', 'creame-whatsapp-me' ) . '</a>';
774
+ $plugin_meta[] = '<a target="_blank" href="https://join.chat/' . $lang . '/support/' . $utm . '">' . __( 'Support', 'creame-whatsapp-me' ) . '</a>';
775
+ }
776
+
777
+ return $plugin_meta;
778
+
779
+ }
780
+
781
/**
782
* Generate the options page in the WordPress admin
783
*
791
// Enqueue WordPress media scripts
792
wp_enqueue_media();
793
// Enqueue assets
794
+ wp_enqueue_script( 'joinchat-admin' );
795
+ wp_enqueue_style( 'wp-color-picker' );
796
+ wp_enqueue_style( 'joinchat-admin' );
797
798
if ( $this->enhanced_phone ) {
799
wp_enqueue_style( 'intl-tel-input' );
800
}
801
802
+ $active_tab = isset( $_GET['tab'] ) && in_array( $_GET['tab'], array_keys( $this->tabs ) ) ? $_GET['tab'] : 'general';
803
?>
804
<div class="wrap">
805
+ <h1><?php _e( 'Join.chat Settings', 'creame-whatsapp-me' ); ?></h1>
806
807
+ <form method="post" id="joinchat_form" action="options.php" autocomplete="off">
808
+ <?php settings_fields( 'joinchat' ); ?>
809
<h2 class="nav-tab-wrapper wp-clearfix" role="tablist">
810
<?php foreach ( $this->tabs as $tab => $name ) : ?>
811
+ <?php if ( $active_tab === $tab ) : ?>
812
+ <a id="navtab_<?php echo $tab; ?>" href="#joinchat_tab_<?php echo $tab; ?>" class="nav-tab nav-tab-active" role="tab" aria-controls="joinchat_tab_<?php echo $tab; ?>" aria-selected="true"><?php echo $name; ?></a>
813
<?php else : ?>
814
+ <a id="navtab_<?php echo $tab; ?>" href="#joinchat_tab_<?php echo $tab; ?>" class="nav-tab" role="tab" aria-controls="joinchat_tab_<?php echo $tab; ?>" aria-selected="false"><?php echo $name; ?></a>
815
<?php endif; ?>
816
<?php endforeach; ?>
817
</h2>
818
+ <div class="joinchat-tabs">
819
+ <?php do_settings_sections( 'joinchat' ); ?>
820
</div><!-- end tabs -->
821
<?php submit_button(); ?>
822
</form>
837
// Custom post types with public url
838
$custom_post_types = array_keys( get_post_types( array( 'has_archive' => true ), 'names' ) );
839
840
+ // Add/remove posts types for "Join.chat" meta box
841
+ $post_types = apply_filters( 'joinchat_post_types_meta_box', array_merge( $builtin_post_types, $custom_post_types ) );
842
843
foreach ( $post_types as $post_type ) {
844
add_meta_box(
845
+ 'joinchat',
846
+ __( 'Join.chat', 'creame-whatsapp-me' ),
847
array( $this, 'meta_box' ),
848
$post_type,
849
'side',
859
* @since 2.0.0 Now can set as [show, hide, default]
860
* @since 2.2.0 Enqueue scripts/styles. Added "telephone"
861
* @since 3.0.3 Capture and filter output
862
+ * @since 3.2.0 Added filter 'joinchat_metabox_placeholders'
863
* @access public
864
* @return void
865
*/
866
public function meta_box( $post ) {
867
868
// Enqueue assets
869
+ wp_enqueue_script( 'joinchat-admin' );
870
+ wp_enqueue_style( 'joinchat-admin' );
871
872
if ( $this->enhanced_phone ) {
873
wp_enqueue_style( 'intl-tel-input' );
874
}
875
876
+ $metadata = get_post_meta( $post->ID, '_joinchat', true ) ?: array();
877
$metadata = array_merge(
878
array(
879
'telephone' => '',
880
'message_text' => '',
881
'message_send' => '',
882
'view' => '',
883
),
884
$metadata
885
);
886
887
$placeholders = apply_filters(
888
+ 'joinchat_metabox_placeholders',
889
array(
890
'telephone' => $this->settings['telephone'],
891
'message_text' => $this->settings['message_text'],
895
$this->settings
896
);
897
898
+ $metabox_vars = apply_filters( 'joinchat_metabox_vars', array( 'SITE', 'URL', 'TITLE' ), $post );
899
900
ob_start();
901
?>
902
+ <div class="joinchat-metabox">
903
+ <?php wp_nonce_field( 'joinchat_data', 'joinchat_nonce' ); ?>
904
<p>
905
+ <label for="joinchat_phone"><?php _e( 'Telephone', 'creame-whatsapp-me' ); ?></label><br>
906
+ <input id="joinchat_phone" <?php echo $this->enhanced_phone ? 'data-' : ''; ?>name="joinchat_telephone" value="<?php echo $metadata['telephone']; ?>" type="text" placeholder="<?php echo $placeholders['telephone']; ?>">
907
</p>
908
<p>
909
+ <label for="joinchat_message"><?php _e( 'Call to Action', 'creame-whatsapp-me' ); ?></label><br>
910
+ <textarea id="joinchat_message" name="joinchat_message" rows="2" placeholder="<?php echo $placeholders['message_text']; ?>" class="large-text"><?php echo $metadata['message_text']; ?></textarea>
911
</p>
912
<p>
913
+ <label for="joinchat_message_send"><?php _e( 'Message', 'creame-whatsapp-me' ); ?></label><br>
914
+ <textarea id="joinchat_message_send" name="joinchat_message_send" rows="2" placeholder="<?php echo $placeholders['message_send']; ?>" class="large-text"><?php echo $metadata['message_send']; ?></textarea>
915
<?php if ( count( $metabox_vars ) ) : ?>
916
<small><?php _e( 'Can use vars', 'creame-whatsapp-me' ); ?> <code>{<?php echo join( '}</code> <code>{', $metabox_vars ); ?>}</code></small>
917
<?php endif; ?>
918
<small><?php _e( 'to leave it blank use', 'creame-whatsapp-me' ); ?> <code>{}</code></small>
919
</p>
920
<p>
921
+ <label><input type="radio" name="joinchat_view" value="yes" <?php checked( 'yes', $metadata['view'] ); ?>>
922
<span class="dashicons dashicons-visibility" title="<?php echo __( 'Show', 'creame-whatsapp-me' ); ?>"></span></label>
923
+ <label><input type="radio" name="joinchat_view" value="no" <?php checked( 'no', $metadata['view'] ); ?>>
924
<span class="dashicons dashicons-hidden" title="<?php echo __( 'Hide', 'creame-whatsapp-me' ); ?>"></span></label>
925
+ <label><input type="radio" name="joinchat_view" value="" <?php checked( '', $metadata['view'] ); ?>>
926
<?php echo __( 'Default visibility', 'creame-whatsapp-me' ); ?></label>
927
</p>
928
</div>
929
<?php
930
$metabox_output = ob_get_clean();
931
932
+ echo apply_filters( 'joinchat_metabox_output', $metabox_output, $post, $metadata );
933
}
934
935
/**
936
+ * Save meta data from "Join.chat" Meta Box on post save
937
*
938
* @since 1.1.0
939
* @since 2.0.0 Change 'hide' key to 'view' now values can be [yes, no]
944
*/
945
public function save_post( $post_id ) {
946
if ( wp_is_post_autosave( $post_id ) ||
947
+ ! isset( $_POST['joinchat_nonce'] ) ||
948
+ ! wp_verify_nonce( $_POST['joinchat_nonce'], 'joinchat_data' ) ) {
949
return;
950
}
951
952
// Clean and delete empty/false fields
953
$metadata = array_filter(
954
+ JoinChatUtil::clean_input(
955
array(
956
+ 'telephone' => $_POST['joinchat_telephone'],
957
+ 'message_text' => $_POST['joinchat_message'],
958
+ 'message_send' => $_POST['joinchat_message_send'],
959
+ 'view' => $_POST['joinchat_view'],
960
)
961
)
962
);
963
964
+ $metadata = apply_filters( 'joinchat_metabox_save', $metadata, $post_id );
965
966
if ( count( $metadata ) ) {
967
+ update_post_meta( $post_id, '_joinchat', $metadata );
968
} else {
969
+ delete_post_meta( $post_id, '_joinchat' );
970
}
971
}
972
980
*/
981
public static function vars_help( $field ) {
982
983
+ $vars = apply_filters( 'joinchat_vars_help', array( 'SITE', 'URL', 'TITLE' ), $field );
984
985
+ return count( $vars ) ? '<div class="joinchat_vars_help">' . __( 'You can use vars', 'creame-whatsapp-me' ) . ' ' .
986
+ '<a class="joinchat-show-help" href="#" title="' . __( 'Show Help', 'creame-whatsapp-me' ) . '">?</a><br> ' .
987
'<code>{' . join( '}</code> <code>{', $vars ) . '}</code></div>' : '';
988
989
}
admin/{class-whatsappme-wooadmin.php → class-joinchat-wooadmin.php} RENAMED
@@ -4,37 +4,37 @@
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_settings_i18n', $this, 'settings_i18n' );
27
- $loader->add_filter( 'whatsappme_admin_tabs', $this, 'admin_tab' );
28
- $loader->add_filter( 'whatsappme_custom_post_types', $this, 'custom_post_types' );
29
- $loader->add_filter( 'whatsappme_tab_advanced_sections', $this, 'advanced_tab_section' );
30
- $loader->add_filter( 'whatsappme_tab_woocommerce_sections', $this, 'woo_tab_sections' );
31
- $loader->add_filter( 'whatsappme_vars_help', $this, 'vars_help', 10, 2 );
32
- $loader->add_filter( 'whatsappme_section_output', $this, 'section_ouput', 10, 2 );
33
- $loader->add_filter( 'whatsappme_field_output', $this, 'field_ouput', 10, 3 );
34
- $loader->add_filter( 'whatsappme_advanced_inheritance', $this, 'advanced_inheritance' );
35
- $loader->add_filter( 'whatsappme_help_tab_styles_and_vars', $this, 'help_vars' );
36
- $loader->add_filter( 'whatsappme_metabox_vars', $this, 'metabox_vars', 10, 2 );
37
- $loader->add_filter( 'whatsappme_metabox_placeholders', $this, 'metabox_placeholders', 10, 3 );
38
}
39
40
/**
@@ -64,9 +64,9 @@ class WhatsAppMe_WooAdmin {
64
*/
65
public function settings_validate( $input ) {
66
67
- $input['message_text_product'] = WhatsAppMe_Util::clean_input( $input['message_text_product'] );
68
- $input['message_text_on_sale'] = WhatsAppMe_Util::clean_input( $input['message_text_on_sale'] );
69
- $input['message_send_product'] = WhatsAppMe_Util::clean_input( $input['message_send_product'] );
70
71
return $input;
72
}
@@ -116,13 +116,13 @@ class WhatsAppMe_WooAdmin {
116
}
117
118
/**
119
- * Woocommerce sections and fields for 'whatsappme_tab_advanced'
120
*
121
* @since 3.0.0
122
* @param array $sections current tab sections and fields.
123
* @return array
124
*/
125
- public function advanced_tab_section( $sections ) {
126
127
$sections['woo'] = array(
128
'view__woocommerce' => __( 'Shop', 'creame-whatsapp-me' ),
@@ -136,7 +136,7 @@ class WhatsAppMe_WooAdmin {
136
}
137
138
/**
139
- * Woocommerce sections and fields for 'whatsappme_tab_woocommerce'
140
*
141
* @since 3.0.0
142
* @param array $sections current tab sections and fields.
@@ -151,7 +151,7 @@ class WhatsAppMe_WooAdmin {
151
);
152
153
foreach ( $woo_sections as $key => $label ) {
154
- $woo_sections[ $key ] = "<label for=\"whatsappme_$key\">$label</label>" . WhatsAppMe_Admin::vars_help( $key );
155
}
156
157
$sections['chat'] = $woo_sections;
@@ -160,7 +160,7 @@ class WhatsAppMe_WooAdmin {
160
}
161
162
/**
163
- * Woocommerce sections and fields for 'whatsappme_tab_woocommerce'
164
*
165
* @since 3.0.0
166
* @param array $sections current tab sections and fields.
@@ -187,11 +187,11 @@ class WhatsAppMe_WooAdmin {
187
*/
188
public function section_ouput( $output, $section_id ) {
189
190
- if ( 'whatsappme_tab_advanced__woo' == $section_id ) {
191
192
$output = '<h2 class="title">' . __( 'WooCommerce', 'creame-whatsapp-me' ) . '</h2>';
193
194
- } elseif ( 'whatsappme_tab_woocommerce__chat' == $section_id ) {
195
196
$output = '<h2 class="title">' . __( 'Product Chat Window', 'creame-whatsapp-me' ) . '</h2>' .
197
'<p>' .
@@ -209,7 +209,7 @@ class WhatsAppMe_WooAdmin {
209
* @since 3.0.0
210
* @param string $output current field output.
211
* @param string $field_id current field id.
212
- * @param array $settings current whatsappme settings.
213
* @return string
214
*/
215
public function field_ouput( $output, $field_id, $settings ) {
@@ -218,21 +218,21 @@ class WhatsAppMe_WooAdmin {
218
219
switch ( $field_id ) {
220
case 'message_text_product':
221
- $output = '<textarea id="whatsappme_message_text_product" name="whatsappme[message_text_product]" rows="4" class="regular-text" ' .
222
'placeholder="' . esc_attr__( "This *{PRODUCT}* can be yours for only *{PRICE}*!\nIf you have any questions, ask us.", 'creame-whatsapp-me' ) . '">' .
223
$value . '</textarea>' .
224
'<p class="description">' . __( 'Define a text for your products to encourage customers to contact', 'creame-whatsapp-me' ) . '</p>';
225
break;
226
227
case 'message_text_on_sale':
228
- $output = '<textarea id="whatsappme_message_text_on_sale" name="whatsappme[message_text_on_sale]" rows="4" class="regular-text" ' .
229
'placeholder="' . esc_attr__( "Save {DISCOUNT}! This *{PRODUCT}* can be yours for only ~{REGULAR}~ *{PRICE}*.\nIf you have any questions, ask us.", 'creame-whatsapp-me' ) . '">' .
230
$value . '</textarea>' .
231
'<p class="description">' . __( 'Define a text for your products on sale to encourage customers to contact', 'creame-whatsapp-me' ) . '</p>';
232
break;
233
234
case 'message_send_product':
235
- $output = '<textarea id="whatsappme_message_send_product" name="whatsappme[message_send_product]" rows="3" class="regular-text" ' .
236
'placeholder="' . esc_attr__( "*Hi {SITE}!*\nI have a question about *{PRODUCT} ({SKU})*", 'creame-whatsapp-me' ) . '">' . $value . '</textarea>' .
237
'<p class="description">' . __( 'Predefined text for the first message the client will send you', 'creame-whatsapp-me' ) . '</p>';
238
break;
@@ -243,13 +243,13 @@ class WhatsAppMe_WooAdmin {
243
244
/**
245
* Modify $inheritance array to properly inherit
246
- * WooCommerce fields on advanced visibily admin tab.
247
*
248
* @since 3.0.0
249
* @param array $inheritance current section output.
250
* @return array
251
*/
252
- public function advanced_inheritance( $inheritance ) {
253
254
// 'woocommerce' inherit from 'all' (Global)
255
$inheritance['all'][] = 'woocommerce';
4
* The admin-specific functionality of the WooCommerce integration.
5
*
6
* @since 3.0.0
7
+ * @package JoinChat
8
+ * @subpackage JoinChat/admin
9
* @author Creame <hola@crea.me>
10
*/
11
+ class JoinChatWooAdmin {
12
13
/**
14
* Initialize all hooks
15
*
16
* @since 3.0.0
17
+ * @param array $joinchat JoinChat object.
18
* @return void
19
*/
20
+ public function init( $joinchat ) {
21
+
22
+ $loader = $joinchat->get_loader();
23
+
24
+ $loader->add_filter( 'joinchat_extra_settings', $this, 'extra_settings' );
25
+ $loader->add_filter( 'joinchat_settings_validate', $this, 'settings_validate' );
26
+ $loader->add_filter( 'joinchat_settings_i18n', $this, 'settings_i18n' );
27
+ $loader->add_filter( 'joinchat_admin_tabs', $this, 'admin_tab' );
28
+ $loader->add_filter( 'joinchat_custom_post_types', $this, 'custom_post_types' );
29
+ $loader->add_filter( 'joinchat_tab_visibility_sections', $this, 'visibility_tab_section' );
30
+ $loader->add_filter( 'joinchat_tab_woocommerce_sections', $this, 'woo_tab_sections' );
31
+ $loader->add_filter( 'joinchat_vars_help', $this, 'vars_help', 10, 2 );
32
+ $loader->add_filter( 'joinchat_section_output', $this, 'section_ouput', 10, 2 );
33
+ $loader->add_filter( 'joinchat_field_output', $this, 'field_ouput', 10, 3 );
34
+ $loader->add_filter( 'joinchat_visibility_inheritance', $this, 'visibility_inheritance' );
35
+ $loader->add_filter( 'joinchat_help_tab_styles_and_vars', $this, 'help_vars' );
36
+ $loader->add_filter( 'joinchat_metabox_vars', $this, 'metabox_vars', 10, 2 );
37
+ $loader->add_filter( 'joinchat_metabox_placeholders', $this, 'metabox_placeholders', 10, 3 );
38
}
39
40
/**
64
*/
65
public function settings_validate( $input ) {
66
67
+ $input['message_text_product'] = JoinChatUtil::clean_input( $input['message_text_product'] );
68
+ $input['message_text_on_sale'] = JoinChatUtil::clean_input( $input['message_text_on_sale'] );
69
+ $input['message_send_product'] = JoinChatUtil::clean_input( $input['message_send_product'] );
70
71
return $input;
72
}
116
}
117
118
/**
119
+ * Woocommerce sections and fields for 'joinchat_tab_visibility'
120
*
121
* @since 3.0.0
122
* @param array $sections current tab sections and fields.
123
* @return array
124
*/
125
+ public function visibility_tab_section( $sections ) {
126
127
$sections['woo'] = array(
128
'view__woocommerce' => __( 'Shop', 'creame-whatsapp-me' ),
136
}
137
138
/**
139
+ * Woocommerce sections and fields for 'joinchat_tab_woocommerce'
140
*
141
* @since 3.0.0
142
* @param array $sections current tab sections and fields.
151
);
152
153
foreach ( $woo_sections as $key => $label ) {
154
+ $woo_sections[ $key ] = "<label for=\"joinchat_$key\">$label</label>" . JoinChatAdmin::vars_help( $key );
155
}
156
157
$sections['chat'] = $woo_sections;
160
}
161
162
/**
163
+ * Woocommerce sections and fields for 'joinchat_tab_woocommerce'
164
*
165
* @since 3.0.0
166
* @param array $sections current tab sections and fields.
187
*/
188
public function section_ouput( $output, $section_id ) {
189
190
+ if ( 'joinchat_tab_visibility__woo' == $section_id ) {
191
192
$output = '<h2 class="title">' . __( 'WooCommerce', 'creame-whatsapp-me' ) . '</h2>';
193
194
+ } elseif ( 'joinchat_tab_woocommerce__chat' == $section_id ) {
195
196
$output = '<h2 class="title">' . __( 'Product Chat Window', 'creame-whatsapp-me' ) . '</h2>' .
197
'<p>' .
209
* @since 3.0.0
210
* @param string $output current field output.
211
* @param string $field_id current field id.
212
+ * @param array $settings current joinchat settings.
213
* @return string
214
*/
215
public function field_ouput( $output, $field_id, $settings ) {
218
219
switch ( $field_id ) {
220
case 'message_text_product':
221
+ $output = '<textarea id="joinchat_message_text_product" name="joinchat[message_text_product]" rows="4" class="regular-text" ' .
222
'placeholder="' . esc_attr__( "This *{PRODUCT}* can be yours for only *{PRICE}*!\nIf you have any questions, ask us.", 'creame-whatsapp-me' ) . '">' .
223
$value . '</textarea>' .
224
'<p class="description">' . __( 'Define a text for your products to encourage customers to contact', 'creame-whatsapp-me' ) . '</p>';
225
break;
226
227
case 'message_text_on_sale':
228
+ $output = '<textarea id="joinchat_message_text_on_sale" name="joinchat[message_text_on_sale]" rows="4" class="regular-text" ' .
229
'placeholder="' . esc_attr__( "Save {DISCOUNT}! This *{PRODUCT}* can be yours for only ~{REGULAR}~ *{PRICE}*.\nIf you have any questions, ask us.", 'creame-whatsapp-me' ) . '">' .
230
$value . '</textarea>' .
231
'<p class="description">' . __( 'Define a text for your products on sale to encourage customers to contact', 'creame-whatsapp-me' ) . '</p>';
232
break;
233
234
case 'message_send_product':
235
+ $output = '<textarea id="joinchat_message_send_product" name="joinchat[message_send_product]" rows="3" class="regular-text" ' .
236
'placeholder="' . esc_attr__( "*Hi {SITE}!*\nI have a question about *{PRODUCT} ({SKU})*", 'creame-whatsapp-me' ) . '">' . $value . '</textarea>' .
237
'<p class="description">' . __( 'Predefined text for the first message the client will send you', 'creame-whatsapp-me' ) . '</p>';
238
break;
243
244
/**
245
* Modify $inheritance array to properly inherit
246
+ * WooCommerce fields on visibility visibily admin tab.
247
*
248
* @since 3.0.0
249
* @param array $inheritance current section output.
250
* @return array
251
*/
252
+ public function visibility_inheritance( $inheritance ) {
253
254
// 'woocommerce' inherit from 'all' (Global)
255
$inheritance['all'][] = 'woocommerce';
admin/css/{whatsappme.css → joinchat.css} RENAMED
@@ -1,53 +1,53 @@
1
- /* WAme chat settings page */
2
3
- .wame-hidden {
4
display: none !important;
5
}
6
7
- .js #whatsappme_form textarea {
8
overflow: hidden;
9
min-height: 100px;
10
}
11
12
- .wametab {
13
display: none;
14
}
15
16
- .wametab-active {
17
display: block !important;
18
}
19
20
- #whatsappme_tab_advanced tr:hover {
21
background: rgba(0, 0, 0, .05);
22
}
23
24
- #whatsappme_tab_advanced th,
25
- #whatsappme_tab_advanced td {
26
padding: 7px 15px;
27
}
28
29
- #whatsappme_tab_advanced label {
30
margin-right: 15px;
31
}
32
33
- #whatsappme_tab_advanced .dashicons {
34
opacity: .5;
35
}
36
37
- #whatsappme_tab_advanced input[type=radio]+span {
38
transition: all 200ms;
39
}
40
41
- #whatsappme_tab_advanced input[type=radio]:checked+span {
42
color: #79ba49;
43
opacity: 1;
44
}
45
46
- #whatsappme_tab_advanced input[type=radio]:checked+.dashicons-hidden {
47
color: #ca4a1f;
48
}
49
50
- .whatsappme-show-help {
51
display: inline-block;
52
width: 1.1em;
53
height: 1.1em;
@@ -60,9 +60,9 @@
60
text-align: center;
61
}
62
63
- .whatsappme-show-help:hover,
64
- .whatsappme-show-help:active,
65
- .whatsappme-show-help:focus {
66
background: #444;
67
color: #fff;
68
}
@@ -71,14 +71,7 @@
71
white-space: nowrap;
72
}
73
74
- #tab-panel-styles-and-vars code {
75
- -webkit-user-select: all;
76
- -moz-user-select: all;
77
- -ms-user-select: all;
78
- user-select: all;
79
- }
80
-
81
- .form-table td p.whatsappme-addon {
82
display: inline-block;
83
padding: 0 6px;
84
border-radius: 3px;
@@ -90,12 +83,12 @@
90
padding-left: 52px !important;
91
}
92
93
- #whatsappme_button_image_wrapper {
94
position: relative;
95
padding: 8px 0 0 80px;
96
}
97
98
- #whatsappme_button_image_holder {
99
position: absolute;
100
top: 0;
101
left: 0;
@@ -109,16 +102,16 @@
109
overflow: hidden;
110
}
111
112
- [dir=rtl] #whatsappme_button_image_wrapper {
113
padding: 8px 80px 0 0;
114
}
115
116
- [dir=rtl] #whatsappme_button_image_holder {
117
right: 0;
118
left: auto;
119
}
120
121
- .whatsappme_vars_help {
122
margin-top: 5px;
123
font-size: 11px;
124
font-weight: normal;
@@ -127,13 +120,13 @@
127
transition: opacity 0.2s ease-out 0.2s;
128
}
129
130
- tr:hover .whatsappme_vars_help,
131
- tr.whatsappme--focus .whatsappme_vars_help {
132
opacity: 1;
133
transition-delay: 0.5s;
134
}
135
136
- .whatsappme_vars_help code {
137
-webkit-user-select: all;
138
-moz-user-select: all;
139
-ms-user-select: all;
@@ -143,24 +136,45 @@ tr.whatsappme--focus .whatsappme_vars_help {
143
vertical-align: bottom;
144
}
145
146
- .whatsappme_vars_help code:hover {
147
background: rgba(0, 0, 0, 0.2);
148
}
149
150
@media screen and (max-width: 782px) {
151
- .whatsappme_vars_help {
152
margin-top: 2px;
153
opacity: 1;
154
}
155
156
- .whatsappme_vars_help br {
157
display: none;
158
}
159
}
160
161
- /* WAme chat metabox */
162
163
- .whatsappme-metabox code {
164
-webkit-user-select: all;
165
-moz-user-select: all;
166
-ms-user-select: all;
@@ -170,37 +184,37 @@ tr.whatsappme--focus .whatsappme_vars_help {
170
vertical-align: text-bottom;
171
}
172
173
- .whatsappme-metabox .dashicons {
174
opacity: .5;
175
}
176
177
- .whatsappme-metabox input::placeholder {
178
color: #dedfe0;
179
}
180
181
- .whatsappme-metabox input::-ms-input-placeholder {
182
color: #dedfe0;
183
}
184
185
- .whatsappme-metabox input[type=radio] {
186
margin-right: 1px;
187
}
188
189
- .whatsappme-metabox input[type=radio]+span {
190
margin-right: 5px;
191
transition: all 200ms;
192
}
193
194
- .whatsappme-metabox input[type=radio]:checked+span {
195
color: #79ba49;
196
opacity: 1;
197
}
198
199
- .whatsappme-metabox input[type=radio]:checked+.dashicons-hidden {
200
color: #ca4a1f;
201
}
202
203
- .js .whatsappme-metabox textarea {
204
overflow: hidden;
205
min-height: 3em;
206
}
1
+ /* Join.chat settings page */
2
3
+ .joinchat-hidden {
4
display: none !important;
5
}
6
7
+ .js #joinchat_form textarea {
8
overflow: hidden;
9
min-height: 100px;
10
}
11
12
+ .joinchat-tab {
13
display: none;
14
}
15
16
+ .joinchat-tab-active {
17
display: block !important;
18
}
19
20
+ #joinchat_tab_visibility tr:hover {
21
background: rgba(0, 0, 0, .05);
22
}
23
24
+ #joinchat_tab_visibility th,
25
+ #joinchat_tab_visibility td {
26
padding: 7px 15px;
27
}
28
29
+ #joinchat_tab_visibility label {
30
margin-right: 15px;
31
}
32
33
+ #joinchat_tab_visibility .dashicons {
34
opacity: .5;
35
}
36
37
+ #joinchat_tab_visibility input[type=radio]+span {
38
transition: all 200ms;
39
}
40
41
+ #joinchat_tab_visibility input[type=radio]:checked+span {
42
color: #79ba49;
43
opacity: 1;
44
}
45
46
+ #joinchat_tab_visibility input[type=radio]:checked+.dashicons-hidden {
47
color: #ca4a1f;
48
}
49
50
+ .joinchat-show-help {
51
display: inline-block;
52
width: 1.1em;
53
height: 1.1em;
60
text-align: center;
61
}
62
63
+ .joinchat-show-help:hover,
64
+ .joinchat-show-help:active,
65
+ .joinchat-show-help:focus {
66
background: #444;
67
color: #fff;
68
}
71
white-space: nowrap;
72
}
73
74
+ .form-table td p.joinchat-addon {
75
display: inline-block;
76
padding: 0 6px;
77
border-radius: 3px;
83
padding-left: 52px !important;
84
}
85
86
+ #joinchat_button_image_wrapper {
87
position: relative;
88
padding: 8px 0 0 80px;
89
}
90
91
+ #joinchat_button_image_holder {
92
position: absolute;
93
top: 0;
94
left: 0;
102
overflow: hidden;
103
}
104
105
+ [dir=rtl] #joinchat_button_image_wrapper {
106
padding: 8px 80px 0 0;
107
}
108
109
+ [dir=rtl] #joinchat_button_image_holder {
110
right: 0;
111
left: auto;
112
}
113
114
+ .joinchat_vars_help {
115
margin-top: 5px;
116
font-size: 11px;
117
font-weight: normal;
120
transition: opacity 0.2s ease-out 0.2s;
121
}
122
123
+ tr:hover .joinchat_vars_help,
124
+ tr.joinchat--focus .joinchat_vars_help {
125
opacity: 1;
126
transition-delay: 0.5s;
127
}
128
129
+ .joinchat_vars_help code {
130
-webkit-user-select: all;
131
-moz-user-select: all;
132
-ms-user-select: all;
136
vertical-align: bottom;
137
}
138
139
+ .joinchat_vars_help code:hover {
140
background: rgba(0, 0, 0, 0.2);
141
}
142
143
@media screen and (max-width: 782px) {
144
+ .joinchat_vars_help {
145
margin-top: 2px;
146
opacity: 1;
147
}
148
149
+ .joinchat_vars_help br {
150
display: none;
151
}
152
}
153
154
+ #joinchat_form .iris-picker {
155
+ visibility: visible;
156
+ }
157
+
158
+ /* Help */
159
+
160
+ .settings_page_joinchat .help-tab-content li ul {
161
+ margin-top: 6px;
162
+ }
163
+
164
+ .settings_page_joinchat .help-tab-content li li {
165
+ list-style-type: circle;
166
+ }
167
+
168
+ .settings_page_joinchat .help-tab-content code {
169
+ -webkit-user-select: all;
170
+ -moz-user-select: all;
171
+ -ms-user-select: all;
172
+ user-select: all;
173
+ }
174
+
175
+ /* Join.chat metabox */
176
177
+ .joinchat-metabox code {
178
-webkit-user-select: all;
179
-moz-user-select: all;
180
-ms-user-select: all;
184
vertical-align: text-bottom;
185
}
186
187
+ .joinchat-metabox .dashicons {
188
opacity: .5;
189
}
190
191
+ .joinchat-metabox input::placeholder {
192
color: #dedfe0;
193
}
194
195
+ .joinchat-metabox input::-ms-input-placeholder {
196
color: #dedfe0;
197
}
198
199
+ .joinchat-metabox input[type=radio] {
200
margin-right: 1px;
201
}
202
203
+ .joinchat-metabox input[type=radio]+span {
204
margin-right: 5px;
205
transition: all 200ms;
206
}
207
208
+ .joinchat-metabox input[type=radio]:checked+span {
209
color: #79ba49;
210
opacity: 1;
211
}
212
213
+ .joinchat-metabox input[type=radio]:checked+.dashicons-hidden {
214
color: #ca4a1f;
215
}
216
217
+ .js .joinchat-metabox textarea {
218
overflow: hidden;
219
min-height: 3em;
220
}
admin/css/joinchat.min.css ADDED
@@ -0,0 +1 @@
1
+ .joinchat-hidden{display:none!important}.js #joinchat_form textarea{overflow:hidden;min-height:100px}.joinchat-tab{display:none}.joinchat-tab-active{display:block!important}#joinchat_tab_visibility tr:hover{background:rgba(0,0,0,.05)}#joinchat_tab_visibility td,#joinchat_tab_visibility th{padding:7px 15px}#joinchat_tab_visibility label{margin-right:15px}#joinchat_tab_visibility .dashicons{opacity:.5}#joinchat_tab_visibility input[type=radio]+span{transition:all .2s}#joinchat_tab_visibility input[type=radio]:checked+span{color:#79ba49;opacity:1}#joinchat_tab_visibility input[type=radio]:checked+.dashicons-hidden{color:#ca4a1f}.joinchat-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}.joinchat-show-help:active,.joinchat-show-help:focus,.joinchat-show-help:hover{background:#444;color:#fff}#tab-panel-styles-and-vars span{white-space:nowrap}.form-table td p.joinchat-addon{display:inline-block;padding:0 6px;border-radius:3px;background:#fffbe5;font-size:13px}.iti--allow-dropdown input{padding-left:52px!important}#joinchat_button_image_wrapper{position:relative;padding:8px 0 0 80px}#joinchat_button_image_holder{position:absolute;top:0;left:0;box-sizing:border-box;width:60px;height:60px;border:1px solid #25d366;border-radius:50%;background:#25d366 url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="36" height="36"><path fill="%23fff" d="M3.516 3.516c4.686-4.686 12.284-4.686 16.97 0 4.686 4.686 4.686 12.283 0 16.97a12.004 12.004 0 01-13.754 2.299l-5.814.735a.392.392 0 01-.438-.44l.748-5.788A12.002 12.002 0 013.517 3.517zm3.61 17.043l.3.158a9.846 9.846 0 0011.534-1.758c3.843-3.843 3.843-10.074 0-13.918-3.843-3.843-10.075-3.843-13.918 0a9.846 9.846 0 00-1.747 11.554l.16.303-.51 3.942a.196.196 0 00.219.22l3.961-.501zm6.534-7.003l-.933 1.164a9.843 9.843 0 01-3.497-3.495l1.166-.933a.792.792 0 00.23-.94L9.561 6.96a.793.793 0 00-.924-.445 1291.6 1291.6 0 00-2.023.524.797.797 0 00-.588.88 11.754 11.754 0 0010.005 10.005.797.797 0 00.88-.587l.525-2.023a.793.793 0 00-.445-.923L14.6 13.327a.792.792 0 00-.94.23z"/></svg>') no-repeat center;box-shadow:1px 6px 24px 0 rgba(7,94,84,.24);overflow:hidden}[dir=rtl] #joinchat_button_image_wrapper{padding:8px 80px 0 0}[dir=rtl] #joinchat_button_image_holder{right:0;left:auto}.joinchat_vars_help{margin-top:5px;font-size:11px;font-weight:400;line-height:1.9;opacity:0;transition:opacity .2s ease-out .2s}tr.joinchat--focus .joinchat_vars_help,tr:hover .joinchat_vars_help{opacity:1;transition-delay:.5s}.joinchat_vars_help code{-webkit-user-select:all;-moz-user-select:all;-ms-user-select:all;user-select:all;padding:2px 1px;font-size:inherit;vertical-align:bottom}.joinchat_vars_help code:hover{background:rgba(0,0,0,.2)}@media screen and (max-width:782px){.joinchat_vars_help{margin-top:2px;opacity:1}.joinchat_vars_help br{display:none}}#joinchat_form .iris-picker{visibility:visible}.settings_page_joinchat .help-tab-content li ul{margin-top:6px}.settings_page_joinchat .help-tab-content li li{list-style-type:circle}.settings_page_joinchat .help-tab-content code{-webkit-user-select:all;-moz-user-select:all;-ms-user-select:all;user-select:all}.joinchat-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}.joinchat-metabox .dashicons{opacity:.5}.joinchat-metabox input::placeholder{color:#dedfe0}.joinchat-metabox input::-ms-input-placeholder{color:#dedfe0}.joinchat-metabox input[type=radio]{margin-right:1px}.joinchat-metabox input[type=radio]+span{margin-right:5px;transition:all .2s}.joinchat-metabox input[type=radio]:checked+span{color:#79ba49;opacity:1}.joinchat-metabox input[type=radio]:checked+.dashicons-hidden{color:#ca4a1f}.js .joinchat-metabox textarea{overflow:hidden;min-height:3em}
admin/css/whatsappme.min.css DELETED
@@ -1 +0,0 @@
1
- .wame-hidden{display:none!important}.js #whatsappme_form textarea{overflow:hidden;min-height:100px}.wametab{display:none}.wametab-active{display:block!important}#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{display:inline-block;padding:0 6px;border-radius:3px;background:#fffbe5;font-size:13px}.iti--allow-dropdown input{padding-left:52px!important}#whatsappme_button_image_wrapper{position:relative;padding:8px 0 0 80px}#whatsappme_button_image_holder{position:absolute;top:0;left:0;box-sizing:border-box;width:60px;height:60px;border:1px solid #25d366;border-radius:50%;background:#25d366 url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="36" height="36"><path fill="%23fff" d="M3.516 3.516c4.686-4.686 12.284-4.686 16.97 0 4.686 4.686 4.686 12.283 0 16.97a12.004 12.004 0 01-13.754 2.299l-5.814.735a.392.392 0 01-.438-.44l.748-5.788A12.002 12.002 0 013.517 3.517zm3.61 17.043l.3.158a9.846 9.846 0 0011.534-1.758c3.843-3.843 3.843-10.074 0-13.918-3.843-3.843-10.075-3.843-13.918 0a9.846 9.846 0 00-1.747 11.554l.16.303-.51 3.942a.196.196 0 00.219.22l3.961-.501zm6.534-7.003l-.933 1.164a9.843 9.843 0 01-3.497-3.495l1.166-.933a.792.792 0 00.23-.94L9.561 6.96a.793.793 0 00-.924-.445 1291.6 1291.6 0 00-2.023.524.797.797 0 00-.588.88 11.754 11.754 0 0010.005 10.005.797.797 0 00.88-.587l.525-2.023a.793.793 0 00-.445-.923L14.6 13.327a.792.792 0 00-.94.23z"/></svg>') no-repeat center;box-shadow:1px 6px 24px 0 rgba(7,94,84,.24);overflow:hidden}[dir=rtl] #whatsappme_button_image_wrapper{padding:8px 80px 0 0}[dir=rtl] #whatsappme_button_image_holder{right:0;left:auto}.whatsappme_vars_help{margin-top:5px;font-size:11px;font-weight:400;line-height:1.9;opacity:0;transition:opacity .2s ease-out .2s}tr.whatsappme--focus .whatsappme_vars_help,tr:hover .whatsappme_vars_help{opacity:1;transition-delay:.5s}.whatsappme_vars_help code{-webkit-user-select:all;-moz-user-select:all;-ms-user-select:all;user-select:all;padding:2px 1px;font-size:inherit;vertical-align:bottom}.whatsappme_vars_help code:hover{background:rgba(0,0,0,.2)}@media screen and (max-width:782px){.whatsappme_vars_help{margin-top:2px;opacity:1}.whatsappme_vars_help br{display:none}}.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}.whatsappme-metabox .dashicons{opacity:.5}.whatsappme-metabox input::placeholder{color:#dedfe0}.whatsappme-metabox input::-ms-input-placeholder{color:#dedfe0}.whatsappme-metabox input[type=radio]{margin-right:1px}.whatsappme-metabox input[type=radio]+span{margin-right:5px;transition:all .2s}.whatsappme-metabox input[type=radio]:checked+span{color:#79ba49;opacity:1}.whatsappme-metabox input[type=radio]:checked+.dashicons-hidden{color:#ca4a1f}.js .whatsappme-metabox textarea{overflow:hidden;min-height:3em}
admin/js/{whatsappme.js → joinchat.js} RENAMED
@@ -8,17 +8,17 @@
8
$(function () {
9
var media_frame;
10
11
- if (typeof (intlTelInput) === 'function' && $('#whatsappme_phone').length) {
12
- var country_request = JSON.parse(localStorage.whatsappme_country_code || '{}');
13
var country_code = (country_request.code && country_request.date == new Date().toDateString()) ? country_request.code : false;
14
- var $phone = $('#whatsappme_phone');
15
16
// If empty value capture placeholdre and remove
17
var placeholder = $phone.val() === '' ? $phone.attr('placeholder') : null;
18
$phone.removeAttr('placeholder');
19
20
var iti = intlTelInput($phone.get(0), {
21
- hiddenInput: $phone.data('name') || 'whatsappme[telephone]',
22
initialCountry: 'auto',
23
preferredCountries: [country_code || ''],
24
geoIpLookup: function (callback) {
@@ -27,7 +27,7 @@
27
} else {
28
$.getJSON('https://ipinfo.io').always(function (resp) {
29
var countryCode = (resp && resp.country) ? resp.country : '';
30
- localStorage.whatsappme_country_code = JSON.stringify({ code: countryCode, date: new Date().toDateString() });
31
callback(countryCode);
32
});
33
}
@@ -39,7 +39,7 @@
39
40
// Post metabox if empty value set placeholder from general settings
41
if (typeof placeholder == 'string' && placeholder != '') {
42
- iti.promise.then(function() {
43
iti.setNumber(placeholder);
44
$phone.attr('placeholder', iti.getNumber(intlTelInputUtils.numberFormat.NATIONAL)).val('');
45
});
@@ -58,30 +58,36 @@
58
});
59
}
60
61
- if ($('#whatsappme_form').length === 1) {
62
// Tabs
63
$('.nav-tab').click(function (e) {
64
e.preventDefault();
65
var $navtab = $(this);
66
67
$('.nav-tab').removeClass('nav-tab-active').attr('aria-selected', 'false');
68
$navtab.addClass('nav-tab-active').attr('aria-selected', 'true').get(0).blur();
69
- $('.wametab').removeClass('wametab-active');
70
- $($navtab.attr('href')).addClass('wametab-active').find('textarea').each(textarea_autoheight);
71
});
72
73
// Toggle WhatsApp web option
74
- $('#whatsappme_mobile_only').change(function () {
75
- $('#whatsappme_whatsapp_web').closest('tr').toggleClass('wame-hidden', this.checked);
76
}).change();
77
78
- // Toggle WhatsApp badge option
79
- $('#whatsappme_message_delay').on('change input', function () {
80
- $('#whatsappme_message_badge').closest('tr').toggleClass('wame-hidden', this.value == '0');
81
}).change();
82
83
// Show help
84
- $('.whatsappme-show-help').click(function (e) {
85
e.preventDefault();
86
var help_tab = $(this).attr('href');
87
if ($('#contextual-help-wrap').is(':visible')) {
@@ -89,20 +95,20 @@
89
} else {
90
$('#contextual-help-link').click();
91
}
92
- $( help_tab != '#' ? help_tab : '#tab-link-styles-and-vars').find('a').click();
93
});
94
95
// Texarea focus and auto height
96
- $('textarea', '#whatsappme_form')
97
- .on('focus', function () { $(this).closest('tr').addClass('whatsappme--focus'); })
98
- .on('blur', function () { $(this).closest('tr').removeClass('whatsappme--focus'); })
99
.on('input', textarea_autoheight)
100
.each(textarea_autoheight);
101
102
103
- // Advanced view inheritance
104
- var $tab_advanced = $('#whatsappme_tab_advanced');
105
- var inheritance = $('.whatsappme_view_all').data('inheritance') || {
106
'all': ['front_page', 'blog_page', '404_page', 'search', 'archive', 'singular', 'cpts'],
107
'archive': ['date', 'author'],
108
'singular': ['page', 'post'],
@@ -110,7 +116,7 @@
110
111
function propagate_inheritance(field, show) {
112
field = field || 'all';
113
- show = show || $('input[name="whatsappme[view][' + field + ']"]:checked').val();
114
115
$('.view_inheritance_' + field)
116
.toggleClass('dashicons-visibility', show == 'yes')
@@ -121,27 +127,27 @@
121
.toggleClass('dashicons-visibility', show == 'yes')
122
.toggleClass('dashicons-hidden', show == 'no');
123
} else if (field in inheritance) {
124
- var value = $('input[name="whatsappme[view][' + field + ']"]:checked').val();
125
value = value === '' ? show : value;
126
127
$.each(inheritance[field], function () { propagate_inheritance(this, value); });
128
}
129
}
130
131
- $('input', $tab_advanced).change(function () {
132
propagate_inheritance();
133
});
134
135
- $('.whatsappme_view_reset').click(function (e) {
136
e.preventDefault();
137
- $('input[value=""]', $tab_advanced).prop('checked', true);
138
- $('.whatsappme_view_all input', $tab_advanced).first().prop('checked', true);
139
propagate_inheritance();
140
});
141
142
propagate_inheritance();
143
144
- $('#whatsappme_button_image_add').click(function (e) {
145
e.preventDefault();
146
147
if (!media_frame) {
@@ -159,14 +165,14 @@
159
var attachment = media_frame.state().get('selection').first().toJSON();
160
var url = attachment.sizes && attachment.sizes.thumbnail && attachment.sizes.thumbnail.url || attachment.url;
161
162
- $('#whatsappme_button_image_holder').css({ 'background-size': 'cover', 'background-image': 'url(' + url + ')' });
163
- $('#whatsappme_button_image').val(attachment.id);
164
- $('#whatsappme_button_image_remove').removeClass('wame-hidden');
165
});
166
167
media_frame.on('open', function () {
168
// Pre-selected attachment
169
- var attachment = wp.media.attachment($('#whatsappme_button_image').val());
170
media_frame.state().get('selection').add(attachment ? [attachment] : []);
171
});
172
}
@@ -174,18 +180,20 @@
174
media_frame.open();
175
});
176
177
- $('#whatsappme_button_image_remove').click(function (e) {
178
e.preventDefault();
179
180
- $('#whatsappme_button_image_holder').removeAttr('style');
181
- $('#whatsappme_button_image').val('');
182
- $(this).addClass('wame-hidden');
183
});
184
}
185
186
- if ($('.whatsappme-metabox').length === 1) {
187
// Texarea auto height
188
- $('textarea', '.whatsappme-metabox').on('focus input', textarea_autoheight).each(textarea_autoheight);
189
}
190
});
191
})(jQuery);
8
$(function () {
9
var media_frame;
10
11
+ if (typeof (intlTelInput) === 'function' && $('#joinchat_phone').length) {
12
+ var country_request = JSON.parse(localStorage.joinchat_country_code || '{}');
13
var country_code = (country_request.code && country_request.date == new Date().toDateString()) ? country_request.code : false;
14
+ var $phone = $('#joinchat_phone');
15
16
// If empty value capture placeholdre and remove
17
var placeholder = $phone.val() === '' ? $phone.attr('placeholder') : null;
18
$phone.removeAttr('placeholder');
19
20
var iti = intlTelInput($phone.get(0), {
21
+ hiddenInput: $phone.data('name') || 'joinchat[telephone]',
22
initialCountry: 'auto',
23
preferredCountries: [country_code || ''],
24
geoIpLookup: function (callback) {
27
} else {
28
$.getJSON('https://ipinfo.io').always(function (resp) {
29
var countryCode = (resp && resp.country) ? resp.country : '';
30
+ localStorage.joinchat_country_code = JSON.stringify({ code: countryCode, date: new Date().toDateString() });
31
callback(countryCode);
32
});
33
}
39
40
// Post metabox if empty value set placeholder from general settings
41
if (typeof placeholder == 'string' && placeholder != '') {
42
+ iti.promise.then(function () {
43
iti.setNumber(placeholder);
44
$phone.attr('placeholder', iti.getNumber(intlTelInputUtils.numberFormat.NATIONAL)).val('');
45
});
58
});
59
}
60
61
+ if ($('#joinchat_form').length === 1) {
62
// Tabs
63
$('.nav-tab').click(function (e) {
64
e.preventDefault();
65
var $navtab = $(this);
66
+ var href = $navtab.attr('href');
67
+ var $referer = $('input[name=_wp_http_referer]');
68
+ var ref_val = $referer.val();
69
+
70
+ // Update form referer to open same tab on submit
71
+ $referer.val(ref_val.substr(0, ref_val.indexOf('page=joinchat')) + 'page=joinchat&tab=' + href.substr(14));
72
73
$('.nav-tab').removeClass('nav-tab-active').attr('aria-selected', 'false');
74
$navtab.addClass('nav-tab-active').attr('aria-selected', 'true').get(0).blur();
75
+ $('.joinchat-tab').removeClass('joinchat-tab-active');
76
+ $(href).addClass('joinchat-tab-active').find('textarea').each(textarea_autoheight);
77
});
78
79
// Toggle WhatsApp web option
80
+ $('#joinchat_mobile_only').change(function () {
81
+ $('#joinchat_whatsapp_web').closest('tr').toggleClass('joinchat-hidden', this.checked);
82
}).change();
83
84
+ // Toggle badge option
85
+ $('#joinchat_message_delay').on('change input', function () {
86
+ $('#joinchat_message_badge, #joinchat_message_views').closest('tr').toggleClass('joinchat-hidden', this.value == '0');
87
}).change();
88
89
// Show help
90
+ $('.joinchat-show-help').click(function (e) {
91
e.preventDefault();
92
var help_tab = $(this).attr('href');
93
if ($('#contextual-help-wrap').is(':visible')) {
95
} else {
96
$('#contextual-help-link').click();
97
}
98
+ $(help_tab != '#' ? help_tab : '#tab-link-styles-and-vars').find('a').click();
99
});
100
101
// Texarea focus and auto height
102
+ $('textarea', '#joinchat_form')
103
+ .on('focus', function () { $(this).closest('tr').addClass('joinchat--focus'); })
104
+ .on('blur', function () { $(this).closest('tr').removeClass('joinchat--focus'); })
105
.on('input', textarea_autoheight)
106
.each(textarea_autoheight);
107
108
109
+ // Visibility view inheritance
110
+ var $tab_visibility = $('#joinchat_tab_visibility');
111
+ var inheritance = $('.joinchat_view_all').data('inheritance') || {
112
'all': ['front_page', 'blog_page', '404_page', 'search', 'archive', 'singular', 'cpts'],
113
'archive': ['date', 'author'],
114
'singular': ['page', 'post'],
116
117
function propagate_inheritance(field, show) {
118
field = field || 'all';
119
+ show = show || $('input[name="joinchat[view][' + field + ']"]:checked').val();
120
121
$('.view_inheritance_' + field)
122
.toggleClass('dashicons-visibility', show == 'yes')
127
.toggleClass('dashicons-visibility', show == 'yes')
128
.toggleClass('dashicons-hidden', show == 'no');
129
} else if (field in inheritance) {
130
+ var value = $('input[name="joinchat[view][' + field + ']"]:checked').val();
131
value = value === '' ? show : value;
132
133
$.each(inheritance[field], function () { propagate_inheritance(this, value); });
134
}
135
}
136
137
+ $('input', $tab_visibility).change(function () {
138
propagate_inheritance();
139
});
140
141
+ $('.joinchat_view_reset').click(function (e) {
142
e.preventDefault();
143
+ $('input[value=""]', $tab_visibility).prop('checked', true);
144
+ $('.joinchat_view_all input', $tab_visibility).first().prop('checked', true);
145
propagate_inheritance();
146
});
147
148
propagate_inheritance();
149
150
+ $('#joinchat_button_image_add').click(function (e) {
151
e.preventDefault();
152
153
if (!media_frame) {
165
var attachment = media_frame.state().get('selection').first().toJSON();
166
var url = attachment.sizes && attachment.sizes.thumbnail && attachment.sizes.thumbnail.url || attachment.url;
167
168
+ $('#joinchat_button_image_holder').css({ 'background-size': 'cover', 'background-image': 'url(' + url + ')' });
169
+ $('#joinchat_button_image').val(attachment.id);
170
+ $('#joinchat_button_image_remove').removeClass('joinchat-hidden');
171
});
172
173
media_frame.on('open', function () {
174
// Pre-selected attachment
175
+ var attachment = wp.media.attachment($('#joinchat_button_image').val());
176
media_frame.state().get('selection').add(attachment ? [attachment] : []);
177
});
178
}
180
media_frame.open();
181
});
182
183
+ $('#joinchat_button_image_remove').click(function (e) {
184
e.preventDefault();
185
186
+ $('#joinchat_button_image_holder').removeAttr('style');
187
+ $('#joinchat_button_image').val('');
188
+ $(this).addClass('joinchat-hidden');
189
});
190
+
191
+ $('#joinchat_color').wpColorPicker();
192
}
193
194
+ if ($('.joinchat-metabox').length === 1) {
195
// Texarea auto height
196
+ $('textarea', '.joinchat-metabox').on('focus input', textarea_autoheight).each(textarea_autoheight);
197
}
198
});
199
})(jQuery);
admin/js/joinchat.min.js ADDED
@@ -0,0 +1 @@
1
+ !function(t){"use strict";function e(){t(this).height(0).height(this.scrollHeight)}t(function(){var a;if("function"==typeof intlTelInput&&t("#joinchat_phone").length){var n=JSON.parse(localStorage.joinchat_country_code||"{}"),i=!(!n.code||n.date!=(new Date).toDateString())&&n.code,o=t("#joinchat_phone"),c=""===o.val()?o.attr("placeholder"):null;o.removeAttr("placeholder");var l=intlTelInput(o.get(0),{hiddenInput:o.data("name")||"joinchat[telephone]",initialCountry:"auto",preferredCountries:[i||""],geoIpLookup:function(e){i?e(i):t.getJSON("https://ipinfo.io").always(function(t){var a=t&&t.country?t.country:"";localStorage.joinchat_country_code=JSON.stringify({code:a,date:(new Date).toDateString()}),e(a)})},utilsScript:"https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/"+intl_tel_input_version+"/js/utils.js"});l.hiddenInput.value=o.val(),"string"==typeof c&&""!=c&&l.promise.then(function(){l.setNumber(c),o.attr("placeholder",l.getNumber(intlTelInputUtils.numberFormat.NATIONAL)).val("")}),o.on("input",function(){var e=t(this),a=intlTelInputGlobals.getInstance(this);e.css("color",e.val().trim()&&!a.isValidNumber()?"#ca4a1f":""),a.hiddenInput.value=a.getNumber()}).on("blur",function(){var t=intlTelInputGlobals.getInstance(this);t.setNumber(t.getNumber())})}if(1===t("#joinchat_form").length){t(".nav-tab").click(function(a){a.preventDefault();var n=t(this),i=n.attr("href"),o=t("input[name=_wp_http_referer]"),c=o.val();o.val(c.substr(0,c.indexOf("page=joinchat"))+"page=joinchat&tab="+i.substr(14)),t(".nav-tab").removeClass("nav-tab-active").attr("aria-selected","false"),n.addClass("nav-tab-active").attr("aria-selected","true").get(0).blur(),t(".joinchat-tab").removeClass("joinchat-tab-active"),t(i).addClass("joinchat-tab-active").find("textarea").each(e)}),t("#joinchat_mobile_only").change(function(){t("#joinchat_whatsapp_web").closest("tr").toggleClass("joinchat-hidden",this.checked)}).change(),t("#joinchat_message_delay").on("change input",function(){t("#joinchat_message_badge, #joinchat_message_views").closest("tr").toggleClass("joinchat-hidden","0"==this.value)}).change(),t(".joinchat-show-help").click(function(e){e.preventDefault();var a=t(this).attr("href");t("#contextual-help-wrap").is(":visible")?t("html, body").animate({scrollTop:0}):t("#contextual-help-link").click(),t("#"!=a?a:"#tab-link-styles-and-vars").find("a").click()}),t("textarea","#joinchat_form").on("focus",function(){t(this).closest("tr").addClass("joinchat--focus")}).on("blur",function(){t(this).closest("tr").removeClass("joinchat--focus")}).on("input",e).each(e);var s=t("#joinchat_tab_visibility"),r=t(".joinchat_view_all").data("inheritance")||{all:["front_page","blog_page","404_page","search","archive","singular","cpts"],archive:["date","author"],singular:["page","post"]};function h(e,a){if(e=e||"all",a=a||t('input[name="joinchat[view]['+e+']"]:checked').val(),t(".view_inheritance_"+e).toggleClass("dashicons-visibility","yes"==a).toggleClass("dashicons-hidden","no"==a),"cpts"==e)t("[class*=view_inheritance_cpt_]").toggleClass("dashicons-visibility","yes"==a).toggleClass("dashicons-hidden","no"==a);else if(e in r){var n=t('input[name="joinchat[view]['+e+']"]:checked').val();n=""===n?a:n,t.each(r[e],function(){h(this,n)})}}t("input",s).change(function(){h()}),t(".joinchat_view_reset").click(function(e){e.preventDefault(),t('input[value=""]',s).prop("checked",!0),t(".joinchat_view_all input",s).first().prop("checked",!0),h()}),h(),t("#joinchat_button_image_add").click(function(e){e.preventDefault(),a||((a=wp.media({title:t(this).data("title")||"Select button image",button:{text:t(this).data("button")||"Use Image"},library:{type:"image"},multiple:!1})).on("select",function(){var e=a.state().get("selection").first().toJSON(),n=e.sizes&&e.sizes.thumbnail&&e.sizes.thumbnail.url||e.url;t("#joinchat_button_image_holder").css({"background-size":"cover","background-image":"url("+n+")"}),t("#joinchat_button_image").val(e.id),t("#joinchat_button_image_remove").removeClass("joinchat-hidden")}),a.on("open",function(){var e=wp.media.attachment(t("#joinchat_button_image").val());a.state().get("selection").add(e?[e]:[])})),a.open()}),t("#joinchat_button_image_remove").click(function(e){e.preventDefault(),t("#joinchat_button_image_holder").removeAttr("style"),t("#joinchat_button_image").val(""),t(this).addClass("joinchat-hidden")}),t("#joinchat_color").wpColorPicker()}1===t(".joinchat-metabox").length&&t("textarea",".joinchat-metabox").on("focus input",e).each(e)})}(jQuery);
admin/js/whatsappme.min.js DELETED
@@ -1 +0,0 @@
1
- !function(e){"use strict";function t(){e(this).height(0).height(this.scrollHeight)}e(function(){var a;if("function"==typeof intlTelInput&&e("#whatsappme_phone").length){var n=JSON.parse(localStorage.whatsappme_country_code||"{}"),i=!(!n.code||n.date!=(new Date).toDateString())&&n.code,s=e("#whatsappme_phone"),l=""===s.val()?s.attr("placeholder"):null;s.removeAttr("placeholder");var o=intlTelInput(s.get(0),{hiddenInput:s.data("name")||"whatsappme[telephone]",initialCountry:"auto",preferredCountries:[i||""],geoIpLookup:function(t){i?t(i):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"});o.hiddenInput.value=s.val(),"string"==typeof l&&""!=l&&o.promise.then(function(){o.setNumber(l),s.attr("placeholder",o.getNumber(intlTelInputUtils.numberFormat.NATIONAL)).val("")}),s.on("input",function(){var t=e(this),a=intlTelInputGlobals.getInstance(this);t.css("color",t.val().trim()&&!a.isValidNumber()?"#ca4a1f":""),a.hiddenInput.value=a.getNumber()}).on("blur",function(){var e=intlTelInputGlobals.getInstance(this);e.setNumber(e.getNumber())})}if(1===e("#whatsappme_form").length){e(".nav-tab").click(function(a){a.preventDefault();var n=e(this);e(".nav-tab").removeClass("nav-tab-active").attr("aria-selected","false"),n.addClass("nav-tab-active").attr("aria-selected","true").get(0).blur(),e(".wametab").removeClass("wametab-active"),e(n.attr("href")).addClass("wametab-active").find("textarea").each(t)}),e("#whatsappme_mobile_only").change(function(){e("#whatsappme_whatsapp_web").closest("tr").toggleClass("wame-hidden",this.checked)}).change(),e("#whatsappme_message_delay").on("change input",function(){e("#whatsappme_message_badge").closest("tr").toggleClass("wame-hidden","0"==this.value)}).change(),e(".whatsappme-show-help").click(function(t){t.preventDefault();var a=e(this).attr("href");e("#contextual-help-wrap").is(":visible")?e("html, body").animate({scrollTop:0}):e("#contextual-help-link").click(),e("#"!=a?a:"#tab-link-styles-and-vars").find("a").click()}),e("textarea","#whatsappme_form").on("focus",function(){e(this).closest("tr").addClass("whatsappme--focus")}).on("blur",function(){e(this).closest("tr").removeClass("whatsappme--focus")}).on("input",t).each(t);var p=e("#whatsappme_tab_advanced"),c=e(".whatsappme_view_all").data("inheritance")||{all:["front_page","blog_page","404_page","search","archive","singular","cpts"],archive:["date","author"],singular:["page","post"]};function r(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 c){var n=e('input[name="whatsappme[view]['+t+']"]:checked').val();n=""===n?a:n,e.each(c[t],function(){r(this,n)})}}e("input",p).change(function(){r()}),e(".whatsappme_view_reset").click(function(t){t.preventDefault(),e('input[value=""]',p).prop("checked",!0),e(".whatsappme_view_all input",p).first().prop("checked",!0),r()}),r(),e("#whatsappme_button_image_add").click(function(t){t.preventDefault(),a||((a=wp.media({title:e(this).data("title")||"Select button image",button:{text:e(this).data("button")||"Use Image"},library:{type:"image"},multiple:!1})).on("select",function(){var t=a.state().get("selection").first().toJSON(),n=t.sizes&&t.sizes.thumbnail&&t.sizes.thumbnail.url||t.url;e("#whatsappme_button_image_holder").css({"background-size":"cover","background-image":"url("+n+")"}),e("#whatsappme_button_image").val(t.id),e("#whatsappme_button_image_remove").removeClass("wame-hidden")}),a.on("open",function(){var t=wp.media.attachment(e("#whatsappme_button_image").val());a.state().get("selection").add(t?[t]:[])})),a.open()}),e("#whatsappme_button_image_remove").click(function(t){t.preventDefault(),e("#whatsappme_button_image_holder").removeAttr("style"),e("#whatsappme_button_image").val(""),e(this).addClass("wame-hidden")})}1===e(".whatsappme-metabox").length&&e("textarea",".whatsappme-metabox").on("focus input",t).each(t)})}(jQuery);
includes/{class-whatsappme-i18n.php → class-joinchat-i18n.php} RENAMED
@@ -7,11 +7,11 @@
7
* so that it is ready for translation.
8
*
9
* @since 1.0.0
10
- * @package WhatsAppMe
11
- * @subpackage WhatsAppMe/includes
12
* @author Creame <hola@crea.me>
13
*/
14
- class WhatsAppMe_i18n {
15
16
17
/**
7
* so that it is ready for translation.
8
*
9
* @since 1.0.0
10
+ * @package JoinChat
11
+ * @subpackage JoinChat/includes
12
* @author Creame <hola@crea.me>
13
*/
14
+ class JoinChat_i18n {
15
16
17
/**
includes/{class-whatsappme-integrations.php → class-joinchat-integrations.php} RENAMED
@@ -4,11 +4,11 @@
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.
@@ -19,20 +19,20 @@ class WhatsAppMe_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
}
4
* Define the third party plugins integration functionality.
5
*
6
* @since 3.0.0
7
+ * @package JoinChat
8
+ * @subpackage JoinChat/includes
9
* @author Creame <hola@crea.me>
10
*/
11
+ class JoinChatIntegrations {
12
13
/**
14
* Load third party plugins integrations.
19
20
// Integration with WooCommerce
21
if ( class_exists( 'WooCommerce' ) ) {
22
+ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-joinchat-wooadmin.php';
23
+ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-joinchat-woopublic.php';
24
25
if ( is_admin() ) {
26
27
+ $plugin_wooadmin = new JoinChatWooAdmin();
28
29
+ add_action( 'joinchat_run_pre', array( $plugin_wooadmin, 'init' ) );
30
31
} else {
32
33
+ $plugin_woopublic = new JoinChatWooPublic();
34
35
+ add_action( 'joinchat_run_pre', array( $plugin_woopublic, 'init' ) );
36
37
}
38
}
includes/{class-whatsappme-loader.php → class-joinchat-loader.php} RENAMED
@@ -8,11 +8,11 @@
8
* run function to execute the list of actions and filters.
9
*
10
* @since 1.0.0
11
- * @package WhatsAppMe
12
- * @subpackage WhatsAppMe/includes
13
* @author Creame <hola@crea.me>
14
*/
15
- class WhatsAppMe_Loader {
16
17
/**
18
* The array of actions registered with WordPress.
8
* run function to execute the list of actions and filters.
9
*
10
* @since 1.0.0
11
+ * @package JoinChat
12
+ * @subpackage JoinChat/includes
13
* @author Creame <hola@crea.me>
14
*/
15
+ class JoinChatLoader {
16
17
/**
18
* The array of actions registered with WordPress.
includes/{class-whatsappme-util.php → class-joinchat-util.php} RENAMED
@@ -6,11 +6,11 @@
6
* Include static methods.
7