is_valid_model($frontend_chat_model, 'anthropic')) { update_option('aieo_chat_provider', 'anthropic'); update_option('aieo_chat_model', $frontend_chat_model); } } } if (isset($_POST['aieo_frontend_embedding_model']) && !empty($_POST['aieo_frontend_embedding_model'])) { $frontend_embedding_selection = sanitize_text_field(wp_unslash( $_POST['aieo_frontend_embedding_model'] )); $parts = explode(':', $frontend_embedding_selection); if (count($parts) === 2) { $frontend_embedding_model = $parts[0]; $dedup_mode = (int)$parts[1]; if (isset($_POST['aieo_chat_deduplication_mode'])) { $dedup_mode = (int)$_POST['aieo_chat_deduplication_mode']; } update_option('aieo_chat_deduplication_mode', $dedup_mode); update_option('aieo_embedding_provider', 'voyage'); update_option('aieo_chat_embedding_model', $frontend_embedding_model); } } if ($is_pro_user) { wp_clear_scheduled_hook('aieo_auto_analytics_event'); wp_clear_scheduled_hook('aieo_auto_embeddings_event'); if (isset($_POST['aieo_auto_analytics_enabled']) && $_POST['aieo_auto_analytics_enabled'] == '1') { $frequency = sanitize_text_field(wp_unslash( $_POST['aieo_auto_analytics_frequency'] )); $time = sanitize_text_field(wp_unslash( $_POST['aieo_auto_analytics_time'] )); $next_run = aieo_calculate_next_run_time($frequency, $time); if ($next_run) { wp_schedule_event($next_run, $frequency === 'daily' ? 'daily' : ($frequency === 'weekly' ? 'weekly' : 'monthly'), 'aieo_auto_analytics_event'); if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { error_log('AIEO: Scheduled analytics automation for ' . gmdate('Y-m-d H:i:s', $next_run)); } } } if (isset($_POST['aieo_auto_embeddings_enabled']) && $_POST['aieo_auto_embeddings_enabled'] == '1' && class_exists('AIEO_Chat_Indexing') && AIEO_Chat_Indexing::enabled()) { $frequency = sanitize_text_field(wp_unslash( $_POST['aieo_auto_embeddings_frequency'] )); $time = sanitize_text_field(wp_unslash( $_POST['aieo_auto_embeddings_time'] )); $next_run = aieo_calculate_next_run_time($frequency, $time); if ($next_run) { wp_schedule_event($next_run, $frequency === 'daily' ? 'daily' : ($frequency === 'weekly' ? 'weekly' : 'monthly'), 'aieo_auto_embeddings_event'); if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { error_log('AIEO: Scheduled embeddings automation for ' . gmdate('Y-m-d H:i:s', $next_run)); } } } } wp_cache_flush(); if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { error_log('AIEO: Flushed object cache after settings save'); } echo '

' . esc_html__('Settings saved successfully!', 'ai-eshop-optimizer') . '

'; $chat_enabled = get_option('aieo_chat_enabled', '0'); $floating_enabled = get_option('aieo_chat_floating_enabled', '0'); $floating_position = get_option('aieo_chat_floating_position', 'bottom-right'); $api_key = get_option('aieo_chat_anthropic_api_key', ''); $voyage_key = get_option('aieo_chat_voyage_api_key', ''); $bot_name = get_option('aieo_chat_bot_name', 'AI Assistant'); $welcome_message = get_option('aieo_chat_welcome_message', 'Hello! How can I help you find the perfect product today?'); $input_placeholder = get_option('aieo_chat_input_placeholder', 'Ask about anything...'); $model = get_option('aieo_chat_model', 'claude-sonnet-4-5'); $max_tokens = get_option('aieo_chat_max_tokens', '2000'); $temperature = get_option('aieo_chat_temperature', '0.5'); $max_results = get_option('aieo_chat_max_results', '10'); $custom_prompt = get_option('aieo_chat_custom_prompt', ''); $hide_images = get_option('aieo_chat_hide_images', '0'); $require_login = get_option('aieo_chat_require_login', '0'); $history_enabled = get_option('aieo_chat_history_enabled', '1'); $show_terms = get_option('aieo_chat_show_terms', '0'); $enabled_post_types = class_exists('AIEO_Content_Types') ? AIEO_Content_Types::chat_post_types() : get_option('aieo_chat_enabled_post_types', array('product')); $context_device_profile = get_option('aieo_chat_context_device_profile', '0'); $context_browsing_history = get_option('aieo_chat_context_browsing_history', '0'); $context_history_pages = get_option('aieo_chat_context_history_pages', '5'); $context_user_preferences = get_option('aieo_chat_context_user_preferences', '0'); $batch_size = get_option('aieo_chat_batch_size', '50'); } add_action('wp_ajax_aieo_chat_save_quick_settings', function() { if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { error_log('AIEO - Quick save AJAX called'); } if (!check_ajax_referer('aieo_chat_admin', 'nonce', false)) { if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { error_log('AIEO - Quick save NONCE FAILED'); } wp_send_json_error(array('message' => 'Nonce verification failed')); return; } if (!current_user_can('manage_options')) { if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { error_log('AIEO - Quick save PERMISSIONS FAILED'); } wp_send_json_error(array('message' => 'Insufficient permissions')); return; } if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { error_log('AIEO - Quick save passed security checks'); } if (isset($_POST['aieo_chat_batch_size'])) { $batch_size = intval($_POST['aieo_chat_batch_size']); if ($batch_size >= 1 && $batch_size <= 999) { update_option('aieo_chat_batch_size', $batch_size); wp_cache_delete('aieo_chat_batch_size', 'options'); if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { error_log('AIEO QUICK SAVE - Batch size: ' . $batch_size . ' | Verify: ' . get_option('aieo_chat_batch_size')); } } } if (isset($_POST['aieo_chat_deduplication_mode'])) { $dedup = $_POST['aieo_chat_deduplication_mode'] === '1' ? '1' : '0'; update_option('aieo_chat_deduplication_mode', $dedup); wp_cache_delete('aieo_chat_deduplication_mode', 'options'); } wp_cache_flush(); wp_send_json_success(array('message' => 'Settings saved')); }); function aieo_calculate_next_run_time($frequency, $time) { if (empty($time)) { return false; } list($hour, $minute) = explode(':', $time); $hour = intval($hour); $minute = intval($minute); $now = current_time('timestamp', true); $today = strtotime(gmdate('Y-m-d', $now) . ' ' . sprintf('%02d:%02d:00', $hour, $minute)); if ($today <= $now) { if ($frequency === 'daily') { return $today + DAY_IN_SECONDS; } elseif ($frequency === 'weekly') { return $today + (7 * DAY_IN_SECONDS); } elseif ($frequency === 'monthly') { return $today + (30 * DAY_IN_SECONDS); } } return $today; } $chat_enabled = get_option('aieo_chat_enabled', '0'); $floating_enabled = get_option('aieo_chat_floating_enabled', '0'); $floating_position = get_option('aieo_chat_floating_position', 'bottom-right'); $api_key = get_option('aieo_chat_anthropic_api_key', ''); $voyage_key = get_option('aieo_chat_voyage_api_key', ''); $bot_name = get_option('aieo_chat_bot_name', 'AI Assistant'); $welcome_message = get_option('aieo_chat_welcome_message', 'Hello! How can I help you find the perfect product today?'); $input_placeholder = get_option('aieo_chat_input_placeholder', 'Ask about anything...'); $model = get_option('aieo_chat_model', 'claude-sonnet-4-5'); $max_tokens = get_option('aieo_chat_max_tokens', '2000'); $temperature = get_option('aieo_chat_temperature', '0.5'); $max_results = get_option('aieo_chat_max_results', '10'); $custom_prompt = get_option('aieo_chat_custom_prompt', ''); $hide_images = get_option('aieo_chat_hide_images', '0'); $require_login = get_option('aieo_chat_require_login', '0'); $history_enabled = get_option('aieo_chat_history_enabled', '1'); $show_terms = get_option('aieo_chat_show_terms', '0'); $enabled_post_types = class_exists('AIEO_Content_Types') ? AIEO_Content_Types::chat_post_types() : get_option('aieo_chat_enabled_post_types', array('product')); $context_device_profile = get_option('aieo_chat_context_device_profile', '0'); $context_browsing_history = get_option('aieo_chat_context_browsing_history', '0'); $context_history_pages = get_option('aieo_chat_context_history_pages', '5'); $context_user_preferences = get_option('aieo_chat_context_user_preferences', '0'); $rerank_enabled = get_option('aieo_chat_rerank_enabled', '1'); $rerank_variations_2_10 = get_option('aieo_chat_rerank_variations_2_10', '1.10'); $rerank_variations_10_50 = get_option('aieo_chat_rerank_variations_10_50', '1.30'); $rerank_variations_50_plus = get_option('aieo_chat_rerank_variations_50_plus', '1.50'); $rerank_primary_category = get_option('aieo_chat_rerank_primary_category', '1.20'); $rerank_needs = get_option('aieo_chat_rerank_needs', '1.00'); $rerank_accessories = get_option('aieo_chat_rerank_accessories', '0.60'); $rerank_recency = get_option('aieo_chat_rerank_recency', '1.30'); $rerank_preferred_brands = get_option('aieo_chat_rerank_preferred_brands', ''); $batch_size = get_option('aieo_chat_batch_size', '50'); if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { error_log('AIEO - Reading batch_size for display: ' . $batch_size); } $db = AI_eShop_Chat_Database_Manager::get_instance(); $stats = $db->get_stats(); $chat_stats = $db->get_chat_stats(); $recent_conversations = $db->get_recent_conversations(5); $api = AI_eShop_Chat_Anthropic_API::get_instance(); $models = $api->get_available_models(); function aieo_chat_getRandomNumberBetween1And3() { return wp_rand(1, 3); } $randomNumber = aieo_chat_getRandomNumberBetween1And3(); $main_admin_url = admin_url('admin.php?page=ai-eshop-optimizer'); $chat_admin_url = admin_url('admin.php?page=ai-eshop-chat'); ?>
'; } ?> prefix . 'aieo_core_product_vitals'; if ($wpdb->get_var("SHOW TABLES LIKE '$aieo_vitals_table'") === $aieo_vitals_table) { $aieo_vitals_rows = (int) $wpdb->get_var("SELECT COUNT(*) FROM $aieo_vitals_table"); } } else { $aieo_vitals_rows = 1; } $aieo_data_analysed = (bool) apply_filters('aieo_chat_data_analysed', $aieo_vitals_rows > 0); if (!$aieo_data_analysed && class_exists('\Rooster\Admin\Ui')) { $aieo_analyze_url = admin_url('admin.php?page=ai-eshop-optimizer#analyze-data-section'); echo \Rooster\Admin\Ui::notice( sprintf( esc_html__('To enable product-based chat capabilities, please complete the %s step in Analytics & Shop Recommendations Setup Analysis first. The AI Chat feature requires preprocessing of product and order data to function properly.', 'ai-eshop-optimizer'), '' . esc_html__('Analyze Data', 'ai-eshop-optimizer') . '' ), 'warning', array( 'title' => __('Product Data Required', 'ai-eshop-optimizer'), 'id' => 'aieo-chat-data-notice', 'actions' => \Rooster\Admin\Ui::button(__('Go to Analyze Data', 'ai-eshop-optimizer'), array('variant' => 'primary', 'href' => $aieo_analyze_url)), ) ); } ?>
' . esc_html($title) . ''; } return rooster_admin_card_section_html($title, '' !== $id ? array('id' => $id) : array()); }; $aieo_cs_notice = static function ($html, $tone, array $opts = array()) { if (class_exists('\Rooster\Admin\Ui')) { return \Rooster\Admin\Ui::notice($html, $tone, $opts + array('inline' => true)); } return '
' . (!empty($opts['title']) ? '

' . esc_html($opts['title']) . '

' : '') . ('' !== $html ? '

' . $html . '

' : '') . (isset($opts['detail']) ? $opts['detail'] : '') . '
'; }; $aieo_cs_stats = static function (array $tiles) { $out = '
'; foreach ($tiles as $tile) { $out .= class_exists('\Rooster\Admin\Ui') ? \Rooster\Admin\Ui::stat((string) $tile[0], (string) $tile[1]) : '

' . esc_html((string) $tile[1]) . ' ' . esc_html((string) $tile[0]) . '

'; } return $out . '
'; }; $aieo_cs_out = static function ($html) { echo $html; }; $aieo_cs_card = static function (array $card, $form_id) use ($aieo_cs_lib) { if (!$aieo_cs_lib) { return AIEO_DMM_UI::card($card); } $card['footer'] = \Rooster\Admin\States::save_button($form_id) . (isset($card['footer']) ? ' ' . $card['footer'] : ''); list($open, $close) = AIEO_DMM_UI::card($card); $at = strpos($open, ''); if (false === $at || 0 !== strpos($close, '
')) { return array($open, $close); } $form = \Rooster\Admin\States::form($form_id, '', array( 'class' => 'aieo-chat-card-form', 'attrs' => array('data-aieo-chat-card' => ''), 'hidden' => array( '_wpnonce' => wp_create_nonce('aieo_chat_settings'), '_wp_http_referer' => remove_query_arg('_wp_http_referer', wp_unslash(isset($_SERVER['REQUEST_URI']) ? (string) $_SERVER['REQUEST_URI'] : '')), 'aieo_chat_save_settings' => '', ), )); $form = substr($form, 0, -strlen('')); return array(substr_replace($open, '' . $form, $at, strlen('')), '
' . substr($close, strlen('
'))); }; $aieo_cs_sizes = static function ($label, $base, $default_d, $default_m) { $parts = array(); foreach (array('d' => array(__('Desktop', 'ai-eshop-optimizer'), $default_d), 'm' => array(__('Mobile', 'ai-eshop-optimizer'), $default_m)) as $k => $p) { $id = str_replace('_', '-', $base) . '-' . $k; $parts[] = array( 'label' => $p[0], 'id' => $id, 'control' => \Rooster\Admin\Ui::input($base . '_' . $k, (string) get_option($base . '_' . $k, $p[1]), array('id' => $id, 'xs' => true, 'placeholder' => $p[1])), ); } return \Rooster\Admin\Fields::compound($parts, array('label' => $label)); }; $aieo_cs_pro_notice = static function ($text) { return \Rooster\Admin\Ui::notice(esc_html($text), 'info', array( 'inline' => true, 'title' => __('Premium Feature', 'ai-eshop-optimizer'), 'actions' => \Rooster\Admin\Ui::button(__('Upgrade to Pro', 'ai-eshop-optimizer'), array('href' => 'https://rooster.systems/get-rooster-one-pro/', 'external' => true)), )); }; $aieo_cs_rerank_on = \Rooster\Admin\Ui::badge(__('Active', 'ai-eshop-optimizer'), 'success'); $aieo_cs_rerank_off = \Rooster\Admin\Ui::badge(__('Disabled', 'ai-eshop-optimizer'), 'mono'); list($aieo_cs_open, $aieo_cs_close) = $aieo_cs_card(array( 'anchor' => 'chat-step-1-api', 'icon' => 'key', 'title' => __('Step 1: API and embeddings', 'ai-eshop-optimizer'), 'description' => __('Connect the AI provider, choose what the chat indexes, and train it on your catalogue.', 'ai-eshop-optimizer'), 'footer' => $aieo_cs_lib ? \Rooster\Admin\Ui::button(__('Start Training', 'ai-eshop-optimizer'), array('attrs' => array('id' => 'aieo-chat-start-training'))) : '', ), 'aieo-chat-form-step-1'); $aieo_cs_out($aieo_cs_open); $aieo_cs_out($aieo_cs_section(__('Indexing', 'ai-eshop-optimizer'), 'aieo-card-chat-indexing', true)); $aieo_cs_index_on = class_exists('AIEO_Chat_Indexing') && AIEO_Chat_Indexing::enabled(); $aieo_cs_index_label = __('Index products and courses for the chat', 'ai-eshop-optimizer'); $aieo_cs_index_help = __('When on, the text of each published product, course and lesson, and of the content chosen below (its name, description, price, brand, categories and similar details), is sent through rooster.systems to Voyage AI to build the chat’s search index: when you start training, and again whenever one of them changes. When off, nothing is sent, and the chat cannot find products or courses.', 'ai-eshop-optimizer'); if ($aieo_cs_lib) { $aieo_cs_out('
' . \Rooster\Admin\Ui::field_row(array( 'id' => 'aieo-chat-indexing-enabled', 'label' => $aieo_cs_index_label, 'control' => \Rooster\Admin\Ui::toggle('aieo_chat_indexing_enabled', $aieo_cs_index_on, array('id' => 'aieo-chat-indexing-enabled', 'hidden' => false, 'label' => __('On', 'ai-eshop-optimizer'))), 'help' => $aieo_cs_index_help, )) . '
'); } else { $aieo_cs_out('

' . esc_html($aieo_cs_index_help) . '

'); } $aieo_cs_out($aieo_cs_section(__('Select Embedding Engine', 'ai-eshop-optimizer'), 'aieo-card-chat-embedding-engine')); $aieo_cs_out($aieo_cs_notice( 'You can train the same content with different embedding models to compare quality and search results.
' . 'Each model creates a separate set of embeddings. Products without embeddings for the selected model will be trained.', 'info', array('title' => 'Multi-Engine Support:') )); ?>
get_models('voyage', 'embedding', true); if ($current_engine && !in_array($current_engine, wp_list_pluck($voyage_embed_models, 'model_id'), true)) { foreach ($embed_model_registry->get_models('voyage', 'embedding', false) as $stale_model) { if ($stale_model->model_id === $current_engine) { $stale_model->stale = true; $voyage_embed_models[] = $stale_model; break; } } } ?>
__('What does deduplication do?', 'ai-eshop-optimizer')))); ?> ' . esc_html__('Example:', 'ai-eshop-optimizer') . '
' . esc_html__('Before:', 'ai-eshop-optimizer') . ' "The best lipstick... unique Lipstick... The lipstick that offers wet look..."
' . esc_html__('After:', 'ai-eshop-optimizer') . ' "the best lipstick unique that offers wet look"
'; $aieo_cs_out(\Rooster\Admin\Guidance::text(wp_strip_all_tags($aieo_cs_ex), 'guidance', array('html' => $aieo_cs_ex))); ?> __('Why train both modes', 'ai-eshop-optimizer')))); ?>
__('How big should a batch be?', 'ai-eshop-optimizer')))); ?>
$pt_label): if ($pt_name === 'product' && class_exists('AI_eShop_Chat_Product_Vitals_Helper')) { $vitals_helper = AI_eShop_Chat_Product_Vitals_Helper::get_instance(); if ($vitals_helper->is_vitals_table_available()) { $published_count = $vitals_helper->count_sellable_units(array('in_stock_only' => true)); } else { $published_count = AIEO_Content_Types::post_type_count($pt_name); } } else { $published_count = AIEO_Content_Types::post_type_count($pt_name); } $is_checked = in_array($pt_name, $enabled_post_types); ?>
__('Why index taxonomies?', 'ai-eshop-optimizer')))); ?>
'', 'product_tag' => '', 'category' => '', 'post_tag' => '', ); foreach (AIEO_Content_Types::taxonomies() as $tax_name => $tax_label): $tax_count = AIEO_Content_Types::taxonomy_count($tax_name); $tax_checked = in_array($tax_name, $enabled_taxonomies); $tax_icon = isset($aieo_chat_tax_icons[$tax_name]) ? $aieo_chat_tax_icons[$tax_name] : ''; ?>
__('What a taxonomy embedding holds', 'ai-eshop-optimizer')))); ?> prefix . 'aieo_core_product_vitals'; $row = $wpdb->get_row( "SELECT SUM(CASE WHEN p.post_type = 'product' AND v.product_id = v.parent_id AND v.stock > 0 AND vp.parent_id IS NULL THEN 1 ELSE 0 END) AS simple_in_stock, SUM(CASE WHEN p.post_type = 'product_variation' AND v.product_id <> v.parent_id AND v.stock > 0 THEN 1 ELSE 0 END) AS variations_in_stock, SUM(CASE WHEN p.post_type = 'product' AND v.product_id = v.parent_id AND vp.parent_id IS NOT NULL THEN 1 ELSE 0 END) AS variable_excluded FROM {$vitals_table_for_box} v INNER JOIN {$wpdb->posts} p ON v.product_id = p.ID LEFT JOIN ( SELECT DISTINCT parent_id FROM {$vitals_table_for_box} WHERE product_id <> parent_id ) vp ON vp.parent_id = v.product_id WHERE p.post_status = 'publish' AND p.post_type IN ('product', 'product_variation')", ARRAY_A ); $breakdown = array( 'simple_in_stock' => (int) ($row['simple_in_stock'] ?? 0), 'variations_in_stock' => (int) ($row['variations_in_stock'] ?? 0), 'variable_excluded' => (int) ($row['variable_excluded'] ?? 0), ); set_transient($breakdown_cache_key, $breakdown, 5 * MINUTE_IN_SECONDS); } $simple_parents_in_stock = $breakdown['simple_in_stock']; $variations_in_stock = $breakdown['variations_in_stock']; $variable_parents_excluded = $breakdown['variable_excluded']; if (($simple_parents_in_stock + $variations_in_stock) > 0): $aieo_cs_out($aieo_cs_notice( esc_html__('Each variation is embedded as its own retrievable unit, inheriting brand / description / category / customer-needs from the parent and adding its own attributes (shade, size, scent).', 'ai-eshop-optimizer') . '
' . esc_html__('Variable parents themselves are containers (not buyable on their own), so they are not embedded — the chat retrieves the specific variation a customer is looking for.', 'ai-eshop-optimizer') . '
' . esc_html__('Out-of-stock units are skipped to keep the embedding budget on items the customer can actually buy.', 'ai-eshop-optimizer'), 'info', array( 'title' => sprintf( __('Sellable units breakdown — %1$d simple products + %2$d variations (variable parents skipped: %3$d)', 'ai-eshop-optimizer'), (int) $simple_parents_in_stock, (int) $variations_in_stock, (int) $variable_parents_excluded ), ) )); endif; ?>
__('What does it hide?', 'ai-eshop-optimizer')))); ?>
' . esc_html__('Learn what these metrics mean for your business', 'ai-eshop-optimizer') . ' →'; $aieo_cs_out(\Rooster\Admin\Guidance::text(wp_strip_all_tags($aieo_cs_mx), 'guidance', array('id' => 'aieo-chat-product-priority-metric-help', 'html' => $aieo_cs_mx, 'question' => __('Which metric?', 'ai-eshop-optimizer')))); ?>
'chat-step-2-frontend', 'icon' => 'app-window', 'title' => __('Step 2: what users see', 'ai-eshop-optimizer'), 'description' => __('Which models answer visitors, and how the chat widget looks and sits on the storefront.', 'ai-eshop-optimizer'), ), 'aieo-chat-form-step-2'); $aieo_cs_out($aieo_cs_open); $aieo_cs_out($aieo_cs_section(__('Select Active Models for Frontend', 'ai-eshop-optimizer'), 'aieo-card-chat-active-models', true)); ?>
__('What the models do', 'ai-eshop-optimizer')))); ?>
prefix . 'aieo_chat_embeddings'; $trained_engines = $wpdb->get_results( "SELECT DISTINCT engine_type, deduplicated FROM {$table_name} WHERE engine_type IS NOT NULL ORDER BY engine_type, deduplicated", ARRAY_A ); $current_provider_embed = get_option('aieo_embedding_provider', 'voyage'); $current_voyage_embed = get_option('aieo_chat_embedding_model', 'voyage-2'); $current_openai_embed = get_option('aieo_chat_openai_embedding_model', 'text-embedding-3-large'); $current_dedup_mode = get_option('aieo_chat_deduplication_mode', 1); $current_embed_model = ($current_provider_embed === 'openai') ? $current_openai_embed : $current_voyage_embed; $current_selection = $current_embed_model . ':' . $current_dedup_mode; ?>

'How This Works:', 'detail' => '', ))); ?> __('What the tester does', 'ai-eshop-optimizer')))); ?>
get_models('anthropic', 'chat', false) : array(); foreach ($aieo_cs_chat_models as $tm) { $aieo_cs_tester_models[(string) $tm->model_id] = $tm->model_name . ' (' . $tm->model_id . ')'; } if (array() === $aieo_cs_tester_models) { $aieo_cs_tester_models[''] = __('No chat models available - Click "Refresh AI Models" first', 'ai-eshop-optimizer'); } $aieo_cs_param = static function ($key, $label, $value, $min, $max, $step, $on) { return \Rooster\Admin\Ui::field_row(array( 'id' => 'aieo-tester-' . $key . '-row', 'label' => $label, 'parts' => array( array('label' => __('Send', 'ai-eshop-optimizer'), 'id' => 'aieo-tester-use-' . $key, 'control' => ''), array('label' => _x('Value', 'the value of a field', 'ai-eshop-optimizer'), 'id' => 'aieo-tester-' . $key, 'control' => \Rooster\Admin\Ui::input('', $value, array('id' => 'aieo-tester-' . $key, 'type' => 'number', 'min' => $min, 'max' => $max, 'step' => $step, 'xs' => true))), ), )); }; $aieo_cs_out('
' . \Rooster\Admin\Ui::field_row(array('id' => 'aieo-tester-model', 'label' => __('Model', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::select('', $aieo_cs_tester_models, (string) $current_chat_model, array('id' => 'aieo-tester-model')))) . \Rooster\Admin\Ui::field_row(array('id' => 'aieo-tester-message', 'label' => __('Test message…', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::textarea('', 'Reply with exactly one word: hello', array('id' => 'aieo-tester-message', 'rows' => 2)))) . $aieo_cs_param('temp', 'temperature', '0.5', '0', '1', '0.1', true) . $aieo_cs_param('topp', 'top_p', '0.9', '0', '1', '0.05', false) . $aieo_cs_param('topk', 'top_k', '40', '0', '500', '1', false) . \Rooster\Admin\Ui::field_row(array('id' => 'aieo-tester-maxtokens', 'label' => 'max_tokens', 'control' => \Rooster\Admin\Ui::input('', '100', array('id' => 'aieo-tester-maxtokens', 'type' => 'number', 'min' => '1', 'max' => '2000', 'step' => '1', 'xs' => true)))) . '
'); ?>
'aieo-tester-status')); ?>
: :

                                            

                                            
'aieo-chat-model-tester'))); ?> __('Bottom Right', 'ai-eshop-optimizer'), 'bottom-centre' => __('Bottom Centre', 'ai-eshop-optimizer'), 'bottom-left' => __('Bottom Left', 'ai-eshop-optimizer'), ); $custom_icon_id = get_option('aieo_chat_floating_custom_icon', 0); $custom_icon_url = $custom_icon_id ? wp_get_attachment_image_url($custom_icon_id, 'thumbnail') : ''; $aieo_cs_icon = '' . '
' . ($custom_icon_url ? 'Custom icon' : '
') . '
' . \Rooster\Admin\Ui::button(__('Upload Icon', 'ai-eshop-optimizer'), array('variant' => 'secondary', 'attrs' => array('id' => 'aieo-upload-custom-icon'))) . ($custom_icon_id ? ' ' . \Rooster\Admin\Ui::button(__('Remove', 'ai-eshop-optimizer'), array('variant' => 'secondary', 'attrs' => array('id' => 'aieo-remove-custom-icon'))) : ''); $aieo_cs_out('
' . \Rooster\Admin\Ui::field_row(array( 'id' => 'aieo-chat-floating-position', 'label' => __('Desktop Widget Position', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::select('aieo_chat_floating_position', $aieo_cs_positions, (string) $floating_position, array('id' => 'aieo-chat-floating-position')), )) . \Rooster\Admin\Ui::field_row(array( 'id' => 'aieo-chat-floating-mobile-position', 'label' => __('Mobile Widget Position', 'ai-eshop-optimizer'), 'help' => __('Position on screens ≤768px', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::select('aieo_chat_floating_mobile_position', $aieo_cs_positions, (string) get_option('aieo_chat_floating_mobile_position', 'bottom-right'), array('id' => 'aieo-chat-floating-mobile-position')), )) . \Rooster\Admin\Ui::field_row(array( 'id' => 'aieo-chat-custom-icon', 'group' => true, 'label' => __('Custom Button Icon (SVG)', 'ai-eshop-optimizer'), 'help' => __('Recommended: 40x40px or 60x60px', 'ai-eshop-optimizer'), 'control' => $aieo_cs_icon, )) . \Rooster\Admin\Ui::field_row(array( 'id' => 'aieo-chat-floating-welcome-bubble', 'label' => __('Welcome Bubble Message', 'ai-eshop-optimizer'), 'help' => __('Shown on first visit only', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::input('aieo_chat_floating_welcome_bubble', (string) get_option('aieo_chat_floating_welcome_bubble', 'Hi! How can I help you?'), array('id' => 'aieo-chat-floating-welcome-bubble', 'placeholder' => 'Hi! How can I help you?')), )) . \Rooster\Admin\Ui::field_row(array( 'id' => 'aieo-chat-floating-popup-width', 'label' => __('Popup Width', 'ai-eshop-optimizer'), 'help' => __('Examples: 390, 50%, 80vw (320-800px for numbers)', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::input('aieo_chat_floating_popup_width', (string) get_option('aieo_chat_floating_popup_width', 390), array('id' => 'aieo-chat-floating-popup-width', 'short' => true, 'placeholder' => '390 or 50% or 80vw')), )) . \Rooster\Admin\Ui::field_row(array( 'id' => 'aieo-chat-floating-popup-height', 'label' => __('Popup Height', 'ai-eshop-optimizer'), 'help' => __('Examples: 600, 80vh, 90% (400-900px for numbers)', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::input('aieo_chat_floating_popup_height', (string) get_option('aieo_chat_floating_popup_height', 600), array('id' => 'aieo-chat-floating-popup-height', 'short' => true, 'placeholder' => '600 or 80vh or 90%')), )) . \Rooster\Admin\Ui::field_row(array( 'id' => 'aieo-chat-floating-button-color', 'label' => __('Buttons Color', 'ai-eshop-optimizer'), 'help' => __('Floating button & send button', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Fields::color('aieo_chat_floating_button_color', (string) get_option('aieo_chat_floating_button_color', '#03163c'), array('id' => 'aieo-chat-floating-button-color', 'default' => '#03163c')), )) . \Rooster\Admin\Ui::field_row(array( 'id' => 'aieo-chat-primary-color', 'label' => __('Primary Color', 'ai-eshop-optimizer'), 'help' => __('Links & user messages', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Fields::color('aieo_chat_primary_color', (string) get_option('aieo_chat_primary_color', '#45B1E8'), array('id' => 'aieo-chat-primary-color', 'default' => '#45B1E8')), )) . \Rooster\Admin\Ui::field_row(array( 'id' => 'aieo-chat-theme', 'label' => __('Chat Theme', 'ai-eshop-optimizer'), 'help' => __('Visual style of the chat interface', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::select('aieo_chat_theme', array( 'rounded' => __('Rounded (Modern with shadows)', 'ai-eshop-optimizer'), 'square' => __('Square (Clean and minimal)', 'ai-eshop-optimizer'), ), (string) get_option('aieo_chat_theme', 'rounded'), array('id' => 'aieo-chat-theme')), )) . \Rooster\Admin\Ui::field_row(array( 'id' => 'aieo-chat-btn-font-size', 'group' => true, 'label' => __('Button Font Size', 'ai-eshop-optimizer'), 'help' => __('Category buttons — Desktop / Mobile', 'ai-eshop-optimizer'), 'control' => $aieo_cs_sizes(__('Button Font Size', 'ai-eshop-optimizer'), 'aieo_chat_btn_font_size', '13px', '12px'), )) . \Rooster\Admin\Ui::field_row(array( 'id' => 'aieo-chat-text-font-size', 'group' => true, 'label' => __('Text Font Size', 'ai-eshop-optimizer'), 'help' => __('Chat messages & input — Desktop / Mobile', 'ai-eshop-optimizer'), 'control' => $aieo_cs_sizes(__('Text Font Size', 'ai-eshop-optimizer'), 'aieo_chat_text_font_size', '15px', '14px'), )) . '
'); ?> 'chat-behaviour', 'icon' => 'bot', 'title' => __('How the chat answers', 'ai-eshop-optimizer'), 'description' => __('The chatbot\'s name and greeting, how long and how creative its replies are, and how many results it gives.', 'ai-eshop-optimizer'), ), 'aieo-chat-form-behaviour'); $aieo_cs_out($aieo_cs_open); $aieo_cs_out($aieo_cs_section(__('Chat Settings', 'ai-eshop-optimizer'), 'aieo-card-chat-settings', true)); ?> ' . \Rooster\Admin\Ui::field_row(array('id' => 'aieo-chat-bot-name', 'label' => __('Chatbot Name', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::input('aieo_chat_bot_name', (string) $bot_name, array('id' => 'aieo-chat-bot-name', 'medium' => true)))) . \Rooster\Admin\Ui::field_row(array('id' => 'aieo-chat-welcome-message', 'label' => __('Welcome Message', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::textarea('aieo_chat_welcome_message', (string) $welcome_message, array('id' => 'aieo-chat-welcome-message', 'rows' => 2)))) . \Rooster\Admin\Ui::field_row(array('id' => 'aieo-chat-input-placeholder', 'label' => __('Input Placeholder', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::input('aieo_chat_input_placeholder', (string) $input_placeholder, array('id' => 'aieo-chat-input-placeholder', 'medium' => true, 'placeholder' => 'Ask about anything...')))) . \Rooster\Admin\Ui::field_row(array('id' => 'aieo-chat-max-tokens', 'label' => __('Max Tokens', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::input('aieo_chat_max_tokens', (string) $max_tokens, array('id' => 'aieo-chat-max-tokens', 'type' => 'number', 'min' => '100', 'max' => '8192', 'step' => '50', 'xs' => true)))) . \Rooster\Admin\Ui::field_row(array('id' => 'aieo-chat-temperature', 'label' => __('Temperature (Creativity)', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::input('aieo_chat_temperature', (string) $temperature, array('id' => 'aieo-chat-temperature', 'type' => 'number', 'min' => '0', 'max' => '1', 'step' => '0.1', 'xs' => true)))) . \Rooster\Admin\Ui::field_row(array('id' => 'aieo-chat-max-results', 'label' => __('Max Results', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::input('aieo_chat_max_results', (string) $max_results, array('id' => 'aieo-chat-max-results', 'type' => 'number', 'min' => '5', 'max' => '50', 'xs' => true)))) . ''); ?>






> ' . \Rooster\Admin\Ui::field_row(array('id' => 'aieo_chat_cpt_post_type_slug', 'label' => __('Post Type Slug:', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::input('aieo_chat_cpt_post_type_slug', (string) get_option('aieo_chat_cpt_post_type_slug', ''), array('id' => 'aieo_chat_cpt_post_type_slug', 'medium' => true, 'code' => true, 'placeholder' => 'e.g., listing')))) . \Rooster\Admin\Ui::field_row(array('id' => 'aieo_chat_cpt_taxonomy_slug', 'label' => __('Taxonomy Slug:', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::input('aieo_chat_cpt_taxonomy_slug', (string) get_option('aieo_chat_cpt_taxonomy_slug', ''), array('id' => 'aieo_chat_cpt_taxonomy_slug', 'medium' => true, 'code' => true, 'placeholder' => 'e.g., listing_category')))) . '
'); ?>
>
__('What the metadata adds', 'ai-eshop-optimizer')))); ?>
__('Privacy Note:', 'ai-eshop-optimizer')) )); ?>
'chat-search-ranking', 'icon' => 'list-filter', 'title' => __('Search and ranking', 'ai-eshop-optimizer'), 'description' => __('How the chat orders the products it finds, with weights that raise or lower each kind.', 'ai-eshop-optimizer'), ), 'aieo-chat-form-search'); $aieo_cs_out($aieo_cs_open); $aieo_cs_out($aieo_cs_section(__('Search Re-Ranking Weights', 'ai-eshop-optimizer'), 'aieo-card-chat-rerank-weights', true)); ?> __('How the weights work', 'ai-eshop-optimizer')))); ?>
'aieo_rerank_toggle', 'hidden' => false, 'label' => __('Enable Re-ranking', 'ai-eshop-optimizer'))); ?>
__('What if re-ranking is off?', 'ai-eshop-optimizer')))); ?>
>

' . \Rooster\Admin\Ui::field_row(array( 'id' => 'aieo-chat-rerank-preferred-brands', 'label' => __('Preferred Brands Boost', 'ai-eshop-optimizer'), 'help' => __('Enter brand names or IDs (comma-separated) to prioritize in search results. Products from these brands will receive a 1.3× boost.', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::textarea('aieo_chat_rerank_preferred_brands', (string) $rerank_preferred_brands, array('id' => 'aieo-chat-rerank-preferred-brands', 'rows' => 3, 'code' => true, 'placeholder' => __('e.g., Nike, Adidas, 123, 456', 'ai-eshop-optimizer'))), )) . '
'); ?> __('How it works:', 'ai-eshop-optimizer')) )); ?> __('What these limits do', 'ai-eshop-optimizer')))); ?>

' . \Rooster\Admin\Ui::field_row(array('id' => 'aieo-chat-min-posts', 'label' => __('Minimum Posts/Pages', 'ai-eshop-optimizer'), 'help' => __('Try to show at least this many (if available above threshold)', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::input('aieo_chat_min_posts', (string) get_option('aieo_chat_min_posts', '2'), array('id' => 'aieo-chat-min-posts', 'type' => 'number', 'min' => '0', 'max' => '20', 'step' => '1', 'xs' => true)))) . \Rooster\Admin\Ui::field_row(array('id' => 'aieo-chat-max-posts', 'label' => __('Maximum Posts/Pages', 'ai-eshop-optimizer'), 'help' => __('Never show more than this many', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::input('aieo_chat_max_posts', (string) get_option('aieo_chat_max_posts', '5'), array('id' => 'aieo-chat-max-posts', 'type' => 'number', 'min' => '0', 'max' => '50', 'step' => '1', 'xs' => true)))) . \Rooster\Admin\Ui::field_row(array('id' => 'aieo-chat-post-threshold', 'label' => __('Post/Page Similarity Threshold (%)', 'ai-eshop-optimizer'), 'help' => __('Only show posts/pages with similarity above this %', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::input('aieo_chat_post_threshold', (string) get_option('aieo_chat_post_threshold', '50'), array('id' => 'aieo-chat-post-threshold', 'type' => 'number', 'min' => '0', 'max' => '100', 'step' => '1', 'xs' => true, 'unit' => '%')))) . ''); ?>

' . \Rooster\Admin\Ui::field_row(array('id' => 'aieo-chat-min-products', 'label' => __('Minimum Products', 'ai-eshop-optimizer'), 'help' => __('Try to show at least this many (if available above threshold)', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::input('aieo_chat_min_products', (string) get_option('aieo_chat_min_products', '3'), array('id' => 'aieo-chat-min-products', 'type' => 'number', 'min' => '0', 'max' => '20', 'step' => '1', 'xs' => true)))) . \Rooster\Admin\Ui::field_row(array('id' => 'aieo-chat-max-products', 'label' => __('Maximum Products', 'ai-eshop-optimizer'), 'help' => __('Never show more than this many', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::input('aieo_chat_max_products', (string) get_option('aieo_chat_max_products', '10'), array('id' => 'aieo-chat-max-products', 'type' => 'number', 'min' => '0', 'max' => '50', 'step' => '1', 'xs' => true)))) . \Rooster\Admin\Ui::field_row(array('id' => 'aieo-chat-product-threshold', 'label' => __('Product Similarity Threshold (%)', 'ai-eshop-optimizer'), 'help' => __('Only show products with similarity above this %', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::input('aieo_chat_product_threshold', (string) get_option('aieo_chat_product_threshold', '50'), array('id' => 'aieo-chat-product-threshold', 'type' => 'number', 'min' => '0', 'max' => '100', 'step' => '1', 'xs' => true, 'unit' => '%')))) . ''); ?> ' . esc_html__('Min Posts: 2, Max Posts: 5, Threshold: 80%', 'ai-eshop-optimizer') . '

' . esc_html__('If search finds 1 post at 85% and 2 products at 75%, only those will display.', 'ai-eshop-optimizer') . '
' . wp_kses_post(__('Quality over quantity! Won\'t force minimums if items don\'t meet thresholds.', 'ai-eshop-optimizer')), 'info', array('title' => trim((string) preg_replace('/^\x{1F4A1}\s*/u', '', __('Example:', 'ai-eshop-optimizer')))) )); ?> __('What testing mode does', 'ai-eshop-optimizer')))); ?>
__('What happens when it is on?', 'ai-eshop-optimizer')))); ?>
'chat-knowledge-base', 'icon' => 'book-open-check', 'title' => __('Step 3: business knowledge', 'ai-eshop-optimizer'), 'description' => __('The facts about your shop the chat always knows, such as locations, hours, shipping and returns.', 'ai-eshop-optimizer'), ), 'aieo-chat-form-knowledge'); $aieo_cs_out($aieo_cs_open); $aieo_cs_out($aieo_cs_section(__('Business Knowledge Base', 'ai-eshop-optimizer'), 'aieo-card-chat-business-kb', true)); $aieo_cs_out($aieo_cs_notice( wp_kses_post(__('Why use this? Customers often ask about store locations, opening hours, shipping costs, and return policies. This information is always included in the AI context, ensuring accurate answers without relying on embedding similarity.', 'ai-eshop-optimizer')), 'info' )); $business_info_enabled = class_exists('AI_eShop_Chat_Business_Info_Manager'); $business_counts = array(); if ($business_info_enabled) { $business_manager = AI_eShop_Chat_Business_Info_Manager::get_instance(); if ($business_manager->table_exists()) { $business_counts = $business_manager->get_counts_by_type(); } } $total_entries = array_sum($business_counts); ?>

__('Why define the identity', 'ai-eshop-optimizer')))); ?>

' . \Rooster\Admin\Ui::field_row(array( 'id' => 'aieo-chat-site-identity-is', 'label' => __('What this site IS:', 'ai-eshop-optimizer'), 'help' => __('Describe what your business/site actually is. This helps the AI use correct terminology.', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::textarea('aieo_chat_site_identity_is', (string) get_option('aieo_chat_site_identity_is', ''), array('id' => 'aieo-chat-site-identity-is', 'rows' => 2, 'placeholder' => __('e.g., A medical clinic specializing in dermatology, A professional photography studio, An organic food store...', 'ai-eshop-optimizer'))), )) . \Rooster\Admin\Ui::field_row(array( 'id' => 'aieo-chat-site-identity-is-not', 'label' => __('What this site is NOT:', 'ai-eshop-optimizer'), 'help' => __('List terms the AI should NEVER use to describe your business. Prevents misidentification.', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::textarea('aieo_chat_site_identity_is_not', (string) get_option('aieo_chat_site_identity_is_not', ''), array('id' => 'aieo-chat-site-identity-is-not', 'rows' => 2, 'placeholder' => __('e.g., Not a shop, Not a restaurant, Not a retail store...', 'ai-eshop-optimizer'))), )) . ''); ?> __('Store Location', 'ai-eshop-optimizer'), 'opening_hours' => __('Opening Hours', 'ai-eshop-optimizer'), 'shipping' => __('Shipping Information', 'ai-eshop-optimizer'), 'contact' => __('Contact Information', 'ai-eshop-optimizer'), 'returns' => __('Returns & Refunds', 'ai-eshop-optimizer'), 'faq' => __('FAQ Entry', 'ai-eshop-optimizer'), 'custom' => __('Custom Information', 'ai-eshop-optimizer'), ); $aieo_cs_out('
' . \Rooster\Admin\Ui::field_row(array('id' => 'aieo-business-info-type', 'label' => __('Information Type:', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::select('', $aieo_cs_info_types, 'store_location', array('id' => 'aieo-business-info-type')))) . \Rooster\Admin\Ui::field_row(array('id' => 'aieo-business-info-title', 'label' => __('Title:', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::input('', '', array('id' => 'aieo-business-info-title', 'medium' => true, 'placeholder' => __('e.g., Athens Store, Monday Hours, Standard Shipping', 'ai-eshop-optimizer'))))) . \Rooster\Admin\Ui::field_row(array( 'id' => 'aieo-business-info-content', 'label' => __('Content:', 'ai-eshop-optimizer'), 'help' => __('Write in a natural, informative style. This text will be directly available to the AI when answering customer questions.', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::textarea('', '', array('id' => 'aieo-business-info-content', 'rows' => 4, 'placeholder' => __('Enter the information that the AI should know and share with customers...', 'ai-eshop-optimizer'))), )) . \Rooster\Admin\Ui::field_row(array('id' => 'aieo-business-info-priority', 'label' => __('Priority:', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::select('', array( 'normal' => __('Normal', 'ai-eshop-optimizer'), 'high' => __('High (important info)', 'ai-eshop-optimizer'), 'critical' => __('Critical (always mention)', 'ai-eshop-optimizer'), ), 'normal', array('id' => 'aieo-business-info-priority')))) . '
' . '

' . \Rooster\Admin\Ui::button(__('Add Business Information', 'ai-eshop-optimizer'), array('variant' => 'secondary', 'icon' => 'plus', 'attrs' => array('id' => 'aieo-save-business-info'))) . '

'); ?>
0; } else { global $wpdb; $aieo_trs_table = $wpdb->prefix . 'aieo_dmm_shipping_rates'; if ( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $aieo_trs_table ) ) === $aieo_trs_table ) { $aieo_trs_active = ( (int) $wpdb->get_var( 'SELECT COUNT(*) FROM `' . $aieo_trs_table . '`' ) ) > 0; } } $wc_table_rates_active = class_exists( 'WC_Table_Rate_Shipping' ); $table_rates_active = $aieo_trs_active || $wc_table_rates_active; ?> ' . \Rooster\Admin\Ui::badge($table_rates_active ? __('Detected', 'ai-eshop-optimizer') : __('Not Configured', 'ai-eshop-optimizer'), $table_rates_active ? 'success' : 'mono') . '

'); } ?> Postal Code Shipping Rates (Operations → Couriers → Postal Code Shipping Rates) are active. You can automatically sync your shipping zones, rates, and conditions into the AI knowledge base.', 'ai-eshop-optimizer')) : wp_kses_post(__('WooCommerce Table Rate Shipping plugin detected! You can automatically sync your shipping zones, rates, and conditions into the AI knowledge base.', 'ai-eshop-optimizer')), 'success' )); ?>

'aieo-shipping-sync-status')); ?>

__('What gets synced:', 'ai-eshop-optimizer'), 'detail' => '', ))); ?> Postal Code Shipping Rates were found yet. Set them up under Operations → Couriers → Postal Code Shipping Rates (or install the WooCommerce Table Rate Shipping plugin) and the AI can automatically learn your shipping costs and conditions.', 'ai-eshop-optimizer')), 'warning' )); ?> __('Adding shipping by hand', 'ai-eshop-optimizer')))); ?> __('What to import', 'ai-eshop-optimizer')))); ?> __('-- Select a page --', 'ai-eshop-optimizer')); foreach (get_pages(array('sort_column' => 'post_title', 'sort_order' => 'ASC')) as $page) { $aieo_cs_import_pages[(string) $page->ID] = $page->post_title; } $aieo_cs_out('
' . \Rooster\Admin\Ui::field_row(array('id' => 'aieo-import-page-select', 'label' => __('Select Page:', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::select('', $aieo_cs_import_pages, '', array('id' => 'aieo-import-page-select')))) . \Rooster\Admin\Ui::field_row(array('id' => 'aieo-import-info-type', 'label' => __('Import as Type:', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::select('', $aieo_cs_info_types, 'store_location', array('id' => 'aieo-import-info-type')))) . '
'); ?>

__('After the import', 'ai-eshop-optimizer')))); ?> 'chat-analytics', 'icon' => 'chart-line', 'title' => __('Chat Analytics and Database Status', 'ai-eshop-optimizer'), 'description' => __('How much the chat is used, and the state of its training data and stored conversations.', 'ai-eshop-optimizer'), ), 'aieo-chat-form-analytics'); $aieo_cs_out($aieo_cs_open); $aieo_cs_out($aieo_cs_section(__('Chat Statistics', 'ai-eshop-optimizer'), 'aieo-card-chat-statistics', true)); ?> __('What the statistics show', 'ai-eshop-optimizer')))); ?>

__('What you manage here', 'ai-eshop-optimizer')))); ?>

0): ?>
' . \Rooster\Admin\Ui::field_row(array( 'id' => 'aieo-chat-delete-engine-filter', 'label' => __('Filter by Embedding Engine:', 'ai-eshop-optimizer'), 'help' => __('Select a specific engine+mode combination to delete only those embeddings, keeping others intact.', 'ai-eshop-optimizer'), 'control' => \Rooster\Admin\Ui::select('', array('' => __('Loading available engines...', 'ai-eshop-optimizer')), '', array('id' => 'aieo-chat-delete-engine-filter')), )) . '
'); ?>

'Products', 'product_variation' => 'Product Variations', 'post' => 'Blog Posts', 'page' => 'Pages' ); ?> $count): ?>
'aieo-chat-delete-fold'))); $aieo_cs_out(\Rooster\Admin\States::confirm( 'aieo-chat-delete-selected-confirm', 'delete', __('Delete these embeddings?', 'ai-eshop-optimizer'), '

' . esc_html__('Are you sure you want to delete embeddings for:', 'ai-eshop-optimizer') . '

' . '

' . esc_html__('This cannot be undone. You will need to retrain these content types.', 'ai-eshop-optimizer') . '

', array('confirm' => __('Delete Selected', 'ai-eshop-optimizer')) )); $aieo_cs_out(\Rooster\Admin\States::confirm( 'aieo-chat-delete-all-confirm', 'loss', __('Delete all embeddings?', 'ai-eshop-optimizer'), '

' . esc_html__('Are you sure you want to delete ALL embeddings of ALL types for ALL engines? This cannot be undone. You will need to retrain everything.', 'ai-eshop-optimizer') . '

', array('confirm' => __('Delete All', 'ai-eshop-optimizer')) )); ?>
__('What automation does', 'ai-eshop-optimizer')))); $aieo_cs_auto_row = static function ($key, $label, $help) use ($is_pro_user) { $row = 'aieo-auto-' . $key; $off = !$is_pro_user; $field = array( 'id' => $row, 'label' => $label, 'parts' => array( array( 'label' => __('Enabled', 'ai-eshop-optimizer'), 'id' => 'aieo_auto_' . $key . '_enabled', 'control' => \Rooster\Admin\Ui::toggle('aieo_auto_' . $key . '_enabled', (bool) get_option('aieo_auto_' . $key . '_enabled', 0), array( 'id' => 'aieo_auto_' . $key . '_enabled', 'hidden' => false, 'disabled' => $off, )), ), array( 'label' => __('Frequency:', 'ai-eshop-optimizer'), 'id' => 'aieo_auto_' . $key . '_frequency', 'control' => \Rooster\Admin\Ui::select('aieo_auto_' . $key . '_frequency', array( 'daily' => __('Daily', 'ai-eshop-optimizer'), 'weekly' => __('Weekly', 'ai-eshop-optimizer'), 'monthly' => __('Monthly', 'ai-eshop-optimizer'), ), (string) get_option('aieo_auto_' . $key . '_frequency', 'weekly'), array( 'id' => 'aieo_auto_' . $key . '_frequency', 'disabled' => $off, 'aria-label' => $label . ', ' . __('Frequency:', 'ai-eshop-optimizer'), )), ), array( 'label' => __('Time (HH:MM):', 'ai-eshop-optimizer'), 'id' => 'aieo_auto_' . $key . '_time', 'control' => \Rooster\Admin\Ui::input('aieo_auto_' . $key . '_time', (string) get_option('aieo_auto_' . $key . '_time', '03:00'), array( 'id' => 'aieo_auto_' . $key . '_time', 'type' => 'time', 'disabled' => $off, )), ), ), 'help' => $help, ); if ($off) { $field['reason'] = __('This feature requires the Pro version.', 'ai-eshop-optimizer'); } return \Rooster\Admin\Ui::field_row($field); }; $aieo_cs_out( '
' . $aieo_cs_auto_row('analytics', __('Automatically update product and order analytics', 'ai-eshop-optimizer'), __('Runs the "Save Settings & Analyze Data" process automatically.', 'ai-eshop-optimizer')) . $aieo_cs_auto_row('embeddings', __('Automatically generate embeddings', 'ai-eshop-optimizer'), __('Uses currently selected embedding engine and deduplication mode.', 'ai-eshop-optimizer')) . '
' ); ?> __('Automation Status:', 'ai-eshop-optimizer')))); ?>

true))); ?>
'aieo-chat-training-progress', 'label' => __('Progress', 'ai-eshop-optimizer'), 'show_value' => true)) . '

' . esc_html__('Initializing...', 'ai-eshop-optimizer') . '

' . '
', array( 'wide' => true, 'footer' => \Rooster\Admin\Ui::button(__('Processing...', 'ai-eshop-optimizer'), array('class' => 'aieo-chat-training-modal-close')), ) ) . \Rooster\Admin\States::confirm( 'aieo-chat-training-cancel-confirm', 'reset', __('Cancel the training?', 'ai-eshop-optimizer'), '

' . esc_html__('Are you sure you want to cancel the training? Progress will be saved but remaining items will not be processed.', 'ai-eshop-optimizer') . '

', array('confirm' => __('Stop training', 'ai-eshop-optimizer'), 'cancel' => __('Keep training', 'ai-eshop-optimizer')) ); echo $aieo_cs_training; ?>