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 -47 8.5.58.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
@@ -64,22 +61,9 @@
64 61 <?php endforeach; ?>
65 62 </div>
66 63 <p class="description">Select multiple custom post types to embed.</p>
67 64 </div>
68 - <div class="mb-4" style="background: #f9f9f9; padding: 15px; border-radius: 8px; border-left: 4px solid #007bff;">
69 - <h4 style="margin-top: 0;"><i class="fa fa-tags"></i> Post Meta Data Settings <span class="pro-badge" style="display:inline-block; margin-left:8px; padding:2px 6px; background:#f0b429; color:#fff; border-radius:3px; font-size:11px; font-weight:bold; text-transform:uppercase;">PRO</span></h4>
70 - <div class="mb-3">
71 - <input type="checkbox" id="rag_embed_meta" <?php checked(get_option('rag_embed_meta'), '1'); ?> disabled>
72 - <label for="rag_embed_meta"><strong>Include Post Meta Data</strong></label>
73 - <p class="description">Enable this to include custom fields/meta data in the embeddings.</p>
74 - </div>
75 65
76 - <div class="mb-3">
77 - <label for="rag_embed_meta_keys"><strong>Meta Keys to Include (comma separated):</strong></label><br>
78 - <input type="text" id="rag_embed_meta_keys" value="<?php echo esc_attr(get_option('rag_embed_meta_keys', '')); ?>" placeholder="e.g. _price, _sku, custom_field_key" style="width: 100%; max-width: 400px; margin-top: 5px;" disabled>
79 - <p class="description">Specify the meta keys you want to include in the context. Leave empty to include all meta (not recommended).</p>
80 - </div>
81 - </div>
82 66
83 67 </div>
84 68 <!-- ===========================
85 69 EXECUTION BUTTON
@@ -161,16 +145,16 @@
161 145 ?>
162 146
163 147 <div class="mb-3">
164 148 <input type="checkbox" id="rag_googlesheets_autosync_enabled" <?php checked(get_option('rag_googlesheets_autosync_enabled'), '1'); ?>>
165 - <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>
166 - <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>
167 151 </div>
168 152
169 153 <div class="mb-3">
170 154 <input type="checkbox" id="rag_googledocs_autosync_enabled" <?php checked(get_option('rag_googledocs_autosync_enabled'), '1'); ?>>
171 - <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>
172 - <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>
173 157 </div>
174 158
175 159 <div class="mb-3">
176 160 <label for="rag_sync_interval"><strong>Sync Interval:</strong></label>
@@ -212,9 +196,9 @@
212 196 CSV UPLOAD (AJAX)
213 197 ============================ -->
214 198 <div class="wrap">
215 199 <h3>Upload CSV Data for RAG</h3>
216 - <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>
217 201
218 202 <form id="rag-csv-form">
219 203 <input type="file" id="rag-csv-files" name="rag_csv[]" multiple accept=".csv,text/csv" />
220 204 <br><br>
@@ -318,9 +302,9 @@
318 302
319 303 <div id="botmaster_googledoc_status" style="margin-top: 10px;"></div>
320 304 </div>
321 305 </div>
322 - <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>
323 307 <div class="wrap">
324 308 <button class="qcld-btn-primary" id="save_rag_setting">Save Settings</button>
325 309 </div>
326 310 </div>
@@ -351,9 +335,9 @@
351 335
352 336 $.post(ajaxurl, {
353 337 action: 'botmaster_submit_sitemap',
354 338 sitemap_url: sitemapUrl,
355 - nonce: '<?php echo esc_attr( wp_create_nonce('botmaster_kb_nonce') ); ?>'
339 + nonce: '<?php echo wp_create_nonce("botmaster_kb_nonce"); ?>'
356 340 }, function(response) {
357 341 $('#botmaster_submit_sitemap_btn').prop('disabled', false);
358 342 if (response.success) {
359 343 statusDiv.html('<div class="notice notice-success inline"><p>' + response.data.message + '</p></div>');
@@ -368,9 +352,9 @@
368 352 <?php if ( $wpchatbot_license_valid != 'master' && $wpchatbot_license_valid != 'professional'): ?>
369 353 <div class="wrap">
370 354 <div style="background-color: #fee; border: 1px solid #c33; padding: 15px; margin: 20px 0; border-radius: 4px;">
371 355 <p style="color: #c33; font-weight: bold; margin: 0; font-size: 14px;">
372 - 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
373 357 </p>
374 358 </div>
375 359 </div>
376 360 <?php endif; ?>
@@ -393,9 +377,9 @@
393 377 <tbody id="rag-sources-list">
394 378 <?php
395 379 global $wpdb;
396 380 $table = $wpdb->prefix . 'rag_documents';
397 - $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");
398 382
399 383 if ($sources) {
400 384 foreach ($sources as $source) {
401 385 $display_url = $source->source_url ?: "Manual Upload";
@@ -507,9 +491,9 @@
507 491 echo '<div class="notice notice-success inline"><p>Database table created successfully.</p></div>';
508 492 }
509 493
510 494 // Check if table exists
511 - $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;
512 496
513 497 if (!$table_exists) {
514 498 ?>
515 499 <div class="wrap">
@@ -532,11 +516,11 @@
532 516 $search_query = isset($_GET['s']) ? sanitize_text_field(wp_unslash($_GET['s'])) : '';
533 517
534 518 if ($search_query) {
535 519 $like = '%' . $wpdb->esc_like($search_query) . '%';
536 - $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));
537 521 } else {
538 - $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}");
539 523 }
540 524 $items_per_page = 50;
541 525 $page = isset($_GET['paged']) ? absint(wp_unslash($_GET['paged'])) : 1;
542 526 $offset = ($page - 1) * $items_per_page;
@@ -544,10 +528,10 @@
544 528
545 529 $pagination_args = array(
546 530 'base' => add_query_arg(array('paged' => '%#%', 's' => $search_query), '?page=wpbot_openAi') . '#ai-knowledge-base-tab#rag-database',
547 531 'format' => '',
548 - 'prev_text' => __( '&laquo;', 'chatbot' ),
549 - 'next_text' => __( '&raquo;', 'chatbot' ),
532 + 'prev_text' => __('&laquo;'),
533 + 'next_text' => __('&raquo;'),
550 534 'total' => $total_pages,
551 535 'current' => $page,
552 536 'type' => 'plain',
553 537 );
@@ -552,11 +536,10 @@
552 536 'type' => 'plain',
553 537 );
554 538
555 539 if ($total_pages > 1) {
556 - // translators: %s: number of items.
557 - 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>';
558 - 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);
559 542 echo '</div>';
560 543 }
561 544 ?>
562 545
@@ -577,19 +560,19 @@
577 560 <tbody id="rag-knowledge-base-list">
578 561 <?php
579 562 if ($search_query) {
580 563 $like = '%' . $wpdb->esc_like($search_query) . '%';
581 - $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));
582 565 } else {
583 - $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));
584 567 }
585 568
586 569 if ($documents) {
587 570 foreach ($documents as $doc) {
588 571 ?>
589 - <tr id="rag-doc-<?php echo esc_attr( $doc->id ); ?>">
572 + <tr id="rag-doc-<?php echo $doc->id; ?>">
590 573 <th scope="qcld-row" class="check-column">
591 - <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; ?>">
592 575 </th>
593 576 <td><?php echo esc_html($doc->title); ?></td>
594 577 <td>
595 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;">
@@ -600,12 +583,12 @@
600 583 <td><?php echo esc_html($doc->source_url ?: $doc->file_url); ?></td>
601 584 <td><?php echo esc_html($doc->status); ?></td>
602 585 <td>
603 586 <?php if (!in_array($doc->source_type, ['csv', 'xml', 'xaml','sitemap'])): ?>
604 - <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>
605 588 <?php endif; ?>
606 - <button class="button button-small rag-edit-doc" data-id="<?php echo esc_attr( $doc->id ); ?>">Edit</button>
607 - <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>
608 591 </td>
609 592 </tr>
610 593 <?php
611 594 }
@@ -618,11 +601,10 @@
618 601
619 602 <div class="tablenav bottom">
620 603 <?php
621 604 if ($total_pages > 1) {
622 - // translators: %s: number of items.
623 - 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>';
624 - 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);
625 607 echo '</div>';
626 608 }
627 609 ?>
628 610 <br class="clear">
@@ -671,9 +653,9 @@
671 653 for (var i = 0; i < fileInput.files.length; i++) {
672 654 formData.append('rag_pdf[]', fileInput.files[i]);
673 655 }
674 656 formData.append('action', 'rag_upload_pdf');
675 - 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'); ?>');
676 658
677 659 $('#rag-pdf-submit').prop('disabled', true);
678 660 $('#rag-pdf-status').html('<span class="spinner is-active" style="float:none;"></span> Uploading and processing...');
679 661 $('#rag-pdf-output').html('');
@@ -717,9 +699,9 @@
717 699 for (var i = 0; i < fileInput.files.length; i++) {
718 700 formData.append('rag_csv[]', fileInput.files[i]);
719 701 }
720 702 formData.append('action', 'rag_upload_csv');
721 - 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'); ?>');
722 704
723 705 $('#rag-csv-submit').prop('disabled', true);
724 706 $('#rag-csv-status').html('<span class="spinner is-active" style="float:none;"></span> Uploading and processing...');
725 707 $('#rag-csv-output').html('');
@@ -763,9 +745,9 @@
763 745 for (var i = 0; i < fileInput.files.length; i++) {
764 746 formData.append('rag_xaml[]', fileInput.files[i]);
765 747 }
766 748 formData.append('action', 'rag_upload_xaml');
767 - 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'); ?>');
768 750
769 751 $('#rag-xaml-submit').prop('disabled', true);
770 752 $('#rag-xaml-status').html('<span class="spinner is-active" style="float:none;"></span> Uploading and processing...');
771 753 $('#rag-xaml-output').html('');