| @@ -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.5 | |
| 6 | + * Version: 3.1.7 | |
| 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 |
| @@ -262,9 +262,8 @@ | ||
| 262 | 262 | 'includes/class-mxchat-meta-box.php', |
| 263 | 263 | 'includes/class-mxchat-chunker.php', |
| 264 | 264 | 'includes/class-mxchat-word-handler.php', |
| 265 | 265 | 'includes/class-mxchat-content-generator.php', |
| 266 | - 'includes/class-rest-api.php', | |
| 267 | 266 | 'admin/class-ajax-handler.php', |
| 268 | 267 | 'admin/class-pinecone-manager.php', |
| 269 | 268 | 'admin/class-knowledge-manager.php' |
| 270 | 269 | ); |
| @@ -276,16 +275,8 @@ | ||
| 276 | 275 | } else { |
| 277 | 276 | //error_log('MxChat: Missing class file - ' . $file); |
| 278 | 277 | } |
| 279 | 278 | } |
| 280 | - | |
| 281 | - // Admin pages that aren't classes (procedural include). | |
| 282 | - if (is_admin()) { | |
| 283 | - $admin_api_page = plugin_dir_path(__FILE__) . 'includes/admin-api-page.php'; | |
| 284 | - if (file_exists($admin_api_page)) { | |
| 285 | - require_once $admin_api_page; | |
| 286 | - } | |
| 287 | - } | |
| 288 | 279 | } |
| 289 | 280 | |
| 290 | 281 | /** |
| 291 | 282 | * Lazy-load the PDF parser library only when needed. |
| @@ -617,33 +608,8 @@ | ||
| 617 | 608 | update_option('mxchat_content_type_migration_version', '2.5.6'); |
| 618 | 609 | } |
| 619 | 610 | |
| 620 | 611 | /** |
| 621 | - * 3.2.4: Backfill the active embedding model option for installs that already | |
| 622 | - * have KB content but no stamped model. The mismatch warning compares this | |
| 623 | - * against the user's currently selected model — no per-row column needed. | |
| 624 | - */ | |
| 625 | -function mxchat_backfill_active_embedding_model() { | |
| 626 | - global $wpdb; | |
| 627 | - | |
| 628 | - if (get_option('mxchat_active_embedding_model', '') !== '') { | |
| 629 | - return; | |
| 630 | - } | |
| 631 | - | |
| 632 | - $kb_table = $wpdb->prefix . 'mxchat_system_prompt_content'; | |
| 633 | - if ($wpdb->get_var("SHOW TABLES LIKE '{$kb_table}'") !== $kb_table) { | |
| 634 | - return; | |
| 635 | - } | |
| 636 | - | |
| 637 | - $kb_count = (int) $wpdb->get_var("SELECT COUNT(*) FROM {$kb_table}"); | |
| 638 | - if ($kb_count > 0) { | |
| 639 | - $options = get_option('mxchat_options', array()); | |
| 640 | - $current_model = $options['embedding_model'] ?? 'text-embedding-ada-002'; | |
| 641 | - update_option('mxchat_active_embedding_model', $current_model, false); | |
| 642 | - } | |
| 643 | -} | |
| 644 | - | |
| 645 | -/** | |
| 646 | 612 | * 2.5.2: Create queue processing tables for reliable background processing |
| 647 | 613 | */ |
| 648 | 614 | function mxchat_create_queue_tables() { |
| 649 | 615 | global $wpdb; |
| @@ -775,9 +741,9 @@ | ||
| 775 | 741 | if (in_array($current_model, $deprecated_claude_models, true)) { |
| 776 | 742 | $options['model'] = 'claude-opus-4-6'; |
| 777 | 743 | $migrated = true; |
| 778 | 744 | $migration_message = sprintf( |
| 779 | - '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'), | |
| 780 | 746 | $current_model |
| 781 | 747 | ); |
| 782 | 748 | } |
| 783 | 749 | |
| @@ -784,9 +750,9 @@ | ||
| 784 | 750 | // Migrate deprecated Claude Haiku 3.5 to Claude Haiku 4.5 |
| 785 | 751 | if ($current_model === 'claude-3-5-haiku-20241022') { |
| 786 | 752 | $options['model'] = 'claude-haiku-4-5-20251001'; |
| 787 | 753 | $migrated = true; |
| 788 | - $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'); | |
| 789 | 755 | } |
| 790 | 756 | |
| 791 | 757 | // Migrate deprecated GPT-4 series and GPT-3.5 Turbo to GPT-5.1 Chat Latest |
| 792 | 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)) { |
| @@ -792,9 +758,9 @@ | ||
| 792 | 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)) { |
| 793 | 759 | $options['model'] = 'gpt-5.1-chat-latest'; |
| 794 | 760 | $migrated = true; |
| 795 | 761 | $migration_message = sprintf( |
| 796 | - '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'), | |
| 797 | 763 | $current_model |
| 798 | 764 | ); |
| 799 | 765 | } |
| 800 | 766 | |
| @@ -802,9 +768,9 @@ | ||
| 802 | 768 | if (in_array($current_model, array('gpt-4o-mini', 'gpt-4.1-mini'), true)) { |
| 803 | 769 | $options['model'] = 'gpt-5-mini'; |
| 804 | 770 | $migrated = true; |
| 805 | 771 | $migration_message = sprintf( |
| 806 | - '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'), | |
| 807 | 773 | $current_model |
| 808 | 774 | ); |
| 809 | 775 | } |
| 810 | 776 | |
| @@ -871,26 +837,13 @@ | ||
| 871 | 837 | enabled_bots LONGTEXT DEFAULT NULL, |
| 872 | 838 | PRIMARY KEY (id) |
| 873 | 839 | ) $charset_collate;"; |
| 874 | 840 | |
| 875 | - // Individual Intent Phrases Table - each phrase gets its own embedding vector | |
| 876 | - $intent_phrases_table = $wpdb->prefix . 'mxchat_intent_phrases'; | |
| 877 | - $sql_intent_phrases_table = "CREATE TABLE $intent_phrases_table ( | |
| 878 | - id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, | |
| 879 | - intent_id BIGINT(20) UNSIGNED NOT NULL, | |
| 880 | - phrase TEXT NOT NULL, | |
| 881 | - embedding_vector LONGTEXT NOT NULL, | |
| 882 | - created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, | |
| 883 | - PRIMARY KEY (id), | |
| 884 | - KEY intent_id (intent_id) | |
| 885 | - ) $charset_collate;"; | |
| 886 | - | |
| 887 | 841 | require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
| 888 | 842 | |
| 889 | 843 | // Create other tables |
| 890 | 844 | dbDelta($sql_system_prompt); |
| 891 | 845 | dbDelta($sql_intents_table); |
| 892 | - dbDelta($sql_intent_phrases_table); | |
| 893 | 846 | |
| 894 | 847 | // Create URL click tracking table |
| 895 | 848 | mxchat_create_url_clicks_table(); |
| 896 | 849 | |
| @@ -946,11 +899,8 @@ | ||
| 946 | 899 | |
| 947 | 900 | // Run migration for existing installations |
| 948 | 901 | mxchat_migrate_pinecone_roles_add_bot_id(); |
| 949 | 902 | |
| 950 | - // 3.2.4: Backfill active embedding model option (replaces 3.2.3 column-based tracking) | |
| 951 | - mxchat_backfill_active_embedding_model(); | |
| 952 | - | |
| 953 | 903 | // Setup cron jobs |
| 954 | 904 | mxchat_setup_cron_jobs(); |
| 955 | 905 | |
| 956 | 906 | // Update version |
| @@ -985,14 +935,13 @@ | ||
| 985 | 935 | // Clear fallback flags if cron scheduling succeeded |
| 986 | 936 | delete_option('mxchat_use_fallback_rate_limits'); |
| 987 | 937 | } |
| 988 | 938 | |
| 989 | - // Schedule transcript cleanup if configured (bucket dropdown OR custom retention-days > 0) | |
| 939 | + // Schedule transcript cleanup if configured | |
| 990 | 940 | $transcript_options = get_option('mxchat_transcripts_options', array()); |
| 991 | 941 | $cleanup_interval = isset($transcript_options['mxchat_auto_delete_transcripts']) ? $transcript_options['mxchat_auto_delete_transcripts'] : 'never'; |
| 992 | - $custom_retention = isset($transcript_options['mxchat_retention_days']) ? (int) $transcript_options['mxchat_retention_days'] : 0; | |
| 993 | - | |
| 994 | - if ($cleanup_interval !== 'never' || $custom_retention > 0) { | |
| 942 | + | |
| 943 | + if ($cleanup_interval !== 'never') { | |
| 995 | 944 | // Check if not already scheduled |
| 996 | 945 | if (!wp_next_scheduled('mxchat_cleanup_old_transcripts')) { |
| 997 | 946 | // Schedule to run daily at 3 AM |
| 998 | 947 | $next_run = strtotime('tomorrow 3:00 AM'); |
| @@ -1126,14 +1075,8 @@ | ||
| 1126 | 1075 | delete_option('mxchat_email_null'); |
| 1127 | 1076 | delete_option('mxchat_name_null'); |
| 1128 | 1077 | } |
| 1129 | 1078 | |
| 1130 | - // 3.2.4: Backfill active embedding model option for the warning UI | |
| 1131 | - // (replaces the per-row column tracking from 3.2.3, which was reverted) | |
| 1132 | - if (version_compare($current_version, '3.2.4', '<')) { | |
| 1133 | - mxchat_backfill_active_embedding_model(); | |
| 1134 | - } | |
| 1135 | - | |
| 1136 | 1079 | // Run full activation to ensure everything is up to date |
| 1137 | 1080 | mxchat_activate(); |
| 1138 | 1081 | |
| 1139 | 1082 | // Run migration functions |
| @@ -1304,9 +1247,9 @@ | ||
| 1304 | 1247 | // Check if we're upgrading TO 3.0.1 and haven't handled this yet |
| 1305 | 1248 | if (version_compare($current_version, $target_version, '<') && !$update_handled) { |
| 1306 | 1249 | // Check if Pro is activated - only show to Pro users |
| 1307 | 1250 | $license_status = get_option('mxchat_license_status', 'inactive'); |
| 1308 | - $is_pro = ($license_status === 'active'); | |
| 1251 | + $is_pro = ($license_status === 'active' || $license_status === esc_html__('active', 'mxchat')); | |
| 1309 | 1252 | |
| 1310 | 1253 | if ($is_pro) { |
| 1311 | 1254 | // Set flag to show the theme migration notification banner |
| 1312 | 1255 | update_option('mxchat_show_theme_migration_notice', true); |
| @@ -1356,16 +1299,8 @@ | ||
| 1356 | 1299 | // Initialize content generator globally — it registers wp_head hook |
| 1357 | 1300 | // for frontend CSS injection, plus wp_ajax_ hooks for admin. |
| 1358 | 1301 | if (class_exists('MxChat_Content_Generator')) { |
| 1359 | 1302 | new MxChat_Content_Generator(); |
| 1360 | - } | |
| 1361 | - | |
| 1362 | - // Initialize REST API globally — endpoints must be registered on | |
| 1363 | - // every request (admin and frontend) so they're reachable via /wp-json/. | |
| 1364 | - // Endpoints are auth-gated and locked until the site owner generates | |
| 1365 | - // a token in MxChat → API Access. | |
| 1366 | - if (class_exists('MxChat_Rest_Api')) { | |
| 1367 | - new MxChat_Rest_Api(); | |
| 1368 | 1303 | } |
| 1369 | 1304 | |
| 1370 | 1305 | // Initialize public classes |
| 1371 | 1306 | if (class_exists('MxChat_Public')) { |