WhatsApp me - Version 1.2.0

Version Description

  • Added International Telephone Input for enhanced phone input
  • Phone number is cleared to generate correct WhatsApp links
Download this release

Release Info

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

Code changes from version 1.1.0 to 1.2.0

README.txt CHANGED
@@ -1,10 +1,11 @@
1
  === WhatsApp me ===
2
  Contributors: creapuntome, pacotole, davidlillo
 
3
  Tags: whatsapp, button, chat, support, contact
4
  Requires at least: 3.0.1
5
- Tested up to: 4.9.2
6
  Requires PHP: 5.3
7
- Stable tag: 1.1.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -43,6 +44,10 @@ Options:
43
 
44
  == Changelog ==
45
 
 
 
 
 
46
  = 1.1.0 =
47
  * Added posts/pages option to override CTA or hide button
48
  * Don't enqueue assets if not show button
1
  === WhatsApp me ===
2
  Contributors: creapuntome, pacotole, davidlillo
3
+ Donate link: https://www.paypal.me/creapuntome/
4
  Tags: whatsapp, button, chat, support, contact
5
  Requires at least: 3.0.1
6
+ Tested up to: 4.9.4
7
  Requires PHP: 5.3
8
+ Stable tag: 1.2.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
44
 
45
  == Changelog ==
46
 
47
+ = 1.2.0 =
48
+ * Added International Telephone Input for enhanced phone input
49
+ * Phone number is cleared to generate correct WhatsApp links
50
+
51
  = 1.1.0 =
52
  * Added posts/pages option to override CTA or hide button
53
  * Don't enqueue assets if not show button
admin/class-whatsappme-admin.php CHANGED
@@ -40,6 +40,14 @@ class WhatsAppMe_Admin {
40
  */
41
  private $settings;
42
 
 
 
 
 
 
 
 
 
43
 
44
  /**
45
  * Initialize the class and set its properties.
@@ -52,6 +60,7 @@ class WhatsAppMe_Admin {
52
 
53
  $this->plugin_name = $plugin_name;
54
  $this->version = $version;
 
55
  $this->get_settings();
56
 
57
  }
@@ -81,8 +90,36 @@ class WhatsAppMe_Admin {
81
 
82
  }
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  /**
85
  * Initialize the settings for wordpress admin
 
86
  *
87
  * @since 1.0.0
88
  * @access public
@@ -103,6 +140,8 @@ class WhatsAppMe_Admin {
103
  foreach ( $this->settings as $key => $value ) {
104
  add_settings_field( 'whatsappme_' . $key, $field_names[ $key ], array( $this, 'field_' . $key ), 'whatsappme', 'whatsappme_section' );
105
  }
 
 
106
  }
107
 
108
  /**
@@ -142,7 +181,8 @@ class WhatsAppMe_Admin {
142
  * @return void
143
  */
144
  public function field_telephone() {
145
- echo '<input name="whatsappme[telephone]" value="' . $this->settings['telephone'] . '" class="regular-text" type="text">' .
 
146
  '<p class="description">' . __( "Contact phone number. <strong>The button will not be shown if it's empty.</strong>", 'creame-whatsapp-me' ) . '</p>';
147
  }
148
 
40
  */
41
  private $settings;
42
 
43
+ /**
44
+ * Use International Telephone Input library (https://intl-tel-input.com/)
45
+ *
46
+ * @since 1.2.0
47
+ * @access private
48
+ * @var boolean $enhanced_phone Use enhanced phone input.
49
+ */
50
+ private $enhanced_phone;
51
 
52
  /**
53
  * Initialize the class and set its properties.
60
 
61
  $this->plugin_name = $plugin_name;
62
  $this->version = $version;
63
+ $this->enhanced_phone = true;
64
  $this->get_settings();
65
 
66
  }
90
 
91
  }
92
 
93
+ /**
94
+ * Register the stylesheets for the admin area.
95
+ *
96
+ * @since 1.2.0
97
+ */
98
+ public function enqueue_styles($hook) {
99
+
100
+ if ( 'settings_page_whatsappme' == $hook && $this->enhanced_phone ) {
101
+ wp_enqueue_style( 'intl-tel-input', 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/12.1.9/css/intlTelInput.css', array(), null, 'all' );
102
+ }
103
+
104
+ }
105
+
106
+ /**
107
+ * Register the JavaScript for the admin area.
108
+ *
109
+ * @since 1.2.0
110
+ */
111
+ public function enqueue_scripts($hook) {
112
+
113
+ if ( 'settings_page_whatsappme' == $hook && $this->enhanced_phone ) {
114
+ wp_enqueue_script( 'intl-tel-input', 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/12.1.9/js/intlTelInput.min.js', array( 'jquery' ), null, true );
115
+ wp_enqueue_script( 'whatsappme-admin', plugin_dir_url( __FILE__ ) . 'js/whatsappme.js', array( 'intl-tel-input' ), $this->version, true );
116
+ }
117
+
118
+ }
119
+
120
  /**
121
  * Initialize the settings for wordpress admin
122
+ * From v1.2.0 also set filter to disable enhanced phone input
123
  *
124
  * @since 1.0.0
125
  * @access public
140
  foreach ( $this->settings as $key => $value ) {
141
  add_settings_field( 'whatsappme_' . $key, $field_names[ $key ], array( $this, 'field_' . $key ), 'whatsappme', 'whatsappme_section' );
142
  }
143
+
144
+ $this->enhanced_phone = apply_filters( 'whatsappme_enhanced_phone', $this->enhanced_phone );
145
  }
146
 
147
  /**
181
  * @return void
182
  */
183
  public function field_telephone() {
184
+ $name = $this->enhanced_phone ? '' : 'whatsappme[telephone]';
185
+ echo '<input id="whatsappme_phone" name="' . $name . '" value="' . $this->settings['telephone'] . '" type="text" style="width:15em;height:28px;line-height:1;">' .
186
  '<p class="description">' . __( "Contact phone number. <strong>The button will not be shown if it's empty.</strong>", 'creame-whatsapp-me' ) . '</p>';
187
  }
188
 
admin/js/whatsappme.js ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function ($) {
2
+ 'use strict';
3
+
4
+ $(function () {
5
+ var country_request = JSON.parse(localStorage.whatsappme_country_code || '{}');
6
+ var country_code = (country_request.code && country_request.date == new Date().toDateString()) ? country_request.code : false;
7
+ var $phone = $("#whatsappme_phone");
8
+
9
+ $phone.intlTelInput({
10
+ hiddenInput: "whatsappme[telephone]",
11
+ initialCountry: "auto",
12
+ preferredCountries: [country_code || ''],
13
+ geoIpLookup: function (callback) {
14
+ if (country_code) {
15
+ callback(country_code);
16
+ } else {
17
+ $.getJSON('https://ipinfo.io').always(function (resp) {
18
+ var countryCode = (resp && resp.country) ? resp.country : "";
19
+ localStorage.whatsappme_country_code = JSON.stringify({ code: countryCode, date: new Date().toDateString() });
20
+ callback(countryCode);
21
+ });
22
+ }
23
+ },
24
+ utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/12.1.9/js/utils.js"
25
+ });
26
+
27
+ $phone.on("keyup change", function () {
28
+ $phone.css('border-color', '');
29
+ });
30
+ $phone.on("blur", function () {
31
+ $phone.css('border-color', $.trim($phone.val()) && !$phone.intlTelInput("isValidNumber") ? '#ff0000' : '');
32
+ });
33
+
34
+ });
35
+ })(jQuery);
includes/class-whatsappme.php CHANGED
@@ -123,10 +123,12 @@ class WhatsAppMe {
123
 
124
  $plugin_admin = new WhatsAppMe_Admin( $this->get_plugin_name(), $this->get_version() );
125
 
126
- $this->loader->add_action( 'admin_init', $plugin_admin, 'settings_init' );
127
- $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_menu' );
128
- $this->loader->add_action( 'add_meta_boxes', $plugin_admin, 'add_meta_boxes' );
129
- $this->loader->add_action( 'save_post', $plugin_admin, 'save_post' );
 
 
130
 
131
  $this->loader->add_filter( "plugin_action_links_creame-whatsapp-me/{$this->plugin_name}.php", $plugin_admin, 'settings_link' );
132
 
@@ -143,10 +145,10 @@ class WhatsAppMe {
143
 
144
  $plugin_public = new WhatsAppMe_Public( $this->get_plugin_name(), $this->get_version() );
145
 
146
- $this->loader->add_action( 'wp', $plugin_public, 'get_settings' );
147
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
148
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
149
- $this->loader->add_action( 'wp_footer', $plugin_public, 'footer_html' );
150
 
151
  }
152
 
123
 
124
  $plugin_admin = new WhatsAppMe_Admin( $this->get_plugin_name(), $this->get_version() );
125
 
126
+ $this->loader->add_action( 'admin_init', $plugin_admin, 'settings_init' );
127
+ $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
128
+ $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
129
+ $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_menu' );
130
+ $this->loader->add_action( 'add_meta_boxes', $plugin_admin, 'add_meta_boxes' );
131
+ $this->loader->add_action( 'save_post', $plugin_admin, 'save_post' );
132
 
133
  $this->loader->add_filter( "plugin_action_links_creame-whatsapp-me/{$this->plugin_name}.php", $plugin_admin, 'settings_link' );
134
 
145
 
146
  $plugin_public = new WhatsAppMe_Public( $this->get_plugin_name(), $this->get_version() );
147
 
148
+ $this->loader->add_action( 'wp', $plugin_public, 'get_settings' );
149
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
150
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
151
+ $this->loader->add_action( 'wp_footer', $plugin_public, 'footer_html' );
152
 
153
  }
154
 
languages/creame-whatsapp-me-es_ES.mo DELETED
Binary file
languages/creame-whatsapp-me-es_ES.po DELETED
@@ -1,115 +0,0 @@
1
- # WordPress Blank Pot
2
- # Copyright (C) 2014 ...
3
- # This file is distributed under the GNU General Public License v2 or later.
4
- msgid ""
5
- msgstr ""
6
- "Project-Id-Version: WhatsApp me\n"
7
- "Report-Msgid-Bugs-To: Translator Name <translations@example.com>\n"
8
- "POT-Creation-Date: 2018-02-20 12:21+0100\n"
9
- "PO-Revision-Date: \n"
10
- "Last-Translator: Pacotole <pacotole@crea.me>\n"
11
- "Language-Team: Creame <hola@crea.me>\n"
12
- "Language: es_ES\n"
13
- "MIME-Version: 1.0\n"
14
- "Content-Type: text/plain; charset=UTF-8\n"
15
- "Content-Transfer-Encoding: 8bit\n"
16
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
17
- "X-Textdomain-Support: yesX-Generator: Poedit 1.6.4\n"
18
- "X-Poedit-SourceCharset: UTF-8\n"
19
- "X-Poedit-KeywordsList: __;_e;esc_html_e;esc_html_x:1,2c;esc_html__;"
20
- "esc_attr_e;esc_attr_x:1,2c;esc_attr__;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;"
21
- "_x:1,2c;_n:1,2;_n_noop:1,2;__ngettext:1,2;__ngettext_noop:1,2;_c,_nc:4c,1,2\n"
22
- "X-Poedit-Basepath: ..\n"
23
- "X-Generator: Poedit 1.8.7.1\n"
24
- "X-Poedit-SearchPath-0: .\n"
25
-
26
- #: admin/class-whatsappme-admin.php:97
27
- msgid "Telephone"
28
- msgstr "Teléfono"
29
-
30
- #: admin/class-whatsappme-admin.php:98 admin/class-whatsappme-admin.php:178
31
- msgid "Mobile only"
32
- msgstr "Solo Móvil"
33
-
34
- #: admin/class-whatsappme-admin.php:99 admin/class-whatsappme-admin.php:280
35
- msgid "Call to action"
36
- msgstr "Llamada a la acción"
37
-
38
- #: admin/class-whatsappme-admin.php:100
39
- msgid "Delay"
40
- msgstr "Retardo"
41
-
42
- #: admin/class-whatsappme-admin.php:123
43
- msgid "Settings saved"
44
- msgstr "Ajustes guardados"
45
-
46
- #: admin/class-whatsappme-admin.php:135
47
- msgid ""
48
- "From here you can configure the behavior of the WhatsApp button on your site."
49
- msgstr ""
50
- "Desde aquí puedes configurar el comportamiento del botón de WhatsApp en tu "
51
- "sitio web."
52
-
53
- #: admin/class-whatsappme-admin.php:146
54
- msgid ""
55
- "Contact phone number. <strong>The button will not be shown if it's empty.</"
56
- "strong>"
57
- msgstr ""
58
- "Número de teléfono de contacto. <strong>El botón no se mostrará si está "
59
- "vacío.</strong>"
60
-
61
- #: admin/class-whatsappme-admin.php:157
62
- msgid ""
63
- "Optional text to invite the user to use the contact via WhatsApp. "
64
- "<strong>Leave empty to disable.</strong>"
65
- msgstr ""
66
- "Texto opcional para invitar al usuario a usar el contacto por WhatsApp. "
67
- "<strong>Dejar vacío para desactivarlo.</strong>"
68
-
69
- #: admin/class-whatsappme-admin.php:167
70
- msgid "milliseconds"
71
- msgstr "milisegundos"
72
-
73
- #: admin/class-whatsappme-admin.php:168
74
- msgid ""
75
- "The <strong>Call to action</strong> will only be displayed once when the "
76
- "user exceeds the estimated delay on a page. It will also be displayed when "
77
- "the user stops the cursor over the WhatsApp button."
78
- msgstr ""
79
- "La <strong>llamada a la acción</strong> sólo se mostrará una única vez "
80
- "cuando el usuario supere el retardo estimado en una página. También se "
81
- "mostrará cuando el usuario detenga el cursor sobre el botón de WhastApp."
82
-
83
- #: admin/class-whatsappme-admin.php:180
84
- msgid "Only display the button on mobile devices"
85
- msgstr "Solo mostrar el botón en móviles"
86
-
87
- #: admin/class-whatsappme-admin.php:205
88
- msgid "Settings"
89
- msgstr "Ajustes"
90
-
91
- #. Name of the plugin
92
- #: admin/class-whatsappme-admin.php:253
93
- msgid "WhatsApp me"
94
- msgstr "WhatsApp me"
95
-
96
- #: admin/class-whatsappme-admin.php:285
97
- #, php-format
98
- msgid "Hide on this %s"
99
- msgstr "Ocultar en este %s"
100
-
101
- #. Description of the theme
102
- msgid "Add support to your clients directly with WhatsApp."
103
- msgstr "Da soporte a tus clientes directamente con WhatsApp."
104
-
105
- #. URI of the plugin
106
- msgid "https://github.com/creame/whatsappme"
107
- msgstr "https://github.com/creame/whatsappme"
108
-
109
- #. Author of the plugin
110
- msgid "Creame"
111
- msgstr "Creame"
112
-
113
- #. Author URI of the plugin
114
- msgid "https://crea.me"
115
- msgstr "https://crea.me"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
public/class-whatsappme-public.php CHANGED
@@ -81,6 +81,7 @@ class WhatsAppMe_Public {
81
  $post_settings = get_post_meta( $post->ID, '_whatsappme', true ) ?: array();
82
 
83
  // Prepare settings
 
84
  $settings['show'] = $settings['telephone'] != '' && ! isset( $post_settings['hide'] );
85
  $settings['mobile_only'] = $settings['mobile_only'] == 'yes';
86
  if ( isset( $post_settings['message_text'] ) ) {
@@ -120,7 +121,7 @@ class WhatsAppMe_Public {
120
  public function enqueue_scripts() {
121
 
122
  if ( $this->settings['show'] ) {
123
- wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/whatsappme.js', array( 'jquery' ), $this->version, false );
124
  }
125
 
126
  }
81
  $post_settings = get_post_meta( $post->ID, '_whatsappme', true ) ?: array();
82
 
83
  // Prepare settings
84
+ $settings['telephone'] = preg_replace( '/^0+|\D/', '', $settings['telephone'] );
85
  $settings['show'] = $settings['telephone'] != '' && ! isset( $post_settings['hide'] );
86
  $settings['mobile_only'] = $settings['mobile_only'] == 'yes';
87
  if ( isset( $post_settings['message_text'] ) ) {
121
  public function enqueue_scripts() {
122
 
123
  if ( $this->settings['show'] ) {
124
+ wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/whatsappme.js', array( 'jquery' ), $this->version, true );
125
  }
126
 
127
  }
whatsappme.php CHANGED
@@ -7,9 +7,9 @@
7
  *
8
  * @wordpress-plugin
9
  * Plugin Name: WhatsApp me
10
- * Plugin URI: https://github.com/creame/whatsappme
11
  * Description: Add support to your clients directly with WhatsApp.
12
- * Version: 1.1.0
13
  * Author: Creame
14
  * Author URI: https://crea.me
15
  * License: GPL-2.0+
@@ -27,7 +27,7 @@ if ( ! defined( 'WPINC' ) ) {
27
  * Currently plugin version.
28
  * Start at version 1.0.0 and use SemVer - https://semver.org
29
  */
30
- define( 'WHATSAPPME_VERSION', '1.1.0' );
31
 
32
  /**
33
  * The core plugin class that is used to define internationalization,
7
  *
8
  * @wordpress-plugin
9
  * Plugin Name: WhatsApp me
10
+ * Plugin URI: https://crea.me/productos/whatsapp-me/
11
  * Description: Add support to your clients directly with WhatsApp.
12
+ * Version: 1.2.0
13
  * Author: Creame
14
  * Author URI: https://crea.me
15
  * License: GPL-2.0+
27
  * Currently plugin version.
28
  * Start at version 1.0.0 and use SemVer - https://semver.org
29
  */
30
+ define( 'WHATSAPPME_VERSION', '1.2.0' );
31
 
32
  /**
33
  * The core plugin class that is used to define internationalization,