From 3c34ae6b2d45f63d47bdf0e694d423eaa5c765a9 Mon Sep 17 00:00:00 2001 From: Paco Toledo Date: Tue, 20 Feb 2018 13:32:16 +0100 Subject: [PATCH] Updated to v1.1.0 --- README.md | 1 + README.txt | 59 +++++---- admin/class-whatsappme-admin.php | 119 +++++++++++++++--- includes/class-whatsappme-i18n.php | 2 +- includes/class-whatsappme.php | 5 +- languages/creame-whatsapp-me-es_ES.mo | Bin 0 -> 2736 bytes ...e-es_ES.po => creame-whatsapp-me-es_ES.po} | 56 ++++++--- languages/creame-whatsapp-me.pot | 104 +++++++++++++++ languages/whatsappme-es_ES.mo | Bin 2444 -> 0 bytes languages/whatsappme.pot | 89 ------------- public/class-whatsappme-public.php | 61 ++++++--- public/js/whatsappme.js | 2 +- whatsappme.php | 10 +- 13 files changed, 337 insertions(+), 171 deletions(-) create mode 100644 languages/creame-whatsapp-me-es_ES.mo rename languages/{whatsappme-es_ES.po => creame-whatsapp-me-es_ES.po} (67%) create mode 100644 languages/creame-whatsapp-me.pot delete mode 100644 languages/whatsappme-es_ES.mo delete mode 100644 languages/whatsappme.pot diff --git a/README.md b/README.md index 0a22886..50e1373 100644 --- a/README.md +++ b/README.md @@ -32,4 +32,5 @@ Si dispones de Google Analytics se dispara un evento cuando el usuario lanza Wha ## Changelog +- **v 1.1.0** Added Custom CTA or hide on every post/page. - **v 1.0.0** First version diff --git a/README.txt b/README.txt index 978f14d..6cde6c0 100644 --- a/README.txt +++ b/README.txt @@ -1,10 +1,10 @@ -=== WhatsApp Me === -Contributors: creapuntome, pacotole +=== WhatsApp me === +Contributors: creapuntome, pacotole, davidlillo Tags: whatsapp, button, chat, support, contact Requires at least: 3.0.1 Tested up to: 4.9.2 Requires PHP: 5.3 -Stable tag: 1.0.0 +Stable tag: 1.1.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -12,35 +12,50 @@ Add support to your visitors directly with WhatsApp. == Description == -## EN -Include a direct link to your WhatsApp profile on the web to support your users. +### The perfect plugin to engage and retain customers. -Options: - - **Phone number** - - **Only on mobile**, on the desktop you will open WhatsApp Web (if available). - - **Call to Action**, write a message to encourage users to contact you through WhatsApp - - **Delay**, you can define a timeout to show the call-to-action message +#### Communication with your customers can be very easy -If you have Google Analytics, an event is triggered when the user launches WhatsApp. +With **WhatsApp me** you will get the visitors of your website to contact you through WhatsApp with a single click. -## ES -Incluye en la web un enlace directo a tu perfil de WhastApp para dar soporte a tus usuarios. +#### Why WhatsApp? +WhatsApp is used in more than 100 countries and supports more than 50 languages. Recent surveys say that 96% of users prefer to use a *messaging app* before calling by phone. If none of this has convinced you, think one thing, your grandmother knows how to use WhatsApp. Do not lose more customers and sales. Try **WhatsApp me**. -Opciones: +Options: +1. Phone: Enter the phone number. +2. Mobile only: Select if you want the button to be visible only on mobile devices. WhatsApp Web/App will open on the desktop (if available). +3. Call to action: Write a message to encourage users to contact you through WhatsApp. +4. Delay: You can define a timeout to display the call-to-action message. +5. If you have Google Analytics, an event is triggered when the user launches WhatsApp. +6. Can override call to action or hide button on every post, page or custom post. - - **Teléfono** - - **Solo en móviles**, en el escritorio se abrirá WhastApp Web (si está disponible) - - **Llamada a la acción**, escribe un mensaje para animar a los usuarios a contactar a través de WhatsApp - - **Retardo**, puedes definir un tiempo de espera para mostrar el mensaje de llamada a la acción +== Installation == -Si dispones de Google Analytics se dispara un evento cuando el usuario lanza WhatsApp. +1. Upload the entire `creame-whatsapp-me` folder to the `/wp-content/plugins/` directory. +1. Activate the plugin through the 'Plugins' menu in WordPress. -== Installation == +== Screenshots == -1. Upload the entire `whatsappme` folder to the `/wp-content/plugins/` directory. -2. Activate the plugin through the 'Plugins' menu in WordPress. +1. WhatsApp me settings. +2. Button on desktop. +3. Call to action on desktop. +4. Button and call to action on mobile. == Changelog == += 1.1.0 = +* Added posts/pages option to override CTA or hide button +* Don't enqueue assets if not show button +* Added filters for developers + += 1.0.3 = +* Readme texts + += 1.0.2 = +* Fix plugin version + += 1.0.1 = +* Fix text domain + = 1.0.0 = * First version diff --git a/admin/class-whatsappme-admin.php b/admin/class-whatsappme-admin.php index aacf78d..5dc7231 100644 --- a/admin/class-whatsappme-admin.php +++ b/admin/class-whatsappme-admin.php @@ -94,10 +94,10 @@ public function settings_init(){ add_settings_section( 'whatsappme_section', null, array( $this, 'section_text' ), 'whatsappme' ); $field_names = array( - 'telephone' => __( 'Telephone', 'whatsappme' ), - 'mobile_only' => __( 'Only mobile', 'whatsappme' ), - 'message_text' => __( 'Call to action', 'whatsappme' ), - 'message_delay' => __( 'Delay', 'whatsappme' ), + 'telephone' => __( 'Telephone', 'creame-whatsapp-me' ), + 'mobile_only' => __( 'Mobile only', 'creame-whatsapp-me' ), + 'message_text' => __( 'Call to action', 'creame-whatsapp-me' ), + 'message_delay' => __( 'Delay', 'creame-whatsapp-me' ), ); foreach ( $this->settings as $key => $value ) { @@ -106,7 +106,7 @@ public function settings_init(){ } /** - * Validate settings, claen and set defaults before save + * Validate settings, clean and set defaults before save * * @since 1.0.0 * @return array @@ -120,7 +120,7 @@ public function settings_validate($input) { $input['message_text'] = trim($input['message_text']); $input['message_delay'] = intval($input['message_delay']); - add_settings_error( 'whatsappme', 'settings_updated', __( 'Settings saved', 'whatsappme' ), 'updated' ); + add_settings_error( 'whatsappme', 'settings_updated', __( 'Settings saved', 'creame-whatsapp-me' ), 'updated' ); return $input; } @@ -132,7 +132,7 @@ public function settings_validate($input) { * @return void */ public function section_text() { - echo '

' . __( 'From here you can configure the behavior of the WhatsApp button on your site.', 'whatsappme' ) . '

'; + echo '

' . __( 'From here you can configure the behavior of the WhatsApp button on your site.', 'creame-whatsapp-me' ) . '

'; } /** @@ -143,7 +143,7 @@ public function section_text() { */ public function field_telephone() { echo '' . - '

' . __( "Contact phone number. The button will not be shown if it's empty.", 'whatsappme' ) . '

'; + '

' . __( "Contact phone number. The button will not be shown if it's empty.", 'creame-whatsapp-me' ) . '

'; } /** @@ -154,7 +154,7 @@ public function field_telephone() { */ public function field_message_text() { echo '' . - '

' . __( 'Optional text to invite the user to use the contact via WhatsApp. Leave empty to disable.', 'whatsappme' ) . '

'; + '

' . __( 'Optional text to invite the user to use the contact via WhatsApp. Leave empty to disable.', 'creame-whatsapp-me' ) . '

'; } /** @@ -164,9 +164,8 @@ public function field_message_text() { * @return void */ public function field_message_delay() { - echo ' ' . __( 'milliseconds', 'whatsappme' ) . - '

' . __( 'The Call to action will only be displayed once when the user exceeds the estimated delay on a page. ' . - 'It will also be displayed when the user stops the cursor over the WhatsApp button.', 'whatsappme' ) . '

'; + echo ' ' . __( 'milliseconds', 'creame-whatsapp-me' ) . + '

' . __( 'The Call to action will only be displayed once when the user exceeds the estimated delay on a page. It will also be displayed when the user stops the cursor over the WhatsApp button.', 'creame-whatsapp-me' ) . '

'; } /** @@ -176,9 +175,9 @@ public function field_message_delay() { * @return void */ public function field_mobile_only() { - echo '
Solo móvil' . + echo '
' . __( 'Mobile only', 'creame-whatsapp-me' ) . '' . '
'; + __('Only display the button on mobile devices', 'creame-whatsapp-me' ) . '
'; } /** @@ -190,7 +189,7 @@ public function field_mobile_only() { */ public function add_menu() { - add_options_page('WhatsApp Me', 'WhatsApp Me', 'manage_options', 'whatsappme', array( $this, 'options_page' )); + add_options_page('WhatsApp me', 'WhatsApp me', 'manage_options', 'whatsappme', array( $this, 'options_page' )); } @@ -203,7 +202,7 @@ public function add_menu() { */ public function settings_link( $links ) { - $settings_link = '' . __( 'Settings', 'whatsappme' ) . ''; + $settings_link = '' . __( 'Settings', 'creame-whatsapp-me' ) . ''; array_unshift( $links, $settings_link ); return $links; @@ -219,7 +218,7 @@ public function settings_link( $links ) { function options_page() { ?>
-

WhatsApp Me

+

WhatsApp me

true ), 'names' ) ); + + // Add/remove posts types for "WhatsApp me" meta box + $post_types = apply_filters( 'whatsappme_post_types_meta_box', array_merge( $builtin_post_types, $custom_post_types ) ); + + foreach ( $post_types as $post_type ) { + add_meta_box( + 'whatsappme', + __( 'WhatsApp me', 'creame-whatsapp-me' ), + array( $this, 'add_meta_box' ), + $post_type, + 'side', + 'default' + ); + } + } + + /** + * Generate Meta Box html + * + * @since 1.1.0 + * @access public + * @return void + */ + public function add_meta_box( $post ) { + + $metadata = get_post_meta( $post->ID, '_whatsappme', true ) ?: array(); + $metadata = array_merge( array( + 'message_text' => '', + 'hide' => false + ), $metadata ); + + $post_type = get_post_type_object( get_post_type( $post->ID ) ); + $post_type_name = mb_strtolower( $post_type->labels->singular_name ); + + wp_nonce_field( 'whatsappme_data', 'whatsappme_nonce' ); + ?> +

+
+ +

+

+ > + +

+ trim( $_POST['whatsappme_message'] ), + 'hide' => isset( $_POST['whatsappme_hide'] ) ? 1 : 0, + ) ); + + if ( count( $metadata ) ) { + update_post_meta( $post_id, '_whatsappme', $metadata ); + } else { + delete_post_meta( $post_id, '_whatsappme' ); + } + } } diff --git a/includes/class-whatsappme-i18n.php b/includes/class-whatsappme-i18n.php index bc5220c..6888da9 100644 --- a/includes/class-whatsappme-i18n.php +++ b/includes/class-whatsappme-i18n.php @@ -22,7 +22,7 @@ class WhatsAppMe_i18n { public function load_plugin_textdomain() { load_plugin_textdomain( - 'whatsappme', + 'creame-whatsapp-me', false, dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' ); diff --git a/includes/class-whatsappme.php b/includes/class-whatsappme.php index 0dc9ea6..5c120e3 100644 --- a/includes/class-whatsappme.php +++ b/includes/class-whatsappme.php @@ -125,8 +125,10 @@ private function define_admin_hooks() { $this->loader->add_action( 'admin_init', $plugin_admin, 'settings_init' ); $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_menu' ); + $this->loader->add_action( 'add_meta_boxes', $plugin_admin, 'add_meta_boxes' ); + $this->loader->add_action( 'save_post', $plugin_admin, 'save_post' ); - $this->loader->add_filter( "plugin_action_links_{$this->plugin_name}/{$this->plugin_name}.php", $plugin_admin, 'settings_link' ); + $this->loader->add_filter( "plugin_action_links_creame-whatsapp-me/{$this->plugin_name}.php", $plugin_admin, 'settings_link' ); } @@ -141,6 +143,7 @@ private function define_public_hooks() { $plugin_public = new WhatsAppMe_Public( $this->get_plugin_name(), $this->get_version() ); + $this->loader->add_action( 'wp', $plugin_public, 'get_settings' ); $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); $this->loader->add_action( 'wp_footer', $plugin_public, 'footer_html' ); diff --git a/languages/creame-whatsapp-me-es_ES.mo b/languages/creame-whatsapp-me-es_ES.mo new file mode 100644 index 0000000000000000000000000000000000000000..86dc5e803a40ac65140b9e64d1266e311c798d48 GIT binary patch literal 2736 zcmai0&2QX96gN=5mhZw5qz3{)MeXc{3L+<|+9oYjBu$hov>aeHYrm`=*)wKlyx9eb z3*ySHCr%Yydgz5BA@v080f_^DLb>rDAi<5_*xrxON?7v#=8fOHkKep`vv*IPxbES3 z9`B2If57_^-mM4lgXbsUTfm=zPXqq~?g39c=y{I-uL2(iegfPE#=vKQ-vgfj{sKG& z{2h1*{2TZfFnXxAmjNG#{5kMf;8#GmZu>-S=Of^&kW=83z^{S-z{WSgGmx)8>Ul2! ze*=CD`~&FXT89%1y-na%;1=*C@H?Qh|0D1f-~>1V{t0yYJp}U{Z~%01jq!6A_$AP- z>$mE-B+$k61<=LyEznWsa(DixkMoIeE1QldXT#Zb&r^7v&&3C3st4(Lpu&5$7Ax-E z9=QjhRz54?d>oT0i$ZBjR?%3MnxZUaX${4x=E!DaI!bLqR}*2)`JxEC4UuI|SwuEf z(%VqdVn{`zB$F)jKI?$ijMYjG&UO=~erc_eFoShcS?V*HL>);=4=A;-8{)jM<6v#6 zS>tVJ7CC#HoQbh_NvoU^*6gCANJxs5JV*y6W~{T$i5R9zlRBv6X`oZL@LZ*3Qp=A7pI`xUEgsfkQp7)nXo|5gTu(aH$K>z@v(|R1RUj zT2va=jvinoBif3eVJhY%&iL74G31&6w+P-vKjQ^1_SxE04vaS)kim-B>vF~w<({K> zO84=-nK4>(?~-)nHz{(Av?HdYgdHF3BG$yCh&eXZ1RI;?!a^~2Tj6*UREPlwblKK6 zMP}4-o5#%=tBTrKRBGdPY3S&IxBu)@;LRqm^@+8G373{4R6?*I4^WC_KZsObead<1 z$knAN3Ml0$u+%UJkBzsh)gj8)za0A?vNqVRaPBha)*ic}_qWX;jr|Md!1!GiQdbLU zGGP(u6_g;Y*=7Rk%{d;4yuj|j{n^&;PSMFtC1WO?;w>v9-d)Z%ZQ)f9`?!4LV zwA)bh_fR)3ghsEmC5-jwzCzj+k+KSfxK=cyb4}`Jp)3a_NcX!q6(QA!gVqw2iF=ho zV$-|0-`c*seQ}<6Cuq0aImNm5yW;|(y24#Tp{H_{qC{xJcKw6yC4XhE=Q2NF?O&9U zicx|gt@Kmd+RaKWGXIj&xd}-Ym1x$NSE(MZzai=6b?Tg2ZCyjiBO9w6Zv6ea&4e^& zbIpI3C2Pksa#tLumO8=P!5J*6MSmZyDB_Jew2E&qtsaFk!wYt%&h6`Gi?94TDJvj=`M5ke86~mrXs+h?$73Tz>>#x)nAw&rPH5QYn3laPV{v-hKEC3q+3%vbEQ&{49BHGUhbTHdB0 zqg-(_POB|V)6jX^(NWi^1lL7p2O{vcGLef|U`2+XC`u={rFUg=CufbWgiglU_HE;75GwLggHE8gJ#+NJfa-k zt4z`MTwgU^U|aN?YvT8gH}6&KUG9H!RYyg(1NOl537(%Qwj}l0;6f9Rm)d| zcxRE#$=c*Y=+%7G){v~bO@~5fiwvDVED^Es8YHv<9gA4GkecoAw#2OYXZP8|`4wO$ zw~_U+y(y)j$sL(Sf`Exz7?%`gOF{29&M75#yjbK#2_R&yZ@20WUpN-kRE?fdlXPjLU|92_iP8gKP%y|C- Da9vWk literal 0 HcmV?d00001 diff --git a/languages/whatsappme-es_ES.po b/languages/creame-whatsapp-me-es_ES.po similarity index 67% rename from languages/whatsappme-es_ES.po rename to languages/creame-whatsapp-me-es_ES.po index 011ece6..de637d6 100644 --- a/languages/whatsappme-es_ES.po +++ b/languages/creame-whatsapp-me-es_ES.po @@ -3,9 +3,9 @@ # This file is distributed under the GNU General Public License v2 or later. msgid "" msgstr "" -"Project-Id-Version: WhatsApp Me\n" +"Project-Id-Version: WhatsApp me\n" "Report-Msgid-Bugs-To: Translator Name \n" -"POT-Creation-Date: 2018-01-26 10:36+0100\n" +"POT-Creation-Date: 2018-02-20 12:21+0100\n" "PO-Revision-Date: \n" "Last-Translator: Pacotole \n" "Language-Team: Creame \n" @@ -23,34 +23,34 @@ msgstr "" "X-Generator: Poedit 1.8.7.1\n" "X-Poedit-SearchPath-0: .\n" -#: admin/class-whatsappme-admin.php:106 +#: admin/class-whatsappme-admin.php:97 msgid "Telephone" msgstr "Teléfono" -#: admin/class-whatsappme-admin.php:107 -msgid "Only mobile" +#: admin/class-whatsappme-admin.php:98 admin/class-whatsappme-admin.php:178 +msgid "Mobile only" msgstr "Solo Móvil" -#: admin/class-whatsappme-admin.php:108 +#: admin/class-whatsappme-admin.php:99 admin/class-whatsappme-admin.php:280 msgid "Call to action" msgstr "Llamada a la acción" -#: admin/class-whatsappme-admin.php:109 +#: admin/class-whatsappme-admin.php:100 msgid "Delay" msgstr "Retardo" -#: admin/class-whatsappme-admin.php:126 +#: admin/class-whatsappme-admin.php:123 msgid "Settings saved" msgstr "Ajustes guardados" -#: admin/class-whatsappme-admin.php:132 +#: admin/class-whatsappme-admin.php:135 msgid "" "From here you can configure the behavior of the WhatsApp button on your site." msgstr "" "Desde aquí puedes configurar el comportamiento del botón de WhatsApp en tu " "sitio web." -#: admin/class-whatsappme-admin.php:138 +#: admin/class-whatsappme-admin.php:146 msgid "" "Contact phone number. The button will not be shown if it's empty." @@ -58,7 +58,7 @@ msgstr "" "Número de teléfono de contacto. El botón no se mostrará si está " "vacío." -#: admin/class-whatsappme-admin.php:143 +#: admin/class-whatsappme-admin.php:157 msgid "" "Optional text to invite the user to use the contact via WhatsApp. " "Leave empty to disable." @@ -66,11 +66,11 @@ msgstr "" "Texto opcional para invitar al usuario a usar el contacto por WhatsApp. " "Dejar vacío para desactivarlo." -#: admin/class-whatsappme-admin.php:147 +#: admin/class-whatsappme-admin.php:167 msgid "milliseconds" msgstr "milisegundos" -#: admin/class-whatsappme-admin.php:148 +#: admin/class-whatsappme-admin.php:168 msgid "" "The Call to action will only be displayed once when the " "user exceeds the estimated delay on a page. It will also be displayed when " @@ -80,14 +80,36 @@ msgstr "" "cuando el usuario supere el retardo estimado en una página. También se " "mostrará cuando el usuario detenga el cursor sobre el botón de WhastApp." -#: admin/class-whatsappme-admin.php:155 +#: admin/class-whatsappme-admin.php:180 msgid "Only display the button on mobile devices" msgstr "Solo mostrar el botón en móviles" -#: admin/class-whatsappme-admin.php:180 +#: admin/class-whatsappme-admin.php:205 msgid "Settings" msgstr "Ajustes" +#. Name of the plugin +#: admin/class-whatsappme-admin.php:253 +msgid "WhatsApp me" +msgstr "WhatsApp me" + +#: admin/class-whatsappme-admin.php:285 +#, php-format +msgid "Hide on this %s" +msgstr "Ocultar en este %s" + #. Description of the theme -msgid "Add support to your visitors directly with WhatsApp." -msgstr "Añade soporte a tus visitantes directamente con WhatsApp." +msgid "Add support to your clients directly with WhatsApp." +msgstr "Da soporte a tus clientes directamente con WhatsApp." + +#. URI of the plugin +msgid "https://github.com/creame/whatsappme" +msgstr "https://github.com/creame/whatsappme" + +#. Author of the plugin +msgid "Creame" +msgstr "Creame" + +#. Author URI of the plugin +msgid "https://crea.me" +msgstr "https://crea.me" diff --git a/languages/creame-whatsapp-me.pot b/languages/creame-whatsapp-me.pot new file mode 100644 index 0000000..e6c920b --- /dev/null +++ b/languages/creame-whatsapp-me.pot @@ -0,0 +1,104 @@ +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: WhatsApp Me\n" +"POT-Creation-Date: 2018-02-20 11:03+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Your Name \n" +"Language-Team: Creame \n" +"Report-Msgid-Bugs-To: Translator Name \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" +"X-Textdomain-Support: yesX-Generator: Poedit 1.6.4\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;esc_html_e;esc_html_x:1,2c;esc_html__;" +"esc_attr_e;esc_attr_x:1,2c;esc_attr__;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;_x:" +"1,2c;_n:1,2;_n_noop:1,2;__ngettext:1,2;__ngettext_noop:1,2;_c,_nc:4c,1,2\n" +"X-Poedit-Basepath: ..\n" +"Language: \n" +"X-Generator: Loco https://localise.biz/\n" +"X-Poedit-SearchPath-0: ." + +#: admin/class-whatsappme-admin.php:97 +msgid "Telephone" +msgstr "" + +#: admin/class-whatsappme-admin.php:98 admin/class-whatsappme-admin.php:178 +msgid "Mobile only" +msgstr "" + +#: admin/class-whatsappme-admin.php:99 admin/class-whatsappme-admin.php:280 +msgid "Call to action" +msgstr "" + +#: admin/class-whatsappme-admin.php:100 +msgid "Delay" +msgstr "" + +#: admin/class-whatsappme-admin.php:123 +msgid "Settings saved" +msgstr "" + +#: admin/class-whatsappme-admin.php:135 +msgid "" +"From here you can configure the behavior of the WhatsApp button on your site." +msgstr "" + +#: admin/class-whatsappme-admin.php:146 +msgid "" +"Contact phone number. The button will not be shown if it's empty." +"" +msgstr "" + +#: admin/class-whatsappme-admin.php:157 +msgid "" +"Optional text to invite the user to use the contact via WhatsApp. " +"Leave empty to disable." +msgstr "" + +#: admin/class-whatsappme-admin.php:167 +msgid "milliseconds" +msgstr "" + +#: admin/class-whatsappme-admin.php:168 +msgid "" +"The Call to action will only be displayed once when the " +"user exceeds the estimated delay on a page. It will also be displayed when " +"the user stops the cursor over the WhatsApp button." +msgstr "" + +#: admin/class-whatsappme-admin.php:180 +msgid "Only display the button on mobile devices" +msgstr "" + +#: admin/class-whatsappme-admin.php:205 +msgid "Settings" +msgstr "" + +#. Name of the plugin +#: admin/class-whatsappme-admin.php:253 +msgid "WhatsApp me" +msgstr "" + +#: admin/class-whatsappme-admin.php:285 +#, php-format +msgid "Hide on this %s" +msgstr "" + +#. Description of the theme +msgid "Add support to your clients directly with WhatsApp." +msgstr "" + +#. URI of the plugin +msgid "https://github.com/creame/whatsappme" +msgstr "" + +#. Author of the plugin +msgid "Creame" +msgstr "" + +#. Author URI of the plugin +msgid "https://crea.me" +msgstr "" diff --git a/languages/whatsappme-es_ES.mo b/languages/whatsappme-es_ES.mo deleted file mode 100644 index 3b21f0d4ee8ff125cfc5938edfa718f2d3c3070e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2444 zcmZuzJ8T?97@m;uIvx@aQBnNRKty(PXRKhY<0y{ffQ6k{_CeCXX>RxT?OMAt%gpTg z4n@#VLJ2h~Q=~xY(omcP4JEV@6&-biM8P+^_pnJ;-uq@||Ht?LGyAO{zIx_+f$L@5 zZ{q$I_iMQS#qF<;P6@FL+yZ)=uYh~N?|@GO{{-#;{{o%`E3{too{ z9sx(d(@2J)xD9*-_zlqK`vLe6_#@Eg`x=X&EMCIxuT}#!$1@nitiF6~Z|`fJT|OS@ z3DB)`fwBLadlF2~}U(FLV!*z=-TDvGr_$OaWwoDa*X9A?^(KB(t2hO>M~Sr>$II21P&DoHY1 zB6Q>4u!2>g`&rJE@Gy(nHkQqrxKa8VCFBtQO396f-BbUSR98LOK{GzV$FCNu?ZcNL#LnDRZk&#ylC$I$buw;>uXRD?{HN zQ2yV(grdMf$Sk8@i50s>AL5t=TS@RK8;fp73y&Rc?Xf?d!HykdNpPha*r2N;>KdtR zE^$ujx-8HZH(h|gz04z7lxS|Oi%YHD8{J^Tu=E=lTt$%)EwwudSN*XvF&Z{w|2I6HW!6=!gkBQPppu3T!N}Ucjs|tGqp-_Dvf2g_DT0zu(Gi8l^?JP zHdU+>oS=wS`k8C(=9Q6oa7~-SMx@GmYS)%lsTr=ltLUvY>YQC|-2&y2OLT!W!G5C$ z5slg23O;1T#`hVuYfdspo$x}q43}ma>_anR-e{;r)Nq?W{g}r`+9Y;6vo4}uZ?(s( zY~x<)iv0L+6m`xm#fwM1dMKSUQ>%J-%&MOIaMQJ(8b!bmAF26P_Tit zK#n+{+&$2$o=kN~FGP7Wr@nUZfgBUmtI$whX(o5bW;mA)gQ1Kk_w+G&+G8h8qM^+e z3FH^m\n" -"Language-Team: Creame \n" -"Report-Msgid-Bugs-To: Translator Name " -"\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Textdomain-Support: yesX-Generator: Poedit 1.6.4\n" -"X-Poedit-SourceCharset: UTF-8\n" -"X-Poedit-KeywordsList: __;_e;esc_html_e;esc_html_x:1,2c;" -"esc_html__;esc_attr_e;esc_attr_x:1,2c;esc_attr__;_ex:1,2c;" -"_nx:4c,1,2;_nx_noop:4c,1,2;_x:1,2c;_n:1,2;_n_noop:1,2;" -"__ngettext:1,2;__ngettext_noop:1,2;_c,_nc:4c,1,2\n" -"X-Poedit-Basepath: ..\n" -"Language: en_US\n" -"X-Generator: Poedit 1.8.7.1\n" -"X-Poedit-SearchPath-0: .\n" - -#: admin/class-whatsappme-admin.php:106 -msgid "Telephone" -msgstr "" - -#: admin/class-whatsappme-admin.php:107 -msgid "Only mobile" -msgstr "" - -#: admin/class-whatsappme-admin.php:108 -msgid "Call to action" -msgstr "" - -#: admin/class-whatsappme-admin.php:109 -msgid "Delay" -msgstr "" - -#: admin/class-whatsappme-admin.php:126 -msgid "Settings saved" -msgstr "" - -#: admin/class-whatsappme-admin.php:132 -msgid "" -"From here you can configure the behavior of the WhatsApp " -"button on your site." -msgstr "" - -#: admin/class-whatsappme-admin.php:138 -msgid "" -"Contact phone number. The button will not be " -"shown if it's empty." -msgstr "" - -#: admin/class-whatsappme-admin.php:143 -msgid "" -"Optional text to invite the user to use the contact via " -"WhatsApp. Leave empty to disable." -msgstr "" - -#: admin/class-whatsappme-admin.php:147 -msgid "milliseconds" -msgstr "" - -#: admin/class-whatsappme-admin.php:148 -msgid "" -"The Call to action will only be " -"displayed once when the user exceeds the estimated delay " -"on a page. It will also be displayed when the user stops " -"the cursor over the WhatsApp button." -msgstr "" - -#: admin/class-whatsappme-admin.php:155 -msgid "Only display the button on mobile devices" -msgstr "" - -#: admin/class-whatsappme-admin.php:180 -msgid "Settings" -msgstr "" - -#. Description of the theme -msgid "Add support to your visitors directly with WhatsApp." -msgstr "" \ No newline at end of file diff --git a/public/class-whatsappme-public.php b/public/class-whatsappme-public.php index 26ff617..f24adbd 100644 --- a/public/class-whatsappme-public.php +++ b/public/class-whatsappme-public.php @@ -50,33 +50,53 @@ public function __construct( $plugin_name, $version ) { $this->plugin_name = $plugin_name; $this->version = $version; - $this->get_settings(); + $this->settings = array( + 'show' => false, + 'telephone' => '', + 'message_text' => '', + 'message_delay' => 10000, + 'mobile_only' => false, + ); } /** - * Get all settings or set defaults + * Get global settings and current post settings and prepare * * @since 1.0.0 */ - private function get_settings() { + public function get_settings() { - $this->settings = array( - 'telephone' => '', - 'message_text' => '', - 'message_delay' => 10000, - 'mobile_only' => 'no', - ); + global $post; + + $global_settings = get_option( 'whatsappme' ); + + if ( is_array( $global_settings ) ) { + // Clean unused saved settings + $settings = array_intersect_key( $global_settings, $this->settings ); + // Merge defaults with saved settings + $settings = array_merge( $this->settings, $settings ); - $saved_settings = get_option( 'whatsappme' ); + // Post custom settings + $post_settings = get_post_meta( $post->ID, '_whatsappme', true ) ?: array(); - if ( is_array( $saved_settings ) ) { - // clean unused saved settings - $saved_settings = array_intersect_key( $saved_settings, $this->settings ); - // merge defaults with saved settings - $this->settings = array_merge( $this->settings, $saved_settings ); + // Prepare settings + $settings['show'] = $settings['telephone'] != '' && ! isset( $post_settings['hide'] ); + $settings['mobile_only'] = $settings['mobile_only'] == 'yes'; + if ( isset( $post_settings['message_text'] ) ) { + $settings['message_text'] = $post_settings['message_text']; + } + + $this->settings = $settings; } + // Apply filter to settings + $this->settings = apply_filters( 'whatsappme_get_settings', $this->settings, $post ); + + // Ensure not show if not phone + if ( ! $this->settings['telephone'] ) { + $this->settings['show'] = false; + } } /** @@ -86,7 +106,9 @@ private function get_settings() { */ public function enqueue_styles() { - wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/whatsappme.css', array(), $this->version, 'all' ); + if ( $this->settings['show'] ) { + wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/whatsappme.css', array(), $this->version, 'all' ); + } } @@ -97,7 +119,9 @@ public function enqueue_styles() { */ public function enqueue_scripts() { - wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/whatsappme.js', array( 'jquery' ), $this->version, false ); + if ( $this->settings['show'] ) { + wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/whatsappme.js', array( 'jquery' ), $this->version, false ); + } } @@ -108,7 +132,7 @@ public function enqueue_scripts() { */ public function footer_html() { - if ( $this->settings['telephone']) { + if ( $this->settings['show'] ) { ?>
@@ -128,4 +152,5 @@ public function footer_html() { } } + } diff --git a/public/js/whatsappme.js b/public/js/whatsappme.js index 0fa46f1..f0913ba 100644 --- a/public/js/whatsappme.js +++ b/public/js/whatsappme.js @@ -21,7 +21,7 @@ localStorage.whatsappme_views = views; // show button / dialog - if (settings.mobile_only == 'no' || is_mobile) { + if (!settings.mobile_only || is_mobile) { setTimeout(function () { $whatsappme.addClass('whatsappme--show'); }, delay_on_start); diff --git a/whatsappme.php b/whatsappme.php index c470b92..72ee602 100644 --- a/whatsappme.php +++ b/whatsappme.php @@ -6,15 +6,15 @@ * @package WhatsAppMe * * @wordpress-plugin - * Plugin Name: WhatsApp Me + * Plugin Name: WhatsApp me * Plugin URI: https://github.com/creame/whatsappme - * Description: Add support to your visitors directly with WhatsApp. - * Version: 1.0.0 + * Description: Add support to your clients directly with WhatsApp. + * Version: 1.1.0 * Author: Creame * Author URI: https://crea.me * License: GPL-2.0+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt - * Text Domain: whatsappme + * Text Domain: creame-whatsapp-me * Domain Path: /languages */ @@ -27,7 +27,7 @@ * Currently plugin version. * Start at version 1.0.0 and use SemVer - https://semver.org */ -define( 'WHATSAPPME_VERSION', '1.0.0' ); +define( 'WHATSAPPME_VERSION', '1.1.0' ); /** * The core plugin class that is used to define internationalization,