Changeset 3317645
- Timestamp:
- 06/25/2025 12:31:54 PM (8 months ago)
- Location:
- mxchat-basic
- Files:
-
- 95 added
- 6 edited
-
tags/2.2.7 (added)
-
tags/2.2.7/admin (added)
-
tags/2.2.7/admin/class-ajax-handler.php (added)
-
tags/2.2.7/admin/class-knowledge-manager.php (added)
-
tags/2.2.7/admin/class-pinecone-manager.php (added)
-
tags/2.2.7/css (added)
-
tags/2.2.7/css/admin-add-ons.css (added)
-
tags/2.2.7/css/admin-style.css (added)
-
tags/2.2.7/css/chat-style.css (added)
-
tags/2.2.7/css/chat-transcripts.css (added)
-
tags/2.2.7/css/content-selector.css (added)
-
tags/2.2.7/css/intent-style.css (added)
-
tags/2.2.7/css/knowledge-style.css (added)
-
tags/2.2.7/css/test-panel.css (added)
-
tags/2.2.7/images (added)
-
tags/2.2.7/images/Icon-01.svg (added)
-
tags/2.2.7/images/Icon-02.svg (added)
-
tags/2.2.7/images/Icon-03.svg (added)
-
tags/2.2.7/images/Icon-04.svg (added)
-
tags/2.2.7/images/pro-only-dark.png (added)
-
tags/2.2.7/includes (added)
-
tags/2.2.7/includes/class-mxchat-addons.php (added)
-
tags/2.2.7/includes/class-mxchat-admin.php (added)
-
tags/2.2.7/includes/class-mxchat-integrator.php (added)
-
tags/2.2.7/includes/class-mxchat-public.php (added)
-
tags/2.2.7/includes/class-mxchat-user.php (added)
-
tags/2.2.7/includes/class-mxchat-utils.php (added)
-
tags/2.2.7/includes/class-mxchat-word-handler.php (added)
-
tags/2.2.7/includes/pdf-parser (added)
-
tags/2.2.7/includes/pdf-parser/alt_autoload.php (added)
-
tags/2.2.7/includes/pdf-parser/src (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Config.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Document.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Element (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Element.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Element/ElementArray.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Element/ElementBoolean.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Element/ElementDate.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Element/ElementHexa.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Element/ElementMissing.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Element/ElementName.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Element/ElementNull.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Element/ElementNumeric.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Element/ElementString.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Element/ElementStruct.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Element/ElementXRef.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Encoding (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Encoding.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Encoding/AbstractEncoding.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Encoding/EncodingLocator.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Encoding/ISOLatin1Encoding.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Encoding/ISOLatin9Encoding.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Encoding/MacRomanEncoding.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Encoding/PDFDocEncoding.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Encoding/PostScriptGlyphs.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Encoding/StandardEncoding.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Encoding/WinAnsiEncoding.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Exception (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Exception/EmptyPdfException.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Exception/EncodingNotFoundException.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Exception/MissingPdfHeaderException.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Exception/NotImplementedException.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Font (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Font.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Font/FontCIDFontType0.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Font/FontCIDFontType2.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Font/FontTrueType.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Font/FontType0.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Font/FontType1.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Font/FontType3.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Header.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/PDFObject.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Page.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Pages.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/Parser.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/RawData (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/RawData/FilterHelper.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/RawData/RawDataParser.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/XObject (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/XObject/Form.php (added)
-
tags/2.2.7/includes/pdf-parser/src/Smalot/PdfParser/XObject/Image.php (added)
-
tags/2.2.7/js (added)
-
tags/2.2.7/js/activation-script.js (added)
-
tags/2.2.7/js/chat-script.js (added)
-
tags/2.2.7/js/content-selector.js (added)
-
tags/2.2.7/js/knowledge-processing.js (added)
-
tags/2.2.7/js/mxchat-admin.js (added)
-
tags/2.2.7/js/mxchat_transcripts.js (added)
-
tags/2.2.7/js/test-panel.js (added)
-
tags/2.2.7/languages (added)
-
tags/2.2.7/languages/mxchat.pot (added)
-
tags/2.2.7/mxchat-basic.php (added)
-
tags/2.2.7/readme.txt (added)
-
trunk/admin/class-pinecone-manager.php (modified) (1 diff)
-
trunk/includes/class-mxchat-addons.php (modified) (1 diff)
-
trunk/includes/class-mxchat-admin.php (modified) (5 diffs)
-
trunk/includes/class-mxchat-integrator.php (modified) (3 diffs)
-
trunk/mxchat-basic.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mxchat-basic/trunk/admin/class-pinecone-manager.php
r3315188 r3317645 591 591 // ======================================== 592 592 593 /** 594 * Deletes data from Pinecone using provided API credentials 595 */ 596 public function mxchat_delete_all_from_pinecone($pinecone_options) { 597 $api_key = $pinecone_options['mxchat_pinecone_api_key'] ?? ''; 598 $host = $pinecone_options['mxchat_pinecone_host'] ?? ''; 599 600 if (empty($api_key) || empty($host)) { 601 return array( 602 'success' => false, 603 'message' => 'Missing Pinecone API credentials' 604 ); 605 } 606 607 try { 608 // First, get all vector IDs 609 $all_vector_ids = array(); 610 611 // Try to get from cache first 612 $cached_vector_ids = get_option('mxchat_pinecone_vector_ids_cache', array()); 613 if (!empty($cached_vector_ids)) { 614 $all_vector_ids = $cached_vector_ids; 615 } else { 616 // Fallback: scan to get vector IDs 617 $records = $this->mxchat_scan_pinecone_vectors($pinecone_options); 618 foreach ($records as $record) { 619 if (!empty($record->id)) { 620 $all_vector_ids[] = $record->id; 621 } 622 } 623 } 624 625 if (empty($all_vector_ids)) { 626 return array( 627 'success' => true, 628 'message' => 'No vectors found to delete' 629 ); 630 } 631 632 // Delete vectors in batches (Pinecone has limits on batch operations) 633 $batch_size = 100; 634 $batches = array_chunk($all_vector_ids, $batch_size); 635 $deleted_count = 0; 636 $failed_batches = 0; 637 638 foreach ($batches as $batch) { 639 $result = $this->mxchat_delete_pinecone_batch($batch, $api_key, $host); 640 if ($result['success']) { 641 $deleted_count += count($batch); 642 } else { 643 $failed_batches++; 644 //error_log('Failed to delete Pinecone batch: ' . $result['message']); 645 } 646 } 647 648 if ($failed_batches > 0) { 649 return array( 650 'success' => false, 651 'message' => sprintf('Deleted %d vectors, but %d batches failed', $deleted_count, $failed_batches) 652 ); 653 } 654 655 return array( 656 'success' => true, 657 'message' => "Successfully deleted {$deleted_count} vectors from Pinecone" 658 ); 659 660 } catch (Exception $e) { 661 //error_log('Pinecone delete all exception: ' . $e->getMessage()); 662 return array( 663 'success' => false, 664 'message' => $e->getMessage() 665 ); 666 } 667 } 593 public function mxchat_delete_all_from_pinecone($pinecone_options) { 594 $api_key = $pinecone_options['mxchat_pinecone_api_key'] ?? ''; 595 $host = $pinecone_options['mxchat_pinecone_host'] ?? ''; 596 597 if (empty($api_key) || empty($host)) { 598 return array( 599 'success' => false, 600 'message' => 'Missing Pinecone API credentials' 601 ); 602 } 603 604 try { 605 // First, get all vector IDs 606 $all_vector_ids = array(); 607 608 // Try to get from cache first 609 $cached_vector_ids = get_option('mxchat_pinecone_vector_ids_cache', array()); 610 if (!empty($cached_vector_ids)) { 611 $all_vector_ids = $cached_vector_ids; 612 } else { 613 // Use the correct method name that exists in your class 614 $records = $this->mxchat_get_recent_1k_entries($pinecone_options); 615 foreach ($records as $record) { 616 if (!empty($record->id)) { 617 $all_vector_ids[] = $record->id; 618 } 619 } 620 } 621 622 if (empty($all_vector_ids)) { 623 return array( 624 'success' => true, 625 'message' => 'No vectors found to delete' 626 ); 627 } 628 629 // Delete vectors in batches (Pinecone has limits on batch operations) 630 $batch_size = 100; 631 $batches = array_chunk($all_vector_ids, $batch_size); 632 $deleted_count = 0; 633 $failed_batches = 0; 634 635 foreach ($batches as $batch) { 636 $result = $this->mxchat_delete_pinecone_batch($batch, $api_key, $host); 637 if ($result['success']) { 638 $deleted_count += count($batch); 639 } else { 640 $failed_batches++; 641 //error_log('Failed to delete Pinecone batch: ' . $result['message']); 642 } 643 } 644 645 // CLEAR ALL RELEVANT CACHES - EXACTLY like your single delete 646 delete_transient('mxchat_pinecone_recent_1k_cache'); 647 delete_option('mxchat_pinecone_vector_ids_cache'); 648 delete_option('mxchat_pinecone_processed_cache'); 649 delete_option('mxchat_processed_content_cache'); 650 651 // Also force refresh for next page load - EXACTLY like your single delete 652 $this->mxchat_refresh_after_new_content($pinecone_options); 653 654 if ($failed_batches > 0) { 655 return array( 656 'success' => false, 657 'message' => sprintf('Deleted %d vectors, but %d batches failed', $deleted_count, $failed_batches) 658 ); 659 } 660 661 return array( 662 'success' => true, 663 'message' => "Successfully deleted {$deleted_count} vectors from Pinecone" 664 ); 665 666 } catch (Exception $e) { 667 //error_log('Pinecone delete all exception: ' . $e->getMessage()); 668 return array( 669 'success' => false, 670 'message' => $e->getMessage() 671 ); 672 } 673 } 668 674 669 675 -
mxchat-basic/trunk/includes/class-mxchat-addons.php
r3315188 r3317645 153 153 */ 154 154 public function enqueue_styles() { 155 $plugin_version = '2.2. 6';155 $plugin_version = '2.2.7'; 156 156 157 157 wp_enqueue_style( -
mxchat-basic/trunk/includes/class-mxchat-admin.php
r3315188 r3317645 3918 3918 } 3919 3919 3920 3921 3922 3923 3924 3920 public function mxchat_rate_limits_callback() { 3925 3921 $all_options = get_option('mxchat_options', []); … … 3947 3943 esc_html__('Set message limits for each user role and customize the experience when users reach those limits. You can use {limit}, {timeframe}, {count}, and {remaining} as placeholders.', 'mxchat') . 3948 3944 '</p>'; 3945 3946 // Add markdown link documentation 3947 echo '<div class="notice notice-info inline" style="margin-bottom: 20px; padding: 10px;">'; 3948 echo '<p><strong>' . esc_html__('Markdown Links Supported:', 'mxchat') . '</strong></p>'; 3949 echo '<p>' . esc_html__('You can include clickable links in your custom messages using markdown syntax:', 'mxchat') . '</p>'; 3950 echo '<ul style="margin-left: 20px;">'; 3951 echo '<li><code>[Link text](https://example.com)</code> - Creates a clickable link</li>'; 3952 echo '<li><code>[Visit our pricing](https://example.com/pricing)</code> - Link with custom text</li>'; 3953 echo '<li><code>Plain URLs like https://example.com will also become clickable</code></li>'; 3954 echo '</ul>'; 3955 echo '</div>'; 3949 3956 3950 3957 // Output the controls for each role … … 4017 4024 esc_textarea($custom_message) . 4018 4025 '</textarea>'; 4026 echo '<p class="description">' . 4027 esc_html__('Example: Rate limit reached! [Visit our pricing page](https://example.com/pricing) to upgrade.', 'mxchat') . 4028 '</p>'; 4019 4029 echo '</div>'; // End message 4020 4030 … … 4028 4038 echo '</div>'; // End pro-feature-wrapper 4029 4039 } 4040 4041 4030 4042 private function mxchat_add_option_field($id, $title, $callback = '') { 4031 4043 add_settings_field( … … 5500 5512 public function mxchat_enqueue_admin_assets() { 5501 5513 // Get plugin version (define this in your main plugin file) 5502 $version = defined('MXCHAT_VERSION') ? MXCHAT_VERSION : '2.2. 6';5514 $version = defined('MXCHAT_VERSION') ? MXCHAT_VERSION : '2.2.7'; 5503 5515 5504 5516 // Use file modification time for development (remove in production) -
mxchat-basic/trunk/includes/class-mxchat-integrator.php
r3315188 r3317645 4927 4927 public function mxchat_enqueue_scripts_styles() { 4928 4928 // Define version numbers for the styles and scripts 4929 $chat_style_version = '2.2. 6';4930 $chat_script_version = '2.2. 6';4929 $chat_style_version = '2.2.7'; 4930 $chat_script_version = '2.2.7'; 4931 4931 // Enqueue the script 4932 4932 wp_enqueue_script( … … 5196 5196 ); 5197 5197 5198 // NEW: Process HTML links in the message 5199 $message = $this->process_rate_limit_message_html($message); 5200 5198 5201 //error_log('MXChat Rate Limit: Limit exceeded. Message: ' . $message); 5199 5202 5200 // Return error with the custommessage5203 // Return error with the processed message 5201 5204 return [ 5202 5205 'error' => true, … … 5212 5215 return true; 5213 5216 } 5217 5218 5219 /** 5220 * Process HTML links in rate limit messages 5221 * 5222 * @param string $message The rate limit message 5223 * @return string The processed message with safe HTML links 5224 */ 5225 private function process_rate_limit_message_html($message) { 5226 // Return original message if empty 5227 if (empty($message)) { 5228 return $message; 5229 } 5230 5231 // First, convert markdown links to HTML 5232 $message = $this->convert_markdown_links($message); 5233 5234 // Then, auto-convert any remaining plain URLs to links 5235 $message = $this->auto_link_urls($message); 5236 5237 // Allow basic HTML tags for links and formatting 5238 $allowed_tags = [ 5239 'a' => [ 5240 'href' => true, 5241 'target' => true, 5242 'rel' => true, 5243 'title' => true, 5244 'class' => true 5245 ], 5246 'strong' => [], 5247 'em' => [], 5248 'br' => [], 5249 'b' => [], 5250 'i' => [], 5251 'span' => ['class' => true] 5252 ]; 5253 5254 // Sanitize but allow the specified HTML tags 5255 $processed_message = wp_kses($message, $allowed_tags); 5256 5257 // If wp_kses stripped everything, return the original message as plain text 5258 if (empty($processed_message) && !empty($message)) { 5259 // Strip all HTML and return plain text as fallback 5260 return wp_strip_all_tags($message); 5261 } 5262 5263 return $processed_message; 5264 } 5265 5266 /** 5267 * Convert markdown links to HTML 5268 * 5269 * @param string $text The text to process 5270 * @return string The text with markdown links converted to HTML 5271 */ 5272 private function convert_markdown_links($text) { 5273 // Return original text if empty 5274 if (empty($text)) { 5275 return $text; 5276 } 5277 5278 // Pattern to match markdown links: [text](url) 5279 $pattern = '/\[([^\]]+)\]\(([^)]+)\)/'; 5280 5281 $processed_text = preg_replace_callback($pattern, function($matches) { 5282 $link_text = $matches[1]; 5283 $url = $matches[2]; 5284 5285 // Clean up any trailing punctuation from the URL 5286 $url = rtrim($url, '.,;:!?'); 5287 5288 // Sanitize the link text and URL 5289 $safe_text = esc_html($link_text); 5290 $safe_url = esc_url($url); 5291 5292 // Create the HTML link 5293 return '<a href="' . $safe_url . '" target="_blank" rel="noopener noreferrer">' . $safe_text . '</a>'; 5294 }, $text); 5295 5296 // If preg_replace_callback failed, return original text 5297 if ($processed_text === null) { 5298 return $text; 5299 } 5300 5301 return $processed_text; 5302 } 5303 5304 /** 5305 * Auto-convert plain URLs to clickable links 5306 * 5307 * @param string $text The text to process 5308 * @return string The text with URLs converted to links 5309 */ 5310 private function auto_link_urls($text) { 5311 // Return original text if empty 5312 if (empty($text)) { 5313 return $text; 5314 } 5315 5316 // Simple pattern that avoids complex lookbehinds 5317 // This will match URLs that are not already inside href attributes or markdown links 5318 $pattern = '/(?<!href=["\'])(?<!\]\()https?:\/\/[^\s<>"\')\]]+/i'; 5319 5320 $processed_text = preg_replace_callback($pattern, function($matches) { 5321 $url = $matches[0]; 5322 // Clean up any trailing punctuation that might have been captured 5323 $url = rtrim($url, '.,;:!?'); 5324 5325 // Add target="_blank" and rel="noopener noreferrer" for security 5326 return '<a href="' . esc_url($url) . '" target="_blank" rel="noopener noreferrer">' . esc_html($url) . '</a>'; 5327 }, $text); 5328 5329 // If preg_replace_callback failed, return original text 5330 if ($processed_text === null) { 5331 return $text; 5332 } 5333 5334 return $processed_text; 5335 } 5336 5214 5337 5215 5338 // Helper function to get client IP address -
mxchat-basic/trunk/mxchat-basic.php
r3315188 r3317645 3 3 * Plugin Name: MxChat 4 4 * Description: AI chatbot for WordPress with OpenAI, Claude, xAI, DeepSeek, live agent, PDF uploads, WooCommerce, and training on website data. 5 * Version: 2.2. 65 * Version: 2.2.7 6 6 * Author: MxChat 7 7 * Author URI: https://mxchat.ai … … 17 17 18 18 // Define plugin version constant for asset versioning 19 define('MXCHAT_VERSION', '2.2. 6');19 define('MXCHAT_VERSION', '2.2.7'); 20 20 21 21 function mxchat_load_textdomain() { -
mxchat-basic/trunk/readme.txt
r3315188 r3317645 6 6 Tested up to: 6.8 7 7 Requires PHP: 7.2 8 Stable tag: 2.2. 68 Stable tag: 2.2.7 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 178 178 == Changelog == 179 179 180 = 2.2.7 = 181 - Fixed a bug that occured when deleting all pinecone records & added support for markdown hyperlinking in rate limit messages. 182 180 183 = 2.2.6 = 181 184 - Brand New Admin Debug Panel – Added a comprehensive frontend debug panel for administrators! You can now see retrieved documents, triggered actions, and other debug and setting information in real-time while testing your chatbot, making it easier than ever to fine-tune your bot's performance. … … 524 527 == Upgrade Notice == 525 528 526 = 2.2. 6=527 - New admin debug panel for real-time chatbot testing and troubleshooting, plus important fixes for Pinecone deletion and WordPress knowledge base editing.529 = 2.2.7 = 530 - Fixed a bug that occured when deleting all pinecone records & added support for markdown hyperlinking in rate limit messages. 528 531 529 532 == License & Warranty ==
Note: See TracChangeset
for help on using the changeset viewer.