- 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
74 lines
2.4 KiB
PHP
74 lines
2.4 KiB
PHP
<?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';
|
|
}
|
|
}
|