WhatsApp me - Version 3.1.2

Version Description

  • NEW: WooCommerce Call to Action for Products on Sale, also added dynamic vars {DISCOUNT} {REGULAR}.
  • FIX Fatal error when selected button image is deleted from media library.
  • FIX WooCommerce settings not registered for translation.
  • For devs: format replacements now also accepts callbacks.
  • For devs: new javascript events for chat window 'whatsappme:show' 'whatsappme:hide'.
Download this release

Release Info

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

Code changes from version 3.1.1 to 3.1.2

README.txt CHANGED
@@ -5,7 +5,7 @@ Tags: whatsapp business, whatsapp, click to chat, button, whatsapp support chat,
5
  Requires at least: 3.0.1
6
  Tested up to: 5.3
7
  Requires PHP: 5.3
8
- Stable tag: 3.1.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -148,6 +148,13 @@ There is a Javascript event that WAme triggers automatically before launch Whats
148
 
149
  == Changelog ==
150
 
 
 
 
 
 
 
 
151
  = 3.1.1 =
152
  * CHANGED Tested up to WordPress 5.3
153
  * FIX Save on the first time can store some settings incorrectly.
5
  Requires at least: 3.0.1
6
  Tested up to: 5.3
7
  Requires PHP: 5.3
8
+ Stable tag: 3.1.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
148
 
149
  == Changelog ==
150
 
151
+ = 3.1.2 =
152
+ * **NEW:** WooCommerce Call to Action for Products on Sale, also added dynamic vars {DISCOUNT} {REGULAR}.
153
+ * FIX Fatal error when selected button image is deleted from media library.
154
+ * FIX WooCommerce settings not registered for translation.
155
+ * For devs: format replacements now also accepts callbacks.
156
+ * For devs: new javascript events for chat window 'whatsappme:show' 'whatsappme:hide'.
157
+
158
  = 3.1.1 =
159
  * CHANGED Tested up to WordPress 5.3
160
  * FIX Save on the first time can store some settings incorrectly.
admin/class-whatsappme-admin.php CHANGED
@@ -113,7 +113,7 @@ class WhatsAppMe_Admin {
113
  'message_delay' => 10,
114
  'message_badge' => 'no',
115
  'message_send' => '',
116
- 'message_start' => '',
117
  'position' => 'right',
118
  'visibility' => array( 'all' => 'yes' ),
119
  ),
@@ -236,16 +236,16 @@ class WhatsAppMe_Admin {
236
  $sections = array(
237
  'button' => array(
238
  'telephone' => '<label for="whatsappme_phone">' . __( 'Telephone', 'creame-whatsapp-me' ) . '</label>',
239
- 'message_send' => '<label for="whatsappme_message_send">' . __( 'Message', 'creame-whatsapp-me' ) . '</label>',
240
  'mobile_only' => __( 'Mobile Only', 'creame-whatsapp-me' ),
241
- 'position' => __( 'Position On Screen', 'creame-whatsapp-me' ),
242
  'button_image' => __( 'Image', 'creame-whatsapp-me' ),
243
  'button_tip' => __( 'Tooltip', 'creame-whatsapp-me' ),
244
  'button_delay' => '<label for="whatsappme_button_delay">' . __( 'Button Delay', 'creame-whatsapp-me' ) . '</label>',
245
  'whatsapp_web' => __( 'WhatsApp Web', 'creame-whatsapp-me' ),
246
  ),
247
  'chat' => array(
248
- 'message_text' => '<label for="whatsappme_message_text">' . __( 'Call To Action', 'creame-whatsapp-me' ) . '</label>',
249
  'message_start' => '<label for="whatsappme_message_start">' . __( 'Start WhatsApp Button', 'creame-whatsapp-me' ) . '</label>',
250
  'message_delay' => '<label for="whatsappme_message_delay">' . __( 'Chat Delay', 'creame-whatsapp-me' ) . '</label>',
251
  'message_badge' => __( 'Notification Balloon', 'creame-whatsapp-me' ),
@@ -358,16 +358,14 @@ class WhatsAppMe_Admin {
358
  /**
359
  * Register WPML/Polylang strings for translation
360
  * https://wpml.org/wpml-hook/wpml_register_single_string/
361
- *
362
- * Note: don't translate string $name to prevent missing translations if
363
- * public front lang is different of admin lang
364
  */
365
- do_action( 'wpml_register_single_string', 'WhatsApp me', 'Tooltip', $input['button_tip'] );
366
- do_action( 'wpml_register_single_string', 'WhatsApp me', 'Call To Action', $input['message_text'] );
367
- do_action( 'wpml_register_single_string', 'WhatsApp me', 'Message', $input['message_send'] );
368
- do_action( 'wpml_register_single_string', 'WhatsApp me', 'Start WhatsApp Button', $input['message_start'] );
369
 
370
- // Action to register more WPML strings or other tasks
 
 
 
 
371
  do_action( 'whatsappme_settings_validate', $input );
372
 
373
  add_settings_error( 'whatsappme', 'settings_updated', __( 'Settings saved', 'creame-whatsapp-me' ), 'updated' );
@@ -423,9 +421,8 @@ class WhatsAppMe_Admin {
423
  case 'whatsappme_tab_general__chat':
424
  $output = '<hr><h2 class="title">' . __( 'Chat Window', 'creame-whatsapp-me' ) . '</h2>' .
425
  '<p>' .
426
- __( 'Set the behavior of the chat window.', 'creame-whatsapp-me' ) . ' ' .
427
- ' <em>' . __( 'You can use styles and dynamic variables', 'creame-whatsapp-me' ) . '</em> ' .
428
- '<a class="whatsappme-show-help" href="#" title="' . __( 'Show Help', 'creame-whatsapp-me' ) . '">?</a>' .
429
  '</p>';
430
  break;
431
 
@@ -493,7 +490,7 @@ class WhatsAppMe_Admin {
493
  break;
494
 
495
  case 'position':
496
- $output = '<fieldset><legend class="screen-reader-text"><span>' . __( 'Position On Screen', 'creame-whatsapp-me' ) . '</span></legend>' .
497
  '<label><input name="whatsappme[position]" value="left" type="radio"' . checked( 'left', $value, false ) . '> ' .
498
  __( 'Left', 'creame-whatsapp-me' ) . '</label><br>' .
499
  '<label><input name="whatsappme[position]" value="right" type="radio"' . checked( 'right', $value, false ) . '> ' .
@@ -501,7 +498,7 @@ class WhatsAppMe_Admin {
501
  break;
502
 
503
  case 'button_image':
504
- $image = intval( $value ) > 0 ? WhatsAppMe_Util::thumb( $value, 116, 116 )['url'] : false;
505
 
506
  $output = '<div id="whatsappme_button_image_wrapper">' .
507
  '<div id="whatsappme_button_image_holder" ' . ( $image ? "style=\"background-size:cover; background-image:url('$image');\"" : '' ) . '></div>' .
@@ -792,14 +789,14 @@ class WhatsAppMe_Admin {
792
  <input id="whatsappme_phone" <?php echo $this->enhanced_phone ? 'data-' : ''; ?>name="whatsappme_telephone" value="<?php echo $metadata['telephone']; ?>" type="text">
793
  </p>
794
  <p>
795
- <label for="whatsappme_message"><?php _e( 'Call To Action', 'creame-whatsapp-me' ); ?></label><br>
796
  <textarea id="whatsappme_message" name="whatsappme_message" rows="2" class="large-text"><?php echo $metadata['message_text']; ?></textarea>
797
  </p>
798
  <p>
799
  <label for="whatsappme_message_send"><?php _e( 'Message', 'creame-whatsapp-me' ); ?></label><br>
800
  <textarea id="whatsappme_message_send" name="whatsappme_message_send" rows="2" class="large-text"><?php echo $metadata['message_send']; ?></textarea>
801
  <?php if ( count( $metabox_vars ) ) : ?>
802
- <small><?php _e( 'You can use vars:', 'creame-whatsapp-me' ); ?> <code>{<?php echo join( '}</code> <code>{', $metabox_vars ); ?>}</code></small>
803
  <?php endif; ?>
804
  </p>
805
  <p>
@@ -854,4 +851,24 @@ class WhatsAppMe_Admin {
854
  delete_post_meta( $post_id, '_whatsappme' );
855
  }
856
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
857
  }
113
  'message_delay' => 10,
114
  'message_badge' => 'no',
115
  'message_send' => '',
116
+ 'message_start' => __( 'Open chat', 'creame-whatsapp-me' ),
117
  'position' => 'right',
118
  'visibility' => array( 'all' => 'yes' ),
119
  ),
236
  $sections = array(
237
  'button' => array(
238
  'telephone' => '<label for="whatsappme_phone">' . __( 'Telephone', 'creame-whatsapp-me' ) . '</label>',
239
+ 'message_send' => '<label for="whatsappme_message_send">' . __( 'Message', 'creame-whatsapp-me' ) . '</label>' . self::vars_help( 'message_send' ),
240
  'mobile_only' => __( 'Mobile Only', 'creame-whatsapp-me' ),
241
+ 'position' => __( 'Position on Screen', 'creame-whatsapp-me' ),
242
  'button_image' => __( 'Image', 'creame-whatsapp-me' ),
243
  'button_tip' => __( 'Tooltip', 'creame-whatsapp-me' ),
244
  'button_delay' => '<label for="whatsappme_button_delay">' . __( 'Button Delay', 'creame-whatsapp-me' ) . '</label>',
245
  'whatsapp_web' => __( 'WhatsApp Web', 'creame-whatsapp-me' ),
246
  ),
247
  'chat' => array(
248
+ 'message_text' => '<label for="whatsappme_message_text">' . __( 'Call to Action', 'creame-whatsapp-me' ) . '</label>' . self::vars_help( 'message_text' ),
249
  'message_start' => '<label for="whatsappme_message_start">' . __( 'Start WhatsApp Button', 'creame-whatsapp-me' ) . '</label>',
250
  'message_delay' => '<label for="whatsappme_message_delay">' . __( 'Chat Delay', 'creame-whatsapp-me' ) . '</label>',
251
  'message_badge' => __( 'Notification Balloon', 'creame-whatsapp-me' ),
358
  /**
359
  * Register WPML/Polylang strings for translation
360
  * https://wpml.org/wpml-hook/wpml_register_single_string/
 
 
 
361
  */
362
+ $settings_i18n = WhatsAppMe_Util::settings_i18n();
 
 
 
363
 
364
+ foreach ( $settings_i18n as $setting_key => $setting_name ) {
365
+ do_action( 'wpml_register_single_string', 'WhatsApp me', $setting_name, $input[ $setting_key ] );
366
+ }
367
+
368
+ // Extra actions on save
369
  do_action( 'whatsappme_settings_validate', $input );
370
 
371
  add_settings_error( 'whatsappme', 'settings_updated', __( 'Settings saved', 'creame-whatsapp-me' ), 'updated' );
421
  case 'whatsappme_tab_general__chat':
422
  $output = '<hr><h2 class="title">' . __( 'Chat Window', 'creame-whatsapp-me' ) . '</h2>' .
423
  '<p>' .
424
+ __( 'If you define a "Call to Action" a window will be displayed simulating a chat before launching WhatsApp.', 'creame-whatsapp-me' ) . ' ' .
425
+ __( 'You can introduce yourself, offer help or even make promotions to your users.', 'creame-whatsapp-me' ) .
 
426
  '</p>';
427
  break;
428
 
490
  break;
491
 
492
  case 'position':
493
+ $output = '<fieldset><legend class="screen-reader-text"><span>' . __( 'Position on Screen', 'creame-whatsapp-me' ) . '</span></legend>' .
494
  '<label><input name="whatsappme[position]" value="left" type="radio"' . checked( 'left', $value, false ) . '> ' .
495
  __( 'Left', 'creame-whatsapp-me' ) . '</label><br>' .
496
  '<label><input name="whatsappme[position]" value="right" type="radio"' . checked( 'right', $value, false ) . '> ' .
498
  break;
499
 
500
  case 'button_image':
501
+ $image = intval( $value ) > 0 && is_array( WhatsAppMe_Util::thumb( $value, 116, 116 ) ) ? WhatsAppMe_Util::thumb( $value, 116, 116 )['url'] : false;
502
 
503
  $output = '<div id="whatsappme_button_image_wrapper">' .
504
  '<div id="whatsappme_button_image_holder" ' . ( $image ? "style=\"background-size:cover; background-image:url('$image');\"" : '' ) . '></div>' .
789
  <input id="whatsappme_phone" <?php echo $this->enhanced_phone ? 'data-' : ''; ?>name="whatsappme_telephone" value="<?php echo $metadata['telephone']; ?>" type="text">
790
  </p>
791
  <p>
792
+ <label for="whatsappme_message"><?php _e( 'Call to Action', 'creame-whatsapp-me' ); ?></label><br>
793
  <textarea id="whatsappme_message" name="whatsappme_message" rows="2" class="large-text"><?php echo $metadata['message_text']; ?></textarea>
794
  </p>
795
  <p>
796
  <label for="whatsappme_message_send"><?php _e( 'Message', 'creame-whatsapp-me' ); ?></label><br>
797
  <textarea id="whatsappme_message_send" name="whatsappme_message_send" rows="2" class="large-text"><?php echo $metadata['message_send']; ?></textarea>
798
  <?php if ( count( $metabox_vars ) ) : ?>
799
+ <small><?php _e( 'You can use vars', 'creame-whatsapp-me' ); ?> <code>{<?php echo join( '}</code> <code>{', $metabox_vars ); ?>}</code></small>
800
  <?php endif; ?>
801
  </p>
802
  <p>
851
  delete_post_meta( $post_id, '_whatsappme' );
852
  }
853
  }
854
+
855
+ /**
856
+ * Return html for dynamic variables help next to field label
857
+ *
858
+ * @since 3.1.2
859
+ * @access public
860
+ * @param string $field field name.
861
+ * @return string
862
+ */
863
+ public static function vars_help( $field ) {
864
+
865
+ $vars = apply_filters( 'whatsappme_vars_help', array( 'SITE', 'URL', 'TITLE' ), $field );
866
+
867
+ return count( $vars ) ? '<div class="whatsappme_vars_help">' . __( 'You can use vars', 'creame-whatsapp-me' ) . ' ' .
868
+ '<a class="whatsappme-show-help" href="#" title="' . __( 'Show Help', 'creame-whatsapp-me' ) . '">?</a><br> ' .
869
+ '<code>{' . join( '}</code> <code>{', $vars ) . '}</code></div>' : '';
870
+
871
+ }
872
+
873
+
874
  }
admin/class-whatsappme-wooadmin.php CHANGED
@@ -23,10 +23,12 @@ class WhatsAppMe_WooAdmin {
23
 
24
  $loader->add_filter( 'whatsappme_extra_settings', $this, 'extra_settings' );
25
  $loader->add_filter( 'whatsappme_settings_validate', $this, 'settings_validate' );
 
26
  $loader->add_filter( 'whatsappme_admin_tabs', $this, 'admin_tab' );
27
  $loader->add_filter( 'whatsappme_custom_post_types', $this, 'custom_post_types' );
28
  $loader->add_filter( 'whatsappme_tab_advanced_sections', $this, 'advanced_tab_section' );
29
  $loader->add_filter( 'whatsappme_tab_woocommerce_sections', $this, 'woo_tab_sections' );
 
30
  $loader->add_filter( 'whatsappme_section_output', $this, 'section_ouput', 10, 2 );
31
  $loader->add_filter( 'whatsappme_field_output', $this, 'field_ouput', 10, 3 );
32
  $loader->add_filter( 'whatsappme_advanced_inheritance', $this, 'advanced_inheritance' );
@@ -45,6 +47,7 @@ class WhatsAppMe_WooAdmin {
45
 
46
  $woo_settings = array(
47
  'message_text_product' => '',
 
48
  'message_send_product' => '',
49
  );
50
 
@@ -61,11 +64,27 @@ class WhatsAppMe_WooAdmin {
61
  public function settings_validate( $input ) {
62
 
63
  $input['message_text_product'] = WhatsAppMe_Util::clean_input( $input['message_text_product'] );
 
64
  $input['message_send_product'] = WhatsAppMe_Util::clean_input( $input['message_send_product'] );
65
 
66
  return $input;
67
  }
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
  /**
71
  * Add WooCommerce admin tab
@@ -124,14 +143,39 @@ class WhatsAppMe_WooAdmin {
124
  */
125
  public function woo_tab_sections( $sections ) {
126
 
127
- $sections['chat'] = array(
128
- 'message_text_product' => '<label for="whatsappme_message_text_product">' . __( 'Call To Action', 'creame-whatsapp-me' ) . '</label>',
129
- 'message_send_product' => '<label for="whatsappme_message_send_product">' . __( 'Message', 'creame-whatsapp-me' ) . '</label>',
 
130
  );
131
 
 
 
 
 
 
 
132
  return $sections;
133
  }
134
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  /**
136
  * Woocommerce sections HTML output
137
  *
@@ -151,8 +195,6 @@ class WhatsAppMe_WooAdmin {
151
  $output = '<h2 class="title">' . __( 'Product Chat Window', 'creame-whatsapp-me' ) . '</h2>' .
152
  '<p>' .
153
  __( 'You can define other different texts for the Chat Window on the product pages.', 'creame-whatsapp-me' ) .
154
- ' <em>' . __( 'You can use styles and dynamic variables', 'creame-whatsapp-me' ) . '</em> ' .
155
- '<a class="whatsappme-show-help" href="#" title="' . __( 'Show Help', 'creame-whatsapp-me' ) . '">?</a>' .
156
  '</p>';
157
 
158
  }
@@ -178,7 +220,14 @@ class WhatsAppMe_WooAdmin {
178
  $output = '<textarea id="whatsappme_message_text_product" name="whatsappme[message_text_product]" rows="4" class="regular-text" ' .
179
  'placeholder="' . esc_attr__( "This *{PRODUCT}* can be yours for only *{PRICE}*!\nIf you have any questions, ask us.", 'creame-whatsapp-me' ) . '">' .
180
  $value . '</textarea>' .
181
- '<p class="description">' . __( 'Define a text to encourage clients to contact by WhatsApp', 'creame-whatsapp-me' ) . '</p>';
 
 
 
 
 
 
 
182
  break;
183
 
184
  case 'message_send_product':
@@ -222,8 +271,13 @@ class WhatsAppMe_WooAdmin {
222
  '<p> ' . __( '<strong>WooCommerce</strong>, in product pages you can also use:', 'creame-whatsapp-me' ) . '</p>' .
223
  '<p>' .
224
  '<span><code>{PRODUCT}</code> ➜ ' . __( 'Product Name', 'creame-whatsapp-me' ) . '</span>, ' .
225
- '<span><code>{PRICE}</code> ➜ ' . strip_tags( wc_price( 9.95 ) ) . '</span>, ' .
226
- '<span><code>{SKU}</code> ➜ ABC98798</span>' .
 
 
 
 
 
227
  '</p>';
228
 
229
  }
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' );
47
 
48
  $woo_settings = array(
49
  'message_text_product' => '',
50
+ 'message_text_on_sale' => '',
51
  'message_send_product' => '',
52
  );
53
 
64
  public function settings_validate( $input ) {
65
 
66
  $input['message_text_product'] = WhatsAppMe_Util::clean_input( $input['message_text_product'] );
67
+ $input['message_text_on_sale'] = WhatsAppMe_Util::clean_input( $input['message_text_on_sale'] );
68
  $input['message_send_product'] = WhatsAppMe_Util::clean_input( $input['message_send_product'] );
69
 
70
  return $input;
71
  }
72
 
73
+ /**
74
+ * WooCommerce settings translations
75
+ *
76
+ * @since 3.1.2
77
+ * @param array $settings translatable settings.
78
+ * @return array
79
+ */
80
+ public function settings_i18n( $settings ) {
81
+
82
+ $settings['message_text_product'] = 'Call to Action for Products';
83
+ $settings['message_text_on_sale'] = 'Call to Action for Products on Sale';
84
+ $settings['message_send_product'] = 'Message for Products';
85
+
86
+ return $settings;
87
+ }
88
 
89
  /**
90
  * Add WooCommerce admin tab
143
  */
144
  public function woo_tab_sections( $sections ) {
145
 
146
+ $woo_sections = array(
147
+ 'message_text_product' => __( 'Call to Action for Products', 'creame-whatsapp-me' ),
148
+ 'message_text_on_sale' => __( 'Call to Action for Products on Sale', 'creame-whatsapp-me' ),
149
+ 'message_send_product' => __( 'Message for Products', 'creame-whatsapp-me' ),
150
  );
151
 
152
+ foreach ( $woo_sections as $key => $label ) {
153
+ $woo_sections[ $key ] = "<label for=\"whatsappme_$key\">$label</label>" . WhatsAppMe_Admin::vars_help( $key );
154
+ }
155
+
156
+ $sections['chat'] = $woo_sections;
157
+
158
  return $sections;
159
  }
160
 
161
+ /**
162
+ * Woocommerce sections and fields for 'whatsappme_tab_woocommerce'
163
+ *
164
+ * @since 3.0.0
165
+ * @param array $sections current tab sections and fields.
166
+ * @return array
167
+ */
168
+ public function vars_help( $vars, $field ) {
169
+
170
+ if ( 'message_text_product' === $field || 'message_send_product' === $field ) {
171
+ $vars = array_merge( $vars, array( 'PRODUCT', 'SKU', 'PRICE' ) );
172
+ } elseif ( 'message_text_on_sale' === $field ) {
173
+ $vars = array_merge( $vars, array( 'PRODUCT', 'SKU', 'REGULAR', 'PRICE', 'DISCOUNT' ) );
174
+ }
175
+
176
+ return $vars;
177
+ }
178
+
179
  /**
180
  * Woocommerce sections HTML output
181
  *
195
  $output = '<h2 class="title">' . __( 'Product Chat Window', 'creame-whatsapp-me' ) . '</h2>' .
196
  '<p>' .
197
  __( 'You can define other different texts for the Chat Window on the product pages.', 'creame-whatsapp-me' ) .
 
 
198
  '</p>';
199
 
200
  }
220
  $output = '<textarea id="whatsappme_message_text_product" name="whatsappme[message_text_product]" rows="4" class="regular-text" ' .
221
  'placeholder="' . esc_attr__( "This *{PRODUCT}* can be yours for only *{PRICE}*!\nIf you have any questions, ask us.", 'creame-whatsapp-me' ) . '">' .
222
  $value . '</textarea>' .
223
+ '<p class="description">' . __( 'Define a text for your products to encourage customers to contact', 'creame-whatsapp-me' ) . '</p>';
224
+ break;
225
+
226
+ case 'message_text_on_sale':
227
+ $output = '<textarea id="whatsappme_message_text_on_sale" name="whatsappme[message_text_on_sale]" rows="4" class="regular-text" ' .
228
+ 'placeholder="' . esc_attr__( "Save {DISCOUNT}! This *{PRODUCT}* can be yours for only ~{REGULAR}~ *{PRICE}*.\nIf you have any questions, ask us.", 'creame-whatsapp-me' ) . '">' .
229
+ $value . '</textarea>' .
230
+ '<p class="description">' . __( 'Define a text for your products on sale to encourage customers to contact', 'creame-whatsapp-me' ) . '</p>';
231
  break;
232
 
233
  case 'message_send_product':
271
  '<p> ' . __( '<strong>WooCommerce</strong>, in product pages you can also use:', 'creame-whatsapp-me' ) . '</p>' .
272
  '<p>' .
273
  '<span><code>{PRODUCT}</code> ➜ ' . __( 'Product Name', 'creame-whatsapp-me' ) . '</span>, ' .
274
+ '<span><code>{SKU}</code> ➜ ABC98798</span>, ' .
275
+ '<span><code>{PRICE}</code> ➜ ' . strip_tags( wc_price( 7.95 ) ) . '</span> ' .
276
+ '</p>' .
277
+ '<p> ' . __( 'For the <strong>Call to Action for Products on Sale</strong>, you can also use:', 'creame-whatsapp-me' ) . '</p>' .
278
+ '<p>' .
279
+ '<span><code>{REGULAR}</code> ➜ ' . strip_tags( wc_price( 9.95 ) ) . '</span>, ' .
280
+ '<span><code>{DISCOUNT}</code> ➜ -20%</span>' .
281
  '</p>';
282
 
283
  }
admin/css/whatsappme.css CHANGED
@@ -114,6 +114,46 @@
114
  left: auto;
115
  }
116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  /* WAme chat metabox */
118
 
119
  .whatsappme-metabox code {
114
  left: auto;
115
  }
116
 
117
+ .whatsappme_vars_help {
118
+ margin-top: 5px;
119
+ font-size: 11px;
120
+ font-weight: normal;
121
+ line-height: 1.9;
122
+ opacity: 0;
123
+ transition: opacity 0.2s ease-out 0.2s;
124
+ }
125
+
126
+ tr:hover .whatsappme_vars_help,
127
+ tr.whatsappme--focus .whatsappme_vars_help {
128
+ opacity: 1;
129
+ transition-delay: 0.5s;
130
+ }
131
+
132
+ .whatsappme_vars_help code {
133
+ -webkit-user-select: all;
134
+ -moz-user-select: all;
135
+ -ms-user-select: all;
136
+ user-select: all;
137
+ padding: 2px 1px;
138
+ font-size: inherit;
139
+ vertical-align: bottom;
140
+ }
141
+
142
+ .whatsappme_vars_help code:hover {
143
+ background: rgba(0, 0, 0, 0.2);
144
+ }
145
+
146
+ @media screen and (max-width: 782px) {
147
+ .whatsappme_vars_help {
148
+ margin-top: 2px;
149
+ opacity: 1;
150
+ }
151
+
152
+ .whatsappme_vars_help br {
153
+ display: none;
154
+ }
155
+ }
156
+
157
  /* WAme chat metabox */
158
 
159
  .whatsappme-metabox code {
admin/css/whatsappme.min.css CHANGED
@@ -1 +1 @@
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{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-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}
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{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 CHANGED
@@ -78,8 +78,13 @@
78
  $('#tab-link-styles-and-vars a').click();
79
  });
80
 
81
- // Texarea auto height
82
- $('textarea', '#whatsappme_form').on('input', textarea_autoheight).each(textarea_autoheight);
 
 
 
 
 
83
 
84
  // Advanced view inheritance
85
  var $tab_advanced = $('#whatsappme_tab_advanced');
78
  $('#tab-link-styles-and-vars a').click();
79
  });
80
 
81
+ // Texarea focus and auto height
82
+ $('textarea', '#whatsappme_form')
83
+ .on('focus', function () { $(this).closest('tr').addClass('whatsappme--focus'); })
84
+ .on('blur', function () { $(this).closest('tr').removeClass('whatsappme--focus'); })
85
+ .on('input', textarea_autoheight)
86
+ .each(textarea_autoheight);
87
+
88
 
89
  // Advanced view inheritance
90
  var $tab_advanced = $('#whatsappme_tab_advanced');
admin/js/whatsappme.min.js CHANGED
@@ -1 +1 @@
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");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"}).hiddenInput.value=s.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(),e("#contextual-help-wrap").is(":visible")?e("html, body").animate({scrollTop:0}):e("#contextual-help-link").click(),e("#tab-link-styles-and-vars a").click()}),e("textarea","#whatsappme_form").on("input",t).each(t);var l=e("#whatsappme_tab_advanced"),o=e(".whatsappme_view_all").data("inheritance")||{all:["front_page","blog_page","404_page","search","archive","singular","cpts"],archive:["date","author"],singular:["page","post"]};function p(t,a){if(t=t||"all",a=a||e('input[name="whatsappme[view]['+t+']"]:checked').val(),e(".view_inheritance_"+t).toggleClass("dashicons-visibility","yes"==a).toggleClass("dashicons-hidden","no"==a),"cpts"==t)e("[class*=view_inheritance_cpt_]").toggleClass("dashicons-visibility","yes"==a).toggleClass("dashicons-hidden","no"==a);else if(t in o){var n=e('input[name="whatsappme[view]['+t+']"]:checked').val();n=""===n?a:n,e.each(o[t],function(){p(this,n)})}}e("input",l).change(function(){p()}),e(".whatsappme_view_reset").click(function(t){t.preventDefault(),e('input[value=""]',l).prop("checked",!0),e(".whatsappme_view_all input",l).first().prop("checked",!0),p()}),p(),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);
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");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"}).hiddenInput.value=s.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(),e("#contextual-help-wrap").is(":visible")?e("html, body").animate({scrollTop:0}):e("#contextual-help-link").click(),e("#tab-link-styles-and-vars a").click()}),e("textarea","#whatsappme_form").on("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 l=e("#whatsappme_tab_advanced"),o=e(".whatsappme_view_all").data("inheritance")||{all:["front_page","blog_page","404_page","search","archive","singular","cpts"],archive:["date","author"],singular:["page","post"]};function p(t,a){if(t=t||"all",a=a||e('input[name="whatsappme[view]['+t+']"]:checked').val(),e(".view_inheritance_"+t).toggleClass("dashicons-visibility","yes"==a).toggleClass("dashicons-hidden","no"==a),"cpts"==t)e("[class*=view_inheritance_cpt_]").toggleClass("dashicons-visibility","yes"==a).toggleClass("dashicons-hidden","no"==a);else if(t in o){var n=e('input[name="whatsappme[view]['+t+']"]:checked').val();n=""===n?a:n,e.each(o[t],function(){p(this,n)})}}e("input",l).change(function(){p()}),e(".whatsappme_view_reset").click(function(t){t.preventDefault(),e('input[value=""]',l).prop("checked",!0),e(".whatsappme_view_all input",l).first().prop("checked",!0),p()}),p(),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-util.php CHANGED
@@ -12,6 +12,29 @@
12
  */
13
  class WhatsAppMe_Util {
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  /**
16
  * Clean user input fields
17
  *
@@ -60,8 +83,13 @@ class WhatsAppMe_Util {
60
  */
61
  public static function thumb( $img, $width, $height, $crop = true ) {
62
 
 
 
 
 
 
 
63
  $uploads = wp_get_upload_dir();
64
- $img_path = intval( $img ) > 0 ? get_attached_file( $img ) : $img;
65
  $img_info = pathinfo( $img_path );
66
  $new_img_path = "{$img_info['dirname']}/{$img_info['filename']}-{$width}x{$height}.{$img_info['extension']}";
67
 
@@ -100,7 +128,7 @@ class WhatsAppMe_Util {
100
  public static function is_animated_gif( $img ) {
101
  $img_path = intval( $img ) > 0 ? get_attached_file( $img ) : $img;
102
 
103
- return (bool) preg_match( '#(\x00\x21\xF9\x04.{4}\x00\x2C.*){2,}#s', file_get_contents( $img_path ) );
104
  }
105
 
106
  /**
@@ -108,6 +136,7 @@ class WhatsAppMe_Util {
108
  * Also apply styles transformations like WhatsApp app.
109
  *
110
  * @since 3.1.0
 
111
  * @param string $string string to apply format replacements
112
  * @return string string formated
113
  */
@@ -115,20 +144,28 @@ class WhatsAppMe_Util {
115
 
116
  $replacements = apply_filters(
117
  'whatsappme_format_replacements', array(
118
- '/_(\S[^_]*\S)_/mu' => '<em>$1</em>',
119
- '/\*(\S[^\*]*\S)\*/mu' => '<strong>$1</strong>',
120
- '/~(\S[^~]*\S)~/mu' => '<del>$1</del>',
121
  )
122
  );
123
 
124
  $replacements = apply_filters_deprecated( 'whatsappme_message_replacements', array( $replacements ), '3.0.3', 'whatsappme_format_replacements' );
125
 
126
- $patterns = array_keys( $replacements );
127
-
128
  // Split text into lines and apply replacements line by line
129
  $lines = explode( "\n", $string );
130
  foreach ( $lines as $key => $line ) {
131
- $lines[ $key ] = preg_replace( $patterns, $replacements, esc_html( $line ) );
 
 
 
 
 
 
 
 
 
 
132
  }
133
 
134
  return self::replace_variables( implode( '<br>', $lines ) );
@@ -156,7 +193,7 @@ class WhatsAppMe_Util {
156
  // Convert VAR to regex {VAR}
157
  $patterns = array_map(
158
  function ( $var ) {
159
- return "/\{$var\}/i";
160
  }, array_keys( $replacements )
161
  );
162
 
12
  */
13
  class WhatsAppMe_Util {
14
 
15
+ /**
16
+ * Return list of settings that can be translated
17
+ *
18
+ * Note: don't translate string $name to prevent missing translations if
19
+ * public front lang is different of admin lang
20
+ *
21
+ * @since 3.1.2
22
+ * @access public
23
+ * @return array setting keys and string names
24
+ */
25
+ public static function settings_i18n() {
26
+
27
+ return apply_filters(
28
+ 'whatsappme_settings_i18n', array(
29
+ 'button_tip' => 'Tooltip',
30
+ 'message_text' => 'Call to Action',
31
+ 'message_send' => 'Message',
32
+ 'message_start' => 'Start WhatsApp Button',
33
+ )
34
+ );
35
+
36
+ }
37
+
38
  /**
39
  * Clean user input fields
40
  *
83
  */
84
  public static function thumb( $img, $width, $height, $crop = true ) {
85
 
86
+ $img_path = intval( $img ) > 0 ? get_attached_file( $img ) : $img;
87
+
88
+ if ( ! file_exists( $img_path ) ) {
89
+ return false;
90
+ }
91
+
92
  $uploads = wp_get_upload_dir();
 
93
  $img_info = pathinfo( $img_path );
94
  $new_img_path = "{$img_info['dirname']}/{$img_info['filename']}-{$width}x{$height}.{$img_info['extension']}";
95
 
128
  public static function is_animated_gif( $img ) {
129
  $img_path = intval( $img ) > 0 ? get_attached_file( $img ) : $img;
130
 
131
+ return file_exists( $img_path ) ? (bool) preg_match( '#(\x00\x21\xF9\x04.{4}\x00\x2C.*){2,}#s', file_get_contents( $img_path ) ) : false;
132
  }
133
 
134
  /**
136
  * Also apply styles transformations like WhatsApp app.
137
  *
138
  * @since 3.1.0
139
+ * @since 3.1.2 Allowed callback replecements
140
  * @param string $string string to apply format replacements
141
  * @return string string formated
142
  */
144
 
145
  $replacements = apply_filters(
146
  'whatsappme_format_replacements', array(
147
+ '/_(\S[^_]*\S)_/u' => '<em>$1</em>',
148
+ '/\*(\S[^\*]*\S)\*/u' => '<strong>$1</strong>',
149
+ '/~(\S[^~]*\S)~/u' => '<del>$1</del>',
150
  )
151
  );
152
 
153
  $replacements = apply_filters_deprecated( 'whatsappme_message_replacements', array( $replacements ), '3.0.3', 'whatsappme_format_replacements' );
154
 
 
 
155
  // Split text into lines and apply replacements line by line
156
  $lines = explode( "\n", $string );
157
  foreach ( $lines as $key => $line ) {
158
+ $escaped_line = esc_html( $line );
159
+
160
+ foreach ( $replacements as $pattern => $replacement ) {
161
+ if ( is_callable( $replacement ) ) {
162
+ $escaped_line = preg_replace_callback( $pattern, $replacement, $escaped_line );
163
+ } else {
164
+ $escaped_line = preg_replace( $pattern, $replacement, $escaped_line );
165
+ }
166
+ }
167
+
168
+ $lines[ $key ] = $escaped_line;
169
  }
170
 
171
  return self::replace_variables( implode( '<br>', $lines ) );
193
  // Convert VAR to regex {VAR}
194
  $patterns = array_map(
195
  function ( $var ) {
196
+ return "/\{$var\}/u";
197
  }, array_keys( $replacements )
198
  );
199
 
languages/creame-whatsapp-me.pot CHANGED
@@ -2,7 +2,7 @@
2
  msgid ""
3
  msgstr ""
4
  "Project-Id-Version: WAme chat\n"
5
- "POT-Creation-Date: 2019-10-18 18:29+0200\n"
6
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
7
  "Last-Translator: Your Name <you@example.com>\n"
8
  "Language-Team: Creame <hola@crea.me>\n"
@@ -21,138 +21,139 @@ msgstr ""
21
  "X-Generator: Poedit 1.8.7.1\n"
22
  "X-Poedit-SearchPath-0: .\n"
23
 
24
- #: admin/class-whatsappme-admin.php:101
25
  msgid "General"
26
  msgstr ""
27
 
28
- #: admin/class-whatsappme-admin.php:102
29
  msgid "Advanced"
30
  msgstr ""
31
 
32
- #: admin/class-whatsappme-admin.php:241 admin/class-whatsappme-admin.php:788
 
 
 
 
 
33
  msgid "Telephone"
34
  msgstr ""
35
 
36
- #: admin/class-whatsappme-admin.php:242 admin/class-whatsappme-admin.php:796
37
- #: admin/class-whatsappme-wooadmin.php:129
38
  msgid "Message"
39
  msgstr ""
40
 
41
- #: admin/class-whatsappme-admin.php:243 admin/class-whatsappme-admin.php:487
42
  msgid "Mobile Only"
43
  msgstr ""
44
 
45
- #: admin/class-whatsappme-admin.php:244 admin/class-whatsappme-admin.php:493
46
- msgid "Position On Screen"
47
  msgstr ""
48
 
49
- #: admin/class-whatsappme-admin.php:245
50
  msgid "Image"
51
  msgstr ""
52
 
53
- #: admin/class-whatsappme-admin.php:246
54
  msgid "Tooltip"
55
  msgstr ""
56
 
57
- #: admin/class-whatsappme-admin.php:247
58
  msgid "Button Delay"
59
  msgstr ""
60
 
61
- #: admin/class-whatsappme-admin.php:248 admin/class-whatsappme-admin.php:523
62
  msgid "WhatsApp Web"
63
  msgstr ""
64
 
65
- #: admin/class-whatsappme-admin.php:251 admin/class-whatsappme-admin.php:792
66
- #: admin/class-whatsappme-wooadmin.php:128
67
- msgid "Call To Action"
68
  msgstr ""
69
 
70
- #: admin/class-whatsappme-admin.php:252
71
  msgid "Start WhatsApp Button"
72
  msgstr ""
73
 
74
- #: admin/class-whatsappme-admin.php:253
75
  msgid "Chat Delay"
76
  msgstr ""
77
 
78
- #: admin/class-whatsappme-admin.php:254 admin/class-whatsappme-admin.php:549
79
  msgid "Notification Balloon"
80
  msgstr ""
81
 
82
- #: admin/class-whatsappme-admin.php:263
83
  msgid "Global"
84
  msgstr ""
85
 
86
- #: admin/class-whatsappme-admin.php:268
87
  msgid "Front Page"
88
  msgstr ""
89
 
90
- #: admin/class-whatsappme-admin.php:269
91
  msgid "Blog Page"
92
  msgstr ""
93
 
94
- #: admin/class-whatsappme-admin.php:270
95
  msgid "404 Page"
96
  msgstr ""
97
 
98
- #: admin/class-whatsappme-admin.php:271
99
  msgid "Search Results"
100
  msgstr ""
101
 
102
- #: admin/class-whatsappme-admin.php:272
103
  msgid "Archives"
104
  msgstr ""
105
 
106
- #: admin/class-whatsappme-admin.php:273
107
  msgid "Date Archives"
108
  msgstr ""
109
 
110
- #: admin/class-whatsappme-admin.php:274
111
  msgid "Author Archives"
112
  msgstr ""
113
 
114
- #: admin/class-whatsappme-admin.php:275
115
  msgid "Singular"
116
  msgstr ""
117
 
118
- #: admin/class-whatsappme-admin.php:276
119
  msgid "Page"
120
  msgstr ""
121
 
122
- #: admin/class-whatsappme-admin.php:277
123
  msgid "Post"
124
  msgstr ""
125
 
126
- #: admin/class-whatsappme-admin.php:370
127
  msgid "Settings saved"
128
  msgstr ""
129
 
130
- #: admin/class-whatsappme-admin.php:416
131
  msgid "Button"
132
  msgstr ""
133
 
134
- #: admin/class-whatsappme-admin.php:417
135
  msgid ""
136
  "Set the contact number and where you want the WhatsApp button to be "
137
  "displayed."
138
  msgstr ""
139
 
140
- #: admin/class-whatsappme-admin.php:421
141
  msgid "Chat Window"
142
  msgstr ""
143
 
144
- #: admin/class-whatsappme-admin.php:423
145
- msgid "Set the behavior of the chat window."
146
- msgstr ""
147
-
148
  #: admin/class-whatsappme-admin.php:424
149
- #: admin/class-whatsappme-wooadmin.php:154
150
- msgid "You can use styles and dynamic variables"
 
151
  msgstr ""
152
 
153
  #: admin/class-whatsappme-admin.php:425
154
- #: admin/class-whatsappme-wooadmin.php:155
155
- msgid "Show Help"
 
156
  msgstr ""
157
 
158
  #: admin/class-whatsappme-admin.php:430
@@ -268,10 +269,6 @@ msgstr ""
268
  msgid "Predefined text for the first message the user will send you"
269
  msgstr ""
270
 
271
- #: admin/class-whatsappme-admin.php:539
272
- msgid "Open chat"
273
- msgstr ""
274
-
275
  #: admin/class-whatsappme-admin.php:540
276
  msgid "Text of the start WhatsApp button on Chat Window"
277
  msgstr ""
@@ -348,72 +345,106 @@ msgstr ""
348
  msgid "WAme chat"
349
  msgstr ""
350
 
351
- #: admin/class-whatsappme-admin.php:799
352
- msgid "You can use vars:"
353
  msgstr ""
354
 
355
  #: admin/class-whatsappme-admin.php:808
356
  msgid "Default visibility"
357
  msgstr ""
358
 
359
- #: admin/class-whatsappme-wooadmin.php:108
 
 
 
 
360
  msgid "Shop"
361
  msgstr ""
362
 
363
- #: admin/class-whatsappme-wooadmin.php:109
364
  msgid "Product Page"
365
  msgstr ""
366
 
367
- #: admin/class-whatsappme-wooadmin.php:110
368
  msgid "Cart"
369
  msgstr ""
370
 
371
- #: admin/class-whatsappme-wooadmin.php:111
372
  msgid "Checkout"
373
  msgstr ""
374
 
375
- #: admin/class-whatsappme-wooadmin.php:112
376
  msgid "My Account"
377
  msgstr ""
378
 
379
  #: admin/class-whatsappme-wooadmin.php:147
 
 
 
 
 
 
 
 
 
 
 
 
380
  msgid "WooCommerce"
381
  msgstr ""
382
 
383
- #: admin/class-whatsappme-wooadmin.php:151
384
  msgid "Product Chat Window"
385
  msgstr ""
386
 
387
- #: admin/class-whatsappme-wooadmin.php:153
388
  msgid ""
389
  "You can define other different texts for the Chat Window on the product "
390
  "pages."
391
  msgstr ""
392
 
393
- #: admin/class-whatsappme-wooadmin.php:179
394
  msgid ""
395
  "This *{PRODUCT}* can be yours for only *{PRICE}*!\n"
396
  "If you have any questions, ask us."
397
  msgstr ""
398
 
399
- #: admin/class-whatsappme-wooadmin.php:181
400
- msgid "Define a text to encourage clients to contact by WhatsApp"
 
 
 
 
 
 
 
 
 
 
 
 
401
  msgstr ""
402
 
403
- #: admin/class-whatsappme-wooadmin.php:186
404
  msgid ""
405
  "*Hi {SITE}!*\n"
406
  "I have a question about *{PRODUCT} ({SKU})*"
407
  msgstr ""
408
 
409
- #: admin/class-whatsappme-wooadmin.php:187
410
  msgid "Predefined text for the first message the client will send you"
411
  msgstr ""
412
 
413
- #: admin/class-whatsappme-wooadmin.php:222
414
  msgid "<strong>WooCommerce</strong>, in product pages you can also use:"
415
  msgstr ""
416
 
417
- #: admin/class-whatsappme-wooadmin.php:224
418
  msgid "Product Name"
419
  msgstr ""
 
 
 
 
 
 
2
  msgid ""
3
  msgstr ""
4
  "Project-Id-Version: WAme chat\n"
5
+ "POT-Creation-Date: 2019-11-13 11:10+0100\n"
6
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
7
  "Last-Translator: Your Name <you@example.com>\n"
8
  "Language-Team: Creame <hola@crea.me>\n"
21
  "X-Generator: Poedit 1.8.7.1\n"
22
  "X-Poedit-SearchPath-0: .\n"
23
 
24
+ #: admin/class-whatsappme-admin.php:98
25
  msgid "General"
26
  msgstr ""
27
 
28
+ #: admin/class-whatsappme-admin.php:99
29
  msgid "Advanced"
30
  msgstr ""
31
 
32
+ #: admin/class-whatsappme-admin.php:116 admin/class-whatsappme-admin.php:539
33
+ #: public/class-whatsappme-public.php:102
34
+ msgid "Open chat"
35
+ msgstr ""
36
+
37
+ #: admin/class-whatsappme-admin.php:238 admin/class-whatsappme-admin.php:788
38
  msgid "Telephone"
39
  msgstr ""
40
 
41
+ #: admin/class-whatsappme-admin.php:239 admin/class-whatsappme-admin.php:796
 
42
  msgid "Message"
43
  msgstr ""
44
 
45
+ #: admin/class-whatsappme-admin.php:240 admin/class-whatsappme-admin.php:487
46
  msgid "Mobile Only"
47
  msgstr ""
48
 
49
+ #: admin/class-whatsappme-admin.php:241 admin/class-whatsappme-admin.php:493
50
+ msgid "Position on Screen"
51
  msgstr ""
52
 
53
+ #: admin/class-whatsappme-admin.php:242
54
  msgid "Image"
55
  msgstr ""
56
 
57
+ #: admin/class-whatsappme-admin.php:243
58
  msgid "Tooltip"
59
  msgstr ""
60
 
61
+ #: admin/class-whatsappme-admin.php:244
62
  msgid "Button Delay"
63
  msgstr ""
64
 
65
+ #: admin/class-whatsappme-admin.php:245 admin/class-whatsappme-admin.php:523
66
  msgid "WhatsApp Web"
67
  msgstr ""
68
 
69
+ #: admin/class-whatsappme-admin.php:248 admin/class-whatsappme-admin.php:792
70
+ msgid "Call to Action"
 
71
  msgstr ""
72
 
73
+ #: admin/class-whatsappme-admin.php:249
74
  msgid "Start WhatsApp Button"
75
  msgstr ""
76
 
77
+ #: admin/class-whatsappme-admin.php:250
78
  msgid "Chat Delay"
79
  msgstr ""
80
 
81
+ #: admin/class-whatsappme-admin.php:251 admin/class-whatsappme-admin.php:549
82
  msgid "Notification Balloon"
83
  msgstr ""
84
 
85
+ #: admin/class-whatsappme-admin.php:260
86
  msgid "Global"
87
  msgstr ""
88
 
89
+ #: admin/class-whatsappme-admin.php:265
90
  msgid "Front Page"
91
  msgstr ""
92
 
93
+ #: admin/class-whatsappme-admin.php:266
94
  msgid "Blog Page"
95
  msgstr ""
96
 
97
+ #: admin/class-whatsappme-admin.php:267
98
  msgid "404 Page"
99
  msgstr ""
100
 
101
+ #: admin/class-whatsappme-admin.php:268
102
  msgid "Search Results"
103
  msgstr ""
104
 
105
+ #: admin/class-whatsappme-admin.php:269
106
  msgid "Archives"
107
  msgstr ""
108
 
109
+ #: admin/class-whatsappme-admin.php:270
110
  msgid "Date Archives"
111
  msgstr ""
112
 
113
+ #: admin/class-whatsappme-admin.php:271
114
  msgid "Author Archives"
115
  msgstr ""
116
 
117
+ #: admin/class-whatsappme-admin.php:272
118
  msgid "Singular"
119
  msgstr ""
120
 
121
+ #: admin/class-whatsappme-admin.php:273
122
  msgid "Page"
123
  msgstr ""
124
 
125
+ #: admin/class-whatsappme-admin.php:274
126
  msgid "Post"
127
  msgstr ""
128
 
129
+ #: admin/class-whatsappme-admin.php:371
130
  msgid "Settings saved"
131
  msgstr ""
132
 
133
+ #: admin/class-whatsappme-admin.php:417
134
  msgid "Button"
135
  msgstr ""
136
 
137
+ #: admin/class-whatsappme-admin.php:418
138
  msgid ""
139
  "Set the contact number and where you want the WhatsApp button to be "
140
  "displayed."
141
  msgstr ""
142
 
143
+ #: admin/class-whatsappme-admin.php:422
144
  msgid "Chat Window"
145
  msgstr ""
146
 
 
 
 
 
147
  #: admin/class-whatsappme-admin.php:424
148
+ msgid ""
149
+ "If you define a \"Call to Action\" a window will be displayed simulating a "
150
+ "chat before launching WhatsApp."
151
  msgstr ""
152
 
153
  #: admin/class-whatsappme-admin.php:425
154
+ msgid ""
155
+ "You can introduce yourself, offer help or even make promotions to your "
156
+ "users."
157
  msgstr ""
158
 
159
  #: admin/class-whatsappme-admin.php:430
269
  msgid "Predefined text for the first message the user will send you"
270
  msgstr ""
271
 
 
 
 
 
272
  #: admin/class-whatsappme-admin.php:540
273
  msgid "Text of the start WhatsApp button on Chat Window"
274
  msgstr ""
345
  msgid "WAme chat"
346
  msgstr ""
347
 
348
+ #: admin/class-whatsappme-admin.php:799 admin/class-whatsappme-admin.php:867
349
+ msgid "You can use vars"
350
  msgstr ""
351
 
352
  #: admin/class-whatsappme-admin.php:808
353
  msgid "Default visibility"
354
  msgstr ""
355
 
356
+ #: admin/class-whatsappme-admin.php:868
357
+ msgid "Show Help"
358
+ msgstr ""
359
+
360
+ #: admin/class-whatsappme-wooadmin.php:127
361
  msgid "Shop"
362
  msgstr ""
363
 
364
+ #: admin/class-whatsappme-wooadmin.php:128
365
  msgid "Product Page"
366
  msgstr ""
367
 
368
+ #: admin/class-whatsappme-wooadmin.php:129
369
  msgid "Cart"
370
  msgstr ""
371
 
372
+ #: admin/class-whatsappme-wooadmin.php:130
373
  msgid "Checkout"
374
  msgstr ""
375
 
376
+ #: admin/class-whatsappme-wooadmin.php:131
377
  msgid "My Account"
378
  msgstr ""
379
 
380
  #: admin/class-whatsappme-wooadmin.php:147
381
+ msgid "Call to Action for Products"
382
+ msgstr ""
383
+
384
+ #: admin/class-whatsappme-wooadmin.php:148
385
+ msgid "Call to Action for Products on Sale"
386
+ msgstr ""
387
+
388
+ #: admin/class-whatsappme-wooadmin.php:149
389
+ msgid "Message for Products"
390
+ msgstr ""
391
+
392
+ #: admin/class-whatsappme-wooadmin.php:191
393
  msgid "WooCommerce"
394
  msgstr ""
395
 
396
+ #: admin/class-whatsappme-wooadmin.php:195
397
  msgid "Product Chat Window"
398
  msgstr ""
399
 
400
+ #: admin/class-whatsappme-wooadmin.php:197
401
  msgid ""
402
  "You can define other different texts for the Chat Window on the product "
403
  "pages."
404
  msgstr ""
405
 
406
+ #: admin/class-whatsappme-wooadmin.php:221
407
  msgid ""
408
  "This *{PRODUCT}* can be yours for only *{PRICE}*!\n"
409
  "If you have any questions, ask us."
410
  msgstr ""
411
 
412
+ #: admin/class-whatsappme-wooadmin.php:223
413
+ msgid "Define a text for your products to encourage customers to contact"
414
+ msgstr ""
415
+
416
+ #: admin/class-whatsappme-wooadmin.php:228
417
+ msgid ""
418
+ "Save {DISCOUNT}! This *{PRODUCT}* can be yours for only ~{REGULAR}~ "
419
+ "*{PRICE}*.\n"
420
+ "If you have any questions, ask us."
421
+ msgstr ""
422
+
423
+ #: admin/class-whatsappme-wooadmin.php:230
424
+ msgid ""
425
+ "Define a text for your products on sale to encourage customers to contact"
426
  msgstr ""
427
 
428
+ #: admin/class-whatsappme-wooadmin.php:235
429
  msgid ""
430
  "*Hi {SITE}!*\n"
431
  "I have a question about *{PRODUCT} ({SKU})*"
432
  msgstr ""
433
 
434
+ #: admin/class-whatsappme-wooadmin.php:236
435
  msgid "Predefined text for the first message the client will send you"
436
  msgstr ""
437
 
438
+ #: admin/class-whatsappme-wooadmin.php:271
439
  msgid "<strong>WooCommerce</strong>, in product pages you can also use:"
440
  msgstr ""
441
 
442
+ #: admin/class-whatsappme-wooadmin.php:273
443
  msgid "Product Name"
444
  msgstr ""
445
+
446
+ #: admin/class-whatsappme-wooadmin.php:277
447
+ msgid ""
448
+ "For the <strong>Call to Action for Products on Sale</strong>, you can also "
449
+ "use:"
450
+ msgstr ""
public/class-whatsappme-public.php CHANGED
@@ -99,7 +99,7 @@ class WhatsAppMe_Public {
99
  'message_delay' => 10,
100
  'message_badge' => 'no',
101
  'message_send' => '',
102
- 'message_start' => '',
103
  'position' => 'right',
104
  'visibility' => array( 'all' => 'yes' ),
105
  ),
@@ -122,13 +122,13 @@ class WhatsAppMe_Public {
122
  }
123
 
124
  // Load WPML/Polylang translated strings
125
- $settings['button_tip'] = apply_filters( 'wpml_translate_single_string', $settings['button_tip'], 'WhatsApp me', 'Tooltip' );
126
- $settings['message_text'] = apply_filters( 'wpml_translate_single_string', $settings['message_text'], 'WhatsApp me', 'Call To Action' );
127
- $settings['message_send'] = apply_filters( 'wpml_translate_single_string', $settings['message_send'], 'WhatsApp me', 'Message' );
128
- $settings['message_start'] = apply_filters( 'wpml_translate_single_string', $settings['message_start'], 'WhatsApp me', 'Start WhatsApp Button' );
 
129
 
130
  // Filter for site settings (can be overriden by post settings)
131
- // You can translate more WPML strings or add/change other settings
132
  $settings = apply_filters( 'whatsappme_get_settings_site', $settings, $obj );
133
 
134
  // Post custom settings override site settings
@@ -241,13 +241,15 @@ class WhatsAppMe_Public {
241
  $powered_site = urlencode( get_bloginfo( 'name' ) );
242
  $powered_link = "https://wame.chat/powered/?site={$powered_site}&url={$powered_url}";
243
 
244
- $image = false;
245
- if ( $this->settings['button_image'] ) {
 
 
246
  $img_path = get_attached_file( $this->settings['button_image'] );
247
 
248
  if ( apply_filters( 'whatsappme_image_original', WhatsAppMe_Util::is_animated_gif( $img_path ) ) ) {
249
  $image = '<img src="' . wp_get_attachment_url( $this->settings['button_image'] ) . '" alt="">';
250
- } else {
251
  $image = '<img src="' . WhatsAppMe_Util::thumb( $img_path, 58, 58 )['url'] . '" srcset="' .
252
  WhatsAppMe_Util::thumb( $img_path, 116, 116 )['url'] . ' 2x, ' .
253
  WhatsAppMe_Util::thumb( $img_path, 174, 174 )['url'] . ' 3x" alt="">';
99
  'message_delay' => 10,
100
  'message_badge' => 'no',
101
  'message_send' => '',
102
+ 'message_start' => __( 'Open chat', 'creame-whatsapp-me' ),
103
  'position' => 'right',
104
  'visibility' => array( 'all' => 'yes' ),
105
  ),
122
  }
123
 
124
  // Load WPML/Polylang translated strings
125
+ $settings_i18n = WhatsAppMe_Util::settings_i18n();
126
+
127
+ foreach ( $settings_i18n as $key => $label ) {
128
+ $settings[ $key ] = $settings[ $key ] ? apply_filters( 'wpml_translate_single_string', $settings[ $key ], 'WhatsApp me', $label ) : '';
129
+ }
130
 
131
  // Filter for site settings (can be overriden by post settings)
 
132
  $settings = apply_filters( 'whatsappme_get_settings_site', $settings, $obj );
133
 
134
  // Post custom settings override site settings
241
  $powered_site = urlencode( get_bloginfo( 'name' ) );
242
  $powered_link = "https://wame.chat/powered/?site={$powered_site}&url={$powered_url}";
243
 
244
+ // Set custom img tag and bypass default image logic
245
+ $image = apply_filters( 'whatsappme_image', null );
246
+
247
+ if ( is_null( $image ) && $this->settings['button_image'] ) {
248
  $img_path = get_attached_file( $this->settings['button_image'] );
249
 
250
  if ( apply_filters( 'whatsappme_image_original', WhatsAppMe_Util::is_animated_gif( $img_path ) ) ) {
251
  $image = '<img src="' . wp_get_attachment_url( $this->settings['button_image'] ) . '" alt="">';
252
+ } elseif ( is_array( WhatsAppMe_Util::thumb( $img_path, 58, 58 ) ) ) {
253
  $image = '<img src="' . WhatsAppMe_Util::thumb( $img_path, 58, 58 )['url'] . '" srcset="' .
254
  WhatsAppMe_Util::thumb( $img_path, 116, 116 )['url'] . ' 2x, ' .
255
  WhatsAppMe_Util::thumb( $img_path, 174, 174 )['url'] . ' 3x" alt="">';
public/class-whatsappme-woopublic.php CHANGED
@@ -22,6 +22,7 @@ class WhatsAppMe_WooPublic {
22
  $loader = $whatsappme->get_loader();
23
 
24
  $loader->add_filter( 'whatsappme_extra_settings', $this, 'woo_settings' );
 
25
  $loader->add_filter( 'whatsappme_get_settings_site', $this, 'product_settings' );
26
  $loader->add_filter( 'whatsappme_visibility', $this, 'visibility', 10, 2 );
27
  $loader->add_filter( 'whatsappme_variable_replacements', $this, 'replacements' );
@@ -40,12 +41,29 @@ class WhatsAppMe_WooPublic {
40
 
41
  $woo_settings = array(
42
  'message_text_product' => '',
 
43
  'message_send_product' => '',
44
  );
45
 
46
  return array_merge( $settings, $woo_settings );
47
  }
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  /**
50
  * Replace general site CTA and send messages with the product ones
51
  *
@@ -57,18 +75,14 @@ class WhatsAppMe_WooPublic {
57
 
58
  // Only applies to product pages
59
  if ( is_product() ) {
60
- if ( '' != $settings['message_text_product'] ) {
61
- $settings['message_text'] = apply_filters(
62
- 'wpml_translate_single_string', $settings['message_text_product'],
63
- 'WhatsApp me', 'Call To Action for Products'
64
- );
65
- }
66
- if ( '' != $settings['message_send_product'] ) {
67
- $settings['message_send'] = apply_filters(
68
- 'wpml_translate_single_string', $settings['message_send_product'],
69
- 'WhatsApp me', 'Message for Products'
70
- );
71
  }
 
72
  }
73
 
74
  return $settings;
@@ -128,9 +142,11 @@ class WhatsAppMe_WooPublic {
128
 
129
  $replacements = array_merge(
130
  $replacements, array(
131
- 'PRODUCT' => $product->get_name(),
132
- 'SKU' => $product->get_sku(),
133
- 'PRICE' => strip_tags( wc_price( $product->get_price() ) ),
 
 
134
  )
135
  );
136
  }
@@ -155,4 +171,66 @@ class WhatsAppMe_WooPublic {
155
  return array_merge( $fields, $excluded );
156
  }
157
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  }
22
  $loader = $whatsappme->get_loader();
23
 
24
  $loader->add_filter( 'whatsappme_extra_settings', $this, 'woo_settings' );
25
+ $loader->add_filter( 'whatsappme_settings_i18n', $this, 'settings_i18n' );
26
  $loader->add_filter( 'whatsappme_get_settings_site', $this, 'product_settings' );
27
  $loader->add_filter( 'whatsappme_visibility', $this, 'visibility', 10, 2 );
28
  $loader->add_filter( 'whatsappme_variable_replacements', $this, 'replacements' );
41
 
42
  $woo_settings = array(
43
  'message_text_product' => '',
44
+ 'message_text_on_sale' => '',
45
  'message_send_product' => '',
46
  );
47
 
48
  return array_merge( $settings, $woo_settings );
49
  }
50
 
51
+ /**
52
+ * WooCommerce settings translations
53
+ *
54
+ * @since 3.1.2
55
+ * @param array $settings translatable settings.
56
+ * @return array
57
+ */
58
+ public function settings_i18n( $settings ) {
59
+
60
+ $settings['message_text_product'] = 'Call to Action for Products';
61
+ $settings['message_text_on_sale'] = 'Call to Action for Products on sale';
62
+ $settings['message_send_product'] = 'Message for Products';
63
+
64
+ return $settings;
65
+ }
66
+
67
  /**
68
  * Replace general site CTA and send messages with the product ones
69
  *
75
 
76
  // Only applies to product pages
77
  if ( is_product() ) {
78
+ $product = wc_get_product();
79
+
80
+ if ( $product->is_on_sale() && $settings['message_text_on_sale'] ) {
81
+ $settings['message_text'] = $settings['message_text_on_sale'];
82
+ } else {
83
+ $settings['message_text'] = $settings['message_text_product'] ?: $settings['message_text'];
 
 
 
 
 
84
  }
85
+ $settings['message_send'] = $settings['message_send_product'] ?: $settings['message_send'];
86
  }
87
 
88
  return $settings;
142
 
143
  $replacements = array_merge(
144
  $replacements, array(
145
+ 'PRODUCT' => $product->get_name(),
146
+ 'SKU' => $product->get_sku(),
147
+ 'REGULAR' => $this->get_regular_price( $product ),
148
+ 'PRICE' => $this->get_price( $product ),
149
+ 'DISCOUNT' => $this->get_discount( $product ),
150
  )
151
  );
152
  }
171
  return array_merge( $fields, $excluded );
172
  }
173
 
174
+ /**
175
+ * Return text formated price.
176
+ * Follow WooCommerce settings for show included/excluded taxes
177
+ *
178
+ * @since 3.1.2
179
+ * @param WC_Product $product current product.
180
+ * @param float $price price to format.
181
+ * @return string formated price
182
+ */
183
+ public function format_price( $product, $price ) {
184
+
185
+ return strip_tags( wc_price( wc_get_price_to_display( $product, array( 'price' => $price ) ) ) );
186
+
187
+ }
188
+
189
+ /**
190
+ * Return regular price of product (if is variable return min price)
191
+ *
192
+ * @since 3.1.2
193
+ * @param WC_Product $product current product.
194
+ * @return float price
195
+ */
196
+ public function get_regular_price( $product ) {
197
+
198
+ $price = 'variable' === $product->get_type() ? $product->get_variation_regular_price( 'min' ) : $product->get_regular_price();
199
+
200
+ return $this->format_price( $product, $price );
201
+
202
+ }
203
+
204
+ /**
205
+ * Return price of product (if is variable return min price)
206
+ *
207
+ * @since 3.1.2
208
+ * @param WC_Product $product current product.
209
+ * @return float price
210
+ */
211
+ public function get_price( $product ) {
212
+
213
+ $price = 'variable' === $product->get_type() ? $product->get_variation_price( 'min' ) : $product->get_price();
214
+
215
+ return $this->format_price( $product, $price );
216
+
217
+ }
218
+
219
+ /**
220
+ * Return percent discount of product on sale
221
+ *
222
+ * @since 3.1.2
223
+ * @param WC_Product $product current product.
224
+ * @return string discount
225
+ */
226
+ public function get_discount( $product ) {
227
+
228
+ $regular_price = 'variable' === $product->get_type() ? $product->get_variation_regular_price( 'min' ) : $product->get_regular_price();
229
+ $sale_price = 'variable' === $product->get_type() ? $product->get_variation_price( 'min' ) : $product->get_price();
230
+ $percentage = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
231
+
232
+ return $percentage ? "-$percentage%" : '';
233
+
234
+ }
235
+
236
  }
public/css/whatsappme.css CHANGED
@@ -10,7 +10,7 @@
10
  bottom: 20px;
11
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
12
  font-size: 16px;
13
- line-height: 26px;
14
  color: #262626;
15
  transform: scale3d(0, 0, 0);
16
  transition: transform .3s ease-in-out;
10
  bottom: 20px;
11
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
12
  font-size: 16px;
13
+ line-height: 1.625em;
14
  color: #262626;
15
  transform: scale3d(0, 0, 0);
16
  transition: transform .3s ease-in-out;
public/css/whatsappme.min.css CHANGED
@@ -1 +1 @@
1
- @font-face{font-family:WAmeIcons;src:url(data:font/woff;base64,d09GRgABAAAAAARgAAsAAAAABBQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABPUy8yAAABCAAAAGAAAABgDxIFgGNtYXAAAAFoAAAAVAAAAFQXVtKIZ2FzcAAAAbwAAAAIAAAACAAAABBnbHlmAAABxAAAAHQAAAB0gkciwGhlYWQAAAI4AAAANgAAADYVuuUSaGhlYQAAAnAAAAAkAAAAJAbCA8dobXR4AAAClAAAABgAAAAYDgACM2xvY2EAAAKsAAAADgAAAA4AYgBAbWF4cAAAArwAAAAgAAAAIAAIAAVuYW1lAAAC3AAAAWIAAAFicC7V7nBvc3QAAARAAAAAIAAAACAAAwAAAAMDVQGQAAUAAAKZAswAAACPApkCzAAAAesAMwEJAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAQAAA6QEDwP/AAEADwABAAAAAAQAAAAAAAAAAAAAAIAAAAAAAAwAAAAMAAAAcAAEAAwAAABwAAwABAAAAHAAEADgAAAAKAAgAAgACAAEAIOkB//3//wAAAAAAIOkA//3//wAB/+MXBAADAAEAAAAAAAAAAAAAAAEAAf//AA8AAQAAAAAAAAAAAAIAADc5AQAAAAABAAAAAAAAAAAAAgAANzkBAAAAAAEAAAAAAAAAAAACAAA3OQEAAAAAAQEzAM0DAALNAAIAAAkBEQMA/jMBzf8AAgAAAAEBAADNAs0CzQACAAABEQECzf4zAs3+AAEAAAABAAAAAQAAtqSnv18PPPUACwQAAAAAANnOUKQAAAAA2c5QpAAAAAADAALNAAAACAACAAAAAAAAAAEAAAPA/8AAAAQAAAAAAAMAAAEAAAAAAAAAAAAAAAAAAAAGBAAAAAAAAAAAAAAAAgAAAAQAATMEAAEAAAAAAAAKABQAHgAsADoAAAABAAAABgADAAEAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAADgCuAAEAAAAAAAEABAAAAAEAAAAAAAIABwBFAAEAAAAAAAMABAAtAAEAAAAAAAQABABaAAEAAAAAAAUACwAMAAEAAAAAAAYABAA5AAEAAAAAAAoAGgBmAAMAAQQJAAEACAAEAAMAAQQJAAIADgBMAAMAAQQJAAMACAAxAAMAAQQJAAQACABeAAMAAQQJAAUAFgAXAAMAAQQJAAYACAA9AAMAAQQJAAoANACAd2FtZQB3AGEAbQBlVmVyc2lvbiAxLjAAVgBlAHIAcwBpAG8AbgAgADEALgAwd2FtZQB3AGEAbQBld2FtZQB3AGEAbQBlUmVndWxhcgBSAGUAZwB1AGwAYQByd2FtZQB3AGEAbQBlRm9udCBnZW5lcmF0ZWQgYnkgSWNvTW9vbi4ARgBvAG4AdAAgAGcAZQBuAGUAcgBhAHQAZQBkACAAYgB5ACAASQBjAG8ATQBvAG8AbgAuAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==) format('woff')}.whatsappme{position:fixed;z-index:1000;right:20px;bottom:20px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Open Sans","Helvetica Neue",sans-serif;font-size:16px;line-height:26px;color:#262626;transform:scale3d(0,0,0);transition:transform .3s ease-in-out;user-select:none;-ms-user-select:none;-moz-user-select:none;-webkit-user-select:none}.whatsappme svg path{fill:currentColor!important}.whatsappme.whatsappme--show{transform:scale3d(1,1,1);transition:transform .5s cubic-bezier(.18,.89,.32,1.28)}.whatsappme__button{display:-ms-flexbox;display:-webkit-flex;display:flex;position:absolute;z-index:2;bottom:8px;right:8px;height:60px;min-width:60px;max-width:95vw;background-color:#25d366;color:#fff;border-radius:30px;box-shadow:1px 6px 24px 0 rgba(7,94,84,.24);cursor:pointer;transition:background-color .2s linear;-webkit-tap-highlight-color:transparent}.whatsappme__button:hover{background-color:#128c7e;transition:background-color 1.5s linear}.whatsappme--dialog .whatsappme__button{background-color:#128c7e;transition:background-color .2s linear}.whatsappme--dialog .whatsappme__button:hover{background-color:#075e54}.whatsappme__button:active{background-color:#075e54;transition:none}@supports (-webkit-overflow-scrolling:touch){.whatsappme--dialog .whatsappme__button{background-color:#34b7f1}.whatsappme--dialog .whatsappme__button:hover,.whatsappme__button:active{background-color:#228bb9}}.whatsappme__button svg{width:36px;height:36px;margin:12px 12px}.whatsappme__button .whatsappme__button__send{margin:12px 11px 12px 13px}.whatsappme__button__image{position:absolute;top:1px;right:1px;width:58px;height:58px;border-radius:50%;overflow:hidden;opacity:0}.whatsappme__button__image img{display:block;width:100%;height:100%;object-fit:cover}.whatsappme--show .whatsappme__button__image{animation:wame_image_loop 20s linear 5s infinite normal both}.whatsappme--image .whatsappme__button__image{opacity:1;animation:none}.whatsappme__button__sendtext{padding:0;max-width:0;font-weight:600;line-height:60px;white-space:nowrap;opacity:0;overflow:hidden;transition:none}.whatsappme--dialog .whatsappme__button__sendtext{padding:0 4px 0 24px;max-width:200px;opacity:1;transition:max-width .2s linear,opacity .4s ease-out .2s}.whatsappme__badge{position:absolute;top:-4px;right:-4px;width:20px;height:20px;border:none;border-radius:50%;background:#e82c0c;font-size:12px;font-weight:600;line-height:20px;text-align:center;box-shadow:none;opacity:0;pointer-events:none}.whatsappme__badge.whatsappme__badge--in{animation:wame_badge_in .5s cubic-bezier(.27,.9,.41,1.28) 1 both}.whatsappme__badge.whatsappme__badge--out{animation:wame_badge_out .4s cubic-bezier(.215,.61,.355,1) 1 both}.whatsappme--dialog .whatsappme__button{box-shadow:0 1px 2px 0 rgba(0,0,0,.3)}.whatsappme .whatsappme__button__send path{fill:none!important;stroke:#fff!important;animation:wame_plain 6s 0s ease-in-out infinite}.whatsappme .whatsappme__button__send path.wame_chat{animation-name:wame_chat}.whatsappme__tooltip{position:absolute;top:14px;right:76px;max-width:calc(100vw - 105px);height:32px;padding:0 14px;border:none;border-radius:16px;background:#fff;color:#075e54;line-height:31px;white-space:nowrap;box-shadow:0 1px 4px 0 rgba(0,0,0,.4);opacity:0}.whatsappme__tooltip::after{font:normal normal 400 20px/1em WAmeIcons;content:'\e900';position:absolute;top:6px;right:-12px;color:#fff;text-align:right;text-shadow:2px 1px 3px rgba(0,0,0,.4)}.whatsappme__tooltip div{overflow:hidden;text-overflow:ellipsis}.whatsappme--tooltip .whatsappme__tooltip{animation:wame_tootlip 20s linear 5s 1 normal both}.whatsappme--dialog .whatsappme__button__send,.whatsappme__button__open{display:block}.whatsappme--dialog .whatsappme__button__image,.whatsappme--dialog .whatsappme__button__open,.whatsappme--dialog .whatsappme__tooltip,.whatsappme__button__send{display:none}.whatsappme__box{position:absolute;bottom:0;right:0;z-index:1;width:calc(100vw - 40px);max-width:400px;min-height:280px;padding-bottom:60px;border-radius:32px;background:#ede4dd url(../images/background.webp) center repeat-y;background-size:100% auto;box-shadow:0 2px 6px 0 rgba(0,0,0,.5);overflow:hidden;transform:scale3d(0,0,0);opacity:0;transition:opacity .4s ease-out,transform 0s linear .3s}.nowebp .whatsappme__box{background-image:url(../images/background.png)}.whatsappme--dialog .whatsappme__box{opacity:1;transform:scale3d(1,1,1);transition:opacity .2s ease-out,transform 0s linear}.whatsappme__header{float:none;display:block;position:static;width:100%;height:70px;padding:0 26px;margin:0;background-color:#2e8c7d;color:rgba(255,255,255,.5)}.whatsappme__header svg{width:120px;height:100%}.whatsappme__close{display:-ms-flexbox;display:-webkit-flex;display:flex;position:absolute;top:18px;right:24px;width:34px;height:34px;border-radius:50%;background:#000;color:#fff;text-align:center;opacity:.4;cursor:pointer;transition:opacity .3s ease-out;-webkit-tap-highlight-color:transparent}.whatsappme__close:hover{opacity:.6}.whatsappme__close svg{display:block;width:12px;height:12px;margin:auto}.whatsappme__message{position:relative;min-height:80px;padding:20px 2px 20px 0;margin:34px 26px;border-radius:32px;background-color:#fff;color:#4a4a4a;box-shadow:0 1px 2px 0 rgba(0,0,0,.3)}.whatsappme__message:before{content:'';display:block;position:absolute;bottom:30px;left:-18px;width:18px;height:18px;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADcAAAA1CAYAAADlE3NNAAAEr0lEQVRo3t2aT0gjVxzHf++9mcn8zWhW6bpELWzcogFNaRar7a4tBNy2WATbHpacpdZ6redeZE+9CL02B1ktXsRD/xwsilhoSwsqag/xYK09hCQlmCiTf28vGRnGmZhE183MFx5vmGQy7zO/P/P7PYLAHUIAQCqDAwDPxMREG3IpHL+zs/MZcgkYAgAMAIwOl8lkYm6xGgYAFgAEAGgZHx9/vVwun7nJJTkAEAGgdW9v73NKKXWLSzIA4AEAGQDazs/P/3ALnNEl1a2trY9oRW6wmu6SEgC0ZrPZn9wCp2dIHgCU1dXVtymlZafDIatEksvlfqYGueG9xgOAcnBw8JSa5GR3vIi1aDTaUSwWj5wOZ3RHPUN6U6nUN9RCTnZHDwDI+/v745TSkpPhrOpHcWlpqbdcLieojZwGpseZMDo66svn87/RKnIaGAsAfCAQ8J6dnX1Pr5DjwABAzmazMVqDHAd2enr6La1RjgGLRCJqLpeL0TrUjFDGrMgCAD8/P38vn8//QutUs1pLT/fC5ubmQKFQOKANqNmspbuhBwDEZDL5BaX0lDaoZoK62NxZXFzs1DRthV5TrxrKGFue/v5+KZ1Of1kul5P0BtQUUAAgxOPx9wuFwl/0BvWq3O8C6vDw8F1N036gL0G3ZaVLUEdHRxFN036kL1E3DWMHxAEAPzc3dyedTk+XSqUdegu6CRijy5mBPLOzs2oikfhU07RFSmmG3qKuaxkdxuhy/MzMjDeRSHyiadrz2wYyClUBMh9bzRfAu7u7PX6//z1RFB9zHBcBALUZKoRqUMgEgyvHeHt7+353d/cjQRBGWJZ9jBDqaMYKHKpYBAEAXltbawsGg2FFUd7iOO4hIeQhQuiOEzpdOzCSTCaftLS0fEUIGXbiHiBjU5njVCr1sc/nW6wkDcduS1u1HKRUKv2KMR4ABwvbAWKMA+BwYbsasFgs/uMWuEtxd3x8/J3b4C4Ag8Hg83g8/iyfz//n5IRi1eZzla00HgA8oijyDMNwlFJCCGH0axiGQQAAXq+XyLLMeL1eRlEURpZlRpIkhud5oigK297eLvl8Prm1tVVSFEWSJEkWRVESBMGrqupriqLcFQThLsaYu612n6vUip4KMFv5HJssjhooEi5laoZh0NjYWNvw8PC9np6ejkAg8MDv9w+oqnrfxsNqhgNTh2wE1MGYChyyWGA9RYJVFWTM3MhwjMPhsDw9PT0QDocHOjs731RV9Y1rv+cMlb4Oiy3garWW1b2sPMfceZgHmZqa6pycnPywr6/vA47jfPXAWbU0xOCOqE44u2K8Wl9oBUfMa+rq6hIWFhbGBwcHn9pBohogcRWwRiCRTUiACQ6ZYpxY9JAkFAopy8vLM4FAYKyRrgA1GGf1JperLGgEM4cNG4vF3olGo18TQkT9JsRmAdQw66NsGlbn7Ibdd0um2XzOblz6/ZWVlX8JIb8PDQ090gFJDU+e2sBeZ1hBU9NcqvIQzDMFALq+vp7GGP85MjLyBCHE1tPO1LP4eq4FG/hqnlGyeSiwsbHxfygUOu7t7Y00059JUY3ZHFm8k1lT0cGfnJw8c0ojepWFzd6CMpnM3y8AJPEkZ9khO4IAAAAASUVORK5CYII=);background-size:100%}.whatsappme__message__wrap{max-height:calc(100vh - 270px);padding:0 20px 0 22px;overflow:auto}.whatsappme__message__wrap::-webkit-scrollbar{width:5px;background:rgba(0,0,0,0)}.whatsappme__message__wrap::-webkit-scrollbar-thumb{border-radius:3px;background:rgba(0,0,0,0)}.whatsappme__message__wrap:hover::-webkit-scrollbar-thumb{background:rgba(0,0,0,.2)}.whatsappme__message a{text-decoration:underline;color:#2e8c7d}.whatsappme__copy{position:absolute;bottom:9px;left:28px;color:#2e8c7d;font-size:11px;letter-spacing:.2px;line-height:16px;opacity:.4;transition:opacity .25s}.whatsappme__copy:hover{opacity:.8;transition:opacity .5s ease-out .5s}.whatsappme__copy a,.whatsappme__copy a:active,.whatsappme__copy a:hover{color:inherit;text-decoration:none}.whatsappme__copy svg{width:40px;height:10px;vertical-align:inherit}.whatsappme--left{right:auto;left:20px}.whatsappme--left .whatsappme__button{right:auto;left:8px;-ms-flex-direction:row-reverse;-webkit-flex-direction:row-reverse;flex-direction:row-reverse}.whatsappme--left.whatsappme--dialog .whatsappme__button__sendtext{padding:0 24px 0 4px}.whatsappme--left .whatsappme__tooltip{right:auto;left:76px}.whatsappme--left .whatsappme__tooltip::after{content:'\e901';left:-12px;right:auto;text-align:left;text-shadow:-2px 1px 3px rgba(0,0,0,.4)}.whatsappme--left .whatsappme__box{right:auto;left:0}.whatsappme--left .whatsappme__copy{left:auto;right:28px;text-align:right}[dir=rtl] .whatsappme__close{right:auto;left:24px}[dir=rtl] .whatsappme__message:before{left:auto;right:-18px;transform:rotateY(180deg)}[dir=rtl] .whatsappme__button{-ms-flex-direction:row-reverse;-webkit-flex-direction:row-reverse;flex-direction:row-reverse}[dir=rtl] .whatsappme--left .whatsappme__button{-ms-flex-direction:row;-webkit-flex-direction:row;flex-direction:row}@media (max-width:480px),(orientation:landscape) and (max-width:767px){.whatsappme{bottom:6px;right:6px}.whatsappme--left{right:auto;left:6px}.whatsappme__box{width:calc(100vw - 12px);min-height:0}.whatsappme__header{height:55px}.whatsappme__close{top:13px;width:28px;height:28px}.whatsappme__message{padding:16px 0;margin:15px 21px 20px;line-height:24px}.whatsappme__message__wrap{max-height:calc(100vh - 194px);padding:0 14px}}@media (max-width:360px){.whatsappme__copy{width:70px}}@keyframes wame_badge_in{from{opacity:0;transform:translateY(50px)}to{opacity:1;transform:translateY(0)}}@keyframes wame_badge_out{from{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-20px)}}@keyframes wame_plain{45%,5%{stroke-dashoffset:0}100%,50%{stroke-dashoffset:1096.67}}@keyframes wame_chat{50%{stroke-dashoffset:1019.22}55%,95%{stroke-dashoffset:0}}@keyframes wame_image_loop{0%{opacity:0}20%,3%{opacity:1}100%,23%{opacity:0}}@keyframes wame_tootlip{0%{opacity:0;transform:scaleY(0)}1%,20%{opacity:1;transform:scaleY(1)}100%,23%{opacity:0;transform:scaleY(1)}}
1
+ @font-face{font-family:WAmeIcons;src:url(data:font/woff;base64,d09GRgABAAAAAARgAAsAAAAABBQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABPUy8yAAABCAAAAGAAAABgDxIFgGNtYXAAAAFoAAAAVAAAAFQXVtKIZ2FzcAAAAbwAAAAIAAAACAAAABBnbHlmAAABxAAAAHQAAAB0gkciwGhlYWQAAAI4AAAANgAAADYVuuUSaGhlYQAAAnAAAAAkAAAAJAbCA8dobXR4AAAClAAAABgAAAAYDgACM2xvY2EAAAKsAAAADgAAAA4AYgBAbWF4cAAAArwAAAAgAAAAIAAIAAVuYW1lAAAC3AAAAWIAAAFicC7V7nBvc3QAAARAAAAAIAAAACAAAwAAAAMDVQGQAAUAAAKZAswAAACPApkCzAAAAesAMwEJAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAQAAA6QEDwP/AAEADwABAAAAAAQAAAAAAAAAAAAAAIAAAAAAAAwAAAAMAAAAcAAEAAwAAABwAAwABAAAAHAAEADgAAAAKAAgAAgACAAEAIOkB//3//wAAAAAAIOkA//3//wAB/+MXBAADAAEAAAAAAAAAAAAAAAEAAf//AA8AAQAAAAAAAAAAAAIAADc5AQAAAAABAAAAAAAAAAAAAgAANzkBAAAAAAEAAAAAAAAAAAACAAA3OQEAAAAAAQEzAM0DAALNAAIAAAkBEQMA/jMBzf8AAgAAAAEBAADNAs0CzQACAAABEQECzf4zAs3+AAEAAAABAAAAAQAAtqSnv18PPPUACwQAAAAAANnOUKQAAAAA2c5QpAAAAAADAALNAAAACAACAAAAAAAAAAEAAAPA/8AAAAQAAAAAAAMAAAEAAAAAAAAAAAAAAAAAAAAGBAAAAAAAAAAAAAAAAgAAAAQAATMEAAEAAAAAAAAKABQAHgAsADoAAAABAAAABgADAAEAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAADgCuAAEAAAAAAAEABAAAAAEAAAAAAAIABwBFAAEAAAAAAAMABAAtAAEAAAAAAAQABABaAAEAAAAAAAUACwAMAAEAAAAAAAYABAA5AAEAAAAAAAoAGgBmAAMAAQQJAAEACAAEAAMAAQQJAAIADgBMAAMAAQQJAAMACAAxAAMAAQQJAAQACABeAAMAAQQJAAUAFgAXAAMAAQQJAAYACAA9AAMAAQQJAAoANACAd2FtZQB3AGEAbQBlVmVyc2lvbiAxLjAAVgBlAHIAcwBpAG8AbgAgADEALgAwd2FtZQB3AGEAbQBld2FtZQB3AGEAbQBlUmVndWxhcgBSAGUAZwB1AGwAYQByd2FtZQB3AGEAbQBlRm9udCBnZW5lcmF0ZWQgYnkgSWNvTW9vbi4ARgBvAG4AdAAgAGcAZQBuAGUAcgBhAHQAZQBkACAAYgB5ACAASQBjAG8ATQBvAG8AbgAuAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==) format('woff')}.whatsappme{position:fixed;z-index:1000;right:20px;bottom:20px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Open Sans","Helvetica Neue",sans-serif;font-size:16px;line-height:1.625em;color:#262626;transform:scale3d(0,0,0);transition:transform .3s ease-in-out;user-select:none;-ms-user-select:none;-moz-user-select:none;-webkit-user-select:none}.whatsappme svg path{fill:currentColor!important}.whatsappme.whatsappme--show{transform:scale3d(1,1,1);transition:transform .5s cubic-bezier(.18,.89,.32,1.28)}.whatsappme__button{display:-ms-flexbox;display:-webkit-flex;display:flex;position:absolute;z-index:2;bottom:8px;right:8px;height:60px;min-width:60px;max-width:95vw;background-color:#25d366;color:#fff;border-radius:30px;box-shadow:1px 6px 24px 0 rgba(7,94,84,.24);cursor:pointer;transition:background-color .2s linear;-webkit-tap-highlight-color:transparent}.whatsappme__button:hover{background-color:#128c7e;transition:background-color 1.5s linear}.whatsappme--dialog .whatsappme__button{background-color:#128c7e;transition:background-color .2s linear}.whatsappme--dialog .whatsappme__button:hover{background-color:#075e54}.whatsappme__button:active{background-color:#075e54;transition:none}@supports (-webkit-overflow-scrolling:touch){.whatsappme--dialog .whatsappme__button{background-color:#34b7f1}.whatsappme--dialog .whatsappme__button:hover,.whatsappme__button:active{background-color:#228bb9}}.whatsappme__button svg{width:36px;height:36px;margin:12px 12px}.whatsappme__button .whatsappme__button__send{margin:12px 11px 12px 13px}.whatsappme__button__image{position:absolute;top:1px;right:1px;width:58px;height:58px;border-radius:50%;overflow:hidden;opacity:0}.whatsappme__button__image img{display:block;width:100%;height:100%;object-fit:cover}.whatsappme--show .whatsappme__button__image{animation:wame_image_loop 20s linear 5s infinite normal both}.whatsappme--image .whatsappme__button__image{opacity:1;animation:none}.whatsappme__button__sendtext{padding:0;max-width:0;font-weight:600;line-height:60px;white-space:nowrap;opacity:0;overflow:hidden;transition:none}.whatsappme--dialog .whatsappme__button__sendtext{padding:0 4px 0 24px;max-width:200px;opacity:1;transition:max-width .2s linear,opacity .4s ease-out .2s}.whatsappme__badge{position:absolute;top:-4px;right:-4px;width:20px;height:20px;border:none;border-radius:50%;background:#e82c0c;font-size:12px;font-weight:600;line-height:20px;text-align:center;box-shadow:none;opacity:0;pointer-events:none}.whatsappme__badge.whatsappme__badge--in{animation:wame_badge_in .5s cubic-bezier(.27,.9,.41,1.28) 1 both}.whatsappme__badge.whatsappme__badge--out{animation:wame_badge_out .4s cubic-bezier(.215,.61,.355,1) 1 both}.whatsappme--dialog .whatsappme__button{box-shadow:0 1px 2px 0 rgba(0,0,0,.3)}.whatsappme .whatsappme__button__send path{fill:none!important;stroke:#fff!important;animation:wame_plain 6s 0s ease-in-out infinite}.whatsappme .whatsappme__button__send path.wame_chat{animation-name:wame_chat}.whatsappme__tooltip{position:absolute;top:14px;right:76px;max-width:calc(100vw - 105px);height:32px;padding:0 14px;border:none;border-radius:16px;background:#fff;color:#075e54;line-height:31px;white-space:nowrap;box-shadow:0 1px 4px 0 rgba(0,0,0,.4);opacity:0}.whatsappme__tooltip::after{font:normal normal 400 20px/1em WAmeIcons;content:'\e900';position:absolute;top:6px;right:-12px;color:#fff;text-align:right;text-shadow:2px 1px 3px rgba(0,0,0,.4)}.whatsappme__tooltip div{overflow:hidden;text-overflow:ellipsis}.whatsappme--tooltip .whatsappme__tooltip{animation:wame_tootlip 20s linear 5s 1 normal both}.whatsappme--dialog .whatsappme__button__send,.whatsappme__button__open{display:block}.whatsappme--dialog .whatsappme__button__image,.whatsappme--dialog .whatsappme__button__open,.whatsappme--dialog .whatsappme__tooltip,.whatsappme__button__send{display:none}.whatsappme__box{position:absolute;bottom:0;right:0;z-index:1;width:calc(100vw - 40px);max-width:400px;min-height:280px;padding-bottom:60px;border-radius:32px;background:#ede4dd url(../images/background.webp) center repeat-y;background-size:100% auto;box-shadow:0 2px 6px 0 rgba(0,0,0,.5);overflow:hidden;transform:scale3d(0,0,0);opacity:0;transition:opacity .4s ease-out,transform 0s linear .3s}.nowebp .whatsappme__box{background-image:url(../images/background.png)}.whatsappme--dialog .whatsappme__box{opacity:1;transform:scale3d(1,1,1);transition:opacity .2s ease-out,transform 0s linear}.whatsappme__header{float:none;display:block;position:static;width:100%;height:70px;padding:0 26px;margin:0;background-color:#2e8c7d;color:rgba(255,255,255,.5)}.whatsappme__header svg{width:120px;height:100%}.whatsappme__close{display:-ms-flexbox;display:-webkit-flex;display:flex;position:absolute;top:18px;right:24px;width:34px;height:34px;border-radius:50%;background:#000;color:#fff;text-align:center;opacity:.4;cursor:pointer;transition:opacity .3s ease-out;-webkit-tap-highlight-color:transparent}.whatsappme__close:hover{opacity:.6}.whatsappme__close svg{display:block;width:12px;height:12px;margin:auto}.whatsappme__message{position:relative;min-height:80px;padding:20px 2px 20px 0;margin:34px 26px;border-radius:32px;background-color:#fff;color:#4a4a4a;box-shadow:0 1px 2px 0 rgba(0,0,0,.3)}.whatsappme__message:before{content:'';display:block;position:absolute;bottom:30px;left:-18px;width:18px;height:18px;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADcAAAA1CAYAAADlE3NNAAAEr0lEQVRo3t2aT0gjVxzHf++9mcn8zWhW6bpELWzcogFNaRar7a4tBNy2WATbHpacpdZ6redeZE+9CL02B1ktXsRD/xwsilhoSwsqag/xYK09hCQlmCiTf28vGRnGmZhE183MFx5vmGQy7zO/P/P7PYLAHUIAQCqDAwDPxMREG3IpHL+zs/MZcgkYAgAMAIwOl8lkYm6xGgYAFgAEAGgZHx9/vVwun7nJJTkAEAGgdW9v73NKKXWLSzIA4AEAGQDazs/P/3ALnNEl1a2trY9oRW6wmu6SEgC0ZrPZn9wCp2dIHgCU1dXVtymlZafDIatEksvlfqYGueG9xgOAcnBw8JSa5GR3vIi1aDTaUSwWj5wOZ3RHPUN6U6nUN9RCTnZHDwDI+/v745TSkpPhrOpHcWlpqbdcLieojZwGpseZMDo66svn87/RKnIaGAsAfCAQ8J6dnX1Pr5DjwABAzmazMVqDHAd2enr6La1RjgGLRCJqLpeL0TrUjFDGrMgCAD8/P38vn8//QutUs1pLT/fC5ubmQKFQOKANqNmspbuhBwDEZDL5BaX0lDaoZoK62NxZXFzs1DRthV5TrxrKGFue/v5+KZ1Of1kul5P0BtQUUAAgxOPx9wuFwl/0BvWq3O8C6vDw8F1N036gL0G3ZaVLUEdHRxFN036kL1E3DWMHxAEAPzc3dyedTk+XSqUdegu6CRijy5mBPLOzs2oikfhU07RFSmmG3qKuaxkdxuhy/MzMjDeRSHyiadrz2wYyClUBMh9bzRfAu7u7PX6//z1RFB9zHBcBALUZKoRqUMgEgyvHeHt7+353d/cjQRBGWJZ9jBDqaMYKHKpYBAEAXltbawsGg2FFUd7iOO4hIeQhQuiOEzpdOzCSTCaftLS0fEUIGXbiHiBjU5njVCr1sc/nW6wkDcduS1u1HKRUKv2KMR4ABwvbAWKMA+BwYbsasFgs/uMWuEtxd3x8/J3b4C4Ag8Hg83g8/iyfz//n5IRi1eZzla00HgA8oijyDMNwlFJCCGH0axiGQQAAXq+XyLLMeL1eRlEURpZlRpIkhud5oigK297eLvl8Prm1tVVSFEWSJEkWRVESBMGrqupriqLcFQThLsaYu612n6vUip4KMFv5HJssjhooEi5laoZh0NjYWNvw8PC9np6ejkAg8MDv9w+oqnrfxsNqhgNTh2wE1MGYChyyWGA9RYJVFWTM3MhwjMPhsDw9PT0QDocHOjs731RV9Y1rv+cMlb4Oiy3garWW1b2sPMfceZgHmZqa6pycnPywr6/vA47jfPXAWbU0xOCOqE44u2K8Wl9oBUfMa+rq6hIWFhbGBwcHn9pBohogcRWwRiCRTUiACQ6ZYpxY9JAkFAopy8vLM4FAYKyRrgA1GGf1JperLGgEM4cNG4vF3olGo18TQkT9JsRmAdQw66NsGlbn7Ibdd0um2XzOblz6/ZWVlX8JIb8PDQ090gFJDU+e2sBeZ1hBU9NcqvIQzDMFALq+vp7GGP85MjLyBCHE1tPO1LP4eq4FG/hqnlGyeSiwsbHxfygUOu7t7Y00059JUY3ZHFm8k1lT0cGfnJw8c0ojepWFzd6CMpnM3y8AJPEkZ9khO4IAAAAASUVORK5CYII=);background-size:100%}.whatsappme__message__wrap{max-height:calc(100vh - 270px);padding:0 20px 0 22px;overflow:auto}.whatsappme__message__wrap::-webkit-scrollbar{width:5px;background:rgba(0,0,0,0)}.whatsappme__message__wrap::-webkit-scrollbar-thumb{border-radius:3px;background:rgba(0,0,0,0)}.whatsappme__message__wrap:hover::-webkit-scrollbar-thumb{background:rgba(0,0,0,.2)}.whatsappme__message a{text-decoration:underline;color:#2e8c7d}.whatsappme__copy{position:absolute;bottom:9px;left:28px;color:#2e8c7d;font-size:11px;letter-spacing:.2px;line-height:16px;opacity:.4;transition:opacity .25s}.whatsappme__copy:hover{opacity:.8;transition:opacity .5s ease-out .5s}.whatsappme__copy a,.whatsappme__copy a:active,.whatsappme__copy a:hover{color:inherit;text-decoration:none}.whatsappme__copy svg{width:40px;height:10px;vertical-align:inherit}.whatsappme--left{right:auto;left:20px}.whatsappme--left .whatsappme__button{right:auto;left:8px;-ms-flex-direction:row-reverse;-webkit-flex-direction:row-reverse;flex-direction:row-reverse}.whatsappme--left.whatsappme--dialog .whatsappme__button__sendtext{padding:0 24px 0 4px}.whatsappme--left .whatsappme__tooltip{right:auto;left:76px}.whatsappme--left .whatsappme__tooltip::after{content:'\e901';left:-12px;right:auto;text-align:left;text-shadow:-2px 1px 3px rgba(0,0,0,.4)}.whatsappme--left .whatsappme__box{right:auto;left:0}.whatsappme--left .whatsappme__copy{left:auto;right:28px;text-align:right}[dir=rtl] .whatsappme__close{right:auto;left:24px}[dir=rtl] .whatsappme__message:before{left:auto;right:-18px;transform:rotateY(180deg)}[dir=rtl] .whatsappme__button{-ms-flex-direction:row-reverse;-webkit-flex-direction:row-reverse;flex-direction:row-reverse}[dir=rtl] .whatsappme--left .whatsappme__button{-ms-flex-direction:row;-webkit-flex-direction:row;flex-direction:row}@media (max-width:480px),(orientation:landscape) and (max-width:767px){.whatsappme{bottom:6px;right:6px}.whatsappme--left{right:auto;left:6px}.whatsappme__box{width:calc(100vw - 12px);min-height:0}.whatsappme__header{height:55px}.whatsappme__close{top:13px;width:28px;height:28px}.whatsappme__message{padding:16px 0;margin:15px 21px 20px;line-height:24px}.whatsappme__message__wrap{max-height:calc(100vh - 194px);padding:0 14px}}@media (max-width:360px){.whatsappme__copy{width:70px}}@keyframes wame_badge_in{from{opacity:0;transform:translateY(50px)}to{opacity:1;transform:translateY(0)}}@keyframes wame_badge_out{from{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-20px)}}@keyframes wame_plain{45%,5%{stroke-dashoffset:0}100%,50%{stroke-dashoffset:1096.67}}@keyframes wame_chat{50%{stroke-dashoffset:1019.22}55%,95%{stroke-dashoffset:0}}@keyframes wame_image_loop{0%{opacity:0}20%,3%{opacity:1}100%,23%{opacity:0}}@keyframes wame_tootlip{0%{opacity:0;transform:scaleY(0)}1%,20%{opacity:1;transform:scaleY(1)}100%,23%{opacity:0;transform:scaleY(1)}}
public/js/whatsappme.js CHANGED
@@ -39,8 +39,9 @@
39
  var is_mobile = !!navigator.userAgent.match(/Android|iPhone|BlackBerry|IEMobile|Opera Mini/i);
40
  var button_delay = wame_settings.button_delay * 1000;
41
  var chat_delay = wame_settings.message_delay * 1000;
42
- var has_cta = wame_settings.message_text !== '';
43
  var wa_web = wame_settings.whatsapp_web && !is_mobile;
 
44
  var timeoutID, timeoutCTA;
45
 
46
  // Check WebP support
@@ -71,26 +72,27 @@
71
  timeoutCTA = setTimeout(function () { $badge.addClass('whatsappme__badge--in'); }, button_delay + chat_delay);
72
  } else if (is_second_visit) {
73
  // Show dialog
74
- timeoutCTA = setTimeout(show_dialog, button_delay + chat_delay);
75
  }
76
  }
77
  }
78
 
79
  if (has_cta && !is_mobile) {
80
  $('.whatsappme__button', $whatsappme)
81
- .mouseenter(function () { timeoutID = setTimeout(show_dialog, 1500); })
82
  .mouseleave(function () { clearTimeout(timeoutID); });
83
  }
84
 
85
  $('.whatsappme__button', $whatsappme).click(function () {
86
- if (has_cta && !$whatsappme.hasClass('whatsappme--dialog')) {
87
- show_dialog();
88
  } else {
89
  var args = { link: whatsapp_link(wa_web, wame_settings.telephone, wame_settings.message_send) };
90
  var secure_link = new RegExp("^https?:\/\/(wa\.me|(api|web|chat)\.whatsapp\.com|" + location.hostname.replace('.', '\.') + ")\/.*", 'i');
91
 
92
- $whatsappme.removeClass('whatsappme--dialog whatsappme--tooltip');
93
- save_message_viewed();
 
94
  // Trigger custom event (args obj allow edit link by third party scripts)
95
  $(document).trigger('whatsappme:open', [args, wame_settings]);
96
 
@@ -106,19 +108,26 @@
106
  }
107
  });
108
 
109
- $('.whatsappme__close', $whatsappme).click(function () {
110
- $whatsappme.removeClass('whatsappme--dialog whatsappme--tooltip');
111
- save_message_viewed();
112
- });
113
 
114
- function show_dialog() {
115
  $whatsappme.addClass('whatsappme--dialog');
 
116
  clearTimeout(timeoutCTA);
117
 
118
  if (wame_settings.message_badge && $badge.hasClass('whatsappme__badge--in')) {
119
- $badge.removeClass('whatsappme__badge--in').addClass('whatsappme__badge--out');
120
- save_message_viewed();
121
  }
 
 
 
 
 
 
 
 
 
 
122
  }
123
 
124
  function save_message_viewed() {
39
  var is_mobile = !!navigator.userAgent.match(/Android|iPhone|BlackBerry|IEMobile|Opera Mini/i);
40
  var button_delay = wame_settings.button_delay * 1000;
41
  var chat_delay = wame_settings.message_delay * 1000;
42
+ var has_cta = !!wame_settings.message_text;
43
  var wa_web = wame_settings.whatsapp_web && !is_mobile;
44
+ var dialog_visible = false;
45
  var timeoutID, timeoutCTA;
46
 
47
  // Check WebP support
72
  timeoutCTA = setTimeout(function () { $badge.addClass('whatsappme__badge--in'); }, button_delay + chat_delay);
73
  } else if (is_second_visit) {
74
  // Show dialog
75
+ timeoutCTA = setTimeout(dialog_show, button_delay + chat_delay);
76
  }
77
  }
78
  }
79
 
80
  if (has_cta && !is_mobile) {
81
  $('.whatsappme__button', $whatsappme)
82
+ .mouseenter(function () { if (!dialog_visible) timeoutID = setTimeout(dialog_show, 1500); })
83
  .mouseleave(function () { clearTimeout(timeoutID); });
84
  }
85
 
86
  $('.whatsappme__button', $whatsappme).click(function () {
87
+ if (has_cta && !dialog_visible) {
88
+ dialog_show();
89
  } else {
90
  var args = { link: whatsapp_link(wa_web, wame_settings.telephone, wame_settings.message_send) };
91
  var secure_link = new RegExp("^https?:\/\/(wa\.me|(api|web|chat)\.whatsapp\.com|" + location.hostname.replace('.', '\.') + ")\/.*", 'i');
92
 
93
+ if (dialog_visible) {
94
+ dialog_hide();
95
+ }
96
  // Trigger custom event (args obj allow edit link by third party scripts)
97
  $(document).trigger('whatsappme:open', [args, wame_settings]);
98
 
108
  }
109
  });
110
 
111
+ $('.whatsappme__close', $whatsappme).click(dialog_hide);
 
 
 
112
 
113
+ function dialog_show() {
114
  $whatsappme.addClass('whatsappme--dialog');
115
+ dialog_visible = true;
116
  clearTimeout(timeoutCTA);
117
 
118
  if (wame_settings.message_badge && $badge.hasClass('whatsappme__badge--in')) {
119
+ $badge.toggleClass('whatsappme__badge--in whatsappme__badge--out');
 
120
  }
121
+ // Trigger custom event
122
+ $(document).trigger('whatsappme:show');
123
+ }
124
+
125
+ function dialog_hide() {
126
+ $whatsappme.removeClass('whatsappme--dialog whatsappme--tooltip');
127
+ dialog_visible = false;
128
+ save_message_viewed();
129
+ // Trigger custom event
130
+ $(document).trigger('whatsappme:hide');
131
  }
132
 
133
  function save_message_viewed() {
public/js/whatsappme.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){"use strict";function t(e,t,a){return(e?"https://web.whatsapp.com/send":"https://api.whatsapp.com/send")+"?phone="+encodeURIComponent(t)+"&text="+encodeURIComponent(a||"")}e(function(){var a,s=e(".whatsappme"),n=s.find(".whatsappme__badge"),o=s.data("settings");try{localStorage.setItem("test",1),localStorage.removeItem("test"),a=localStorage}catch(e){a={_data:{},setItem:function(e,t){this._data[e]=String(t)},getItem:function(e){return this._data.hasOwnProperty(e)?this._data[e]:null}}}if(void 0===o)try{o=JSON.parse(s.attr("data-settings"))}catch(e){o=void 0}s.length&&o&&o.telephone&&function(){var i,p,m=!!navigator.userAgent.match(/Android|iPhone|BlackBerry|IEMobile|Opera Mini/i),c=1e3*o.button_delay,l=1e3*o.message_delay,h=""!==o.message_text,r=o.whatsapp_web&&!m,d=new Image;d.src="data:image/webp;base64,UklGRi4AAABXRUJQVlA4TCEAAAAvAUAAEB8wAiMwAgSSNtse/cXjxyCCmrYNWPwmHRH9jwMA",d.onload=d.onerror=function(){2!==d.height&&s.addClass("nowebp")};var u=(a.getItem("whatsappme_hashes")||"").split(",").filter(Boolean),g="yes"==a.getItem("whatsappme_visited"),w=h?function(e){for(var t=0,a=1;t<e.length;t++)a=Math.imul(a+e.charCodeAt(t)|0,2654435761);return(a^a>>>17)>>>0}(o.message_text).toString():"no_cta",f=u.indexOf(w)>-1;if(a.setItem("whatsappme_visited","yes"),!o.mobile_only||m){var _="whatsappme--show";f||h&&l&&!o.message_badge&&g||(_+=" whatsappme--tooltip"),setTimeout(function(){s.addClass(_)},c),h&&!f&&l&&(o.message_badge?p=setTimeout(function(){n.addClass("whatsappme__badge--in")},c+l):g&&(p=setTimeout(v,c+l)))}h&&!m&&e(".whatsappme__button",s).mouseenter(function(){i=setTimeout(v,1500)}).mouseleave(function(){clearTimeout(i)});function v(){s.addClass("whatsappme--dialog"),clearTimeout(p),o.message_badge&&n.hasClass("whatsappme__badge--in")&&(n.removeClass("whatsappme__badge--in").addClass("whatsappme__badge--out"),b())}function b(){f||(u.push(w),a.setItem("whatsappme_hashes",u.join(",")),f=!0)}e(".whatsappme__button",s).click(function(){if(h&&!s.hasClass("whatsappme--dialog"))v();else{var a={link:t(r,o.telephone,o.message_send)},n=new RegExp("^https?://(wa.me|(api|web|chat).whatsapp.com|"+location.hostname.replace(".",".")+")/.*","i");s.removeClass("whatsappme--dialog whatsappme--tooltip"),b(),e(document).trigger("whatsappme:open",[a,o]),n.test(a.link)?(!function(e){"object"==typeof dataLayer&&dataLayer.push({event:"WhatsAppMe",eventAction:"click",eventLabel:e});if("function"==typeof gtag)gtag("event","click",{event_category:"WhatsAppMe",event_label:e,transport_type:"beacon"});else if("function"==typeof ga&&"function"==typeof ga.getAll){ga("set","transport","beacon");var t=ga.getAll();t.forEach(function(t){t.send("event","WhatsAppMe","click",e)})}"function"==typeof fbq&&fbq("trackCustom","WhatsAppMe",{eventAction:"click",eventLabel:e})}(a.link),window.open(a.link,"whatsappme")):console.error("WAme: the link doesn't seem safe, it must point to the current domain or whatsapp.com")}}),e(".whatsappme__close",s).click(function(){s.removeClass("whatsappme--dialog whatsappme--tooltip"),b()})}()}),Math.imul=Math.imul||function(e,t){var a=65535&e,s=65535&t;return a*s+((e>>>16&65535)*s+a*(t>>>16&65535)<<16>>>0)|0}}(jQuery);
1
+ !function(e){"use strict";function t(e,t,a){return(e?"https://web.whatsapp.com/send":"https://api.whatsapp.com/send")+"?phone="+encodeURIComponent(t)+"&text="+encodeURIComponent(a||"")}e(function(){var a,n=e(".whatsappme"),s=n.find(".whatsappme__badge"),o=n.data("settings");try{localStorage.setItem("test",1),localStorage.removeItem("test"),a=localStorage}catch(e){a={_data:{},setItem:function(e,t){this._data[e]=String(t)},getItem:function(e){return this._data.hasOwnProperty(e)?this._data[e]:null}}}if(void 0===o)try{o=JSON.parse(n.attr("data-settings"))}catch(e){o=void 0}n.length&&o&&o.telephone&&function(){var i,p,c=!!navigator.userAgent.match(/Android|iPhone|BlackBerry|IEMobile|Opera Mini/i),m=1e3*o.button_delay,r=1e3*o.message_delay,h=!!o.message_text,l=o.whatsapp_web&&!c,g=!1,u=new Image;u.src="data:image/webp;base64,UklGRi4AAABXRUJQVlA4TCEAAAAvAUAAEB8wAiMwAgSSNtse/cXjxyCCmrYNWPwmHRH9jwMA",u.onload=u.onerror=function(){2!==u.height&&n.addClass("nowebp")};var d=(a.getItem("whatsappme_hashes")||"").split(",").filter(Boolean),w="yes"==a.getItem("whatsappme_visited"),f=h?function(e){for(var t=0,a=1;t<e.length;t++)a=Math.imul(a+e.charCodeAt(t)|0,2654435761);return(a^a>>>17)>>>0}(o.message_text).toString():"no_cta",_=d.indexOf(f)>-1;if(a.setItem("whatsappme_visited","yes"),!o.mobile_only||c){var b="whatsappme--show";_||h&&r&&!o.message_badge&&w||(b+=" whatsappme--tooltip"),setTimeout(function(){n.addClass(b)},m),h&&!_&&r&&(o.message_badge?p=setTimeout(function(){s.addClass("whatsappme__badge--in")},m+r):w&&(p=setTimeout(v,m+r)))}h&&!c&&e(".whatsappme__button",n).mouseenter(function(){g||(i=setTimeout(v,1500))}).mouseleave(function(){clearTimeout(i)});function v(){n.addClass("whatsappme--dialog"),g=!0,clearTimeout(p),o.message_badge&&s.hasClass("whatsappme__badge--in")&&s.toggleClass("whatsappme__badge--in whatsappme__badge--out"),e(document).trigger("whatsappme:show")}function A(){n.removeClass("whatsappme--dialog whatsappme--tooltip"),g=!1,_||(d.push(f),a.setItem("whatsappme_hashes",d.join(",")),_=!0),e(document).trigger("whatsappme:hide")}e(".whatsappme__button",n).click(function(){if(h&&!g)v();else{var a={link:t(l,o.telephone,o.message_send)},n=new RegExp("^https?://(wa.me|(api|web|chat).whatsapp.com|"+location.hostname.replace(".",".")+")/.*","i");g&&A(),e(document).trigger("whatsappme:open",[a,o]),n.test(a.link)?(!function(e){"object"==typeof dataLayer&&dataLayer.push({event:"WhatsAppMe",eventAction:"click",eventLabel:e});if("function"==typeof gtag)gtag("event","click",{event_category:"WhatsAppMe",event_label:e,transport_type:"beacon"});else if("function"==typeof ga&&"function"==typeof ga.getAll){ga("set","transport","beacon");var t=ga.getAll();t.forEach(function(t){t.send("event","WhatsAppMe","click",e)})}"function"==typeof fbq&&fbq("trackCustom","WhatsAppMe",{eventAction:"click",eventLabel:e})}(a.link),window.open(a.link,"whatsappme")):console.error("WAme: the link doesn't seem safe, it must point to the current domain or whatsapp.com")}}),e(".whatsappme__close",n).click(A)}()}),Math.imul=Math.imul||function(e,t){var a=65535&e,n=65535&t;return a*n+((e>>>16&65535)*n+a*(t>>>16&65535)<<16>>>0)|0}}(jQuery);
whatsappme.php CHANGED
@@ -9,7 +9,7 @@
9
  * Plugin Name: WAme chat
10
  * Plugin URI: https://wame.chat
11
  * Description: Connect a WordPress chat with WhatsApp. The best solution for marketing and support. Stop losing customers and increase your sales.
12
- * Version: 3.1.1
13
  * Author: Creame
14
  * Author URI: https://crea.me
15
  * License: GPL-2.0+
@@ -27,7 +27,7 @@ if ( ! defined( 'WPINC' ) ) {
27
  * Currently plugin version.
28
  * Start at version 1.0.0 and use SemVer - https://semver.org
29
  */
30
- define( 'WHATSAPPME_VERSION', '3.1.1' );
31
 
32
  /**
33
  * The core plugin class that is used to define internationalization,
9
  * Plugin Name: WAme chat
10
  * Plugin URI: https://wame.chat
11
  * Description: Connect a WordPress chat with WhatsApp. The best solution for marketing and support. Stop losing customers and increase your sales.
12
+ * Version: 3.1.2
13
  * Author: Creame
14
  * Author URI: https://crea.me
15
  * License: GPL-2.0+
27
  * Currently plugin version.
28
  * Start at version 1.0.0 and use SemVer - https://semver.org
29
  */
30
+ define( 'WHATSAPPME_VERSION', '3.1.2' );
31
 
32
  /**
33
  * The core plugin class that is used to define internationalization,