| @@ -2,9 +2,9 @@ | ||
| 2 | 2 | /** |
| 3 | 3 | * Plugin Name: MxChat |
| 4 | 4 | * Plugin URI: https://mxchat.ai/ |
| 5 | 5 | * Description: AI chatbot for WordPress with OpenAI, Claude, xAI, DeepSeek, live agent, PDF uploads, WooCommerce, and training on website data. |
| 6 | - * Version: 3.2.3 | |
| 6 | + * Version: 3.1.4 | |
| 7 | 7 | * Author: MxChat |
| 8 | 8 | * Author URI: https://mxchat.ai |
| 9 | 9 | * License: GPLv2 or later |
| 10 | 10 | * License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| @@ -608,54 +608,8 @@ | ||
| 608 | 608 | update_option('mxchat_content_type_migration_version', '2.5.6'); |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | /** |
| 612 | - * 3.2.3: Add embedding_model column to KB and intent tables so we can detect | |
| 613 | - * when the active embedding model is changed while content is already embedded. | |
| 614 | - */ | |
| 615 | -function mxchat_add_embedding_model_columns() { | |
| 616 | - global $wpdb; | |
| 617 | - | |
| 618 | - $migration_version = get_option('mxchat_embedding_model_migration_version', '0'); | |
| 619 | - if (version_compare($migration_version, '3.2.3', '>=')) { | |
| 620 | - return; | |
| 621 | - } | |
| 622 | - | |
| 623 | - $tables = array( | |
| 624 | - $wpdb->prefix . 'mxchat_system_prompt_content', | |
| 625 | - $wpdb->prefix . 'mxchat_intents', | |
| 626 | - $wpdb->prefix . 'mxchat_intent_phrases', | |
| 627 | - ); | |
| 628 | - | |
| 629 | - foreach ($tables as $table) { | |
| 630 | - if ($wpdb->get_var("SHOW TABLES LIKE '{$table}'") !== $table) { | |
| 631 | - continue; | |
| 632 | - } | |
| 633 | - $col_exists = $wpdb->get_results("SHOW COLUMNS FROM {$table} LIKE 'embedding_model'"); | |
| 634 | - if (empty($col_exists)) { | |
| 635 | - $wpdb->query("ALTER TABLE {$table} ADD COLUMN embedding_model VARCHAR(64) DEFAULT NULL"); | |
| 636 | - } | |
| 637 | - } | |
| 638 | - | |
| 639 | - // Best-effort backfill: if any existing content lacks a stamped model, assume | |
| 640 | - // it was embedded with whatever model is currently selected. This is the | |
| 641 | - // safest assumption for installations upgrading to 3.2.3 — if it was wrong | |
| 642 | - // already, the mismatch detection will surface it on the next switch. | |
| 643 | - $options = get_option('mxchat_options', array()); | |
| 644 | - $current_model = $options['embedding_model'] ?? 'text-embedding-ada-002'; | |
| 645 | - | |
| 646 | - if (get_option('mxchat_active_embedding_model', '') === '') { | |
| 647 | - $kb_table = $wpdb->prefix . 'mxchat_system_prompt_content'; | |
| 648 | - $kb_count = (int) $wpdb->get_var("SELECT COUNT(*) FROM {$kb_table}"); | |
| 649 | - if ($kb_count > 0) { | |
| 650 | - update_option('mxchat_active_embedding_model', $current_model, false); | |
| 651 | - } | |
| 652 | - } | |
| 653 | - | |
| 654 | - update_option('mxchat_embedding_model_migration_version', '3.2.3'); | |
| 655 | -} | |
| 656 | - | |
| 657 | -/** | |
| 658 | 612 | * 2.5.2: Create queue processing tables for reliable background processing |
| 659 | 613 | */ |
| 660 | 614 | function mxchat_create_queue_tables() { |
| 661 | 615 | global $wpdb; |
| @@ -787,9 +741,9 @@ | ||
| 787 | 741 | if (in_array($current_model, $deprecated_claude_models, true)) { |
| 788 | 742 | $options['model'] = 'claude-opus-4-6'; |
| 789 | 743 | $migrated = true; |
| 790 | 744 | $migration_message = sprintf( |
| 791 | - 'Your chatbot model has been automatically updated from %s to Claude Opus 4.6 due to Anthropic deprecating older Claude models.', | |
| 745 | + __('Your chatbot model has been automatically updated from %s to Claude Opus 4.6 due to Anthropic deprecating older Claude models.', 'mxchat'), | |
| 792 | 746 | $current_model |
| 793 | 747 | ); |
| 794 | 748 | } |
| 795 | 749 | |
| @@ -796,9 +750,9 @@ | ||
| 796 | 750 | // Migrate deprecated Claude Haiku 3.5 to Claude Haiku 4.5 |
| 797 | 751 | if ($current_model === 'claude-3-5-haiku-20241022') { |
| 798 | 752 | $options['model'] = 'claude-haiku-4-5-20251001'; |
| 799 | 753 | $migrated = true; |
| 800 | - $migration_message = 'Your chatbot model has been automatically updated from Claude Haiku 3.5 to Claude Haiku 4.5 due to Anthropic deprecating the older model.'; | |
| 754 | + $migration_message = __('Your chatbot model has been automatically updated from Claude Haiku 3.5 to Claude Haiku 4.5 due to Anthropic deprecating the older model.', 'mxchat'); | |
| 801 | 755 | } |
| 802 | 756 | |
| 803 | 757 | // Migrate deprecated GPT-4 series and GPT-3.5 Turbo to GPT-5.1 Chat Latest |
| 804 | 758 | if (in_array($current_model, array('gpt-4o', 'gpt-4.1-2025-04-14', 'gpt-4-turbo', 'gpt-4', 'gpt-3.5-turbo'), true)) { |
| @@ -804,9 +758,9 @@ | ||
| 804 | 758 | if (in_array($current_model, array('gpt-4o', 'gpt-4.1-2025-04-14', 'gpt-4-turbo', 'gpt-4', 'gpt-3.5-turbo'), true)) { |
| 805 | 759 | $options['model'] = 'gpt-5.1-chat-latest'; |
| 806 | 760 | $migrated = true; |
| 807 | 761 | $migration_message = sprintf( |
| 808 | - 'Your chatbot model has been automatically updated from %s to GPT-5.1 Chat Latest due to OpenAI deprecating older models.', | |
| 762 | + __('Your chatbot model has been automatically updated from %s to GPT-5.1 Chat Latest due to OpenAI deprecating older models.', 'mxchat'), | |
| 809 | 763 | $current_model |
| 810 | 764 | ); |
| 811 | 765 | } |
| 812 | 766 | |
| @@ -814,9 +768,9 @@ | ||
| 814 | 768 | if (in_array($current_model, array('gpt-4o-mini', 'gpt-4.1-mini'), true)) { |
| 815 | 769 | $options['model'] = 'gpt-5-mini'; |
| 816 | 770 | $migrated = true; |
| 817 | 771 | $migration_message = sprintf( |
| 818 | - 'Your chatbot model has been automatically updated from %s to GPT-5 Mini due to OpenAI deprecating GPT-4 series models.', | |
| 772 | + __('Your chatbot model has been automatically updated from %s to GPT-5 Mini due to OpenAI deprecating GPT-4 series models.', 'mxchat'), | |
| 819 | 773 | $current_model |
| 820 | 774 | ); |
| 821 | 775 | } |
| 822 | 776 | |
| @@ -864,9 +818,8 @@ | ||
| 864 | 818 | embedding_vector LONGTEXT, |
| 865 | 819 | source_url TEXT DEFAULT NULL, |
| 866 | 820 | role_restriction VARCHAR(50) DEFAULT 'public', |
| 867 | 821 | content_type VARCHAR(50) DEFAULT 'content', |
| 868 | - embedding_model VARCHAR(64) DEFAULT NULL, | |
| 869 | 822 | timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, |
| 870 | 823 | PRIMARY KEY (id), |
| 871 | 824 | KEY content_type (content_type) |
| 872 | 825 | ) $charset_collate;"; |
| @@ -881,31 +834,16 @@ | ||
| 881 | 834 | callback_function VARCHAR(255) NOT NULL, |
| 882 | 835 | similarity_threshold FLOAT DEFAULT 0.85, |
| 883 | 836 | enabled TINYINT(1) NOT NULL DEFAULT 1, |
| 884 | 837 | enabled_bots LONGTEXT DEFAULT NULL, |
| 885 | - embedding_model VARCHAR(64) DEFAULT NULL, | |
| 886 | 838 | PRIMARY KEY (id) |
| 887 | 839 | ) $charset_collate;"; |
| 888 | 840 | |
| 889 | - // Individual Intent Phrases Table - each phrase gets its own embedding vector | |
| 890 | - $intent_phrases_table = $wpdb->prefix . 'mxchat_intent_phrases'; | |
| 891 | - $sql_intent_phrases_table = "CREATE TABLE $intent_phrases_table ( | |
| 892 | - id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, | |
| 893 | - intent_id BIGINT(20) UNSIGNED NOT NULL, | |
| 894 | - phrase TEXT NOT NULL, | |
| 895 | - embedding_vector LONGTEXT NOT NULL, | |
| 896 | - embedding_model VARCHAR(64) DEFAULT NULL, | |
| 897 | - created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, | |
| 898 | - PRIMARY KEY (id), | |
| 899 | - KEY intent_id (intent_id) | |
| 900 | - ) $charset_collate;"; | |
| 901 | - | |
| 902 | 841 | require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
| 903 | 842 | |
| 904 | 843 | // Create other tables |
| 905 | 844 | dbDelta($sql_system_prompt); |
| 906 | 845 | dbDelta($sql_intents_table); |
| 907 | - dbDelta($sql_intent_phrases_table); | |
| 908 | 846 | |
| 909 | 847 | // Create URL click tracking table |
| 910 | 848 | mxchat_create_url_clicks_table(); |
| 911 | 849 | |
| @@ -961,11 +899,8 @@ | ||
| 961 | 899 | |
| 962 | 900 | // Run migration for existing installations |
| 963 | 901 | mxchat_migrate_pinecone_roles_add_bot_id(); |
| 964 | 902 | |
| 965 | - // 3.2.3: Add embedding_model column to KB and intent tables | |
| 966 | - mxchat_add_embedding_model_columns(); | |
| 967 | - | |
| 968 | 903 | // Setup cron jobs |
| 969 | 904 | mxchat_setup_cron_jobs(); |
| 970 | 905 | |
| 971 | 906 | // Update version |
| @@ -1134,19 +1069,8 @@ | ||
| 1134 | 1069 | if (version_compare($current_version, '3.1.2', '<')) { |
| 1135 | 1070 | mxchat_migrate_transcripts_charset(); |
| 1136 | 1071 | } |
| 1137 | 1072 | |
| 1138 | - // 3.1.7: Clean up stale shared session email/name entries | |
| 1139 | - if (version_compare($current_version, '3.1.7', '<')) { | |
| 1140 | - delete_option('mxchat_email_null'); | |
| 1141 | - delete_option('mxchat_name_null'); | |
| 1142 | - } | |
| 1143 | - | |
| 1144 | - // 3.2.3: Add embedding_model tracking columns and backfill active model | |
| 1145 | - if (version_compare($current_version, '3.2.3', '<')) { | |
| 1146 | - mxchat_add_embedding_model_columns(); | |
| 1147 | - } | |
| 1148 | - | |
| 1149 | 1073 | // Run full activation to ensure everything is up to date |
| 1150 | 1074 | mxchat_activate(); |
| 1151 | 1075 | |
| 1152 | 1076 | // Run migration functions |
| @@ -1317,9 +1241,9 @@ | ||
| 1317 | 1241 | // Check if we're upgrading TO 3.0.1 and haven't handled this yet |
| 1318 | 1242 | if (version_compare($current_version, $target_version, '<') && !$update_handled) { |
| 1319 | 1243 | // Check if Pro is activated - only show to Pro users |
| 1320 | 1244 | $license_status = get_option('mxchat_license_status', 'inactive'); |
| 1321 | - $is_pro = ($license_status === 'active'); | |
| 1245 | + $is_pro = ($license_status === 'active' || $license_status === esc_html__('active', 'mxchat')); | |
| 1322 | 1246 | |
| 1323 | 1247 | if ($is_pro) { |
| 1324 | 1248 | // Set flag to show the theme migration notification banner |
| 1325 | 1249 | update_option('mxchat_show_theme_migration_notice', true); |