Changeset 3441628
- Timestamp:
- 01/17/2026 03:25:29 PM (2 months ago)
- Location:
- ai-search
- Files:
-
- 24 added
- 4 edited
-
tags/1.12.0 (added)
-
tags/1.12.0/admin (added)
-
tags/1.12.0/admin/class-admin-manager.php (added)
-
tags/1.12.0/admin/class-settings-pages.php (added)
-
tags/1.12.0/admin/class-setup-wizard.php (added)
-
tags/1.12.0/admin/css (added)
-
tags/1.12.0/admin/css/admin-settings.css (added)
-
tags/1.12.0/admin/views (added)
-
tags/1.12.0/admin/views/settings-cache.php (added)
-
tags/1.12.0/admin/views/settings-custom-fields.php (added)
-
tags/1.12.0/admin/views/settings-embeddings.php (added)
-
tags/1.12.0/admin/views/settings-general.php (added)
-
tags/1.12.0/admin/views/settings-woocommerce.php (added)
-
tags/1.12.0/admin/views/wizard (added)
-
tags/1.12.0/admin/views/wizard/completion.php (added)
-
tags/1.12.0/admin/views/wizard/step-final.php (added)
-
tags/1.12.0/admin/views/wizard/step-provider.php (added)
-
tags/1.12.0/admin/views/wizard/step-welcome.php (added)
-
tags/1.12.0/ai-search.php (added)
-
tags/1.12.0/assets (added)
-
tags/1.12.0/assets/icon.svg (added)
-
tags/1.12.0/includes (added)
-
tags/1.12.0/includes/class-ai-search-service.php (added)
-
tags/1.12.0/readme.txt (added)
-
trunk/admin/class-setup-wizard.php (modified) (1 diff)
-
trunk/admin/views/settings-general.php (modified) (5 diffs)
-
trunk/ai-search.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ai-search/trunk/admin/class-setup-wizard.php
r3419047 r3441628 218 218 } 219 219 220 /**221 * Plugin activation handler222 */223 public static function activate_plugin() {224 // Set flag to show setup wizard225 update_option( 'ai_search_show_setup_wizard', true );226 227 // Set default settings228 add_option( 'ai_search_provider', 'ai_service' );229 add_option( 'ai_search_similarity_threshold', 0.5 );230 231 // Set activation redirect flag232 update_option( 'ai_search_activation_redirect', true );233 }234 220 } -
ai-search/trunk/admin/views/settings-general.php
r3434325 r3441628 12 12 $badge_public = get_option( 'ai_search_badge_public', false ); 13 13 14 // Handle token validationmessages14 // Handle connection check messages 15 15 if ( isset( $_GET['token_validation'] ) ) { 16 16 $validation_status = sanitize_text_field( $_GET['token_validation'] ); 17 17 18 18 if ( $validation_status === 'success' ) { 19 19 $validation_data = get_transient( 'ai_search_validation_data' ); 20 20 if ( $validation_data ) { 21 echo '<div class=" updated"><p><strong>Token Validation Successful!</strong></p>';21 echo '<div class="notice notice-success"><p><strong>Connection successful!</strong> AI Search Service is working correctly.</p>'; 22 22 if ( isset( $validation_data['client'] ) ) { 23 23 $client = $validation_data['client']; 24 echo '<ul style="margin-left: 20px;">'; 25 echo '<li><strong>Client ID:</strong> ' . esc_html( $client['id'] ?? 'N/A' ) . '</li>'; 26 echo '<li><strong>Origin:</strong> ' . esc_html( $client['origin'] ?? 'N/A' ) . '</li>'; 27 echo '<li><strong>Daily Limit:</strong> ' . esc_html( number_format( $client['daily_limit'] ?? 0 ) ) . '</li>'; 28 echo '<li><strong>Total Limit:</strong> ' . esc_html( number_format( $client['total_limit'] ?? 0 ) ) . '</li>'; 29 echo '<li><strong>Used Daily:</strong> ' . esc_html( number_format( $client['used_daily'] ?? 0 ) ) . '</li>'; 30 echo '<li><strong>Used Total:</strong> ' . esc_html( number_format( $client['used_total'] ?? 0 ) ) . '</li>'; 31 echo '<li><strong>Quotas Exceeded:</strong> ' . ( 32 isset( $client['quotas_exceeded']['daily'] ) && $client['quotas_exceeded']['daily'] ? 'Daily' : '' 33 ) . ( 34 isset( $client['quotas_exceeded']['total'] ) && $client['quotas_exceeded']['total'] ? ' Total' : '' 35 ) . ( 36 !( $client['quotas_exceeded']['daily'] ?? false ) && !( $client['quotas_exceeded']['total'] ?? false ) ? 'None' : '' 37 ) . '</li>'; 38 echo '</ul>'; 24 $used_total = intval( $client['used_total'] ?? 0 ); 25 $total_limit = intval( $client['total_limit'] ?? 10000 ); 26 $remaining = $total_limit - $used_total; 27 echo '<p>Embeddings used: <strong>' . esc_html( number_format( $used_total ) ) . '</strong> / ' . esc_html( number_format( $total_limit ) ) . ' (' . esc_html( number_format( $remaining ) ) . ' remaining)</p>'; 39 28 } 40 29 echo '</div>'; … … 43 32 } elseif ( $validation_status === 'invalid' ) { 44 33 $error_data = get_transient( 'ai_search_validation_error' ); 45 echo '<div class=" error"><p><strong>Token Validation Failed!</strong></p>';34 echo '<div class="notice notice-error"><p><strong>Connection failed!</strong></p>'; 46 35 if ( $error_data && isset( $error_data['details'] ) ) { 47 echo '<p> Error:' . esc_html( $error_data['details'] ) . '</p>';36 echo '<p>' . esc_html( $error_data['details'] ) . '</p>'; 48 37 } 49 38 echo '</div>'; 50 39 delete_transient( 'ai_search_validation_error' ); 51 40 } elseif ( $validation_status === 'error' ) { 52 echo '<div class=" error"><p><strong>Token Validation Error!</strong> Unable to connect to AI Search Service.</p></div>';41 echo '<div class="notice notice-error"><p><strong>Connection failed!</strong> Unable to reach AI Search Service. Please try again later.</p></div>'; 53 42 } elseif ( $validation_status === 'no_token' ) { 54 echo '<div class=" error"><p><strong>No Token Found!</strong> Please save your settings first to generate a service token.</p></div>';43 echo '<div class="notice notice-warning"><p><strong>Not registered.</strong> Please save your settings to register with the AI Search Service.</p></div>'; 55 44 } 56 45 } … … 68 57 update_option( 'ai_search_similarity_threshold', floatval( $_POST['similarity_threshold'] ) ); 69 58 70 // Save service token if provided71 if ( isset( $_POST['service_token'] ) ) {72 update_option( 'ai_search_service_token', sanitize_text_field( wp_unslash( $_POST['service_token'] ) ) );73 }74 75 59 // Save badge public visibility option 76 60 update_option( 'ai_search_badge_public', isset( $_POST['badge_public'] ) && $_POST['badge_public'] === '1' ); … … 111 95 112 96 <div id="service-token-container" style="display: <?php echo ( $provider === 'ai_service' ? 'block' : 'none' ); ?>;"> 113 <label for="service_token">AI Search Service Token:</label><br>114 <input type="text" id="service_token" name="service_token" value="<?php echo esc_attr( $service_token ); ?>" style="width: 100%; max-width: 400px;" />115 <p><em>This token is automatically generated when you select the AI Service. You can manually update it if needed.</em></p>116 117 97 <?php if ( ! empty( $service_token ) ) : ?> 118 <div style="margin-top: 10px;"> 119 <button type="button" id="validate-token-btn" class="button button-secondary">Validate Token</button> 120 <span id="validation-spinner" style="display: none; margin-left: 10px;">Validating...</span> 121 <p><em>Click to validate your token and check usage statistics.</em></p> 98 <div class="ai-search-connection-status" style="background: #f0f6fc; padding: 15px; border-radius: 4px; border-left: 4px solid #2271b1;"> 99 <p style="margin: 0 0 10px 0;"><strong>Status:</strong> Registered with AI Search Service</p> 100 <button type="button" id="check-connection-btn" class="button button-secondary">Check Connection</button> 101 <span id="connection-spinner" style="display: none; margin-left: 10px;">Checking...</span> 102 </div> 103 <?php else : ?> 104 <div class="ai-search-connection-status" style="background: #fff3cd; padding: 15px; border-radius: 4px; border-left: 4px solid #856404;"> 105 <p style="margin: 0;"><strong>Status:</strong> Not registered. Save settings to register automatically.</p> 122 106 </div> 123 107 <?php endif; ?> … … 359 343 } 360 344 361 var validateBtn = document.getElementById("validate-token-btn");362 if ( validateBtn) {363 validateBtn.addEventListener("click", function() {364 var spinner = document.getElementById(" validation-spinner");365 validateBtn.disabled = true;345 var checkConnectionBtn = document.getElementById("check-connection-btn"); 346 if (checkConnectionBtn) { 347 checkConnectionBtn.addEventListener("click", function() { 348 var spinner = document.getElementById("connection-spinner"); 349 checkConnectionBtn.disabled = true; 366 350 spinner.style.display = "inline"; 367 351 368 352 // Create a form and submit it 369 353 var form = document.createElement("form"); 370 354 form.method = "POST"; 371 355 form.action = "<?php echo esc_url( admin_url( 'admin-post.php?action=ai_search_validate_token' ) ); ?>"; 372 356 373 357 var nonceField = document.createElement("input"); 374 358 nonceField.type = "hidden"; 375 359 nonceField.name = "_wpnonce"; 376 360 nonceField.value = "<?php echo wp_create_nonce( 'ai_search_validate_token' ); ?>"; 377 361 378 362 form.appendChild(nonceField); 379 363 document.body.appendChild(form); -
ai-search/trunk/ai-search.php
r3434325 r3441628 3 3 * Plugin Name: AI Search 4 4 * Description: Replaces the default search with an intelligent search system. 5 * Version: 1.1 1.05 * Version: 1.12.0 6 6 * Author: Samuel Silva 7 7 * Author URI: https://samuelsilva.pt … … 17 17 18 18 // Define plugin constants 19 define( 'AI_SEARCH_VERSION', '1.1 1.0' );19 define( 'AI_SEARCH_VERSION', '1.12.0' ); 20 20 define( 'AI_SEARCH_PATH', plugin_dir_path( __FILE__ ) ); 21 21 define( 'AI_SEARCH_URL', plugin_dir_url( __FILE__ ) ); … … 39 39 * Plugin version. 40 40 */ 41 const VERSION = '1.1 1.0';41 const VERSION = '1.12.0'; 42 42 43 43 /** … … 787 787 788 788 // Plugin activation hook 789 register_activation_hook( __FILE__, function() { 789 register_activation_hook( __FILE__, 'ai_search_activate_plugin' ); 790 791 /** 792 * Plugin activation handler. 793 */ 794 function ai_search_activate_plugin() { 790 795 // Set default settings 791 796 add_option( 'ai_search_provider', 'ai_service' ); 792 797 add_option( 'ai_search_similarity_threshold', 0.5 ); 793 } ); 798 799 // Set flag to show setup wizard 800 update_option( 'ai_search_show_setup_wizard', true ); 801 802 // Register origin with AI Search Service immediately 803 require_once plugin_dir_path( __FILE__ ) . 'includes/class-ai-search-service.php'; 804 $service_client = new AI_Search_Service(); 805 $service_token = $service_client->register_origin(); 806 if ( $service_token ) { 807 update_option( 'ai_search_service_token', $service_token ); 808 } 809 810 // Set activation redirect flag 811 set_transient( 'ai_search_activation_redirect', true, 30 ); 812 } 813 814 // Handle activation redirect 815 add_action( 'admin_init', 'ai_search_activation_redirect' ); 816 817 /** 818 * Redirect to setup wizard after plugin activation. 819 */ 820 function ai_search_activation_redirect() { 821 // Check if we should redirect 822 if ( ! get_transient( 'ai_search_activation_redirect' ) ) { 823 return; 824 } 825 826 // Delete the transient so we don't redirect again 827 delete_transient( 'ai_search_activation_redirect' ); 828 829 // Don't redirect if activating multiple plugins or doing bulk action 830 if ( isset( $_GET['activate-multi'] ) || ! current_user_can( 'manage_options' ) ) { 831 return; 832 } 833 834 // Don't redirect if setup was already completed 835 if ( get_option( 'ai_search_setup_completed', false ) ) { 836 return; 837 } 838 839 // Redirect to setup wizard 840 wp_safe_redirect( admin_url( 'options-general.php?page=ai-search&setup=wizard' ) ); 841 exit; 842 } 794 843 795 844 // Initialize the plugin. -
ai-search/trunk/readme.txt
r3434325 r3441628 3 3 Tags: search, AI, semantic search, WooCommerce, ecommerce, product search, smart search, OpenAI 4 4 Tested up to: 6.8 5 Stable tag: 1.1 1.05 Stable tag: 1.12.0 6 6 Requires PHP: 8.0 7 7 License: GPLv2 … … 87 87 88 88 == Changelog == 89 90 = 1.12.0 = 91 - **Automatic Service Registration**: Plugin now registers with AI Search Service immediately on activation 92 - **Setup Wizard Redirect**: Users are automatically redirected to the setup wizard after plugin activation 93 - **Simplified Settings UI**: Removed service token field from settings - connection is now managed automatically 94 - **Check Connection Button**: Replaced "Validate Token" with cleaner "Check Connection" button showing usage stats 95 - **Streamlined Onboarding**: Better first-time user experience with automatic configuration 96 - **Code Cleanup**: Removed unused spelling suggestions and search highlighter classes 89 97 90 98 = 1.11.0 =
Note: See TracChangeset
for help on using the changeset viewer.