PluginProbe
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services / 8.3.8
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services v8.3.8
8.7.7 8.7.6 8.7.5 8.7.4 8.7.3 8.7.2 8.7.1 8.7.0 8.6.9 8.6.8 8.6.7 8.6.6 8.6.5 8.6.4 8.6.2 8.6.1 8.6.0 8.5.9 8.5.8 8.5.7 8.5.6 8.5.5 8.5.4 8.5.3 8.5.2 All 533 releases
← All changes | includes/admin/templates/rag.php +29 -34 8.5.28.3.8 View file →
@@ -3,13 +3,10 @@
3 3 /**
4 4 * AI Assistant Template - RAG Feature Extended
5 5 * @package Botmaster
6 6 */
7 -if (get_option('wpchatbot_license_valid') == 'master' && get_option('wpchatbot_license_valid') == 'professional') {
8 - update_option('wpchatbot_license_valid', 'starter');
9 -}
10 7
11 -$wpchatbot_license_valid = get_option('wpchatbot_license_valid');
8 +$wpchatbot_license_valid = get_option('wpchatbot_license_valid');
12 9 // $wpchatbot_license_valid = 'starter';
13 10
14 11 ?>
15 12
@@ -148,16 +145,16 @@
148 145 ?>
149 146
150 147 <div class="mb-3">
151 148 <input type="checkbox" id="rag_googlesheets_autosync_enabled" <?php checked(get_option('rag_googlesheets_autosync_enabled'), '1'); ?>>
152 - <label for="rag_googlesheets_autosync_enabled"><strong>Enable Google Sheets Auto Sync <span class="rag-sync-label"><?php echo esc_html( $current_label ); ?></span></strong></label>
153 - <p class="description">Automatically re-sync all Google Sheets in the knowledge base <span class="rag-sync-desc"><?php echo esc_html( $current_desc ); ?></span>.</p>
149 + <label for="rag_googlesheets_autosync_enabled"><strong>Enable Google Sheets Auto Sync <span class="rag-sync-label"><?php echo $current_label; ?></span></strong></label>
150 + <p class="description">Automatically re-sync all Google Sheets in the knowledge base <span class="rag-sync-desc"><?php echo $current_desc; ?></span>.</p>
154 151 </div>
155 152
156 153 <div class="mb-3">
157 154 <input type="checkbox" id="rag_googledocs_autosync_enabled" <?php checked(get_option('rag_googledocs_autosync_enabled'), '1'); ?>>
158 - <label for="rag_googledocs_autosync_enabled"><strong>Enable Google Docs Auto Sync <span class="rag-sync-label"><?php echo esc_html( $current_label ); ?></span></strong></label>
159 - <p class="description">Automatically re-sync all Google Docs in the knowledge base <span class="rag-sync-desc"><?php echo esc_html( $current_desc ); ?></span>.</p>
155 + <label for="rag_googledocs_autosync_enabled"><strong>Enable Google Docs Auto Sync <span class="rag-sync-label"><?php echo $current_label; ?></span></strong></label>
156 + <p class="description">Automatically re-sync all Google Docs in the knowledge base <span class="rag-sync-desc"><?php echo $current_desc; ?></span>.</p>
160 157 </div>
161 158
162 159 <div class="mb-3">
163 160 <label for="rag_sync_interval"><strong>Sync Interval:</strong></label>
@@ -199,9 +196,9 @@
199 196 CSV UPLOAD (AJAX)
200 197 ============================ -->
201 198 <div class="wrap">
202 199 <h3>Upload CSV Data for RAG</h3>
203 - <p>Upload CSV files with data to be embedded. Each row will be processed as a separate document. <a href="<?php echo esc_url( plugin_dir_url(__FILE__).'download/rag_test_data.csv' ); ?>">Download Test Data</a></p>
200 + <p>Upload CSV files with data to be embedded. Each row will be processed as a separate document. <a href="<?php echo plugin_dir_url(__FILE__).'download/rag_test_data.csv'; ?>">Download Test Data</a></p>
204 201
205 202 <form id="rag-csv-form">
206 203 <input type="file" id="rag-csv-files" name="rag_csv[]" multiple accept=".csv,text/csv" />
207 204 <br><br>
@@ -305,9 +302,9 @@
305 302
306 303 <div id="botmaster_googledoc_status" style="margin-top: 10px;"></div>
307 304 </div>
308 305 </div>
309 - <h5 style="color: #c33;">Notes: These are based on AI system, so make sure you have enabled any AI features and set up valid API keys. <b><a href="<?php echo esc_url('https://wpbot.pro/docs/knowledgebase/how-to-use-an-embedded-vector-database-and-rag-to-get-customized-responses-from-ai/'); ?>" target="_blank">Check this Tutorial for more details.</a></b></h5>
306 + <h5 style="color: #c33;">Notes: These are based on AI system, so make sure you have enabled any AI features and set up valid API keys. <b><a href="https://wpbot.pro/docs/knowledgebase/how-to-use-an-embedded-vector-database-and-rag-to-get-customized-responses-from-ai/" target="_blank">Check this Tutorial for more details.</a></b></h5>
310 307 <div class="wrap">
311 308 <button class="qcld-btn-primary" id="save_rag_setting">Save Settings</button>
312 309 </div>
313 310 </div>
@@ -338,9 +335,9 @@
338 335
339 336 $.post(ajaxurl, {
340 337 action: 'botmaster_submit_sitemap',
341 338 sitemap_url: sitemapUrl,
342 - nonce: '<?php echo esc_attr( wp_create_nonce('botmaster_kb_nonce') ); ?>'
339 + nonce: '<?php echo wp_create_nonce("botmaster_kb_nonce"); ?>'
343 340 }, function(response) {
344 341 $('#botmaster_submit_sitemap_btn').prop('disabled', false);
345 342 if (response.success) {
346 343 statusDiv.html('<div class="notice notice-success inline"><p>' + response.data.message + '</p></div>');
@@ -355,9 +352,9 @@
355 352 <?php if ( $wpchatbot_license_valid != 'master' && $wpchatbot_license_valid != 'professional'): ?>
356 353 <div class="wrap">
357 354 <div style="background-color: #fee; border: 1px solid #c33; padding: 15px; margin: 20px 0; border-radius: 4px;">
358 355 <p style="color: #c33; font-weight: bold; margin: 0; font-size: 14px;">
359 - These options are available with the WPBot Pro <a href="<?php echo esc_url('https://www.wpbot.pro/pricing/'); ?>" target="_blank" style="color: #c33; text-decoration: underline;">Professional</a> and <a href="<?php echo esc_url('https://www.wpbot.pro/pricing/'); ?>" target="_blank" style="color: #c33; text-decoration: underline;">Master</a> Licenses
356 + These options are available with the WPBot Pro <a href="https://www.wpbot.pro/pricing/" target="_blank" style="color: #c33; text-decoration: underline;">Professional</a> and <a href="https://www.wpbot.pro/pricing/" target="_blank" style="color: #c33; text-decoration: underline;">Master</a> Licenses
360 357 </p>
361 358 </div>
362 359 </div>
363 360 <?php endif; ?>
@@ -380,9 +377,9 @@
380 377 <tbody id="rag-sources-list">
381 378 <?php
382 379 global $wpdb;
383 380 $table = $wpdb->prefix . 'rag_documents';
384 - $sources = $wpdb->get_results("SELECT source_url, source_type, COUNT(*) as count, MAX(title) as display_name FROM {$table} GROUP BY source_url, source_type ORDER BY count DESC"); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter
381 + $sources = $wpdb->get_results("SELECT source_url, source_type, COUNT(*) as count, MAX(title) as display_name FROM $table GROUP BY source_url, source_type ORDER BY count DESC");
385 382
386 383 if ($sources) {
387 384 foreach ($sources as $source) {
388 385 $display_url = $source->source_url ?: "Manual Upload";
@@ -494,9 +491,9 @@
494 491 echo '<div class="notice notice-success inline"><p>Database table created successfully.</p></div>';
495 492 }
496 493
497 494 // Check if table exists
498 - $table_exists = $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $wpdb->esc_like($table_rag_documents))) === $table_rag_documents; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
495 + $table_exists = $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $wpdb->esc_like($table_rag_documents))) === $table_rag_documents;
499 496
500 497 if (!$table_exists) {
501 498 ?>
502 499 <div class="wrap">
@@ -519,11 +516,11 @@
519 516 $search_query = isset($_GET['s']) ? sanitize_text_field(wp_unslash($_GET['s'])) : '';
520 517
521 518 if ($search_query) {
522 519 $like = '%' . $wpdb->esc_like($search_query) . '%';
523 - $total_items = $wpdb->get_var($wpdb->prepare("SELECT COUNT(id) FROM {$table_name} WHERE title LIKE %s OR content LIKE %s", $like, $like)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter
520 + $total_items = $wpdb->get_var($wpdb->prepare("SELECT COUNT(id) FROM {$table_name} WHERE title LIKE %s OR content LIKE %s", $like, $like));
524 521 } else {
525 - $total_items = $wpdb->get_var("SELECT COUNT(id) FROM {$table_name}"); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter
522 + $total_items = $wpdb->get_var("SELECT COUNT(id) FROM {$table_name}");
526 523 }
527 524 $items_per_page = 50;
528 525 $page = isset($_GET['paged']) ? absint(wp_unslash($_GET['paged'])) : 1;
529 526 $offset = ($page - 1) * $items_per_page;
@@ -531,10 +528,10 @@
531 528
532 529 $pagination_args = array(
533 530 'base' => add_query_arg(array('paged' => '%#%', 's' => $search_query), '?page=wpbot_openAi') . '#ai-knowledge-base-tab#rag-database',
534 531 'format' => '',
535 - 'prev_text' => __( '&laquo;', 'chatbot' ),
536 - 'next_text' => __( '&raquo;', 'chatbot' ),
532 + 'prev_text' => __('&laquo;'),
533 + 'next_text' => __('&raquo;'),
537 534 'total' => $total_pages,
538 535 'current' => $page,
539 536 'type' => 'plain',
540 537 );
@@ -539,11 +536,10 @@
539 536 'type' => 'plain',
540 537 );
541 538
542 539 if ($total_pages > 1) {
543 - // translators: %s: number of items.
544 - echo '<div class="tablenav-pages"><span class="displaying-num">' . sprintf( esc_html( _n( '%s item', '%s items', $total_items, 'chatbot' ) ), esc_html( number_format_i18n($total_items) ) ) . '</span>';
545 - echo wp_kses_post( paginate_links($pagination_args) );
540 + echo '<div class="tablenav-pages"><span class="displaying-num">' . sprintf(_n('%s item', '%s items', $total_items), number_format_i18n($total_items)) . '</span>';
541 + echo paginate_links($pagination_args);
546 542 echo '</div>';
547 543 }
548 544 ?>
549 545
@@ -564,19 +560,19 @@
564 560 <tbody id="rag-knowledge-base-list">
565 561 <?php
566 562 if ($search_query) {
567 563 $like = '%' . $wpdb->esc_like($search_query) . '%';
568 - $documents = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$table_name} WHERE title LIKE %s OR content LIKE %s ORDER BY created_at DESC LIMIT %d OFFSET %d", $like, $like, $items_per_page, $offset)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter
564 + $documents = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$table_name} WHERE title LIKE %s OR content LIKE %s ORDER BY created_at DESC LIMIT %d OFFSET %d", $like, $like, $items_per_page, $offset));
569 565 } else {
570 - $documents = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$table_name} ORDER BY created_at DESC LIMIT %d OFFSET %d", $items_per_page, $offset)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter
566 + $documents = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$table_name} ORDER BY created_at DESC LIMIT %d OFFSET %d", $items_per_page, $offset));
571 567 }
572 568
573 569 if ($documents) {
574 570 foreach ($documents as $doc) {
575 571 ?>
576 - <tr id="rag-doc-<?php echo esc_attr( $doc->id ); ?>">
572 + <tr id="rag-doc-<?php echo $doc->id; ?>">
577 573 <th scope="qcld-row" class="check-column">
578 - <input type="checkbox" class="rag-doc-checkbox" value="<?php echo esc_attr( $doc->id ); ?>">
574 + <input type="checkbox" class="rag-doc-checkbox" value="<?php echo $doc->id; ?>">
579 575 </th>
580 576 <td><?php echo esc_html($doc->title); ?></td>
581 577 <td>
582 578 <div style="max-height: 4.5em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; line-height: 1.5em; font-size: 13px; color: #666;">
@@ -587,12 +583,12 @@
587 583 <td><?php echo esc_html($doc->source_url ?: $doc->file_url); ?></td>
588 584 <td><?php echo esc_html($doc->status); ?></td>
589 585 <td>
590 586 <?php if (!in_array($doc->source_type, ['csv', 'xml', 'xaml','sitemap'])): ?>
591 - <button class="button button-small rag-sync-doc" data-id="<?php echo esc_attr( $doc->id ); ?>" title="Re-sync data from source">Sync</button>
587 + <button class="button button-small rag-sync-doc" data-id="<?php echo $doc->id; ?>" title="Re-sync data from source">Sync</button>
592 588 <?php endif; ?>
593 - <button class="button button-small rag-edit-doc" data-id="<?php echo esc_attr( $doc->id ); ?>">Edit</button>
594 - <button class="button button-small button-link-delete rag-delete-doc" data-id="<?php echo esc_attr( $doc->id ); ?>">Delete</button>
589 + <button class="button button-small rag-edit-doc" data-id="<?php echo $doc->id; ?>">Edit</button>
590 + <button class="button button-small button-link-delete rag-delete-doc" data-id="<?php echo $doc->id; ?>">Delete</button>
595 591 </td>
596 592 </tr>
597 593 <?php
598 594 }
@@ -605,11 +601,10 @@
605 601
606 602 <div class="tablenav bottom">
607 603 <?php
608 604 if ($total_pages > 1) {
609 - // translators: %s: number of items.
610 - echo '<div class="tablenav-pages"><span class="displaying-num">' . sprintf( esc_html( _n( '%s item', '%s items', $total_items, 'chatbot' ) ), esc_html( number_format_i18n($total_items) ) ) . '</span>';
611 - echo wp_kses_post( paginate_links($pagination_args) );
605 + echo '<div class="tablenav-pages"><span class="displaying-num">' . sprintf(_n('%s item', '%s items', $total_items), number_format_i18n($total_items)) . '</span>';
606 + echo paginate_links($pagination_args);
612 607 echo '</div>';
613 608 }
614 609 ?>
615 610 <br class="clear">
@@ -658,9 +653,9 @@
658 653 for (var i = 0; i < fileInput.files.length; i++) {
659 654 formData.append('rag_pdf[]', fileInput.files[i]);
660 655 }
661 656 formData.append('action', 'rag_upload_pdf');
662 - formData.append('nonce', '<?php echo esc_js( wp_create_nonce('rag_upload_nonce') ); ?>');
657 + formData.append('nonce', '<?php echo wp_create_nonce('rag_upload_nonce'); ?>');
663 658
664 659 $('#rag-pdf-submit').prop('disabled', true);
665 660 $('#rag-pdf-status').html('<span class="spinner is-active" style="float:none;"></span> Uploading and processing...');
666 661 $('#rag-pdf-output').html('');
@@ -704,9 +699,9 @@
704 699 for (var i = 0; i < fileInput.files.length; i++) {
705 700 formData.append('rag_csv[]', fileInput.files[i]);
706 701 }
707 702 formData.append('action', 'rag_upload_csv');
708 - formData.append('nonce', '<?php echo esc_js( wp_create_nonce('rag_upload_nonce') ); ?>');
703 + formData.append('nonce', '<?php echo wp_create_nonce('rag_upload_nonce'); ?>');
709 704
710 705 $('#rag-csv-submit').prop('disabled', true);
711 706 $('#rag-csv-status').html('<span class="spinner is-active" style="float:none;"></span> Uploading and processing...');
712 707 $('#rag-csv-output').html('');
@@ -750,9 +745,9 @@
750 745 for (var i = 0; i < fileInput.files.length; i++) {
751 746 formData.append('rag_xaml[]', fileInput.files[i]);
752 747 }
753 748 formData.append('action', 'rag_upload_xaml');
754 - formData.append('nonce', '<?php echo esc_js( wp_create_nonce('rag_upload_nonce') ); ?>');
749 + formData.append('nonce', '<?php echo wp_create_nonce('rag_upload_nonce'); ?>');
755 750
756 751 $('#rag-xaml-submit').prop('disabled', true);
757 752 $('#rag-xaml-status').html('<span class="spinner is-active" style="float:none;"></span> Uploading and processing...');
758 753 $('#rag-xaml-output').html('');