From 998adb2eec7e4b8d03c7f745ba06804a5b4b0336 Mon Sep 17 00:00:00 2001 From: rockwellll Date: Wed, 8 Jan 2025 10:43:42 +0300 Subject: [PATCH 01/11] add input for setting webchat --- src/Misc/Settings.php | 99 +++++++++++++++++++++++++++---------------- 1 file changed, 62 insertions(+), 37 deletions(-) diff --git a/src/Misc/Settings.php b/src/Misc/Settings.php index 94e846f..e6df390 100644 --- a/src/Misc/Settings.php +++ b/src/Misc/Settings.php @@ -3,54 +3,79 @@ add_action( 'admin_init', 'hellotext_settings_init' ); function hellotext_settings_init() { - add_settings_section( - 'hellotext_setting_section', - __( 'Settings', 'hellotext_settings' ), - 'hellotext_description_section_callback', - 'hellotext-form' - ); + // Add settings section + add_settings_section( + 'hellotext_setting_section', + __( 'Settings', 'hellotext' ), + 'hellotext_description_section_callback', + 'hellotext-form' + ); - // Hellotext business ID - add_settings_field( - 'hellotext_business_id', - __( 'Business ID', 'hellotext_business_id' ), - 'hellotext_business_id_field', - 'hellotext-form', - 'hellotext_setting_section' - ); + // Hellotext Business ID + add_settings_field( + 'hellotext_business_id', + __( 'Business ID', 'hellotext' ), + 'hellotext_business_id_field', + 'hellotext-form', + 'hellotext_setting_section' + ); - // Hellotext Access Token - add_settings_field( - 'hellotext_access_token', - __( 'Access Token', 'hellotext_access_token' ), - 'hellotext_access_token_field', - 'hellotext-form', - 'hellotext_setting_section' - ); + // Hellotext Access Token + add_settings_field( + 'hellotext_access_token', + __( 'Access Token', 'hellotext' ), + 'hellotext_access_token_field', + 'hellotext-form', + 'hellotext_setting_section' + ); - register_setting( 'hellotext-form', 'hellotext_business_id' ); - register_setting( 'hellotext-form', 'hellotext_access_token' ); + // Hellotext Webchat ID + add_settings_field( + 'hellotext_webchat_id', + __( 'Webchat', 'hellotext' ), + 'hellotext_webchat_id_field', + 'hellotext-form', + 'hellotext_setting_section' + ); + + // Register settings + register_setting( 'hellotext-form', 'hellotext_business_id' ); + register_setting( 'hellotext-form', 'hellotext_access_token' ); + register_setting( 'hellotext-form', 'hellotext_webchat_id' ); // Corrected ID } -function hellotext_description_section_callback () { - ?> -

You can find your Business ID on the Hellotext business settings.

-

You can create a new Access Token on the Hellotext business settings > Authorizations.

- +

You can find your Business ID on the Hellotext business settings.

+

You can create a new Access Token on the Hellotext business settings > Authorizations.

+ - - + + - - + + + + Date: Wed, 8 Jan 2025 10:52:22 +0300 Subject: [PATCH 02/11] configure the webchat when has been set --- src/Misc/Scripts.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Misc/Scripts.php b/src/Misc/Scripts.php index 996fd6f..3423b35 100644 --- a/src/Misc/Scripts.php +++ b/src/Misc/Scripts.php @@ -6,10 +6,22 @@ function hellotext_script () { global $HELLOTEXT_API_URL; - ?> - - + config.webChat = { + id: '' + }; + + + Hellotext.initialize('', config); + + Date: Wed, 8 Jan 2025 11:09:21 +0300 Subject: [PATCH 03/11] add register functinos for webchat placement and behaviour --- src/Misc/Scripts.php | 6 +++++- src/Misc/Settings.php | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/Misc/Scripts.php b/src/Misc/Scripts.php index 3423b35..3bde4a8 100644 --- a/src/Misc/Scripts.php +++ b/src/Misc/Scripts.php @@ -8,6 +8,8 @@ function hellotext_script () { $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'); ?>