- Allow multiple instances of Evie on 1 website. Shortcode is now parametrized.
This commit is contained in:
Binary file not shown.
@@ -3,7 +3,7 @@
|
|||||||
Plugin Name: EveAI Chat Widget
|
Plugin Name: EveAI Chat Widget
|
||||||
Plugin URI: https://askeveai.com/
|
Plugin URI: https://askeveai.com/
|
||||||
Description: Integrates the EveAI chat interface into your WordPress site.
|
Description: Integrates the EveAI chat interface into your WordPress site.
|
||||||
Version: 1.3.23
|
Version: 1.4.1
|
||||||
Author: Josako, Pieter Laroy
|
Author: Josako, Pieter Laroy
|
||||||
Author URI: https://askeveai.com/about/
|
Author URI: https://askeveai.com/about/
|
||||||
*/
|
*/
|
||||||
@@ -18,15 +18,28 @@ function eveai_chat_enqueue_scripts() {
|
|||||||
wp_enqueue_style('eveai-chat-style', plugin_dir_url(__FILE__) . 'css/eveai-chat-style.css');
|
wp_enqueue_style('eveai-chat-style', plugin_dir_url(__FILE__) . 'css/eveai-chat-style.css');
|
||||||
}
|
}
|
||||||
add_action('wp_enqueue_scripts', 'eveai_chat_enqueue_scripts');
|
add_action('wp_enqueue_scripts', 'eveai_chat_enqueue_scripts');
|
||||||
|
add_action('admin_enqueue_scripts', 'eveai_chat_enqueue_scripts');
|
||||||
|
|
||||||
// Shortcode function
|
// Shortcode function
|
||||||
function eveai_chat_shortcode($atts) {
|
function eveai_chat_shortcode($atts) {
|
||||||
$options = get_option('eveai_chat_options');
|
// Default values
|
||||||
$tenant_id = esc_js($options['tenant_id']);
|
$defaults = array(
|
||||||
$api_key = esc_js($options['api_key']);
|
'tenant_id' => '',
|
||||||
$domain = esc_js($options['domain']);
|
'api_key' => '',
|
||||||
$language = esc_js($options['language']);
|
'domain' => '',
|
||||||
$supported_languages = esc_js($options['supported_languages']);
|
'language' => 'en',
|
||||||
|
'supported_languages' => 'en,fr,de,es'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Merge provided attributes with defaults
|
||||||
|
$atts = shortcode_atts($defaults, $atts, 'eveai_chat');
|
||||||
|
|
||||||
|
// Sanitize inputs
|
||||||
|
$tenant_id = sanitize_text_field($atts['tenant_id']);
|
||||||
|
$api_key = sanitize_text_field($atts['api_key']);
|
||||||
|
$domain = esc_url_raw($atts['domain']);
|
||||||
|
$language = sanitize_text_field($atts['language']);
|
||||||
|
$supported_languages = sanitize_text_field($atts['supported_languages']);
|
||||||
|
|
||||||
// Generate a unique ID for this instance of the chat widget
|
// Generate a unique ID for this instance of the chat widget
|
||||||
$chat_id = 'chat-container-' . uniqid();
|
$chat_id = 'chat-container-' . uniqid();
|
||||||
@@ -49,80 +62,3 @@ function eveai_chat_shortcode($atts) {
|
|||||||
}
|
}
|
||||||
add_shortcode('eveai_chat', 'eveai_chat_shortcode');
|
add_shortcode('eveai_chat', 'eveai_chat_shortcode');
|
||||||
|
|
||||||
// Add admin menu
|
|
||||||
function eveai_chat_admin_menu() {
|
|
||||||
add_options_page('EveAI Chat Settings', 'EveAI Chat', 'manage_options', 'eveai-chat-settings', 'eveai_chat_settings_page');
|
|
||||||
}
|
|
||||||
add_action('admin_menu', 'eveai_chat_admin_menu');
|
|
||||||
|
|
||||||
// Settings page
|
|
||||||
function eveai_chat_settings_page() {
|
|
||||||
?>
|
|
||||||
<div class="wrap">
|
|
||||||
<h1>EveAI Chat Settings</h1>
|
|
||||||
<form method="post" action="options.php">
|
|
||||||
<?php
|
|
||||||
settings_fields('eveai_chat_options');
|
|
||||||
do_settings_sections('eveai-chat-settings');
|
|
||||||
submit_button();
|
|
||||||
?>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register settings
|
|
||||||
function eveai_chat_register_settings() {
|
|
||||||
register_setting('eveai_chat_options', 'eveai_chat_options', 'eveai_chat_options_validate');
|
|
||||||
|
|
||||||
add_settings_section('eveai_chat_main', 'Main Settings', 'eveai_chat_section_text', 'eveai-chat-settings');
|
|
||||||
|
|
||||||
add_settings_field('eveai_chat_tenant_id', 'Tenant ID', 'eveai_chat_tenant_id_input', 'eveai-chat-settings', 'eveai_chat_main');
|
|
||||||
add_settings_field('eveai_chat_api_key', 'API Key', 'eveai_chat_api_key_input', 'eveai-chat-settings', 'eveai_chat_main');
|
|
||||||
add_settings_field('eveai_chat_domain', 'Domain', 'eveai_chat_domain_input', 'eveai-chat-settings', 'eveai_chat_main');
|
|
||||||
add_settings_field('eveai_chat_language', 'Default Language', 'eveai_chat_language_input', 'eveai-chat-settings', 'eveai_chat_main');
|
|
||||||
add_settings_field('eveai_chat_supported_languages', 'Supported Languages', 'eveai_chat_supported_languages_input', 'eveai-chat-settings', 'eveai_chat_main');
|
|
||||||
}
|
|
||||||
add_action('admin_init', 'eveai_chat_register_settings');
|
|
||||||
|
|
||||||
function eveai_chat_section_text() {
|
|
||||||
echo '<p>Enter your EveAI Chat configuration details below:</p>';
|
|
||||||
}
|
|
||||||
|
|
||||||
function eveai_chat_tenant_id_input() {
|
|
||||||
$options = get_option('eveai_chat_options');
|
|
||||||
echo "<input id='eveai_chat_tenant_id' name='eveai_chat_options[tenant_id]' type='text' value='" . esc_attr($options['tenant_id']) . "' />";
|
|
||||||
}
|
|
||||||
|
|
||||||
function eveai_chat_api_key_input() {
|
|
||||||
$options = get_option('eveai_chat_options');
|
|
||||||
echo "<input id='eveai_chat_api_key' name='eveai_chat_options[api_key]' type='password' value='" . esc_attr($options['api_key']) . "' />";
|
|
||||||
}
|
|
||||||
|
|
||||||
function eveai_chat_domain_input() {
|
|
||||||
$options = get_option('eveai_chat_options');
|
|
||||||
echo "<input id='eveai_chat_domain' name='eveai_chat_options[domain]' type='text' value='" . esc_attr($options['domain']) . "' />";
|
|
||||||
}
|
|
||||||
|
|
||||||
function eveai_chat_language_input() {
|
|
||||||
$options = get_option('eveai_chat_options');
|
|
||||||
echo "<input id='eveai_chat_language' name='eveai_chat_options[language]' type='text' value='" . esc_attr($options['language']) . "' />";
|
|
||||||
}
|
|
||||||
|
|
||||||
function eveai_chat_supported_languages_input() {
|
|
||||||
$options = get_option('eveai_chat_options');
|
|
||||||
$supported_languages = isset($options['supported_languages']) ? $options['supported_languages'] : 'en,fr,de,es';
|
|
||||||
echo "<input id='eveai_chat_supported_languages' name='eveai_chat_options[supported_languages]' type='text' value='" . esc_attr($supported_languages) . "' />";
|
|
||||||
echo "<p class='description'>Enter comma-separated language codes (e.g., en,fr,de,es)</p>";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function eveai_chat_options_validate($input) {
|
|
||||||
$new_input = array();
|
|
||||||
$new_input['tenant_id'] = sanitize_text_field($input['tenant_id']);
|
|
||||||
$new_input['api_key'] = sanitize_text_field($input['api_key']);
|
|
||||||
$new_input['domain'] = esc_url_raw($input['domain']);
|
|
||||||
$new_input['language'] = sanitize_text_field($input['language']);
|
|
||||||
$new_input['supported_languages'] = sanitize_text_field($input['supported_languages']);
|
|
||||||
return $new_input;
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,7 @@ Contributors: Josako
|
|||||||
Tags: chat, ai
|
Tags: chat, ai
|
||||||
Requires at least: 5.0
|
Requires at least: 5.0
|
||||||
Tested up to: 5.9
|
Tested up to: 5.9
|
||||||
Stable tag: 1.3.0
|
Stable tag: 1.4.1
|
||||||
License: GPLv2 or later
|
License: GPLv2 or later
|
||||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
|
||||||
@@ -17,7 +17,18 @@ This plugin allows you to easily add the EveAI chat widget to your WordPress sit
|
|||||||
|
|
||||||
1. Upload the `eveai-chat-widget` folder to the `/wp-content/plugins/` directory
|
1. Upload the `eveai-chat-widget` folder to the `/wp-content/plugins/` directory
|
||||||
2. Activate the plugin through the 'Plugins' menu in WordPress
|
2. Activate the plugin through the 'Plugins' menu in WordPress
|
||||||
3. Go to Settings > EveAI Chat to configure your chat widget parameters
|
3. Add EveAI Chat Widget to your page or post using the instructions below.
|
||||||
|
|
||||||
|
== Usage ==
|
||||||
|
|
||||||
|
To add an EveAI Chat Widget to your page or post, use the following shortcode:
|
||||||
|
|
||||||
|
[eveai_chat tenant_id="YOUR_TENANT_ID" api_key="YOUR_API_KEY" domain="YOUR_DOMAIN" language="LANGUAGE_CODE" supported_languages="COMMA_SEPARATED_LANGUAGE_CODES"]
|
||||||
|
|
||||||
|
Example:
|
||||||
|
[eveai_chat tenant_id="123456" api_key="your_api_key_here" domain="https://your-domain.com" language="en" supported_languages="en,fr,de,es"]
|
||||||
|
|
||||||
|
You can add multiple chat widgets with different configurations by using the shortcode multiple times with different parameters.
|
||||||
|
|
||||||
== Frequently Asked Questions ==
|
== Frequently Asked Questions ==
|
||||||
|
|
||||||
@@ -27,6 +38,13 @@ Contact your EveAI service provider to obtain your Tenant ID, API Key, and Domai
|
|||||||
|
|
||||||
== Changelog ==
|
== Changelog ==
|
||||||
|
|
||||||
|
= 1.4.1 - 1.4...=
|
||||||
|
* Bug fixes
|
||||||
|
|
||||||
|
= 1.4.0 =
|
||||||
|
* Allow for multiple instances of Evie on the same website
|
||||||
|
* Parametrization of the shortcode
|
||||||
|
|
||||||
= 1.3.3 - =
|
= 1.3.3 - =
|
||||||
* ensure all attributes (also height and supportedLanguages) are set before initializing the socket
|
* ensure all attributes (also height and supportedLanguages) are set before initializing the socket
|
||||||
* Bugfixing
|
* Bugfixing
|
||||||
|
|||||||
Reference in New Issue
Block a user