| @@ -1,11 +1,11 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * Plugin Name: AI ChatBot - WPBot |
| 4 | - * Plugin URI: https://www.wpbot.pro/ | |
| 4 | + * Plugin URI: https://wordpress.org/plugins/chatbot/ | |
| 5 | 5 | * Description: ChatBot is a native WordPress ChatBot plugin to provide live chat support and lead generation |
| 6 | 6 | * Donate link: https://www.wpbot.pro/ |
| 7 | - * Version: 8.6.0 | |
| 7 | + * Version: 8.3.8 | |
| 8 | 8 | * @author QuantumCloud |
| 9 | 9 | * Author: ChatBot for WordPress - WPBot |
| 10 | 10 | * Author URI: https://www.wpbot.pro/ |
| 11 | 11 | * Requires at least: 4.6 |
| @@ -18,39 +18,31 @@ | ||
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | if (!defined('ABSPATH')) exit; // Exit if accessed directly. |
| 21 | 21 | |
| 22 | +add_action( 'plugins_loaded', 'qcld_chatbot_existing_plugin_activate_check_callback' ); | |
| 23 | +if( !function_exists('qcld_chatbot_existing_plugin_activate_check_callback') ){ | |
| 24 | + function qcld_chatbot_existing_plugin_activate_check_callback(){ | |
| 22 | 25 | |
| 23 | -// Abort execution if Pro version is active to prevent conflicts | |
| 24 | -if ( ! function_exists( 'is_plugin_active' ) ) { | |
| 25 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; | |
| 26 | -} | |
| 26 | + $check_existing_plugin = get_option('qcld_chatbot_existing_plugin_activate_check'); | |
| 27 | 27 | |
| 28 | -$active_plugins = (array) get_option( 'active_plugins', array() ); | |
| 29 | -if ( is_multisite() ) { | |
| 30 | - $active_plugins = array_merge( $active_plugins, array_keys( (array) get_site_option( 'active_sitewide_plugins', array() ) ) ); | |
| 31 | -} | |
| 32 | 28 | |
| 33 | -$current_plugin = plugin_basename( __FILE__ ); | |
| 34 | - | |
| 35 | -foreach ( $active_plugins as $plugin ) { | |
| 36 | - if ( $plugin !== $current_plugin && basename( $plugin ) === 'qcld-wpwbot.php' ) { | |
| 37 | - return; | |
| 29 | + if ( class_exists( 'qcld_wb_Chatbot' ) && isset($check_existing_plugin) && ($check_existing_plugin !== 'yes') ) { | |
| 30 | + update_option('qcld_chatbot_existing_plugin_activate_check', 'yes'); | |
| 31 | + }else if ( ! class_exists( 'qcld_wb_Chatbot' ) ) { | |
| 32 | + delete_option('qcld_chatbot_existing_plugin_activate_check'); | |
| 33 | + } | |
| 34 | + | |
| 38 | 35 | } |
| 39 | 36 | } |
| 40 | 37 | |
| 41 | -// Also abort if we are currently activating the Pro plugin | |
| 42 | -if ( isset($_REQUEST['action']) ) { | |
| 43 | - if ( $_REQUEST['action'] == 'activate' && isset($_REQUEST['plugin']) && ( ( strpos($_REQUEST['plugin'], 'wpbot-pro-master') !== false ) || ( strpos($_REQUEST['plugin'], 'wpbot-pro-professional') !== false ) || ( strpos($_REQUEST['plugin'], 'wpbot-pro-professional') !== false ) || ( strpos($_REQUEST['plugin'], 'wpbot-pro-starter') !== false ) ) ) { | |
| 44 | - return; | |
| 45 | - } | |
| 46 | - if ( $_REQUEST['action'] == 'activate-selected' && isset($_POST['checked']) && ( in_array('wpbot-pro-master/qcld-wpwbot.php', $_POST['checked']) || in_array('wpbot-pro-professional/qcld-wpwbot.php', $_POST['checked']) || in_array('wpbot-pro-starter/qcld-wpwbot.php', $_POST['checked']) ) ) { | |
| 47 | - return; | |
| 48 | - } | |
| 38 | +$check_existing_plugin = get_option('qcld_chatbot_existing_plugin_activate_check'); | |
| 39 | +if ( isset($check_existing_plugin) && ($check_existing_plugin == 'yes') || class_exists( 'qcld_wb_Chatbot' ) ) { | |
| 40 | + return; | |
| 49 | 41 | } |
| 50 | 42 | |
| 51 | 43 | if ( ! defined( 'QCLD_wpCHATBOT_VERSION' ) ) { |
| 52 | - define('QCLD_wpCHATBOT_VERSION', '8.6.0'); | |
| 44 | + define('QCLD_wpCHATBOT_VERSION', '8.3.8'); | |
| 53 | 45 | } |
| 54 | 46 | if ( ! defined( 'QCLD_wpCHATBOT_REQUIRED_wpCOMMERCE_VERSION' ) ) { |
| 55 | 47 | define('QCLD_wpCHATBOT_REQUIRED_wpCOMMERCE_VERSION', 2.2); |
| 56 | 48 | } |
| @@ -103,12 +95,8 @@ | ||
| 103 | 95 | // require_once( QCLD_wpCHATBOT_PLUGIN_DIR_PATH . '/inc/qcld-floating-openai-style-filter.php' ); |
| 104 | 96 | // require_once( QCLD_wpCHATBOT_PLUGIN_DIR_PATH . '/inc/qcld_openai_floating_content.php' ); |
| 105 | 97 | // } |
| 106 | 98 | |
| 107 | -// Built-in Chat Sessions & Analytics module. | |
| 108 | -// Defers to the Pro addon automatically when it's active. | |
| 109 | -require_once( QCLD_wpCHATBOT_PLUGIN_DIR_PATH . 'includes/chat-sessions/wpbot-chat-sessions.php' ); | |
| 110 | - | |
| 111 | 99 | /** |
| 112 | 100 | * Main Class. |
| 113 | 101 | */ |
| 114 | 102 | |
| @@ -248,14 +236,12 @@ | ||
| 248 | 236 | $capability = 'publish_posts'; |
| 249 | 237 | }else{ |
| 250 | 238 | $capability = 'manage_options'; |
| 251 | 239 | } |
| 252 | - add_menu_page( esc_html('WPBot - ChatBot Lite'), esc_html('WPBot - ChatBot Lite'), 'manage_options','wpbot-panel', array($this, 'qcld_wb_chatbot_admin_page'),'dashicons-format-status', 6 ); | |
| 240 | + add_menu_page( esc_html('ChatBot WPBot Lite'), esc_html('ChatBot WPBot Lite'), 'manage_options','wpbot-panel', array($this, 'qcld_wb_chatbot_admin_page'),'dashicons-format-status', 6 ); | |
| 253 | 241 | |
| 254 | 242 | add_submenu_page( 'wpbot-panel', esc_html('Settings'), esc_html('Settings'), 'manage_options','wpbot', array($this, 'qcld_wb_chatbot_admin_page_settings') ); |
| 255 | 243 | |
| 256 | - add_submenu_page( 'wpbot-panel', esc_html('User Data'), esc_html('User Data'), 'manage_options','email-subscription', array($this, 'qcld_wb_chatbot_admin_page1') ); | |
| 257 | - | |
| 258 | 244 | add_submenu_page( 'wpbot-panel', esc_html('AI Settings'), esc_html('AI Settings'), 'manage_options','wpbot_openAi', 'wpbot_openAi_setting_func' ); |
| 259 | 245 | |
| 260 | 246 | $hook = add_submenu_page( 'wpbot-panel', esc_html('Simple Text Responses'), esc_html('Simple Text Responses'), $capability,'simple-text-response', array($this, 'qcld_wb_chatbot_admin_str') ); |
| 261 | 247 | |
| @@ -262,9 +248,9 @@ | ||
| 262 | 248 | add_action( "load-$hook", [ $this, 'screen_option' ] ); |
| 263 | 249 | |
| 264 | 250 | // add_submenu_page( 'wpbot-panel', esc_html('Conversational Form '), esc_html('Conversational Form'), 'manage_options','wpbots', [$this, 'qcld_wb_chatbot_admin_conversational_settings'] ); |
| 265 | 251 | |
| 266 | - add_submenu_page( 'wpbot-panel', esc_html('Get Support'), esc_html('Get Support'), 'manage_options','wpbot_support_page', 'qcpromo_wpbot_free_support_page_callback_func' ); | |
| 252 | + add_submenu_page( 'wpbot-panel', esc_html('Support'), esc_html('Support'), 'manage_options','wpbot_support_page', 'qcpromo_wpbot_free_support_page_callback_func' ); | |
| 267 | 253 | |
| 268 | 254 | add_submenu_page( 'wpbot-panel', esc_html('Help and Debugging'), esc_html('Help and Debugging'), 'manage_options','wpbot_help_page', 'wpbot_help_page_callback_func' ); |
| 269 | 255 | |
| 270 | 256 | |
| @@ -371,9 +357,9 @@ | ||
| 371 | 357 | public function qcld_get_formbuilder_forms(){ |
| 372 | 358 | global $wpdb; |
| 373 | 359 | $forms = array(); |
| 374 | 360 | if(class_exists('Qcformbuilder_Forms_Admin')){ |
| 375 | - $results = $wpdb->get_results($wpdb->prepare("SELECT * FROM ". $wpdb->prefix."wfb_forms WHERE type=%s", 'primary')); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter | |
| 361 | + $results = $wpdb->get_results($wpdb->prepare("SELECT * FROM ". $wpdb->prefix."wfb_forms WHERE type=%s", 'primary')); //DB Call OK, No Caching OK | |
| 376 | 362 | if(!empty($results)){ |
| 377 | 363 | foreach($results as $result){ |
| 378 | 364 | $form = maybe_unserialize($result->config); |
| 379 | 365 | $forms[] = trim($form['name']); |
| @@ -385,15 +371,12 @@ | ||
| 385 | 371 | }else{ |
| 386 | 372 | return array(); |
| 387 | 373 | } |
| 388 | 374 | } |
| 389 | - public function qcld_wb_chatbot_admin_page1() { | |
| 390 | - require_once QCLD_wpCHATBOT_PLUGIN_DIR_PATH . 'includes/admin/templates/email_subscription.php'; | |
| 391 | - } | |
| 392 | 375 | public function qcld_wpbot_simple_response_intent(){ |
| 393 | 376 | global $wpdb; |
| 394 | 377 | $table = $wpdb->prefix.'wpbot_response'; |
| 395 | - $results = $wpdb->get_results("SELECT `intent` FROM `{$table}` WHERE 1 and `intent` !=''"); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter | |
| 378 | + $results = $wpdb->get_results("SELECT `intent` FROM `$table` WHERE 1 and `intent` !=''"); //DB Call OK, No Caching OK | |
| 396 | 379 | $response = array(); |
| 397 | 380 | if(!empty($results)){ |
| 398 | 381 | foreach($results as $result){ |
| 399 | 382 | $response[] = $result->intent; |
| @@ -405,9 +388,9 @@ | ||
| 405 | 388 | global $wpdb; |
| 406 | 389 | $command = array(); |
| 407 | 390 | if(class_exists('Qcformbuilder_Forms_Admin')){ |
| 408 | 391 | $primary = 'primary'; |
| 409 | - $results = $wpdb->get_results($wpdb->prepare("SELECT * FROM ". $wpdb->prefix."wfb_forms WHERE type = %s", $primary)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter | |
| 392 | + $results = $wpdb->get_results($wpdb->prepare("SELECT * FROM ". $wpdb->prefix."wfb_forms WHERE type = %s", $primary)); //DB Call OK, No Caching OK | |
| 410 | 393 | |
| 411 | 394 | if(!empty($results)){ |
| 412 | 395 | foreach($results as $result){ |
| 413 | 396 | $form = maybe_unserialize($result->config); |
| @@ -426,8 +409,9 @@ | ||
| 426 | 409 | } |
| 427 | 410 | } |
| 428 | 411 | public function promotion_notice(){ |
| 429 | 412 | $screen = get_current_screen(); |
| 413 | + // var_dump($screen->base ); | |
| 430 | 414 | // if( isset($screen->base) && (( $screen->base == 'wpbot-lite_page_wpbot') || ( $screen->base == 'toplevel_page_wpbot-panel"'))){ |
| 431 | 415 | ?> |
| 432 | 416 | <div id="promotion-wpchatbot" data-dismiss-type="qcbot-feedback-notice" class="notice is-dismissible qcbot-feedback" style="background: #120976 !important"> |
| 433 | 417 | <div class=""> |
| @@ -444,9 +428,9 @@ | ||
| 444 | 428 | public function qcld_get_formbuilder_form_ids(){ |
| 445 | 429 | global $wpdb; |
| 446 | 430 | $forms = array(); |
| 447 | 431 | if(class_exists('Qcformbuilder_Forms_Admin')){ |
| 448 | - $results = $wpdb->get_results($wpdb->prepare("SELECT * FROM ". $wpdb->prefix."wfb_forms WHERE type=%s", 'primary')); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter | |
| 432 | + $results = $wpdb->get_results($wpdb->prepare("SELECT * FROM ". $wpdb->prefix."wfb_forms WHERE type=%s", 'primary')); //DB Call OK, No Caching OK | |
| 449 | 433 | |
| 450 | 434 | if(!empty($results)){ |
| 451 | 435 | foreach($results as $result){ |
| 452 | 436 | $form = maybe_unserialize($result->config); |
| @@ -480,9 +464,9 @@ | ||
| 480 | 464 | $conversation_form_ids = array(); |
| 481 | 465 | $conversation_form_names = array(); |
| 482 | 466 | |
| 483 | 467 | if(class_exists('Qcformbuilder_Forms_Admin')){ |
| 484 | - $results = $wpdb->get_results($wpdb->prepare("SELECT * FROM ". $wpdb->prefix."wfb_forms WHERE type=%s", 'primary')); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter | |
| 468 | + $results = $wpdb->get_results($wpdb->prepare("SELECT * FROM ". $wpdb->prefix."wfb_forms WHERE type=%s", 'primary')); //DB Call OK, No Caching OK | |
| 485 | 469 | if(!empty($results)){ |
| 486 | 470 | |
| 487 | 471 | foreach($results as $result){ |
| 488 | 472 | $form = maybe_unserialize($result->config); |
| @@ -508,12 +492,12 @@ | ||
| 508 | 492 | 'yes' => str_replace('\\', '',get_option('qlcd_wp_chatbot_yes')), |
| 509 | 493 | 'no' => str_replace('\\', '',get_option('qlcd_wp_chatbot_no')), |
| 510 | 494 | 'or' => str_replace('\\', '',get_option('qlcd_wp_chatbot_or')), |
| 511 | 495 | 'host' => str_replace('\\', '',get_option('qlcd_wp_chatbot_host')), |
| 512 | - 'agent' => str_replace(['\\','<','>'], '',esc_html(is_array(maybe_unserialize(get_option('qlcd_wp_chatbot_agent'))) ? current(maybe_unserialize(get_option('qlcd_wp_chatbot_agent'))) : get_option('qlcd_wp_chatbot_agent'))), | |
| 496 | + 'agent' => str_replace(['\\','<','>'], '',esc_html(get_option('qlcd_wp_chatbot_agent'))), | |
| 513 | 497 | 'agent_image' => get_option('wp_chatbot_agent_image'), |
| 514 | 498 | 'agent_image_path' => esc_url((!empty(get_option('wp_chatbot_custom_icon_path')) && !is_404(get_option('wp_chatbot_custom_icon_path'))) ? $this->qcld_wb_chatbot_agent_icon() : QCLD_wpCHATBOT_IMG_URL . 'icon-1.png'), |
| 515 | - 'shopper_demo_name' => str_replace('\\', '', is_array(maybe_unserialize(get_option('qlcd_wp_chatbot_shopper_demo_name'))) ? current(maybe_unserialize(get_option('qlcd_wp_chatbot_shopper_demo_name'))) : get_option('qlcd_wp_chatbot_shopper_demo_name')), | |
| 499 | + 'shopper_demo_name' => str_replace('\\', '',get_option('qlcd_wp_chatbot_shopper_demo_name')), | |
| 516 | 500 | 'agent_join' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_agent_join'))), |
| 517 | 501 | 'welcome' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_welcome'))), |
| 518 | 502 | 'welcome_back' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_welcome_back'))), |
| 519 | 503 | 'hi_there' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_hi_there'))), |
| @@ -539,54 +523,54 @@ | ||
| 539 | 523 | 'sys_key_order' => get_option('qlcd_wp_chatbot_sys_key_order'), |
| 540 | 524 | 'sys_key_support' => get_option('qlcd_wp_chatbot_sys_key_support'), |
| 541 | 525 | 'sys_key_reset' => get_option('qlcd_wp_chatbot_sys_key_reset'), |
| 542 | 526 | 'sys_key_email' => get_option('qlcd_wp_chatbot_sys_key_email'), |
| 543 | - 'help_welcome' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_help_welcome'))), | |
| 544 | - 'back_to_start' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_back_to_start'))), | |
| 545 | - 'help_msg' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_help_msg'))), | |
| 546 | - 'reset' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_reset'))), | |
| 547 | - 'wildcard_product' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_wildcard_product'))), | |
| 548 | - 'wildcard_catalog' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_wildcard_catalog'))), | |
| 549 | - 'featured_products' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_featured_products'))), | |
| 550 | - 'sale_products' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_sale_products'))), | |
| 551 | - 'wildcard_order' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_wildcard_order'))), | |
| 527 | + 'help_welcome' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_help_welcome'))), | |
| 528 | + 'back_to_start' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_back_to_start'))), | |
| 529 | + 'help_msg' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_help_msg'))), | |
| 530 | + 'reset' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_reset'))), | |
| 531 | + 'wildcard_product' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_wildcard_product'))), | |
| 532 | + 'wildcard_catalog' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_wildcard_catalog'))), | |
| 533 | + 'featured_products' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_featured_products'))), | |
| 534 | + 'sale_products' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_sale_products'))), | |
| 535 | + 'wildcard_order' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_wildcard_order'))), | |
| 552 | 536 | 'wildcard_support' => get_option('qlcd_wp_chatbot_wildcard_support'), |
| 553 | - 'product_asking' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_product_asking'))), | |
| 554 | - 'product_suggest' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_product_suggest'))), | |
| 555 | - 'product_infinite' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_product_infinite'))), | |
| 556 | - 'product_success' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_product_success'))), | |
| 557 | - 'product_fail' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_product_fail'))), | |
| 558 | - 'support_welcome' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_support_welcome'))), | |
| 537 | + 'product_asking' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_product_asking'))), | |
| 538 | + 'product_suggest' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_product_suggest'))), | |
| 539 | + 'product_infinite' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_product_infinite'))), | |
| 540 | + 'product_success' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_product_success'))), | |
| 541 | + 'product_fail' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_product_fail'))), | |
| 542 | + 'support_welcome' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_support_welcome'))), | |
| 559 | 543 | 'support_email' => get_option('qlcd_wp_chatbot_support_email'), |
| 560 | - 'support_option_again' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_support_option_again'))), | |
| 561 | - 'asking_email' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_asking_email'))), | |
| 562 | - 'asking_msg' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_asking_msg'))), | |
| 563 | - 'no_result' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_no_result'))), | |
| 544 | + 'support_option_again' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_support_option_again'))), | |
| 545 | + 'asking_email' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_asking_email'))), | |
| 546 | + 'asking_msg' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_asking_msg'))), | |
| 547 | + 'no_result' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_no_result'))), | |
| 564 | 548 | 'support_phone' => get_option('qlcd_wp_chatbot_support_phone'), |
| 565 | - 'asking_phone' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_asking_phone'))), | |
| 566 | - 'thank_for_phone' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_thank_for_phone'))), | |
| 567 | - 'support_query' => ((gettype(get_option('support_query')) == 'string') ? $this->qcld_wb_chatbot_str_replace(maybe_unserialize( get_option('support_query'))) : $this->qcld_wb_chatbot_str_replace(( get_option('support_query')))), | |
| 568 | - 'support_ans' => (gettype(get_option('support_ans')) == 'string') ? $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('support_ans'))) : $this->qcld_wb_chatbot_str_replace((get_option('support_ans'))), | |
| 549 | + 'asking_phone' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_asking_phone'))), | |
| 550 | + 'thank_for_phone' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_thank_for_phone'))), | |
| 551 | + 'support_query' => ((gettype(get_option('support_query')) == 'string') ? $this->qcld_wb_chatbot_str_replace(unserialize( get_option('support_query'))) : $this->qcld_wb_chatbot_str_replace(( get_option('support_query')))), | |
| 552 | + 'support_ans' => (gettype(get_option('support_ans')) == 'string') ? $this->qcld_wb_chatbot_str_replace(unserialize(get_option('support_ans'))) : $this->qcld_wb_chatbot_str_replace((get_option('support_ans'))), | |
| 569 | 553 | 'notification_interval' => get_option('qlcd_wp_chatbot_notification_interval'), |
| 570 | - 'notifications' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_notifications'))), | |
| 571 | - 'order_welcome' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_order_welcome'))), | |
| 572 | - 'order_username_asking' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_order_username_asking'))), | |
| 573 | - 'order_username_password' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_order_username_password'))), | |
| 554 | + 'notifications' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_notifications'))), | |
| 555 | + 'order_welcome' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_order_welcome'))), | |
| 556 | + 'order_username_asking' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_order_username_asking'))), | |
| 557 | + 'order_username_password' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_order_username_password'))), | |
| 574 | 558 | 'order_user' => get_option('qlcd_wp_chatbot_order_user'), |
| 575 | 559 | 'order_login' => is_user_logged_in(), |
| 576 | 560 | 'is_chat_session_active' => qcld_wpbot_is_active_chat_history(), |
| 577 | 561 | 'order_nonce' => wp_create_nonce("wpwbot-order-nonce"), |
| 578 | - 'order_email_support' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_order_email_support'))), | |
| 562 | + 'order_email_support' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_order_email_support'))), | |
| 579 | 563 | 'email_fail' => str_replace('\\', '', get_option('qlcd_wp_chatbot_email_fail')), |
| 580 | - 'invalid_email' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_invalid_email'))), | |
| 564 | + 'invalid_email' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_invalid_email'))), | |
| 581 | 565 | 'stop_words' => str_replace('\\', '', get_option('qlcd_wp_chatbot_stop_words')), |
| 582 | 566 | 'currency_symbol' => '', |
| 583 | 567 | 'enable_messenger' => get_option('enable_wp_chatbot_messenger'), |
| 584 | - 'messenger_label' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_messenger_label'))), | |
| 568 | + 'messenger_label' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_messenger_label'))), | |
| 585 | 569 | 'fb_page_id' => get_option('qlcd_wp_chatbot_fb_page_id'), |
| 586 | 570 | 'enable_skype' => get_option('enable_wp_chatbot_skype'), |
| 587 | 571 | 'enable_whats' => get_option('enable_wp_chatbot_whats'), |
| 588 | - 'whats_label' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_whats_label'))), | |
| 572 | + 'whats_label' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_whats_label'))), | |
| 589 | 573 | 'whats_num' => get_option('qlcd_wp_chatbot_whats_num'), |
| 590 | 574 | 'ret_greet' => get_option('qlcd_wp_chatbot_ret_greet'), |
| 591 | 575 | 'enable_exit_intent' => get_option('enable_wp_chatbot_exit_intent'), |
| 592 | 576 | 'exit_intent_msg' => str_replace('\\', '', get_option('wp_chatbot_exit_intent_msg')), |
| @@ -601,9 +585,9 @@ | ||
| 601 | 585 | 'auto_open_once' => get_option('wp_chatbot_auto_open_once'), |
| 602 | 586 | 'proactive_bg_color' => get_option('wp_chatbot_proactive_bg_color'), |
| 603 | 587 | 'disable_feedback' => get_option('disable_wp_chatbot_feedback'), |
| 604 | 588 | 'disable_faq' => get_option('disable_wp_chatbot_faq'), |
| 605 | - 'feedback_label' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_feedback_label'))), | |
| 589 | + 'feedback_label' => $this->qcld_wb_chatbot_str_replace(unserialize(get_option('qlcd_wp_chatbot_feedback_label'))), | |
| 606 | 590 | 'enable_meta_title' =>get_option('enable_wp_chatbot_meta_title'), |
| 607 | 591 | 'meta_label' =>str_replace('\\', '', get_option('qlcd_wp_chatbot_meta_label')), |
| 608 | 592 | 'phone_number' => get_option('qlcd_wp_chatbot_phone'), |
| 609 | 593 | 'disable_site_search' => get_option('disable_wp_chatbot_site_search'), |
| @@ -651,9 +635,8 @@ | ||
| 651 | 635 | 'current_user_id' => $user_id, |
| 652 | 636 | 'display_name' => esc_html( $display_name ), |
| 653 | 637 | 'skip_wp_greetings' => get_option('skip_wp_greetings'), |
| 654 | 638 | 'skip_greetings_and_menu' => get_option('skip_wp_greetings_donot_show_menu'), |
| 655 | - 'ask_email_wp_greetings' => get_option('ask_email_wp_greetings'), | |
| 656 | 639 | 'skip_chat_reactions_menu' => get_option('skip_chat_reactions_menu'), |
| 657 | 640 | 'qlcd_wp_chatbot_like_text' => get_option('qlcd_wp_chatbot_like_text'), |
| 658 | 641 | 'qlcd_wp_chatbot_dislike_text' => get_option('qlcd_wp_chatbot_dislike_text'), |
| 659 | 642 | 'enable_chat_report_menu' => get_option('enable_chat_report_menu'), |
| @@ -1087,15 +1070,8 @@ | ||
| 1087 | 1070 | if(isset( $_POST["skip_wp_greetings"])){ |
| 1088 | 1071 | $skip_wp_greetings = sanitize_text_field(wp_unslash($_POST["skip_wp_greetings"])); |
| 1089 | 1072 | }else{ $skip_wp_greetings='';} |
| 1090 | 1073 | update_option('skip_wp_greetings', wp_unslash($skip_wp_greetings)); |
| 1091 | - | |
| 1092 | - if( $skip_wp_greetings == '1' || $skip_wp_greetings_donot_show_menu == '1' ){ | |
| 1093 | - $ask_email_wp_greetings = ''; | |
| 1094 | - } elseif(isset( $_POST["ask_email_wp_greetings"])){ | |
| 1095 | - $ask_email_wp_greetings = sanitize_text_field(wp_unslash($_POST["ask_email_wp_greetings"])); | |
| 1096 | - }else{ $ask_email_wp_greetings='';} | |
| 1097 | - update_option('ask_email_wp_greetings', wp_unslash($ask_email_wp_greetings)); | |
| 1098 | 1074 | //Enable /disable wpwbot |
| 1099 | 1075 | if(isset( $_POST["disable_wp_chatbot"])){ |
| 1100 | 1076 | $disable_wp_chatbot = sanitize_text_field(wp_unslash($_POST["disable_wp_chatbot"])); |
| 1101 | 1077 | }else{ $disable_wp_chatbot='';} |
| @@ -1302,14 +1278,8 @@ | ||
| 1302 | 1278 | |
| 1303 | 1279 | //Theming |
| 1304 | 1280 | $qcld_wb_chatbot_theme = (isset($_POST['qcld_wb_chatbot_theme']) ? sanitize_text_field(wp_unslash($_POST['qcld_wb_chatbot_theme'])) : 'template-00'); |
| 1305 | 1281 | update_option('qcld_wb_chatbot_theme', $qcld_wb_chatbot_theme); |
| 1306 | - | |
| 1307 | - //Avatar Location | |
| 1308 | - if(isset($_POST['qcld_chatbot_avatar_location'])) { | |
| 1309 | - $qcld_chatbot_avatar_location = sanitize_text_field(wp_unslash($_POST['qcld_chatbot_avatar_location'])); | |
| 1310 | - update_option('qcld_chatbot_avatar_location', $qcld_chatbot_avatar_location); | |
| 1311 | - } | |
| 1312 | 1282 | //Theme custom background option |
| 1313 | 1283 | if(isset( $_POST["qcld_wb_chatbot_change_bg"])) { |
| 1314 | 1284 | $qcld_wb_chatbot_change_bg = sanitize_text_field(wp_unslash($_POST["qcld_wb_chatbot_change_bg"])); |
| 1315 | 1285 | }else{$qcld_wb_chatbot_change_bg='';} |
| @@ -2491,15 +2461,13 @@ | ||
| 2491 | 2461 | |
| 2492 | 2462 | require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
| 2493 | 2463 | dbDelta( $sql_sliders_Table1 ); |
| 2494 | 2464 | |
| 2495 | - | |
| 2496 | 2465 | //Bot Response Table |
| 2497 | 2466 | $table_rag_documents = $wpdb->prefix . "rag_documents"; |
| 2498 | 2467 | |
| 2499 | 2468 | $charset = $wpdb->get_charset_collate(); |
| 2500 | - if ($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 | |
| 2501 | - // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange | |
| 2469 | + if ($wpdb->get_var("SHOW TABLES LIKE '$table_rag_documents'") != $table_rag_documents) { | |
| 2502 | 2470 | $sql_rag_documents = "CREATE TABLE $table_rag_documents ( |
| 2503 | 2471 | id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, |
| 2504 | 2472 | doc_id VARCHAR(100) DEFAULT NULL, |
| 2505 | 2473 | title VARCHAR(255) NOT NULL, |
| @@ -2513,14 +2481,12 @@ | ||
| 2513 | 2481 | created_at DATETIME DEFAULT CURRENT_TIMESTAMP |
| 2514 | 2482 | ) $charset;"; |
| 2515 | 2483 | require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
| 2516 | 2484 | dbDelta($sql_rag_documents); |
| 2517 | - // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange | |
| 2518 | 2485 | } |
| 2519 | 2486 | $table_report = $wpdb->prefix . 'wpbot_chat_report'; |
| 2520 | 2487 | |
| 2521 | - if ( $wpdb->get_var( $wpdb->prepare("SHOW TABLES LIKE %s", $wpdb->esc_like($table_report)) ) != $table_report ) { // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | |
| 2522 | - // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange | |
| 2488 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '$table_report'" ) != $table_report ) { | |
| 2523 | 2489 | $sql_report = " |
| 2524 | 2490 | CREATE TABLE `$table_report` ( |
| 2525 | 2491 | `id` int(11) NOT NULL AUTO_INCREMENT, |
| 2526 | 2492 | `user_id` int(11) NOT NULL, |
| @@ -2534,40 +2500,20 @@ | ||
| 2534 | 2500 | "; |
| 2535 | 2501 | |
| 2536 | 2502 | require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
| 2537 | 2503 | dbDelta( $sql_report ); |
| 2538 | - // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange | |
| 2539 | 2504 | } |
| 2540 | 2505 | |
| 2541 | - $sqlqry = $wpdb->get_results($wpdb->prepare("select * from {$table1} where id = %d", 1)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter | |
| 2506 | + $sqlqry = $wpdb->get_results($wpdb->prepare("select * from $table1 where id = %d", 1)); //DB Call OK, No Caching OK | |
| 2542 | 2507 | if(empty($sqlqry)){ |
| 2543 | 2508 | |
| 2544 | - $query = 'What are you?'; | |
| 2545 | - $response = 'I am an Automated ChatBot to answer your questions. This is a sample Simple Text Response that can be edited or deleted.'; | |
| 2509 | + $query = 'What Can WPBot do for you?'; | |
| 2510 | + $response = 'WPBot can converse fluidly with users on website and FB messenger. It can search your website, send/collect eMails, user feedback & phone numbers . You can create Custom Intents from DialogFlow with Rich Messages & Card responses!'; | |
| 2546 | 2511 | |
| 2547 | 2512 | $data = array('query' => $query, 'keyword' => '', 'response'=> $response, 'intent'=> ''); |
| 2548 | 2513 | $format = array('%s','%s', '%s', '%s'); |
| 2549 | - $wpdb->insert($table1,$data,$format); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, PluginCheck.Security.DirectDB.UnescapedDBParameter | |
| 2514 | + $wpdb->insert($table1,$data,$format); //DB Call OK, No Caching OK | |
| 2550 | 2515 | } |
| 2551 | - | |
| 2552 | - $table = $wpdb->prefix . 'wpbot_subscription'; | |
| 2553 | - if ($wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $table)) != $table) { // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter | |
| 2554 | - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange | |
| 2555 | - $sql_sliders_Table = " | |
| 2556 | - CREATE TABLE IF NOT EXISTS `$table` ( | |
| 2557 | - `id` int(11) NOT NULL AUTO_INCREMENT, | |
| 2558 | - `name` varchar(256) NOT NULL, | |
| 2559 | - `email` varchar(256) NOT NULL, | |
| 2560 | - `phone` varchar(256) NOT NULL, | |
| 2561 | - `url` text NOT NULL, | |
| 2562 | - `date` datetime NOT NULL, | |
| 2563 | - `user_agent` text NOT NULL, | |
| 2564 | - PRIMARY KEY (`id`) | |
| 2565 | - ) $collate AUTO_INCREMENT=1 "; | |
| 2566 | - require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| 2567 | - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange | |
| 2568 | - dbDelta($sql_sliders_Table); | |
| 2569 | - } | |
| 2570 | 2516 | |
| 2571 | 2517 | $url = get_site_url(); |
| 2572 | 2518 | $url = wp_parse_url($url); |
| 2573 | 2519 | $domain = $url['host']; |
| @@ -2659,19 +2605,11 @@ | ||
| 2659 | 2605 | if(!get_option('wp_chatbot_show_home_page')) { |
| 2660 | 2606 | update_option('wp_chatbot_show_home_page', 'on'); |
| 2661 | 2607 | } |
| 2662 | 2608 | if(!get_option('qc_wpbot_menu_order')) { |
| 2663 | - $site_search_label = get_option('qlcd_wp_chatbot_wildcard_site_search') != '' ? get_option('qlcd_wp_chatbot_wildcard_site_search') : 'Site Search'; | |
| 2664 | - $support_email_label = get_option('qlcd_wp_chatbot_support_email') != '' ? get_option('qlcd_wp_chatbot_support_email') : 'Send us Email.'; | |
| 2665 | - $support_phone_label = get_option('qlcd_wp_chatbot_support_phone') != '' ? get_option('qlcd_wp_chatbot_support_phone') : 'Leave your number. We will call you back!'; | |
| 2666 | - $default_menu = '<span class="qcld-chatbot-wildcard qc_draggable_item qcld-chatbot-site-search" data-wildcart="site_search">' . esc_attr($site_search_label) . '</span>'; | |
| 2667 | - $default_menu .= '<span class="qcld-chatbot-suggest-email qc_draggable_item">' . esc_attr($support_email_label) . '</span>'; | |
| 2668 | - $default_menu .= '<span class="qcld-chatbot-suggest-phone qc_draggable_item">' . esc_attr($support_phone_label) . '</span>'; | |
| 2669 | - update_option('qc_wpbot_menu_order', $default_menu); | |
| 2609 | + update_option('qc_wpbot_menu_order', ''); | |
| 2670 | 2610 | } |
| 2671 | - if(!get_option('qcld_chatbot_avatar_location')) { | |
| 2672 | - update_option('qcld_chatbot_avatar_location', 'side'); | |
| 2673 | - } | |
| 2611 | + | |
| 2674 | 2612 | if(!get_option('wp_chatbot_show_posts')) { |
| 2675 | 2613 | update_option('wp_chatbot_show_posts', 'on'); |
| 2676 | 2614 | } |
| 2677 | 2615 | if(!get_option('wp_chatbot_show_pages')){ |
| @@ -3467,9 +3405,8 @@ | ||
| 3467 | 3405 | delete_option('wp_chat_user_font_family'); |
| 3468 | 3406 | delete_option('wp_chat_bot_font_family'); |
| 3469 | 3407 | delete_option('wp_chatbot_bot_font'); |
| 3470 | 3408 | delete_option('wp_chatbot_user_font'); |
| 3471 | - delete_option('qcld_chatbot_avatar_location'); | |
| 3472 | 3409 | set_transient( 'qcld_bot_clear_cache', 1, DAY_IN_SECONDS ); |
| 3473 | 3410 | qcld_wb_chatboot_defualt_options(); |
| 3474 | 3411 | $html='Reset all options to default successfully.'; |
| 3475 | 3412 | wp_send_json($html); |
| @@ -3539,9 +3476,9 @@ | ||
| 3539 | 3476 | <div class="wrap qcld-main-wrapper"> |
| 3540 | 3477 | <div class="qcld-wp-chatbot-wrap-header"> |
| 3541 | 3478 | |
| 3542 | 3479 | <div class="qcld-wp-chatbot-wrap-header-logo"><a href="#" class="qcld-wp-chatbot-wrap-site__logo"><img style="width:100%" src="<?php echo esc_url( QCLD_wpCHATBOT_IMG_URL . '/chatbot.png' ); ?>" alt="Dialogflow CX"> WPBot Control Panel </a> |
| 3543 | - <p><strong>Core Version:</strong> v<?php echo esc_html( QCLD_wpCHATBOT_VERSION ); ?></p> | |
| 3480 | + <p><strong>Core Version:</strong> v<?php echo QCLD_wpCHATBOT_VERSION; ?></p> | |
| 3544 | 3481 | </div> |
| 3545 | 3482 | <ul class="qcld-wp-chatbot-wrap-version-wrapper"> |
| 3546 | 3483 | <li> |
| 3547 | 3484 | <a class="wpchatbot-Upgrade" href="https://www.wpbot.pro/" target="_blank">Upgrade To Pro</a> |
| @@ -4141,17 +4078,17 @@ | ||
| 4141 | 4078 | if(!get_option('qlcd_wp_chatbot_did_you_mean')) { |
| 4142 | 4079 | update_option('qlcd_wp_chatbot_did_you_mean', maybe_serialize(array('Did you mean?'))); |
| 4143 | 4080 | } |
| 4144 | 4081 | |
| 4145 | - $sqlqry = $wpdb->get_results( $wpdb->prepare( "select * from {$table1} where id = %d", 1 ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter | |
| 4082 | + $sqlqry = $wpdb->get_results( $wpdb->prepare( "select * from $table1 where id = %d", 1 ) ); //DB Call OK, No Caching OK | |
| 4146 | 4083 | if(empty($sqlqry)){ |
| 4147 | 4084 | |
| 4148 | - $query = 'What are you?'; | |
| 4149 | - $response = 'I am an Automated ChatBot to answer your questions. This is a sample Simple Text Response that can be edited or deleted.'; | |
| 4085 | + $query = 'What Can WPBot do for you?'; | |
| 4086 | + $response = 'WPBot can converse fluidly with users on website and FB messenger. It can search your website, send/collect eMails, user feedback & phone numbers . You can create Custom Intents from DialogFlow with Rich Messages & Card responses!'; | |
| 4150 | 4087 | |
| 4151 | 4088 | $data = array('query' => $query, 'keyword' => '', 'response'=> $response, 'intent'=> ''); |
| 4152 | 4089 | $format = array('%s','%s', '%s', '%s'); |
| 4153 | - $wpdb->insert($table1,$data,$format); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, PluginCheck.Security.DirectDB.UnescapedDBParameter | |
| 4090 | + $wpdb->insert($table1,$data,$format); //DB Call OK, No Caching OK | |
| 4154 | 4091 | } |
| 4155 | 4092 | |
| 4156 | 4093 | update_option('qc_wpb_simple_response_db_upgrade_free2', 'done'); |
| 4157 | 4094 | |
| @@ -4197,11 +4134,11 @@ | ||
| 4197 | 4134 | if(isset($_POST['qc_bot_str_id']) && wp_unslash($_POST['qc_bot_str_id'])!=''){ |
| 4198 | 4135 | $id = sanitize_text_field(wp_unslash($_POST['qc_bot_str_id'])); |
| 4199 | 4136 | $where = array('id'=>$id); |
| 4200 | 4137 | $whereformat = array('%d'); |
| 4201 | - $wpdb->update( $table, $data, $where, $format, $whereformat ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | |
| 4138 | + $wpdb->update( $table, $data, $where, $format, $whereformat ); //DB Call OK, No Caching OK | |
| 4202 | 4139 | }else{ |
| 4203 | - $wpdb->insert($table,$data,$format); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery | |
| 4140 | + $wpdb->insert($table,$data,$format); //DB Call OK, No Caching OK | |
| 4204 | 4141 | } |
| 4205 | 4142 | |
| 4206 | 4143 | qcld_mysql_remove_existing_indexes(); |
| 4207 | 4144 | |
| @@ -4207,9 +4144,9 @@ | ||
| 4207 | 4144 | |
| 4208 | 4145 | // phpcs:ignore |
| 4209 | 4146 | $wpdb->query("ALTER TABLE $table ADD FULLTEXT(`query`, `keyword`, `response`)"); |
| 4210 | 4147 | |
| 4211 | - wp_safe_redirect(admin_url('admin.php?page=simple-text-response'));exit; | |
| 4148 | + wp_redirect(admin_url('admin.php?page=simple-text-response'));exit; | |
| 4212 | 4149 | |
| 4213 | 4150 | } |
| 4214 | 4151 | $table = $wpdb->prefix.'wpbot_response'; |
| 4215 | 4152 | |
| @@ -4240,27 +4177,15 @@ | ||
| 4240 | 4177 | } |
| 4241 | 4178 | if(isset($_POST['qc_bot_str_fields']) && !empty($_POST['qc_bot_str_fields'])){ |
| 4242 | 4179 | $table = $wpdb->prefix.'wpbot_response'; |
| 4243 | 4180 | $fields = rest_sanitize_array(wp_unslash($_POST['qc_bot_str_fields'])); |
| 4244 | - | |
| 4245 | - $allowed_fields = array('query', 'keyword', 'response'); | |
| 4246 | - $valid_fields = array(); | |
| 4247 | - if(is_array($fields)){ | |
| 4248 | - foreach($fields as $field){ | |
| 4249 | - if(in_array($field, $allowed_fields)){ | |
| 4250 | - $valid_fields[] = $field; | |
| 4251 | - } | |
| 4252 | - } | |
| 4253 | - } | |
| 4254 | - $fields = $valid_fields; | |
| 4255 | - | |
| 4256 | 4181 | update_option('qc_bot_str_fields', $fields); |
| 4257 | 4182 | qcld_mysql_remove_existing_indexes(); |
| 4258 | 4183 | |
| 4259 | 4184 | if($fields && !empty($fields)){ |
| 4260 | - $safe_fields = array_map(function($f) { return '`' . $f . '`'; }, $fields); | |
| 4185 | + | |
| 4261 | 4186 | // phpcs:ignore |
| 4262 | - $wpdb->query("ALTER TABLE $table ADD FULLTEXT(".implode(', ', $safe_fields).")"); | |
| 4187 | + $wpdb->query("ALTER TABLE $table ADD FULLTEXT(".implode(', ', $fields).")"); | |
| 4263 | 4188 | |
| 4264 | 4189 | } |
| 4265 | 4190 | } |
| 4266 | 4191 | |
| @@ -4284,9 +4209,9 @@ | ||
| 4284 | 4209 | if( !function_exists('qcld_wpbot_simple_response_intent') ){ |
| 4285 | 4210 | function qcld_wpbot_simple_response_intent(){ |
| 4286 | 4211 | global $wpdb; |
| 4287 | 4212 | $table = $wpdb->prefix.'wpbot_response'; |
| 4288 | - $results = $wpdb->get_results("SELECT `intent` FROM `{$table}` WHERE 1 and `intent` !=''"); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter | |
| 4213 | + $results = $wpdb->get_results("SELECT `intent` FROM `$table` WHERE 1 and `intent` !=''"); //DB Call OK, No Caching OK | |
| 4289 | 4214 | $response = array(); |
| 4290 | 4215 | if(!empty($results)){ |
| 4291 | 4216 | foreach($results as $result){ |
| 4292 | 4217 | $response[] = $result->intent; |
| @@ -4299,9 +4224,9 @@ | ||
| 4299 | 4224 | function qcld_mysql_remove_existing_indexes(){ |
| 4300 | 4225 | global $wpdb; |
| 4301 | 4226 | $table = $wpdb->prefix.'wpbot_response'; |
| 4302 | 4227 | |
| 4303 | - $results = $wpdb->get_results("SHOW INDEX FROM {$table}"); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter | |
| 4228 | + $results = $wpdb->get_results("SHOW INDEX FROM $table"); //DB Call OK, No Caching OK | |
| 4304 | 4229 | $indexes = array(); |
| 4305 | 4230 | foreach($results as $result){ |
| 4306 | 4231 | |
| 4307 | 4232 | |