PluginProbe
MxChat – AI Chatbot & Content Generation for WordPress / 1.0.8
MxChat – AI Chatbot & Content Generation for WordPress v1.0.8
3.2.21 3.2.20 3.2.19 3.2.18 3.2.17 3.2.16 3.2.15 3.2.14 3.2.12 3.2.13 3.2.11 3.2.10 3.2.9 3.2.8 3.2.7 3.2.6 3.2.5 3.2.4 3.2.3 3.2.2 3.2.1 2.0.3 2.0.4 2.0.5 2.0.6 All 152 releases
← All changes | mxchat-basic.php +66 -116 2.0.61.0.8 View file →
@@ -1,15 +1,12 @@
1 1 <?php
2 2 /**
3 3 * Plugin Name: MxChat
4 - * Description: AI chatbot for WordPress with OpenAI, Claude, xAI, DeepSeek, live agent, PDF uploads, WooCommerce, and training on website data.
5 - * Version: 2.0.6
4 + * Description: AI Chatbot for WordPress. Features like custom knowledge submission, chat transcripts, and OpenAI integration for real-time user interaction. Perfect for blogs, business sites, e-commerce platforms, and more.
5 + * Version: 1.0.8
6 6 * Author: MxChat
7 - * Author URI: https://mxchat.ai
8 7 * License: GPLv2 or later
9 8 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
10 - * Text Domain: mxchat
11 - * Domain Path: /languages
12 9 */
13 10
14 11 if (!defined('ABSPATH')) {
15 12 exit; // Exit if accessed directly.
@@ -14,14 +11,8 @@
14 11 if (!defined('ABSPATH')) {
15 12 exit; // Exit if accessed directly.
16 13 }
17 14
18 -
19 -function mxchat_load_textdomain() {
20 - load_plugin_textdomain('mxchat', false, dirname(plugin_basename(__FILE__)) . '/languages');
21 -}
22 -add_action('plugins_loaded', 'mxchat_load_textdomain');
23 -
24 15 // Include classes
25 16 require_once plugin_dir_path(__FILE__) . 'includes/class-mxchat-integrator.php';
26 17 require_once plugin_dir_path(__FILE__) . 'includes/class-mxchat-admin.php';
27 18 require_once plugin_dir_path(__FILE__) . 'includes/class-mxchat-public.php';
@@ -26,147 +17,106 @@
26 17 require_once plugin_dir_path(__FILE__) . 'includes/class-mxchat-admin.php';
27 18 require_once plugin_dir_path(__FILE__) . 'includes/class-mxchat-public.php';
28 19 require_once plugin_dir_path(__FILE__) . 'includes/class-mxchat-utils.php';
29 20 require_once plugin_dir_path(__FILE__) . 'includes/class-mxchat-user.php';
30 -require_once plugin_dir_path(__FILE__) . 'includes/pdf-parser/alt_autoload.php';
31 -require_once plugin_dir_path(__FILE__) . 'includes/class-mxchat-word-handler.php';
21 +require_once plugin_dir_path(__FILE__) . 'includes/class-mxchat-woocommerce.php';
32 22
33 23 function mxchat_activate() {
34 24 global $wpdb;
35 - $charset_collate = $wpdb->get_charset_collate();
36 25
37 26 // Chat Transcripts Table
38 27 $chat_transcripts_table = $wpdb->prefix . 'mxchat_chat_transcripts';
39 28 $sql_chat_transcripts = "CREATE TABLE $chat_transcripts_table (
40 - id MEDIUMINT(9) NOT NULL AUTO_INCREMENT,
41 - user_id MEDIUMINT(9) DEFAULT 0,
42 - session_id VARCHAR(255) NOT NULL,
43 - role VARCHAR(255) NOT NULL,
44 - message TEXT NOT NULL,
45 - user_email VARCHAR(255) DEFAULT NULL,
46 - timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
47 - PRIMARY KEY (id)
48 - ) $charset_collate;";
29 + id mediumint(9) NOT NULL AUTO_INCREMENT,
30 + user_id mediumint(9) DEFAULT 0,
31 + session_id varchar(255) NOT NULL,
32 + role varchar(255) NOT NULL,
33 + message text NOT NULL,
34 + timestamp timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
35 + PRIMARY KEY (id)
36 + );";
49 37
50 38 // System Prompt Content Table
51 39 $system_prompt_table = $wpdb->prefix . 'mxchat_system_prompt_content';
52 40 $sql_system_prompt = "CREATE TABLE $system_prompt_table (
53 - id MEDIUMINT(9) NOT NULL AUTO_INCREMENT,
54 - url VARCHAR(255) NOT NULL,
55 - article_content LONGTEXT NOT NULL,
56 - embedding_vector LONGTEXT,
57 - source_url VARCHAR(255) DEFAULT NULL,
58 - timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
59 - PRIMARY KEY (id)
60 - ) $charset_collate;";
41 + id mediumint(9) NOT NULL AUTO_INCREMENT,
42 + url varchar(255) NOT NULL,
43 + article_content longtext NOT NULL,
44 + embedding_vector longtext,
45 + timestamp timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
46 + PRIMARY KEY (id)
47 + );";
61 48
62 - // Intents Table
63 - $intents_table = $wpdb->prefix . 'mxchat_intents';
64 - $sql_intents_table = "CREATE TABLE $intents_table (
65 - id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
66 - intent_label VARCHAR(255) NOT NULL,
67 - phrases TEXT NOT NULL,
68 - embedding_vector LONGTEXT NOT NULL,
69 - callback_function VARCHAR(255) NOT NULL,
70 - similarity_threshold FLOAT DEFAULT 0.85,
71 - PRIMARY KEY (id)
72 - ) $charset_collate;";
49 + require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
73 50
74 - require_once ABSPATH . 'wp-admin/includes/upgrade.php';
51 + // Create or update the chat transcripts table
52 + dbDelta($sql_chat_transcripts);
75 53
76 - // Create or update tables
77 - dbDelta($sql_chat_transcripts);
54 + // Create or update the system prompt content table
78 55 dbDelta($sql_system_prompt);
79 - dbDelta($sql_intents_table);
80 56
81 - // Ensure additional columns in `mxchat_chat_transcripts`
82 - mxchat_add_missing_columns($chat_transcripts_table, 'user_identifier', 'VARCHAR(255)');
83 - mxchat_add_missing_columns($chat_transcripts_table, 'user_email', 'VARCHAR(255) DEFAULT NULL');
57 + // Ensure 'embedding_vector' column exists in the 'system_prompt_content' table
58 + $column_exists = $wpdb->get_results($wpdb->prepare(
59 + "SHOW COLUMNS FROM {$system_prompt_table} LIKE %s",
60 + 'embedding_vector'
61 + ));
62 + if (empty($column_exists)) {
63 + $wpdb->query(
64 + "ALTER TABLE {$system_prompt_table} ADD COLUMN embedding_vector longtext"
65 + );
66 + }
84 67
85 - // Ensure additional columns in `mxchat_system_prompt_content`
86 - mxchat_add_missing_columns($system_prompt_table, 'embedding_vector', 'LONGTEXT');
87 - mxchat_add_missing_columns($system_prompt_table, 'source_url', 'VARCHAR(255) DEFAULT NULL');
68 + // Ensure 'source_url' column exists in the 'system_prompt_content' table
69 + $source_url_exists = $wpdb->get_results($wpdb->prepare(
70 + "SHOW COLUMNS FROM {$system_prompt_table} LIKE %s",
71 + 'source_url'
72 + ));
73 + if (empty($source_url_exists)) {
74 + $wpdb->query(
75 + "ALTER TABLE {$system_prompt_table} ADD COLUMN source_url VARCHAR(255) DEFAULT NULL"
76 + );
77 + }
88 78
89 - // Set default thresholds for existing intents
90 - $wpdb->query("UPDATE {$intents_table} SET similarity_threshold = 0.85 WHERE similarity_threshold IS NULL");
79 + // Ensure 'user_identifier' and 'user_email' columns exist in the 'chat_transcripts' table
80 + $user_identifier_exists = $wpdb->get_results($wpdb->prepare(
81 + "SHOW COLUMNS FROM {$chat_transcripts_table} LIKE %s",
82 + 'user_identifier'
83 + ));
84 + if (empty($user_identifier_exists)) {
85 + $wpdb->query(
86 + "ALTER TABLE {$chat_transcripts_table} ADD COLUMN user_identifier VARCHAR(255)"
87 + );
88 + }
91 89
92 - // Update plugin version in the database
93 - update_option('mxchat_plugin_version', '2.0.6');
94 -}
90 + $user_email_exists = $wpdb->get_results($wpdb->prepare(
91 + "SHOW COLUMNS FROM {$chat_transcripts_table} LIKE %s",
92 + 'user_email'
93 + ));
94 + if (empty($user_email_exists)) {
95 + $wpdb->query(
96 + "ALTER TABLE {$chat_transcripts_table} ADD COLUMN user_email VARCHAR(255)"
97 + );
98 + }
95 99
96 -
97 -function mxchat_add_missing_columns($table, $column_name, $column_type) {
98 - global $wpdb;
99 - $column_exists = $wpdb->get_results($wpdb->prepare("SHOW COLUMNS FROM $table LIKE %s", $column_name));
100 - if (empty($column_exists)) {
101 - $wpdb->query("ALTER TABLE $table ADD COLUMN $column_name $column_type");
102 - }
100 + // Update the version number in the database
101 + update_option('mxchat_plugin_version', '1.0.8');
103 102 }
104 103
105 104 function mxchat_check_for_update() {
106 105 $current_version = get_option('mxchat_plugin_version');
107 - $plugin_version = '2.0.6'; // Update with your latest version
106 + $plugin_version = '1.0.8';
108 107
109 108 if ($current_version !== $plugin_version) {
110 - mxchat_activate(); // Run the activation script to apply schema changes
111 - mxchat_migrate_live_agent_status(); // Add migration for live agent status
112 - update_option('mxchat_plugin_version', $plugin_version); // Update the version
109 + mxchat_activate(); // Run the activation script which includes database migrations
110 + update_option('mxchat_plugin_version', $plugin_version); // Update to the latest version
113 111 }
114 112 }
115 113
116 -function mxchat_migrate_live_agent_status() {
117 - $options = get_option('mxchat_options', []);
118 -
119 - // Check if live_agent_status exists
120 - if (isset($options['live_agent_status'])) {
121 - $current_status = $options['live_agent_status'];
122 - $needs_update = false;
123 -
124 - // Convert to new format if needed
125 - if ($current_status === 'online') {
126 - $options['live_agent_status'] = 'on';
127 - $needs_update = true;
128 - } else if ($current_status === 'offline') {
129 - $options['live_agent_status'] = 'off';
130 - $needs_update = true;
131 - } else if (!in_array($current_status, ['on', 'off'])) {
132 - // Default to off for any unexpected values
133 - $options['live_agent_status'] = 'off';
134 - $needs_update = true;
135 - }
136 -
137 - // Only update if needed
138 - if ($needs_update) {
139 - update_option('mxchat_options', $options);
140 - }
141 - } else {
142 - // If status doesn't exist, set default to off
143 - $options['live_agent_status'] = 'off';
144 - update_option('mxchat_options', $options);
145 - }
146 -}
147 -
148 -
149 114 // Run the update check function on every request
150 115 add_action('plugins_loaded', 'mxchat_check_for_update');
151 116
152 117 // Register activation hook
153 118 register_activation_hook(__FILE__, 'mxchat_activate');
154 -
155 -
156 -add_filter('cron_schedules', function($schedules) {
157 - $schedules['one_minute'] = array(
158 - 'interval' => 60,
159 - 'display' => 'Every Minute'
160 - );
161 - return $schedules;
162 -});
163 -
164 -add_action('init', function() {
165 - add_action('mxchat_process_pdf_pages', array('MxChat_Admin', 'process_pdf_pages_cron'), 10, 5);
166 - add_action('mxchat_process_sitemap_urls', array('MxChat_Admin', 'process_sitemap_urls_cron'), 10, 5);
167 -});
168 -
169 119
170 120 // Instantiate classes
171 121 if (is_admin()) {
172 122 $mxchat_admin = new MxChat_Admin();