Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webchat Integration #5

Merged
merged 11 commits into from
Jan 15, 2025
13 changes: 10 additions & 3 deletions hellotext.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
*
* @wordpress-plugin
* Plugin Name: Hellotext
* Plugin URI: https://hellotext.com
* Plugin URI: https://github.com/hellotext/hellotext-wordpress
* Description: Integrates Hellotext tracking to WooCommerce.
* Version: 1.1.2
* Author: Hellotext Team
* Author URI: https://github.com/hellotext
* Author: Hellotext
* Author URI: https://www.hellotext.com
* License: GPL v2
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: hellotext
* Domain Path: /languages
*/

// TODO: Refactor this to use the APP_ENV variable
Expand Down Expand Up @@ -81,3 +83,8 @@ function version_check() {
}
}
add_action( 'admin_notices', 'version_check' );

function hellotext_load_textdomain() {
load_plugin_textdomain( 'hellotext', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
add_action( 'plugins_loaded', 'hellotext_load_textdomain' );
Binary file added languages/hellotext-en_US.mo
Binary file not shown.
75 changes: 75 additions & 0 deletions languages/hellotext-en_US.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Copyright (C) 2025 Hellotext
# This file is distributed under the GPL v2.
msgid ""
msgstr ""
"Project-Id-Version: Hellotext 1.1.2\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/hellotext-wordpress\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2025-01-10T14:15:22+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.11.0\n"
"X-Domain: hellotext\n"

#. Plugin Name of the plugin
#. Author of the plugin
#: hellotext.php
msgid "Hellotext"
msgstr ""

#. Plugin URI of the plugin
#: hellotext.php
msgid "https://www.hellotext.com"
msgstr ""

#. Description of the plugin
#: hellotext.php
msgid "Integrates Hellotext tracking to WooCommerce."
msgstr ""

#. Author URI of the plugin
#: hellotext.php
msgid "https://github.com/hellotext"
msgstr ""

msgid "settings.title"
msgstr "Settings"

msgid "settings.business_id"
msgstr "Business ID"

msgid "settings.access_token"
msgstr "Access Token"

msgid "settings.webchat_id"
msgstr "Webchat ID"

msgid "webchat_unavailable"
msgstr "No active Webchat found."

msgid "settings.webchat_placement"
msgstr "Webchat Placement"

msgid "settings.webchat_placement_bottom-right"
msgstr "Bottom Right"

msgid "settings.webchat_placement_bottom-left"
msgstr "Bottom Left"

msgid "settings.webchat_placement_top-right"
msgstr "Top Right"

msgid "settings.webchat_placement_top-left"
msgstr "Top Left"

msgid "settings.webchat_behaviour"
msgstr "Webchat Behaviour"

msgid "description.paragraphs.one"
msgstr "You can find your Business ID on the <a href=\"https://www.hellotext.com/businesses\" target=\"_blank\" style=\"color: #FF4C00;\">Hellotext business settings</a>."

msgid "description.paragraphs.two"
msgstr "You can create a new Access Token on the <a href=\"https://www.hellotext.com/businesses\" target=\"_blank\" style=\"color: #FF4C00;\">Hellotext business settings > Authorizations</a>."
Binary file added languages/hellotext-es_ES.mo
Binary file not shown.
75 changes: 75 additions & 0 deletions languages/hellotext-es_ES.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Copyright (C) 2025 Hellotext
# This file is distributed under the GPL v2.
msgid ""
msgstr ""
"Project-Id-Version: Hellotext 1.1.2\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/hellotext-wordpress\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2025-01-10T14:15:22+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.11.0\n"
"X-Domain: hellotext\n"

#. Plugin Name of the plugin
#. Author of the plugin
#: hellotext.php
msgid "Hellotext"
msgstr ""

#. Plugin URI of the plugin
#: hellotext.php
msgid "https://www.hellotext.com"
msgstr ""

#. Description of the plugin
#: hellotext.php
msgid "Integrates Hellotext tracking to WooCommerce."
msgstr "Integra el seguimiento de Hellotext en WooCommerce."

#. Author URI of the plugin
#: hellotext.php
msgid "https://github.com/hellotext/hellotext-wordpress"
msgstr ""

msgid "settings.title"
msgstr "Configuración"

msgid "settings.business_id"
msgstr "ID del negiocio"

msgid "settings.access_token"
msgstr "Token de acceso"

msgid "settings.webchat_id"
msgstr "ID del Webchat"

msgid "webchat_unavailable"
msgstr "No se encontró ningún Webchat activo."

msgid "settings.webchat_placement"
msgstr "Ubicación del Webchat"

msgid "settings.webchat_placement_bottom-right"
msgstr "Abajo a la derecha"

msgid "settings.webchat_placement_bottom-left"
msgstr "Abajo a la izquierda"

msgid "settings.webchat_placement_top-right"
msgstr "Arriba a la derecha"

msgid "settings.webchat_placement_top-left"
msgstr "Arriba a la izquierda"

msgid "settings.webchat_behaviour"
msgstr "Comportamiento del Webchat"

msgid "description.paragraphs.one"
msgstr "Puedes encontrar tu ID de negocio en la <a href=\"https://www.hellotext.com/businesses\" target=\"_blank\" style=\"color: #FF4C00;\">configuración de negocios de Hellotext</a>."

msgid "description.paragraphs.two"
msgstr "Puedes crear un nuevo Token de Acceso en la <a href=\"https://www.hellotext.com/businesses\" target=\"_blank\" style=\"color: #FF4C00;\">configuración de negocios de Hellotext > Autorizaciones</a>."
75 changes: 75 additions & 0 deletions languages/hellotext.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Copyright (C) 2025 Hellotext
# This file is distributed under the GPL v2.
msgid ""
msgstr ""
"Project-Id-Version: Hellotext 1.1.2\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/hellotext-wordpress\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2025-01-10T14:15:22+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.11.0\n"
"X-Domain: hellotext\n"

#. Plugin Name of the plugin
#. Author of the plugin
#: hellotext.php
msgid "Hellotext"
msgstr ""

#. Plugin URI of the plugin
#: hellotext.php
msgid "https://www.hellotext.com"
msgstr ""

#. Description of the plugin
#: hellotext.php
msgid "Integrates Hellotext tracking to WooCommerce."
msgstr ""

#. Author URI of the plugin
#: hellotext.php
msgid "https://github.com/hellotext/hellotext-wordpress"
msgstr ""

msgid "settings.title"
msgstr ""

msgid "settings.business_id"
msgstr ""

msgid "settings.access_token"
msgstr ""

msgid "settings.webchat_id"
msgstr ""

msgid "webchat_unavailable"
msgstr ""

msgid "settings.webchat_placement"
msgstr ""

msgid "settings.webchat_placement_bottom-right"
msgstr ""

msgid "settings.webchat_placement_bottom-left"
msgstr ""

msgid "settings.webchat_placement_top-right"
msgstr ""

msgid "settings.webchat_placement_top-left"
msgstr ""

msgid "settings.webchat_behaviour"
msgstr ""

msgid "description.paragraphs.one"
msgstr ""

msgid "description.paragraphs.two"
msgstr ""
18 changes: 18 additions & 0 deletions src/Api/Webchat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Hellotext\Api;

use Hellotext\Api\Client;

class Webchat {
public static function index() {
$hellotext_access_token = get_option('hellotext_access_token');

if(!$hellotext_access_token) {
return [];
}

$body = Client::with_sufix()->get('/v1/wordpress/webchats');
return is_array($body['body']) && isset($body['body']['ids']) ? $body['body']['ids'] : [];
}
}
26 changes: 21 additions & 5 deletions src/Misc/Scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,26 @@
function hellotext_script () {
global $HELLOTEXT_API_URL;

?>
<script type="module">
$business_id = get_option('hellotext_business_id');
$webchat_id = get_option('hellotext_webchat_id');
$placement = get_option('hellotext_webchat_placement', 'bottom-right');
$behaviour = get_option('hellotext_webchat_behaviour', 'popover');

?>
<script type="module">
import 'https://unpkg.com/@hellotext/hellotext@latest/dist/hellotext.js';
Hellotext.initialize('<?php echo esc_html(get_option('hellotext_business_id')); ?>');
</script>
<?php

let config = {};

<?php if ($webchat_id) : ?>
config.webChat = {
id: '<?php echo esc_html($webchat_id); ?>',
placement: '<?php echo esc_html($placement); ?>',
behaviour: '<?php echo esc_html($behaviour); ?>',
};
<?php endif; ?>

Hellotext.initialize('<?php echo esc_html($business_id); ?>', config);
</script>
<?php
}
Loading
Loading