- Modernized authentication with the introduction of TenantProject

- Created a base mail template
- Adapt and improve document API to usage of catalogs and processors
- Adapt eveai_sync to new authentication mechanism and usage of catalogs and processors
This commit is contained in:
Josako
2024-11-21 17:24:33 +01:00
parent 4c009949b3
commit 7702a6dfcc
72 changed files with 2338 additions and 503 deletions

View File

@@ -0,0 +1,74 @@
<?php
class EveAI_Chat_Admin {
private $version;
public function __construct($version) {
$this->version = $version;
}
public function add_plugin_admin_menu() {
add_options_page(
'EveAI Chat Settings', // Page title
'EveAI Chat', // Menu title
'manage_options', // Capability required
'eveai-chat-settings', // Menu slug
array($this, 'display_plugin_settings_page') // Callback function
);
}
public function register_settings() {
register_setting(
'eveai_chat_settings', // Option group
'eveai_chat_settings', // Option name
array($this, 'validate_settings') // Sanitization callback
);
add_settings_section(
'eveai_chat_general', // ID
'General Settings', // Title
array($this, 'section_info'), // Callback
'eveai-chat-settings' // Page
);
add_settings_field(
'api_key', // ID
'API Key', // Title
array($this, 'api_key_callback'), // Callback
'eveai-chat-settings', // Page
'eveai_chat_general' // Section
);
// Add more settings fields as needed
}
public function section_info() {
echo 'Enter your EveAI Chat configuration settings below:';
}
public function api_key_callback() {
$options = get_option('eveai_chat_settings');
$api_key = isset($options['api_key']) ? $options['api_key'] : '';
?>
<input type="password"
id="api_key"
name="eveai_chat_settings[api_key]"
value="<?php echo esc_attr($api_key); ?>"
class="regular-text">
<p class="description">Enter your EveAI API key. You can find this in your EveAI dashboard.</p>
<?php
}
public function validate_settings($input) {
$new_input = array();
if(isset($input['api_key']))
$new_input['api_key'] = sanitize_text_field($input['api_key']);
return $new_input;
}
public function display_plugin_settings_page() {
// Load the settings page template
require_once plugin_dir_path(__FILE__) . 'views/settings-page.php';
}
}

View File

@@ -0,0 +1,31 @@
<div class="wrap">
<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
<form action="options.php" method="post">
<?php
// Output security fields
settings_fields('eveai_chat_settings');
// Output setting sections and their fields
do_settings_sections('eveai-chat-settings');
// Output save settings button
submit_button('Save Settings');
?>
</form>
<div class="eveai-chat-help">
<h2>How to Use EveAI Chat</h2>
<p>To add the chat widget to your pages or posts, use the following shortcode:</p>
<code>[eveai_chat tenant_id="YOUR_TENANT_ID" language="en" supported_languages="en,fr,de,es"]</code>
<h3>Available Shortcode Parameters:</h3>
<ul>
<li><strong>tenant_id</strong> (required): Your EveAI tenant ID</li>
<li><strong>language</strong> (optional): Default language for the chat widget (default: en)</li>
<li><strong>supported_languages</strong> (optional): Comma-separated list of supported languages (default: en,fr,de,es)</li>
<li><strong>server_url</strong> (optional): EveAI server URL (default: https://evie.askeveai.com)</li>
<li><strong>specialist_id</strong> (optional): ID of the specialist to use (default: 1)</li>
</ul>
</div>
</div>