qcld_wb_chatbot_init();
}
return self::$instance;
}
/**
* Construct empty on purpose
*/
private function __construct()
{
$this->promotion = QCLD_wpCHATBOT_IMG_URL . "/NY-26-wpbot.jpg";
}
/**
* Init behaves like, and replaces, construct
*/
public function qcld_wb_chatbot_init()
{
// Check if wpCommerce is active, and is required wpCommerce version.
/*if (!class_exists('wpCommerce') || version_compare(get_option('wpcommerce_db_version'), QCLD_wpCHATBOT_REQUIRED_wpCOMMERCE_VERSION, '<')) {
add_action('admin_notices', array($this, 'wpcommerce_inactive_notice_for_wp_chatbot'));
return;
}*/
add_action('admin_menu', array($this, 'qcld_wb_chatbot_admin_menu'));
if ((!empty($_GET["page"])) && ($_GET["page"] == "wpbot")) {
add_action('admin_init', array($this, 'qcld_wb_chatbot_save_options'));
}
if( ( !empty($_GET['page']) && $_GET["page"] == "wpbot") || ( !empty($_GET['page']) && $_GET["page"] == "wpbot-panel")|| ( !empty($_GET['page']) && $_GET['page'] == 'wpbot_openAi') || ( !empty($_GET['page']) && $_GET['page'] == 'wpbot_ai_actions') || ( !empty($_GET['page']) && $_GET['page'] == 'simple-text-response') ){
// add_action( 'admin_notices', array( $this, 'promotion_notice' ) );
}
if (is_admin() && !empty($_GET["page"]) && ($_GET["page"] == "wpbot") || (!empty($_GET['page']) && $_GET['page']=='wpbot_help_page')
|| ( !empty($_GET['page']) && $_GET['page'] == 'wpbot_ai_actions')
|| (!empty($_GET['page']) && $_GET['page']=='wpbot_openAi')
|| (!empty($_GET['page']) && $_GET['page']=='wpbot-panel') || ( !empty($_GET['page']) && $_GET["page"] == "wbcs-botsessions-page") || ( !empty($_GET['page']) && $_GET["page"] == "wpbot_ai_actions") ) {
add_action('admin_enqueue_scripts', array($this, 'qcld_wb_chatbot_admin_scripts'));
if( get_option('wp_chatbot_index_count')<=0 && get_option('qlcd_wp_chatbot_search_option')=='advanced'){
add_action( 'admin_notices', array( $this, 'admin_notice_reindex' ) );
}
}
//loading frontend scripts
add_action('wp', array($this, 'qcld_wpchatbot_init_fnc'));
add_action('init', array($this, 'qcld_wpchatbot_init2_fnc'));
}
public function qcld_wpchatbot_init_fnc(){
if (!is_admin() && get_option('disable_wp_chatbot') != 1 && wp_chatbot_load_controlling() === true) {
add_action('wp_enqueue_scripts', array($this, 'qcld_wb_chatbot_frontend_scripts'));
}
}
public function qcld_register_ai_form_cpt() {
$args = array(
'public' => false,
'show_ui' => true,
'show_in_menu' => 'wpbot', // under WPBot menu
'label' => 'AI Form Entries',
'supports' => array('title', 'custom-fields')
);
register_post_type('wpbot_form_entry', $args);
}
public function qcld_wpchatbot_init2_fnc(){
$this->qcld_register_ai_form_cpt();
global $wpdb;
if( is_admin() ){
$connection = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if($connection === false){
return;
}
$content = $connection->server_info;
$mysql_server_info = $wpdb->db_server_info();
// Check for the MariaDB.
$is_mariadb = false;
if ( ! empty( $mysql_server_info ) && strpos( strtolower( $mysql_server_info ), 'maria' ) !== false ) {
$is_mariadb = true;
}
preg_match_all('/\d+\.\d+/', $content, $matches);
if( !empty( $matches ) && isset( $matches[0] ) && !empty( $matches[0] ) && is_array( $matches[0] ) && ! $is_mariadb ){
$versions = $matches[0];
$notice = true;
foreach( $versions as $version ){
if (version_compare($version, '5.5', '>')) {
$this->mysql_version = $version;
$notice = false;
}else{
$this->mysql_version = $version;
}
}
if( $notice ){
add_action('admin_notices', array($this, 'mysql_version_notice') );
}
}
$connection->close();
}
}
public function mysql_version_notice(){
$class="notice notice-error is-dismissible qc-notice-error";
$message = "Your server's MySQL version is **".$this->mysql_version."**. MySQL version 5.6+ is required for Simple Text Responses to work. Please contact your hosting support to upgrade the MySQL to the latest version.";
printf( '
', esc_attr( $class ), esc_html( $message ) );
}
/**
* Add a submenu item to the wpCommerce menu
*/
public function qcld_wb_chatbot_admin_menu()
{
/* add_submenu_page('wpcommerce',
__('wpwBot Pro', 'chatbot'),
__('wpwBot Pro', 'chatbot'),
'manage_wpcommerce',
$this->id,
array($this, 'qcld_wb_chatbot_admin_page'));*/
if( get_option( 'qc_bot_str_allow_author_editor' ) == 1 ){
$capability = 'publish_posts';
}else{
$capability = 'manage_options';
}
add_menu_page( esc_html('WPBot - ChatBot'), esc_html('WPBot - ChatBot'), 'manage_options','wpbot-panel', array($this, 'qcld_wb_chatbot_admin_page'),'dashicons-format-status', 6 );
add_submenu_page( 'wpbot-panel', esc_html('General Settings'), esc_html('General Settings'), 'manage_options','wpbot', array($this, 'qcld_wb_chatbot_admin_page_settings') );
add_submenu_page( 'wpbot-panel', esc_html('AI Settings'), esc_html('AI Settings'), 'manage_options','wpbot_openAi', 'wpbot_openAi_setting_func' );
add_submenu_page( 'wpbot-panel', esc_html('AI Actions'), esc_html('AI Actions'), 'manage_options','wpbot_ai_actions', 'wpbot_Ai_actions_func' );
$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') );
add_action( "load-$hook", [ $this, 'screen_option' ] );
add_submenu_page( 'wpbot-panel', esc_html('User Data'), esc_html('User Data'), 'manage_options','email-subscription', array($this, 'qcld_wb_chatbot_admin_page1') );
//$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') );
// add_submenu_page( 'wpbot-panel', esc_html('Conversational Form '), esc_html('Conversational Form'), 'manage_options','wpbots', [$this, 'qcld_wb_chatbot_admin_conversational_settings'] );
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' );
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' );
}
function screen_option(){
if( isset($_POST['wp_screen_options']) && !empty($_POST['wp_screen_options'])){
$per_page_str = (int)$_POST['wp_screen_options']["value"];
}else{
$per_page_str = 20;
}
$option = 'per_page';
$args = [
'label' => 'Response',
'default' => $per_page_str,
'option' => 'responses_per_page'
];
$this->response_list = new Response_list();
}
public function qcld_wb_chatbot_admin_str(){
require_once("includes/simple_text_response.php");
}
/**
* Include admin scripts
*/
public function qcld_wb_chatbot_admin_scripts($hook)
{
global $wpcommerce, $wp_scripts;
$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
if (((!empty($_GET["page"])) && ($_GET["page"] == "wpbot")) || ($hook == "widgets.php") || $_GET['page']=='wpbot_help_page' || $_GET['page']=='wpbot_openAi' || $_GET['page']=='simple-text-response'
|| $_GET['page']=='wpbot-panel' || $_GET["page"] == "wbcs-botsessions-page" || $_GET["page"] == "wpbot_ai_actions" ) {
wp_enqueue_script('jquery');
//wp_enqueue_style('wpcommerce_admin_styles', $wpcommerce->plugin_url() . '/assets/css/admin.css');
wp_register_style('qlcd-wp-chatbot-admin-style', plugins_url(basename(plugin_dir_path(__FILE__)) . '/css/admin-style.css', basename(__FILE__)), '', QCLD_wpCHATBOT_VERSION, 'screen');
wp_enqueue_style('qlcd-wp-chatbot-admin-style');
wp_register_style('qlcd-wp-chatbot-tabs-style', plugins_url(basename(plugin_dir_path(__FILE__)) . '/css/wp-chatbot-tabs.css', basename(__FILE__)), '', QCLD_wpCHATBOT_VERSION, 'screen');
wp_enqueue_style('qlcd-wp-chatbot-tabs-style');
wp_register_style('jquery.fontpicker.min.css', QCLD_wpCHATBOT_PLUGIN_URL . 'css/fontpicker.min.css', '', QCLD_wpCHATBOT_VERSION, 'screen');
wp_enqueue_style('jquery.fontpicker.min.css');
//wp_register_style('qlcd-openai-bootstap', plugins_url(basename(plugin_dir_path(__FILE__)) . '/openai/css/openai-admin-style.css', basename(__FILE__)), array(), true);
//wp_enqueue_style('qlcd-openai-bootstap');
wp_enqueue_script('jquery');
wp_enqueue_script( 'jquery-ui-draggable' );
wp_enqueue_script( 'jquery-ui-droppable' );
wp_enqueue_script('jquery-ui-core');
wp_enqueue_style( 'wp-color-picker');
wp_enqueue_script( 'wp-color-picker');
wp_enqueue_script( 'jquery-ui-sortable');
wp_register_script('qcld-wp-fontpicker', plugins_url(basename(plugin_dir_path(__FILE__)) . '/js/fontpicker.js', basename(__FILE__)), array(), true);
wp_enqueue_script('qcld-wp-fontpicker');
wp_register_script('qcld-wp-chatbot-cbpFWTabs', plugins_url(basename(plugin_dir_path(__FILE__)) . '/js/cbpFWTabs.js', basename(__FILE__)), array(), QCLD_wpCHATBOT_VERSION, true);
wp_enqueue_script('qcld-wp-chatbot-cbpFWTabs');
wp_register_script('qcld-wp-chatbot-modernizr-custom', plugins_url(basename(plugin_dir_path(__FILE__)) . '/js/modernizr.custom.js', basename(__FILE__)), array(), true);
wp_enqueue_script('qcld-wp-chatbot-modernizr-custom');
wp_register_script('qcld-wp-chatbot-bootstrap-js', plugins_url(basename(plugin_dir_path(__FILE__)) . '/js/bootstrap.js', basename(__FILE__)), array('jquery'), true);
wp_enqueue_script('qcld-wp-chatbot-bootstrap-js');
// wp_register_script('qcld-wp-openai-setting-js', plugins_url(basename(plugin_dir_path(__FILE__)) . '/js/openai_settings.js', basename(__FILE__)), array('jquery'), true);
// wp_enqueue_script('qcld-wp-openai-setting-js');
wp_localize_script( 'qcld-wp-openai-setting-js', 'openai_ajax', array(
'url' => admin_url( 'admin-ajax.php' ),
) );
wp_register_style('qcld-wp-chatbot-bootstrap-css', plugins_url(basename(plugin_dir_path(__FILE__)) . '/css/bootstrap.min.css', basename(__FILE__)), '', QCLD_wpCHATBOT_VERSION, 'screen');
wp_enqueue_style('qcld-wp-chatbot-bootstrap-css');
//jquery time picker
wp_register_script('qcld-wp-chatbot-timepicker-js', plugins_url(basename(plugin_dir_path(__FILE__)) . '/js/jquery.timepicker.js', basename(__FILE__)), array('jquery'), true);
wp_enqueue_script('qcld-wp-chatbot-timepicker-js');
wp_register_style('qcld-wp-chatbot-timepicker-css', plugins_url(basename(plugin_dir_path(__FILE__)) . '/css/jquery.timepicker.css', basename(__FILE__)), '', QCLD_wpCHATBOT_VERSION, 'screen');
wp_enqueue_style('qcld-wp-chatbot-timepicker-css');
wp_register_script('qcld-wp-chatbot-sweetalrt', plugins_url(basename(plugin_dir_path(__FILE__)) . '/js/sweetalrt.js', basename(__FILE__)), array(), true);
wp_enqueue_script('qcld-wp-chatbot-sweetalrt');
wp_register_script('qcld-wp-chatbot-admin-js', plugins_url(basename(plugin_dir_path(__FILE__)) . '/js/qcld-wp-chatbot-admin.js', basename(__FILE__)), array('jquery', 'jquery-ui-core','jquery-ui-sortable','jquery-ui-droppable','wp-color-picker','qcld-wp-chatbot-timepicker-js'), QCLD_wpCHATBOT_VERSION, true);
wp_enqueue_script('qcld-wp-chatbot-admin-js');
wp_localize_script('qcld-wp-chatbot-admin-js', 'qcld_gemini_admin_data',
array('ajax_url' => admin_url('admin-ajax.php'),'ajax_nonce' => wp_create_nonce('wp_chatbot'),'image_path' => QCLD_wpCHATBOT_IMG_URL));
// WordPress Media library
wp_enqueue_media();
}
}
public function qcld_get_formbuilder_forms(){
global $wpdb;
$forms = array();
if(class_exists('Qcformbuilder_Forms_Admin')){
$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
if(!empty($results)){
foreach($results as $result){
$form = maybe_unserialize($result->config);
$forms[] = trim($form['name']);
}
return $forms;
}else{
return array();
}
}else{
return array();
}
}
public function qcld_wb_chatbot_admin_page1() {
require_once QCLD_wpCHATBOT_PLUGIN_DIR_PATH . 'includes/admin/templates/email_subscription.php';
}
public function qcld_wpbot_simple_response_intent(){
global $wpdb;
$table = $wpdb->prefix.'wpbot_response';
$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
$response = array();
if(!empty($results)){
foreach($results as $result){
$response[] = $result->intent;
}
}
return $response;
}
public function qcld_get_formbuilder_form_commands(){
global $wpdb;
$command = array();
if(class_exists('Qcformbuilder_Forms_Admin')){
$primary = 'primary';
$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
if(!empty($results)){
foreach($results as $result){
$form = maybe_unserialize($result->config);
if(isset($form['command'])){
$command[] = array_map('trim', explode(',', strtolower($form['command'])));
}
}
return $command;
}else{
return array();
}
}else{
return array();
}
}
public function promotion_notice(){
$screen = get_current_screen();
// if( isset($screen->base) && (( $screen->base == 'wpbot-lite_page_wpbot') || ( $screen->base == 'toplevel_page_wpbot-panel"'))){
?>
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
if(!empty($results)){
foreach($results as $result){
$form = maybe_unserialize($result->config);
$forms[] = trim($form['ID']);
}
return $forms;
}else{
return array();
}
}else{
return array();
}
}
public function qcld_wb_chatbot_frontend_scripts()
{
global $wpcommerce, $wp_scripts, $wpdb, $current_user;
$display_name = '';
$display_email = '';
$user_image = get_option('wp_custom_client_icon');
$user_id = 0;
$user_image = get_option('wp_custom_client_icon');
if ( is_user_logged_in() ) {
$display_name = $current_user->display_name;
$display_email = $current_user->user_email;
$user_image = esc_url( get_avatar_url( $current_user->ID ) );
$user_id = $current_user->ID;
}
$conversation_form_ids = array();
$conversation_form_names = array();
if(class_exists('Qcformbuilder_Forms_Admin')){
$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
if(!empty($results)){
foreach($results as $result){
$form = maybe_unserialize($result->config);
$conversation_form_ids[] = $form['ID'];
$conversation_form_names[] = $form['name'];
}
}
}
$wp_chatbot_obj = array(
'wp_chatbot_position_x' => get_option('wp_chatbot_position_x'),
'wp_chatbot_position_y' => get_option('wp_chatbot_position_y'),
'disable_icon_animation' => get_option('disable_wp_chatbot_icon_animation'),
'disable_featured_product' => get_option('disable_wp_chatbot_featured_product'),
'disable_product_search' => get_option('disable_wp_chatbot_product_search'),
'disable_catalog' => get_option('disable_wp_chatbot_catalog'),
'disable_order_status' => get_option('disable_wp_chatbot_order_status'),
'disable_sale_product' => get_option('disable_wp_chatbot_sale_product'),
'open_product_detail' => get_option('wp_chatbot_open_product_detail'),
'order_user' => get_option('qlcd_wp_chatbot_order_user'),
'ajax_url' => admin_url('admin-ajax.php'),
'image_path' => QCLD_wpCHATBOT_IMG_URL,
'yes' => str_replace('\\', '',get_option('qlcd_wp_chatbot_yes')),
'no' => str_replace('\\', '',get_option('qlcd_wp_chatbot_no')),
'or' => str_replace('\\', '',get_option('qlcd_wp_chatbot_or')),
'host' => str_replace('\\', '',get_option('qlcd_wp_chatbot_host')),
'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'))),
'agent_image' => get_option('wp_chatbot_agent_image'),
'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'),
'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')),
'agent_join' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_agent_join'))),
'welcome' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_welcome'))),
'welcome_back' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_welcome_back'))),
'hi_there' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_hi_there'))),
'hello' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_hello'))),
'asking_name' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_asking_name'))),
'i_am' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_i_am'))),
'name_greeting' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_name_greeting'))),
'wildcard_msg' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_wildcard_msg'))),
'empty_filter_msg' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_empty_filter_msg'))),
'did_you_mean' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_did_you_mean'))),
'is_typing' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_is_typing'))),
'send_a_msg' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_send_a_msg'))),
'viewed_products' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_viewed_products'))),
'shopping_cart' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_shopping_cart'))),
'cart_updating' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_cart_updating'))),
'cart_removing' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_cart_removing'))),
'imgurl' => QCLD_wpCHATBOT_IMG_URL,
'sys_key_help' => get_option('qlcd_wp_chatbot_sys_key_help'),
'sys_key_product' => get_option('qlcd_wp_chatbot_sys_key_product'),
'sys_key_catalog' => get_option('qlcd_wp_chatbot_sys_key_catalog'),
'sys_key_order' => get_option('qlcd_wp_chatbot_sys_key_order'),
'sys_key_support' => get_option('qlcd_wp_chatbot_sys_key_support'),
'sys_key_reset' => get_option('qlcd_wp_chatbot_sys_key_reset'),
'sys_key_email' => get_option('qlcd_wp_chatbot_sys_key_email'),
'help_welcome' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_help_welcome'))),
'back_to_start' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_back_to_start'))),
'help_msg' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_help_msg'))),
'reset' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_reset'))),
'wildcard_product' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_wildcard_product'))),
'wildcard_catalog' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_wildcard_catalog'))),
'featured_products' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_featured_products'))),
'sale_products' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_sale_products'))),
'wildcard_order' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_wildcard_order'))),
'wildcard_support' => get_option('qlcd_wp_chatbot_wildcard_support'),
'product_asking' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_product_asking'))),
'product_suggest' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_product_suggest'))),
'product_infinite' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_product_infinite'))),
'product_success' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_product_success'))),
'product_fail' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_product_fail'))),
'support_welcome' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_support_welcome'))),
'support_email' => get_option('qlcd_wp_chatbot_support_email'),
'support_option_again' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_support_option_again'))),
'asking_email' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_asking_email'))),
'asking_msg' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_asking_msg'))),
'no_result' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_no_result'))),
'support_phone' => get_option('qlcd_wp_chatbot_support_phone'),
'asking_phone' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_asking_phone'))),
'thank_for_phone' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_thank_for_phone'))),
'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')))),
'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'))),
'notification_interval' => get_option('qlcd_wp_chatbot_notification_interval'),
'notifications' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_notifications'))),
'order_welcome' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_order_welcome'))),
'order_username_asking' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_order_username_asking'))),
'order_username_password' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_order_username_password'))),
'order_user' => get_option('qlcd_wp_chatbot_order_user'),
'order_login' => is_user_logged_in(),
'is_chat_session_active' => qcld_wpbot_is_active_chat_history(),
'order_nonce' => wp_create_nonce("wpwbot-order-nonce"),
'order_email_support' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_order_email_support'))),
'email_fail' => str_replace('\\', '', get_option('qlcd_wp_chatbot_email_fail')),
'invalid_email' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_invalid_email'))),
'stop_words' => str_replace('\\', '', get_option('qlcd_wp_chatbot_stop_words')),
'currency_symbol' => '',
'enable_messenger' => get_option('enable_wp_chatbot_messenger'),
'messenger_label' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_messenger_label'))),
'fb_page_id' => get_option('qlcd_wp_chatbot_fb_page_id'),
'enable_skype' => get_option('enable_wp_chatbot_skype'),
'enable_whats' => get_option('enable_wp_chatbot_whats'),
'whats_label' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_whats_label'))),
'whats_num' => get_option('qlcd_wp_chatbot_whats_num'),
'ret_greet' => get_option('qlcd_wp_chatbot_ret_greet'),
'enable_exit_intent' => get_option('enable_wp_chatbot_exit_intent'),
'exit_intent_msg' => str_replace('\\', '', get_option('wp_chatbot_exit_intent_msg')),
'exit_intent_once' => get_option('wp_chatbot_exit_intent_once'),
'enable_scroll_open' => get_option('enable_wp_chatbot_scroll_open'),
'scroll_open_msg' => str_replace('\\', '', get_option('wp_chatbot_scroll_open_msg')),
'scroll_open_percent' => get_option('wp_chatbot_scroll_percent'),
'scroll_open_once' => get_option('wp_chatbot_scroll_once'),
'enable_auto_open' => get_option('enable_wp_chatbot_auto_open'),
'auto_open_msg' => str_replace('\\', '', get_option('wp_chatbot_auto_open_msg')),
'auto_open_time' => get_option('wp_chatbot_auto_open_time'),
'auto_open_once' => get_option('wp_chatbot_auto_open_once'),
'proactive_bg_color' => get_option('wp_chatbot_proactive_bg_color'),
'disable_feedback' => get_option('disable_wp_chatbot_feedback'),
'disable_faq' => get_option('disable_wp_chatbot_faq'),
'feedback_label' => $this->qcld_wb_chatbot_str_replace(maybe_unserialize(get_option('qlcd_wp_chatbot_feedback_label'))),
'enable_meta_title' =>get_option('enable_wp_chatbot_meta_title'),
'meta_label' =>str_replace('\\', '', get_option('qlcd_wp_chatbot_meta_label')),
'phone_number' => get_option('qlcd_wp_chatbot_phone'),
'disable_site_search' => get_option('disable_wp_chatbot_site_search'),
'search_keyword' => get_option('qlcd_wp_chatbot_asking_search_keyword'),
'ajax_nonce'=> wp_create_nonce('qcsecretbotnonceval123qc'),
'session_nonce'=> wp_create_nonce('wp_chatbot'),
'site_search' => get_option('qlcd_wp_site_search'),
'open_links_newtab' => get_option('open_links_new_window'),
'call_gen' => get_option('disable_wp_chatbot_call_gen'),
'call_sup' => get_option('disable_wp_chatbot_call_sup'),
'enable_ret_sound' => get_option('enable_wp_chatbot_ret_sound'),
'found_result_message' => get_option('qlcd_wp_chatbot_found_result'),
'enable_ret_user_show' => get_option('enable_wp_chatbot_ret_user_show'),
'enable_inactive_time_show' => get_option('enable_wp_chatbot_inactive_time_show'),
'ret_inactive_user_once' => get_option('wp_chatbot_inactive_once'),
'mobile_full_screen' => '1',
'chatbot_content' => get_option( 'chatbot_content_max_height' ),
'chatbot_content_responsive' => get_option( 'chatbot_content_max_height_responsive' ),
'botpreloadingtime' => (get_option('wpbot_preloading_time')?get_option('wpbot_preloading_time'):800),
'inactive_time' => get_option('wp_chatbot_inactive_time'),
'checkout_msg' => str_replace('\\', '', get_option('wp_chatbot_checkout_msg')),
'ai_df_enable' => get_option('enable_wp_chatbot_dailogflow'),
'ai_df_token' => get_option('qlcd_wp_chatbot_dialogflow_client_token'),
'df_defualt_reply' => str_replace('\\', '', get_option('qlcd_wp_chatbot_dialogflow_defualt_reply')),
'df_agent_lan' => get_option('qlcd_wp_chatbot_dialogflow_agent_language'),
'openai_enabled' => get_option('ai_enabled'),
'is_stream_enabled' => ( get_option('is_stream_enabled', '1') == '1' ? '1' : '0' ),
'qcld_openai_append_content' => get_option('qcld_openai_append_content'),
'openrouter_enabled' => (get_option('qcld_openrouter_enabled')=='1'? get_option('qcld_openrouter_enabled') : '0'),
'gemini_enabled' => (get_option('qcld_gemini_enabled')=='1'? get_option('qcld_gemini_enabled') : '0'),
'grok_enabled' => (get_option('qcld_grok_enabled')=='1'? get_option('qcld_grok_enabled') : '0'),
'qcld_gemini_prepend_content' => get_option('qcld_gemini_prepend_content'),
'qcld_gemini_append_content' => get_option('qcld_gemini_append_content'),
'qcld_openrouter_append_content' => get_option('qcld_openrouter_append_content'),
'qcld_openrouter_prepend_content' => get_option('qcld_openrouter_prepend_content'),
'start_menu' => wp_unslash(get_option('qc_wpbot_menu_order')),
'conversation_form_ids' => $conversation_form_ids,
'conversation_form_names' => $conversation_form_names,
'simple_response_intent' => $this->qcld_wpbot_simple_response_intent(),
'forms' => $this->qcld_get_formbuilder_forms(),
'form_ids' =>$this->qcld_get_formbuilder_form_ids(),
'form_commands' => $this->qcld_get_formbuilder_form_commands(),
'df_api_version' => (get_option('wp_chatbot_df_api')==''?'v1':get_option('wp_chatbot_df_api')),
'v2_client_url'=> esc_url(get_site_url().'/?action=qcld_dfv2_api'),
'show_menu_after_greetings'=> (get_option('show_menu_after_greetings')!=''?get_option('show_menu_after_greetings'):0),
'disable_back_to_start'=> (get_option('disable_back_to_start_menu')!=''?get_option('disable_back_to_start_menu'):0),
'current_user_id' => $user_id,
'display_name' => esc_html( $display_name ),
'skip_wp_greetings' => get_option('skip_wp_greetings'),
'skip_greetings_and_menu' => get_option('skip_wp_greetings_donot_show_menu'),
'skip_wp_greetings_trigger_intent' => get_option('skip_wp_greetings_trigger_intent'),
'intent_for_non_logged_in_user' => get_option('qlcd_wp_chatbot_intent_for_non_logged_in_user'),
'intent_for_logged_in_user' => get_option('qlcd_wp_chatbot_intent_for_logged_in_user'),
'ask_email_wp_greetings' => get_option('enable_asking_for_email'),
'skip_chat_reactions_menu' => get_option('skip_chat_reactions_menu'),
'qlcd_wp_chatbot_like_text' => get_option('qlcd_wp_chatbot_like_text'),
'qlcd_wp_chatbot_dislike_text' => get_option('qlcd_wp_chatbot_dislike_text'),
'enable_chat_report_menu' => get_option('enable_chat_report_menu'),
'qlcd_wp_chatbot_report_text' => get_option('qlcd_wp_chatbot_report_text'),
'enable_chat_share_menu' => get_option('enable_chat_share_menu'),
'qlcd_wp_chatbot_share_text' => get_option('qlcd_wp_chatbot_share_text'),
'icon_video' => get_option('wp_chatbot_icon_video', ''),
'icon_video_delay' => absint(get_option('wp_chatbot_icon_video_delay', 0)),
);
$user_font = get_option('wp_chatbot_user_font') != '' ? get_option('wp_chatbot_user_font') : '';
if($user_font != '' ){
$parts = explode(':', $user_font);
// Create an object
$user_font_family = new stdClass();
// Assign values
$user_font_family->fontfamily = $parts[0];
$user_font_family->fontWeight = isset($parts[1]) ? $parts[1] : '400'; // default weight
$user_font_family->fontStyle = 'normal';
if(get_option('enable_wp_chatbot_custom_color')==1){
$user_enqueue_font = 'https://fonts.googleapis.com/css2?family='. $user_font_family->fontfamily;
wp_enqueue_style( 'qcld-chatbot-user-google-fonts', $user_enqueue_font, false );
wp_enqueue_style( 'qcld-chatbot-user-google-fonts');
}
}
$bot_font = get_option('wp_chatbot_bot_font') != '' ? get_option('wp_chatbot_bot_font') : '';
if($bot_font != '' ){
$parts = explode(':', $bot_font);
// Create an object
$bot_font_family = new stdClass();
// Assign values
$bot_font_family->fontFamily = $parts[0];
$bot_font_family->fontWeight = isset($parts[1]) ? $parts[1] : '400'; // default weight
$bot_font_family->fontStyle = 'normal';
if(get_option('enable_wp_chatbot_custom_color')==1){
$bot_enqueue_font = 'https://fonts.googleapis.com/css2?family='.$bot_font_family->fontFamily;
wp_enqueue_style( 'qcld-chatbot-bot-google-fonts', $bot_enqueue_font, false );
wp_enqueue_style( 'qcld-chatbot-bot-google-fonts');
}
}
wp_enqueue_style( 'dashicons' );
wp_register_script('qcld-wp-chatbot-slimscroll-js', plugins_url(basename(plugin_dir_path(__FILE__)) . '/js/jquery.slimscroll.min.js', basename(__FILE__)), array('jquery'), QCLD_wpCHATBOT_VERSION, true);
wp_enqueue_script('qcld-wp-chatbot-slimscroll-js');
wp_register_script('qcld-wp-chatbot-jquery-cookie', plugins_url(basename(plugin_dir_path(__FILE__)) . '/js/jquery.cookie.js', basename(__FILE__)), array('jquery'), QCLD_wpCHATBOT_VERSION, true);
wp_enqueue_script('qcld-wp-chatbot-jquery-cookie');
wp_register_script('qcld-wp-chatbot-magnify-popup', plugins_url(basename(plugin_dir_path(__FILE__)) . '/js/jquery.magnific-popup.min.js', basename(__FILE__)), array('jquery'), QCLD_wpCHATBOT_VERSION, true);
wp_enqueue_script('qcld-wp-chatbot-magnify-popup');
wp_register_script('qcld-wp-chatbot-plugin', plugins_url(basename(plugin_dir_path(__FILE__)) . '/js/qcld-wp-chatbot-plugin.js', basename(__FILE__)), array('jquery', 'qcld-wp-chatbot-jquery-cookie','qcld-wp-chatbot-magnify-popup'), QCLD_wpCHATBOT_VERSION, true);
wp_enqueue_script('qcld-wp-chatbot-plugin');
$saved_ai_forms = get_option('wpbot_ai_forms', array());
$ai_form_titles = array();
if (is_array($saved_ai_forms)) {
foreach ($saved_ai_forms as $form) {
if (!isset($form['interactive']) || $form['interactive'] == 1) {
$ai_form_titles[] = trim(strtolower($form['title']));
}
}
}
$nonce = wp_create_nonce('wp_chatbot');
// Pass data to JS
wp_localize_script('qcld-wp-chatbot-plugin', 'qcld_chatbot_obj', [
'ajax_url' => admin_url('admin-ajax.php'),
'nonce' => $nonce,
'stream_endpoint' => admin_url('admin-ajax.php?action=qcld_stream_openai'),
'ai_form_titles' => $ai_form_titles,
]);
wp_register_script('qcld-wp-chatbot-front-js', plugins_url(basename(plugin_dir_path(__FILE__)) . '/js/qcld-wp-chatbot-front.js', basename(__FILE__)), array('jquery', 'qcld-wp-chatbot-jquery-cookie'), QCLD_wpCHATBOT_VERSION, true);
wp_enqueue_script('qcld-wp-chatbot-front-js');
wp_localize_script('qcld-wp-chatbot-front-js', 'wp_chatbot_obj', $wp_chatbot_obj);
//wp_register_script('qcld-wp-chatbot-frontend', plugins_url(basename(plugin_dir_path(__FILE__)) . '/js/qcld-wp-chatbot-frontend.js', basename(__FILE__)), array('jquery','qcld-wp-chatbot-jquery-cookie'), QCLD_wpCHATBOT_VERSION, true);
//wp_enqueue_script('qcld-wp-chatbot-frontend');
//wp_localize_script('qcld-wp-chatbot-frontend', 'wp_chatbot_obj', $wp_chatbot_obj);
wp_localize_script('qcld-wp-chatbot-frontend', 'wp_chatbot_obj', $wp_chatbot_obj);
if ( ! function_exists( 'wp_register_style' ) || ! function_exists( 'wp_enqueue_style' ) || ! function_exists( 'plugins_url' ) || ! function_exists( 'plugin_dir_path' ) || ! function_exists( 'get_option' ) || ! function_exists( 'sanitize_hex_color' ) || ! function_exists( 'wp_add_inline_style' ) ) {
// Return early if critical WordPress functions are not available.
// This indicates the code needs to be hooked into an appropriate action.
return;
}
wp_register_style('qcld-wp-chatbot-common-style', plugins_url(basename(plugin_dir_path(__FILE__)) . '/css/common-style.css', basename(__FILE__)), '', QCLD_wpCHATBOT_VERSION, 'screen');
wp_enqueue_style('qcld-wp-chatbot-common-style');
$floating_icon_bg_color = get_option('wp_chatbot_floatingiconbg_color');
$floating_icon_bg_color = sanitize_hex_color($floating_icon_bg_color); // ensures it's a valid hex color like #ffffff
if ( ! empty($floating_icon_bg_color) ) {
$inline_floating_icon_styles = "
.wp-chatbot-ball {
background: {$floating_icon_bg_color} !important;
}
.wp-chatbot-ball:hover,
.wp-chatbot-ball:focus {
background: {$floating_icon_bg_color} !important;
}";
wp_add_inline_style( 'qcld-wp-chatbot-common-style', $inline_floating_icon_styles );
}
wp_register_style('qcld-wp-chatbot-magnific-popup', plugins_url(basename(plugin_dir_path(__FILE__)) . '/css/magnific-popup.css', basename(__FILE__)), '', QCLD_wpCHATBOT_VERSION, 'screen');
wp_enqueue_style('qcld-wp-chatbot-magnific-popup');
$qcld_wb_chatbot_theme = get_option('qcld_wb_chatbot_theme');
/* if (file_exists(QCLD_wpCHATBOT_PLUGIN_DIR_PATH . '/templates/' . $qcld_wb_chatbot_theme . '/style.css')) {
wp_register_style('qcld-wp-chatbot-style', plugins_url(basename(plugin_dir_path(__FILE__)) . '/templates/' . $qcld_wb_chatbot_theme . '/style.css', basename(__FILE__)), '', QCLD_wpCHATBOT_VERSION, 'screen');
wp_enqueue_style('qcld-wp-chatbot-style');
}*/
//Loading shortcode style
if (file_exists(QCLD_wpCHATBOT_PLUGIN_DIR_PATH . '/templates/' . $qcld_wb_chatbot_theme . '/shortcode.css')) {
wp_register_style('qcld-wp-chatbot-shortcode-style', plugins_url(basename(plugin_dir_path(__FILE__)) . '/templates/' . $qcld_wb_chatbot_theme . '/shortcode.css', basename(__FILE__)), '', QCLD_wpCHATBOT_VERSION, 'screen');
wp_enqueue_style('qcld-wp-chatbot-shortcode-style');
}
$inline_chat_custom_styles = ''; // Initialize a new variable for general chat custom styles.
if(get_option('enable_wp_chatbot_custom_color')==1){
// Sanitize all color options before using them in CSS to prevent invalid values.
$text_color = sanitize_hex_color( get_option('wp_chatbot_text_color') );
$link_color = sanitize_hex_color( get_option('wp_chatbot_link_color') );
$link_hover_color = sanitize_hex_color( get_option('wp_chatbot_link_hover_color') );
$bot_msg_text_color = sanitize_hex_color( get_option('wp_chatbot_bot_msg_text_color') );
$bot_msg_bg_color = sanitize_hex_color( get_option('wp_chatbot_bot_msg_bg_color') );
$buttons_text_color = sanitize_hex_color( get_option('wp_chatbot_buttons_text_color') );
$buttons_bg_color = sanitize_hex_color( get_option('wp_chatbot_buttons_bg_color') );
$buttons_text_color_hover = sanitize_hex_color( get_option('wp_chatbot_buttons_text_color_hover') );
$buttons_bg_color_hover = sanitize_hex_color( get_option('wp_chatbot_buttons_bg_color_hover') );
$user_msg_text_color = sanitize_hex_color( get_option('wp_chatbot_user_msg_text_color') );
$wp_chatbot_text_color = sanitize_hex_color( get_option('wp_chatbot_text_color') );
$user_msg_bg_color = sanitize_hex_color( get_option('wp_chatbot_user_msg_bg_color') );
$header_background_color = sanitize_hex_color( get_option('wp_chatbot_header_background_color') );
$chatbot_content_max_height = sanitize_text_field( get_option('chatbot_content_max_height') );
$chatbot_content_max_height_responsive = sanitize_text_field( get_option('chatbot_content_max_height_responsive') );
$inline_chat_custom_styles .= "
#wp-chatbot-chat-container, .wp-chatbot-product-description, .wp-chatbot-product-description p,.wp-chatbot-product-quantity label, .wp-chatbot-product-variable label {
color: ". $text_color ." !important;
}
#wp-chatbot-chat-container a {
color: ". $link_color ." !important;
}
#wp-chatbot-chat-container a p{
color: ". $link_color ." !important;
}
#wp-chatbot-chat-container a p span{
color: ". $link_color ." !important;
}
#wp-chatbot-chat-container a:hover {
color: ". $link_hover_color ." !important;
}
ul.wp-chatbot-messages-container > li.wp-chatbot-msg .wp-chatbot-paragraph,
.wp-chatbot-agent-profile .wp-chatbot-bubble {
color: ". $bot_msg_text_color ." !important;
background-color: ". $bot_msg_bg_color ." !important;
word-break: break-word;
}
span.qcld-chatbot-product-category, span.qcld-chatbot-support-items, span.qcld-chatbot-wildcard, span.qcld-chatbot-suggest-email, span.qcld-chatbot-reset-btn, #woo-chatbot-loadmore, .wp-chatbot-shortcode-template-container span.qcld-chatbot-product-category, .wp-chatbot-shortcode-template-container span.qcld-chatbot-support-items, .wp-chatbot-shortcode-template-container span.qcld-chatbot-wildcard, .wp-chatbot-shortcode-template-container span.wp-chatbot-card-button, .wp-chatbot-shortcode-template-container span.qcld-chatbot-suggest-email, span.qcld-chatbot-suggest-phone, .wp-chatbot-shortcode-template-container span.qcld-chatbot-reset-btn, .wp-chatbot-shortcode-template-container #wp-chatbot-loadmore, .wp-chatbot-ball-cart-items, .wpbd_subscription, .qcld-chatbot-site-search, .qcld_subscribe_confirm, .qcld-chat-common, .qcld-chatbot-custom-intent {
color: ". $buttons_text_color ." !important;
background-color: ". $buttons_bg_color ." !important;
background-image: none !important;
}
span.qcld-chatbot-product-category:hover, span.qcld-chatbot-support-items:hover, span.qcld-chatbot-wildcard:hover, span.qcld-chatbot-suggest-email:hover, span.qcld-chatbot-reset-btn:hover, #woo-chatbot-loadmore:hover, .wp-chatbot-shortcode-template-container:hover span.qcld-chatbot-product-category:hover, .wp-chatbot-shortcode-template-container:hover span.qcld-chatbot-support-items:hover, .wp-chatbot-shortcode-template-container:hover span.qcld-chatbot-wildcard:hover, .wp-chatbot-shortcode-template-container:hover span.wp-chatbot-card-button:hover, .wp-chatbot-shortcode-template-container:hover span.qcld-chatbot-suggest-email:hover, span.qcld-chatbot-suggest-phone:hover, .wp-chatbot-shortcode-template-container:hover span.qcld-chatbot-reset-btn:hover, .wp-chatbot-shortcode-template-container:hover #wp-chatbot-loadmore:hover, .wp-chatbot-ball-cart-items:hover, .wpbd_subscription:hover, .qcld-chatbot-site-search:hover, .qcld_subscribe_confirm:hover, .qcld-chat-common:hover, .qcld-chatbot-custom-intent:hover {
color: ". $buttons_text_color_hover ." !important;
background-color: ". $buttons_bg_color_hover ." !important;
background-image: none !important;
}
li.wp-chat-user-msg .wp-chatbot-paragraph {
color: ". $user_msg_text_color ." !important;
background: ". $user_msg_bg_color ." !important;
}
ul.wp-chatbot-messages-container li:first-child.wp-chatbot-msg .wp-chatbot-paragraph {
color: ". $wp_chatbot_text_color ." !important;
}
ul.wp-chatbot-messages-container > li.wp-chatbot-msg > .wp-chatbot-paragraph:before,
.wp-chatbot-bubble:before {
border-right: 10px solid ". $bot_msg_bg_color ." !important;
}
ul.wp-chatbot-messages-container > li.wp-chat-user-msg > .wp-chatbot-paragraph:before {
border-left: 10px solid ". $user_msg_bg_color ." !important;
}
#wp-chatbot-chat-container .wp-chatbot-header{
background: ". $header_background_color ." !important;
}
.wp-chatbot-container ul.wp-chatbot-messages-container > li.wp-chatbot-msg .chat-container, .wp-chatbot-container .wp-chatbot-agent-profile .wp-chatbot-bubble {
color: ". $bot_msg_text_color ." !important;
background: ". $bot_msg_bg_color ." !important;
}
";
// Apply the accumulated general chat custom styles.
// This ensures these styles are added if the custom color option is enabled.
wp_add_inline_style( 'qcld-wp-chatbot-common-style', $inline_chat_custom_styles );
}
$custom_colors ="";
if((get_option('enable_wp_chatbot_custom_color')==1) && $user_font != ''){
$custom_colors .="
#wp-chatbot-messages-container > li.wp-chatbot-msg > .wp-chatbot-paragraph,
#wp-chatbot-messages-container > li.wp-chatbot-msg > span{
font-family: ".$bot_font_family->fontFamily.";
font-weight: ".$bot_font_family->fontWeight.";
font-style: ".$bot_font_family->fontStyle.";
font-size: ". get_option('wp_chatbot_font_size'). "px;
}
ul.wp-chatbot-messages-container > li.wp-chatbot-msg .wp-chatbot-paragraph, .wp-chatbot-agent-profile .wp-chatbot-bubble {
font-family: ".$bot_font_family->fontFamily.";
font-weight: ".$bot_font_family->fontWeight.";
font-style: ".$bot_font_family->fontStyle.";
font-size: ". get_option('wp_chatbot_font_size'). "px;
}
ul#wp-chatbot-messages-container .wp-chatbot-textanimation span {
font-family: ".$bot_font_family->fontFamily.";
font-weight: ".$bot_font_family->fontWeight.";
font-style: ".$bot_font_family->fontStyle.";
font-size: ". get_option('wp_chatbot_font_size'). "px;
}
";
}
if ( get_option('enable_wp_chatbot_custom_color') == 1 && ! empty($bot_font) ) {
// Sanitize each CSS-related value
$font_family = isset( $user_font_family->fontfamily ) ? esc_attr( $user_font_family->fontfamily ) : 'inherit';
$font_weight = isset( $user_font_family->fontWeight ) ? esc_attr( $user_font_family->fontWeight ) : 'normal';
$font_style = isset( $user_font_family->fontStyle ) ? esc_attr( $user_font_family->fontStyle ) : 'normal';
$font_size = get_option( 'wp_chatbot_font_size' );
$font_size = esc_attr( trim( $font_size ) );
// Optional: ensure font size includes units.
if ( ! preg_match( '/(px|em|rem|%)$/', $font_size ) ) {
$font_size .= 'px'; // fallback to px if unit missing.
}
$custom_colors .= "
#wp-chatbot-messages-container > li.wp-chat-user-msg > .wp-chatbot-paragraph {
font-family: {$font_family};
font-weight: {$font_weight};
font-style: {$font_style};
font-size: {$font_size};
}
";
}
if(get_option('wp_chatbot_custom_css')!=""){
wp_add_inline_style( 'qcld-wp-chatbot-common-style', get_option('wp_chatbot_custom_css') );
}
if ( ( get_option( 'chatbot_content_max_height' ) != '' ) ) {
$chatbot_h_vh = absint( get_option( 'chatbot_content_max_height' ) );
if ( $chatbot_h_vh <= 0 ) {
$chatbot_h_vh = 80;
}
if ( $chatbot_h_vh > 100 ) {
$chatbot_h_vh = 100;
}
// Expand adds a modest bump based on admin height (never above 100vh).
$chatbot_h_expanded_vh = min( 100, $chatbot_h_vh + 8 );
$chatbot_h_mobile_vh = absint( get_option( 'chatbot_content_max_height_responsive' ) );
if ( $chatbot_h_mobile_vh <= 0 ) {
$chatbot_h_mobile_vh = 90;
}
if ( $chatbot_h_mobile_vh > 100 ) {
$chatbot_h_mobile_vh = 100;
}
$custom_colors .= ' .slimScrollDiv{
height: calc(' . $chatbot_h_vh . 'vh - 270px) !important;
max-height: calc(' . $chatbot_h_vh . 'vh - 270px) !important;
}';
$custom_colors .= 'div#wp-chatbot-board-container{
height: calc(' . $chatbot_h_vh . 'vh - 100px) !important;
max-height: calc(' . $chatbot_h_vh . 'vh - 100px) !important;
}';
$custom_colors .= '.wp-chatbot-content{
height: calc(' . $chatbot_h_vh . 'vh - 270px) !important;
max-height: calc(' . $chatbot_h_vh . 'vh - 270px) !important;
}';
// Desktop expand: width toggle also grows height from admin base + bump.
$custom_colors .= '
div#wp-chatbot-board-container.wp-chatbot-expanded,
.wp-chatbot-board-container.wp-chatbot-expanded {
height: calc(' . $chatbot_h_expanded_vh . 'vh - 100px) !important;
max-height: calc(' . $chatbot_h_expanded_vh . 'vh - 100px) !important;
}
div#wp-chatbot-board-container.wp-chatbot-expanded .slimScrollDiv,
div#wp-chatbot-board-container.wp-chatbot-expanded .wp-chatbot-content,
div#wp-chatbot-board-container.wp-chatbot-expanded .wp-chatbot-ball-inner,
.wp-chatbot-board-container.wp-chatbot-expanded .slimScrollDiv,
.wp-chatbot-board-container.wp-chatbot-expanded .wp-chatbot-content,
.wp-chatbot-board-container.wp-chatbot-expanded .wp-chatbot-ball-inner {
height: calc(' . $chatbot_h_expanded_vh . 'vh - 270px) !important;
max-height: calc(' . $chatbot_h_expanded_vh . 'vh - 270px) !important;
}
';
$custom_colors .= '
@media screen and (max-width: 480px) {
div#wp-chatbot-board-container{
height: calc(' . $chatbot_h_mobile_vh . 'vh - 0px) !important;
max-height: calc(' . $chatbot_h_mobile_vh . 'vh - 0px) !important;
}
.slimScrollDiv{
height: calc(' . $chatbot_h_mobile_vh . 'vh - 170px) !important;
max-height: calc(' . $chatbot_h_mobile_vh . 'vh - 170px) !important;
}
.wp-chatbot-content{
height: calc(' . $chatbot_h_mobile_vh . 'vh - 170px) !important;
max-height: calc(' . $chatbot_h_mobile_vh . 'vh - 170px) !important;
}
}
';
}
wp_add_inline_style( 'qcld-wp-chatbot-common-style', $custom_colors );
}
public function qcld_wb_chatbot_str_replace($messages=array()){
$allowed_html = array(
'a' => array(
'href' => array(),
'title' => array()
),
'div' => array(
'class' => array()
),
'span' => array(
'class' => array()
),
'img' => array(
'src' => array()
),
'h3' => array(),
'h4' => array(),
'h5' => array(),
'h6' => array(),
'b' => array(),
'br' => array(),
'em' => array(),
'ul' => array(),
'li' => array(),
'strong' => array(),
);
$refined_mesgses=array();
if(!empty($messages) && is_array($messages)){
foreach ($messages as $message){
$from = array('<', '>');
$to = array('<', '>');
if(!is_array($message)){
$message = str_replace($from, $to, $message);
$msg = wp_kses( ($message), $allowed_html);
$refined_msg=str_replace('\\', '', $msg);
array_push($refined_mesgses,$refined_msg);
}
}
}else{
$from = array('<', '>');
$to = array('<', '>');
$message = str_replace($from, $to, $messages);
if(!empty($messages )){
$msg = wp_kses( $messages, $allowed_html);
}else{
$msg = '';
}
$refined_msg=str_replace('\\', '', $msg);
array_push($refined_mesgses,$refined_msg);
}
return $refined_mesgses;
}
//getting exact agent icon path
public function qcld_wb_chatbot_agent_icon(){
if(get_option('wp_chatbot_custom_agent_path')!="" && get_option('wp_chatbot_agent_image')=="custom-agent.png" ){
$wp_chatbot_custom_icon_path=get_option('wp_chatbot_custom_agent_path');
}
else if(get_option('wp_chatbot_custom_agent_path')!="" && get_option('wp_chatbot_agent_image')!="custom-agent.png"){
$wp_chatbot_custom_icon_path=QCLD_wpCHATBOT_IMG_URL.get_option('wp_chatbot_agent_image');
}
else
{
if(get_option('wp_chatbot_agent_image')!=''){
$wp_chatbot_custom_icon_path=QCLD_wpCHATBOT_IMG_URL.get_option('wp_chatbot_agent_image');
}else{
$wp_chatbot_custom_icon_path=QCLD_wpCHATBOT_IMG_URL.'custom-agent.png';
}
}
return $wp_chatbot_custom_icon_path;
}
/**
* Render the admin page
*/
public function qcld_wb_chatbot_admin_page()
{
global $wpcommerce;
$action = 'admin.php?page=wpbot-panel';
require_once("admin_ui2.php");
}
public function qcld_wb_chatbot_admin_page_settings()
{
global $wpcommerce;
$action = 'admin.php?page=wpbot';
require_once("admin_ui.php");
}
public function qcld_wb_chatbot_dynamic_multi_option($options, $option_name, $option_text)
{
?>
0) {
foreach ($options as $key => $value) {
?>
array(
'href' => array(),
'title' => array()
),
'br' => array(),
'em' => array(),
'strong' => array(),
);
$support_query = @wp_unslash($_POST["support_query"]);
$clean_support_query = [];
if(!empty($support_query)){
foreach($support_query as $key => $val) {
$clean_support_query[wp_kses($key,$allowed_html)] = wp_kses($val,$allowed_html);
}
}
update_option('support_query', (maybe_serialize($clean_support_query)));
$support_ans = @wp_unslash($_POST["support_ans"]);
$clean_support_ans = [];
if(!empty($support_query)){
foreach($support_ans as $key => $val) {
$clean_support_ans[wp_kses($key,$allowed_html)] = wp_kses($val,$allowed_html);
}
}
update_option('support_ans', (maybe_serialize($clean_support_ans)));
//Create Mobile app pages.
if(isset( $_POST["wp_chatbot_app_pages"])) {
$wp_chatbot_app_pages = wp_unslash($_POST["wp_chatbot_app_pages"]);
}else{ $wp_chatbot_app_pages='';}
update_option('wp_chatbot_app_pages', wp_unslash($wp_chatbot_app_pages));
//Messenger Options
if(isset( $_POST["enable_wp_chatbot_messenger"])) {
$enable_wp_chatbot_messenger = wp_unslash($_POST["enable_wp_chatbot_messenger"]);
}else{ $enable_wp_chatbot_messenger='';}
update_option('enable_wp_chatbot_messenger', wp_unslash($enable_wp_chatbot_messenger));
if(isset( $_POST["enable_wp_chatbot_messenger_floating_icon"])) {
$enable_wp_chatbot_messenger_floating_icon = wp_unslash($_POST["enable_wp_chatbot_messenger_floating_icon"]);
}else{ $enable_wp_chatbot_messenger_floating_icon='';}
update_option('enable_wp_chatbot_messenger_floating_icon', wp_unslash($enable_wp_chatbot_messenger_floating_icon));
if(isset($_POST["qlcd_wp_chatbot_fb_app_id"])){
$qlcd_wp_chatbot_fb_app_id = @wp_unslash($_POST["qlcd_wp_chatbot_fb_app_id"]);
update_option('qlcd_wp_chatbot_fb_app_id', sanitize_text_field($qlcd_wp_chatbot_fb_app_id));
}
if(isset($_POST["qlcd_wp_chatbot_fb_page_id"])){
$qlcd_wp_chatbot_fb_page_id = @wp_unslash($_POST["qlcd_wp_chatbot_fb_page_id"]);
update_option('qlcd_wp_chatbot_fb_page_id', sanitize_text_field($qlcd_wp_chatbot_fb_page_id));
}
if(isset($_POST["qlcd_wp_chatbot_fb_color"])){
$qlcd_wp_chatbot_fb_color= @wp_unslash($_POST["qlcd_wp_chatbot_fb_color"]);
update_option('qlcd_wp_chatbot_fb_color', wp_unslash($qlcd_wp_chatbot_fb_color));
}
if(isset($_POST["qlcd_wp_chatbot_fb_in_msg"])){
$qlcd_wp_chatbot_fb_in_msg = @wp_unslash($_POST["qlcd_wp_chatbot_fb_in_msg"]);
update_option('qlcd_wp_chatbot_fb_in_msg', stripslashes(sanitize_text_field($qlcd_wp_chatbot_fb_in_msg)));
}
if(isset($_POST["qlcd_wp_chatbot_fb_out_msg"])){
$qlcd_wp_chatbot_fb_out_msg = @wp_unslash($_POST["qlcd_wp_chatbot_fb_out_msg"]);
update_option('qlcd_wp_chatbot_fb_out_msg', stripslashes(sanitize_text_field($qlcd_wp_chatbot_fb_out_msg)));
}
//Skype option
if(isset( $_POST["enable_wp_chatbot_skype_floating_icon"])) {
$enable_wp_chatbot_skype_floating_icon = wp_unslash($_POST["enable_wp_chatbot_skype_floating_icon"]);
}else{ $enable_wp_chatbot_skype_floating_icon='';}
update_option('enable_wp_chatbot_skype_floating_icon', sanitize_text_field($enable_wp_chatbot_skype_floating_icon));
if(isset( $_POST["enable_wp_chatbot_skype_id"])) {
$enable_wp_chatbot_skype_id = wp_unslash($_POST["enable_wp_chatbot_skype_id"]);
}else{ $enable_wp_chatbot_skype_id='';}
update_option('enable_wp_chatbot_skype_id', sanitize_text_field($enable_wp_chatbot_skype_id));
//WhatsApp
if(isset( $_POST["enable_wp_chatbot_whats"])) {
$enable_wp_chatbot_whats= wp_unslash($_POST["enable_wp_chatbot_whats"]);
}else{ $enable_wp_chatbot_whats='';}
update_option('enable_wp_chatbot_whats', sanitize_text_field($enable_wp_chatbot_whats));
if(isset($_POST["qlcd_wp_chatbot_whats_label"])){
$qlcd_wp_chatbot_whats_label = @wp_unslash($_POST["qlcd_wp_chatbot_whats_label"]);
update_option('qlcd_wp_chatbot_whats_label', maybe_serialize(sanitize_array($qlcd_wp_chatbot_whats_label)));
}
if(isset( $_POST["enable_wp_chatbot_floating_whats"])) {
$enable_wp_chatbot_floating_whats= wp_unslash($_POST["enable_wp_chatbot_floating_whats"]);
}else{ $enable_wp_chatbot_floating_whats='';}
update_option('enable_wp_chatbot_floating_whats', sanitize_text_field($enable_wp_chatbot_floating_whats));
if(isset($_POST["qlcd_wp_chatbot_whats_num"])){
$qlcd_wp_chatbot_whats_num = @wp_unslash($_POST["qlcd_wp_chatbot_whats_num"]);
update_option('qlcd_wp_chatbot_whats_num', sanitize_text_field($qlcd_wp_chatbot_whats_num));
}
//Viber
if(isset( $_POST["enable_wp_chatbot_floating_viber"])) {
$enable_wp_chatbot_floating_viber = wp_unslash($_POST["enable_wp_chatbot_floating_viber"]);
}else{ $enable_wp_chatbot_floating_viber='';}
update_option('enable_wp_chatbot_floating_viber', sanitize_text_field($enable_wp_chatbot_floating_viber));
if(isset($_POST["qlcd_wp_chatbot_viber_acc"])){
$qlcd_wp_chatbot_viber_acc = @wp_unslash($_POST["qlcd_wp_chatbot_viber_acc"]);
update_option('qlcd_wp_chatbot_viber_acc', sanitize_text_field($qlcd_wp_chatbot_viber_acc));
}
//Others integration
if(isset( $_POST["enable_wp_chatbot_floating_phone"])) {
$enable_wp_chatbot_floating_phone = wp_unslash($_POST["enable_wp_chatbot_floating_phone"]);
}else{ $enable_wp_chatbot_floating_phone='';}
update_option('enable_wp_chatbot_floating_phone', sanitize_text_field($enable_wp_chatbot_floating_phone));
if(isset($_POST["qlcd_wp_chatbot_phone"])){
$qlcd_wp_chatbot_phone = @wp_unslash($_POST["qlcd_wp_chatbot_phone"]);
update_option('qlcd_wp_chatbot_phone', sanitize_text_field($qlcd_wp_chatbot_phone));
}
if(isset( $_POST["enable_wp_chatbot_floating_link"])) {
$enable_wp_chatbot_floating_link = wp_unslash($_POST["enable_wp_chatbot_floating_link"]);
}else{ $enable_wp_chatbot_floating_link='';}
update_option('enable_wp_chatbot_floating_link', sanitize_text_field($enable_wp_chatbot_floating_link));
if(isset($_POST["qlcd_wp_chatbot_weblink"])){
$qlcd_wp_chatbot_weblink = @wp_unslash($_POST["qlcd_wp_chatbot_weblink"]);
update_option('qlcd_wp_chatbot_weblink', sanitize_text_field($qlcd_wp_chatbot_weblink));
}
//Re Targetting.
if(isset($_POST["qlcd_wp_chatbot_ret_greet"])){
$qlcd_wp_chatbot_ret_greet = @wp_unslash($_POST["qlcd_wp_chatbot_ret_greet"]);
update_option('qlcd_wp_chatbot_ret_greet', sanitize_text_field($qlcd_wp_chatbot_ret_greet));
}
if(isset( $_POST["enable_wp_chatbot_exit_intent"])) {
$enable_wp_chatbot_exit_intent = wp_unslash($_POST["enable_wp_chatbot_exit_intent"]);
}else{ $enable_wp_chatbot_exit_intent='';}
update_option('enable_wp_chatbot_exit_intent', sanitize_text_field($enable_wp_chatbot_exit_intent));
if(isset($_POST["wp_chatbot_exit_intent_msg"])){
$wp_chatbot_exit_intent_msg = @wp_unslash($_POST["wp_chatbot_exit_intent_msg"]);
update_option('wp_chatbot_exit_intent_msg', wp_unslash($wp_chatbot_exit_intent_msg));
}
if(isset( $_POST["wp_chatbot_exit_intent_once"])) {
$wp_chatbot_exit_intent_once = wp_unslash($_POST["wp_chatbot_exit_intent_once"]);
}else{ $wp_chatbot_exit_intent_once='';}
update_option('wp_chatbot_exit_intent_once', sanitize_text_field($wp_chatbot_exit_intent_once));
if(isset( $_POST["enable_wp_chatbot_scroll_open"])) {
$enable_wp_chatbot_scroll_open = wp_unslash($_POST["enable_wp_chatbot_scroll_open"]);
}else{ $enable_wp_chatbot_scroll_open='';}
update_option('enable_wp_chatbot_scroll_open', sanitize_text_field($enable_wp_chatbot_scroll_open));
if(isset($_POST["wp_chatbot_scroll_open_msg"])){
$wp_chatbot_scroll_open_msg= @wp_unslash($_POST["wp_chatbot_scroll_open_msg"]);
update_option('wp_chatbot_scroll_open_msg', wp_unslash($wp_chatbot_scroll_open_msg));
}
if(isset($_POST["wp_chatbot_scroll_percent"])){
$wp_chatbot_scroll_percent= @wp_unslash($_POST["wp_chatbot_scroll_percent"]);
update_option('wp_chatbot_scroll_percent', wp_unslash($wp_chatbot_scroll_percent));
}
if(isset( $_POST["wp_chatbot_scroll_once"])) {
$wp_chatbot_scroll_once = sanitize_text_field(wp_unslash($_POST["wp_chatbot_scroll_once"]));
}else{ $wp_chatbot_scroll_once='';}
update_option('wp_chatbot_scroll_once', $wp_chatbot_scroll_once);
if(isset( $_POST["enable_wp_chatbot_auto_open"])) {
$enable_wp_chatbot_auto_open = sanitize_text_field(wp_unslash($_POST["enable_wp_chatbot_auto_open"]));
}else{ $enable_wp_chatbot_auto_open='';}
update_option('enable_wp_chatbot_auto_open', $enable_wp_chatbot_auto_open);
if(isset( $_POST["enable_wp_chatbot_ret_sound"])) {
$enable_wp_chatbot_ret_sound = sanitize_text_field(wp_unslash($_POST["enable_wp_chatbot_ret_sound"]));
}else{ $enable_wp_chatbot_ret_sound='';}
update_option('enable_wp_chatbot_ret_sound', $enable_wp_chatbot_ret_sound);
if(isset( $_POST["enable_wp_chatbot_sound_initial"])) {
$enable_wp_chatbot_sound_initial = sanitize_text_field(wp_unslash($_POST["enable_wp_chatbot_sound_initial"]));
}else{ $enable_wp_chatbot_sound_initial='';}
update_option('enable_wp_chatbot_sound_initial', $enable_wp_chatbot_sound_initial);
if(isset($_POST["wp_chatbot_auto_open_msg"])){
$wp_chatbot_auto_open_msg = @wp_unslash($_POST["wp_chatbot_auto_open_msg"]);
update_option('wp_chatbot_auto_open_msg', wp_unslash($wp_chatbot_auto_open_msg));
}
if(isset($_POST["wp_chatbot_auto_open_time"])){
$wp_chatbot_auto_open_time = @wp_unslash($_POST["wp_chatbot_auto_open_time"]);
update_option('wp_chatbot_auto_open_time', wp_unslash($wp_chatbot_auto_open_time));
}
//to complate checkout.
if(isset( $_POST["enable_wp_chatbot_ret_user_show"])) {
$enable_wp_chatbot_ret_user_show = sanitize_text_field(wp_unslash($_POST["enable_wp_chatbot_ret_user_show"]));
}else{ $enable_wp_chatbot_ret_user_show='';}
update_option('enable_wp_chatbot_ret_user_show', $enable_wp_chatbot_ret_user_show);
if(isset( $_POST["enable_wp_chatbot_inactive_time_show"])) {
$enable_wp_chatbot_inactive_time_show = sanitize_text_field(wp_unslash($_POST["enable_wp_chatbot_inactive_time_show"]));
}else{ $enable_wp_chatbot_inactive_time_show='';}
update_option('enable_wp_chatbot_inactive_time_show', $enable_wp_chatbot_inactive_time_show);
if(isset($_POST["wp_chatbot_inactive_time"])){
$wp_chatbot_inactive_time = @wp_unslash($_POST["wp_chatbot_inactive_time"]);
update_option('wp_chatbot_inactive_time', sanitize_text_field($wp_chatbot_inactive_time));
}
if(isset($_POST["wp_chatbot_checkout_msg"])){
$wp_chatbot_checkout_msg = @wp_unslash($_POST["wp_chatbot_checkout_msg"]);
update_option('wp_chatbot_checkout_msg', wp_unslash($wp_chatbot_checkout_msg));
}
if(isset( $_POST["wp_chatbot_auto_open_once"])) {
$wp_chatbot_auto_open_once = sanitize_text_field(wp_unslash($_POST["wp_chatbot_auto_open_once"]));
}else{ $wp_chatbot_auto_open_once='';}
update_option('wp_chatbot_auto_open_once', $wp_chatbot_auto_open_once);
if(isset( $_POST["wp_chatbot_inactive_once"])) {
$wp_chatbot_inactive_once = sanitize_text_field(wp_unslash($_POST["wp_chatbot_inactive_once"]));
}else{ $wp_chatbot_inactive_once='';}
update_option('wp_chatbot_inactive_once', $wp_chatbot_inactive_once);
if(isset($_POST["wp_chatbot_proactive_bg_color"])){
$wp_chatbot_proactive_bg_color = @wp_unslash($_POST["wp_chatbot_proactive_bg_color"]);
update_option('wp_chatbot_proactive_bg_color', sanitize_text_field($wp_chatbot_proactive_bg_color));
}
if(isset( $_POST["disable_wp_chatbot_call_gen"])) {
$disable_wp_chatbot_call_gen = sanitize_text_field(wp_unslash($_POST["disable_wp_chatbot_call_gen"]));
}else{ $disable_wp_chatbot_call_gen='';}
update_option('disable_wp_chatbot_call_gen', $disable_wp_chatbot_call_gen);
if(isset( $_POST["disable_wp_chatbot_site_search"])) {
$disable_wp_chatbot_site_search = sanitize_text_field(wp_unslash($_POST["disable_wp_chatbot_site_search"]));
update_option('enable_wp_chatbot_post_content', '');
}else{ $disable_wp_chatbot_site_search='';}
update_option('disable_wp_chatbot_site_search', $disable_wp_chatbot_site_search);
if(isset( $_POST["enable_wp_chatbot_post_content"])) {
$enable_wp_chatbot_post_content = sanitize_text_field(wp_unslash($_POST["enable_wp_chatbot_post_content"]));
}else{ $enable_wp_chatbot_post_content='';}
update_option('enable_wp_chatbot_post_content', $enable_wp_chatbot_post_content);
if(isset( $_POST["disable_wp_chatbot_call_sup"])) {
$disable_wp_chatbot_call_sup = sanitize_text_field(wp_unslash($_POST["disable_wp_chatbot_call_sup"]));
}else{ $disable_wp_chatbot_call_sup='';}
update_option('disable_wp_chatbot_call_sup', $disable_wp_chatbot_call_sup);
if(isset( $_POST["disable_wp_chatbot_feedback"])) {
$disable_wp_chatbot_feedback = sanitize_text_field(wp_unslash($_POST["disable_wp_chatbot_feedback"]));
}else{ $disable_wp_chatbot_feedback='';}
update_option('disable_wp_chatbot_feedback', $disable_wp_chatbot_feedback);
if(isset( $_POST["disable_wp_chatbot_faq"])) {
$disable_wp_chatbot_faq = sanitize_text_field(wp_unslash($_POST["disable_wp_chatbot_faq"]));
}else{ $disable_wp_chatbot_faq='';}
update_option('disable_wp_chatbot_faq', $disable_wp_chatbot_faq);
if(isset($_POST["qlcd_wp_chatbot_feedback_label"])){
$qlcd_wp_chatbot_feedback_label = (@wp_unslash($_POST["qlcd_wp_chatbot_feedback_label"]));
update_option('qlcd_wp_chatbot_feedback_label', maybe_serialize(sanitize_array($qlcd_wp_chatbot_feedback_label)));
}
if(isset( $_POST["enable_wp_chatbot_meta_title"])) {
$enable_wp_chatbot_meta_title = sanitize_text_field(wp_unslash($_POST["enable_wp_chatbot_meta_title"]));
}else{ $enable_wp_chatbot_meta_title='';}
update_option('enable_wp_chatbot_meta_title', $enable_wp_chatbot_meta_title);
if(isset($_POST["qlcd_wp_chatbot_meta_label"])){
$qlcd_wp_chatbot_meta_label = esc_html(@wp_unslash($_POST["qlcd_wp_chatbot_meta_label"]));
update_option('qlcd_wp_chatbot_meta_label', stripslashes(sanitize_text_field($qlcd_wp_chatbot_meta_label)));
}
if (isset($_POST["qlcd_wp_chatbot_phone_sent"])) {
$qlcd_wp_chatbot_phone_sent = sanitize_text_field(wp_unslash($_POST["qlcd_wp_chatbot_phone_sent"]));
update_option('qlcd_wp_chatbot_phone_sent', $qlcd_wp_chatbot_phone_sent);
}
if (isset($_POST["qlcd_wp_chatbot_phone_fail"])) {
$qlcd_wp_chatbot_phone_fail = sanitize_text_field(wp_unslash($_POST["qlcd_wp_chatbot_phone_fail"]));
update_option('qlcd_wp_chatbot_phone_fail', $qlcd_wp_chatbot_phone_fail);
}
if (isset($_POST["qlcd_wp_chatbot_asking_search_keyword"])) {
$qlcd_wp_chatbot_asking_search_keyword = sanitize_text_field(wp_unslash($_POST["qlcd_wp_chatbot_asking_search_keyword"]));
update_option('qlcd_wp_chatbot_asking_search_keyword', $qlcd_wp_chatbot_asking_search_keyword);
}
if (isset($_POST["qlcd_wp_chatbot_found_result"])) {
$qlcd_wp_chatbot_found_result = sanitize_text_field(wp_unslash($_POST["qlcd_wp_chatbot_found_result"]));
update_option('qlcd_wp_chatbot_found_result', $qlcd_wp_chatbot_found_result);
}
if(isset( $_POST["enable_wp_chatbot_opening_hour"])) {
$enable_wp_chatbot_opening_hour = stripslashes(sanitize_text_field(wp_unslash($_POST["enable_wp_chatbot_opening_hour"])));
}else{ $enable_wp_chatbot_opening_hour='';}
update_option('enable_wp_chatbot_opening_hour', esc_html($enable_wp_chatbot_opening_hour));
if(isset($_POST["wpwbot_hours"])){
$wpwbot_hours= @wp_unslash($_POST["wpwbot_hours"]);
update_option('wpwbot_hours', maybe_serialize(sanitize_array($wpwbot_hours)));
}
if(isset( $_POST["enable_wp_chatbot_dailogflow"])) {
$enable_wp_chatbot_dailogflow = stripslashes(sanitize_text_field(wp_unslash($_POST["enable_wp_chatbot_dailogflow"])));
}else{ $enable_wp_chatbot_dailogflow='';}
update_option('enable_wp_chatbot_dailogflow', $enable_wp_chatbot_dailogflow);
if(isset($_POST["qlcd_wp_chatbot_dialogflow_client_token"])){
$qlcd_wp_chatbot_dialogflow_client_token= esc_html(@wp_unslash($_POST["qlcd_wp_chatbot_dialogflow_client_token"]));
update_option('qlcd_wp_chatbot_dialogflow_client_token', stripslashes(sanitize_text_field($qlcd_wp_chatbot_dialogflow_client_token)));
}
if (isset($_POST["qlcd_wp_chatbot_dialogflow_defualt_reply"])) {
$qlcd_wp_chatbot_dialogflow_defualt_reply = sanitize_text_field(wp_unslash($_POST["qlcd_wp_chatbot_dialogflow_defualt_reply"]));
update_option('qlcd_wp_chatbot_dialogflow_defualt_reply', $qlcd_wp_chatbot_dialogflow_defualt_reply);
}
if (isset($_POST["qlcd_wp_chatbot_dialogflow_agent_language"])) {
$qlcd_wp_chatbot_dialogflow_agent_language = sanitize_text_field(wp_unslash($_POST["qlcd_wp_chatbot_dialogflow_agent_language"]));
update_option('qlcd_wp_chatbot_dialogflow_agent_language', $qlcd_wp_chatbot_dialogflow_agent_language);
}
// style option save.
if(isset( $_POST["enable_wp_chatbot_custom_color"])) {
$enable_wp_chatbot_custom_color = esc_html(wp_unslash($_POST["enable_wp_chatbot_custom_color"]));
}else{ $enable_wp_chatbot_custom_color='';}
update_option('enable_wp_chatbot_custom_color', stripslashes(sanitize_text_field($enable_wp_chatbot_custom_color)));
if (isset($_POST["wp_chatbot_text_color"])) {
$wp_chatbot_text_color = sanitize_hex_color(wp_unslash($_POST["wp_chatbot_text_color"]));
update_option('wp_chatbot_text_color', $wp_chatbot_text_color);
}
if (isset($_POST["wp_chatbot_floatingiconbg_color"])) {
$wp_chatbot_floatingiconbg_color = sanitize_hex_color(wp_unslash($_POST["wp_chatbot_floatingiconbg_color"]));
update_option('wp_chatbot_floatingiconbg_color', $wp_chatbot_floatingiconbg_color);
}
if (isset($_POST["wp_chatbot_link_color"])) {
$wp_chatbot_link_color = sanitize_hex_color(wp_unslash($_POST["wp_chatbot_link_color"]));
update_option('wp_chatbot_link_color', $wp_chatbot_link_color);
}
if (isset($_POST["wp_chatbot_link_hover_color"])) {
$wp_chatbot_link_hover_color = sanitize_hex_color(wp_unslash($_POST["wp_chatbot_link_hover_color"]));
update_option('wp_chatbot_link_hover_color', $wp_chatbot_link_hover_color);
}
if (isset($_POST["wp_chatbot_bot_msg_bg_color"])) {
$wp_chatbot_bot_msg_bg_color = sanitize_hex_color(wp_unslash($_POST["wp_chatbot_bot_msg_bg_color"]));
update_option('wp_chatbot_bot_msg_bg_color', $wp_chatbot_bot_msg_bg_color);
}
if (isset($_POST["wp_chatbot_bot_msg_text_color"])) {
$wp_chatbot_bot_msg_text_color = sanitize_hex_color(wp_unslash($_POST["wp_chatbot_bot_msg_text_color"]));
update_option('wp_chatbot_bot_msg_text_color', $wp_chatbot_bot_msg_text_color);
}
if (isset($_POST["wp_chatbot_user_msg_bg_color"])) {
$wp_chatbot_user_msg_bg_color = sanitize_hex_color(wp_unslash($_POST["wp_chatbot_user_msg_bg_color"]));
update_option('wp_chatbot_user_msg_bg_color', $wp_chatbot_user_msg_bg_color);
}
if (isset($_POST["wp_chatbot_user_msg_text_color"])) {
$wp_chatbot_user_msg_text_color = sanitize_hex_color(wp_unslash($_POST["wp_chatbot_user_msg_text_color"]));
update_option('wp_chatbot_user_msg_text_color', $wp_chatbot_user_msg_text_color);
}
if (isset($_POST["wp_chatbot_buttons_bg_color"])) {
$wp_chatbot_buttons_bg_color = sanitize_hex_color(wp_unslash($_POST["wp_chatbot_buttons_bg_color"]));
update_option('wp_chatbot_buttons_bg_color', $wp_chatbot_buttons_bg_color);
}
if (isset($_POST["wp_chatbot_buttons_text_color"])) {
$wp_chatbot_buttons_text_color = sanitize_hex_color(wp_unslash($_POST["wp_chatbot_buttons_text_color"]));
update_option('wp_chatbot_buttons_text_color', $wp_chatbot_buttons_text_color);
}
if (isset($_POST["wp_chatbot_buttons_bg_color_hover"])) {
$wp_chatbot_buttons_bg_color_hover = sanitize_hex_color(wp_unslash($_POST["wp_chatbot_buttons_bg_color_hover"]));
update_option('wp_chatbot_buttons_bg_color_hover', $wp_chatbot_buttons_bg_color_hover);
}
if (isset($_POST["wp_chatbot_buttons_text_color_hover"])) {
$wp_chatbot_buttons_text_color_hover = sanitize_hex_color(wp_unslash($_POST["wp_chatbot_buttons_text_color_hover"]));
update_option('wp_chatbot_buttons_text_color_hover', $wp_chatbot_buttons_text_color_hover);
}
if (isset($_POST["wp_chatbot_theme_secondary_color"])) {
$wp_chatbot_theme_secondary_color = sanitize_hex_color(wp_unslash($_POST["wp_chatbot_theme_secondary_color"]));
update_option('wp_chatbot_theme_secondary_color', $wp_chatbot_theme_secondary_color);
}
if (isset($_POST["wp_chatbot_header_background_color"])) {
$wp_chatbot_header_background_color = sanitize_hex_color(wp_unslash($_POST["wp_chatbot_header_background_color"]));
update_option('wp_chatbot_header_background_color', $wp_chatbot_header_background_color);
}
if (isset($_POST["wp_chatbot_font_size"])) {
$wp_chatbot_font_size = sanitize_text_field(wp_unslash($_POST["wp_chatbot_font_size"]));
// Additional validation for font size format (e.g., '14px', '1.2em') could be added here if strict adherence to CSS units is required.
update_option('wp_chatbot_font_size', $wp_chatbot_font_size);
}
if (isset($_POST["wp_chat_bot_font_family"])) {
$wp_chat_bot_font_family = sanitize_text_field(wp_unslash($_POST["wp_chat_bot_font_family"]));
update_option('wp_chat_bot_font_family', $wp_chat_bot_font_family);
}
if (isset($_POST["wp_chat_user_font_family"])) {
$wp_chat_user_font_family = sanitize_text_field(wp_unslash($_POST["wp_chat_user_font_family"]));
update_option('wp_chat_user_font_family', $wp_chat_user_font_family);
}
if (isset($_POST['wp_chatbot_user_font'])) {
$wp_chatbot_user_font = sanitize_text_field(wp_unslash($_POST['wp_chatbot_user_font']));
update_option('wp_chatbot_user_font', $wp_chatbot_user_font);
}
if (isset($_POST['wp_chatbot_bot_font'])) {
$wp_chatbot_bot_font = sanitize_text_field(wp_unslash($_POST['wp_chatbot_bot_font']));
update_option('wp_chatbot_bot_font', $wp_chatbot_bot_font);
}
set_transient( 'qcld_bot_clear_cache', 1, DAY_IN_SECONDS );
wp_enqueue_script( 'wp_chatbot_bot-front-js', plugins_url(basename(plugin_dir_path(__FILE__))) . '/js/sweetalrt.js', array('jquery'), '', true);
$script = "
console.log('sdaas');
function callsweetalert(){
Swal.fire({
title: 'Your settings are saved.',
html: 'Please clear your browser cache and cookies both and reload the front end before testing. Alternatively, you can launch a new browser window in Incognito /Private mode (Ctrl+Shift+N in chrome) to test.
',
width: 450,
icon: 'success',
confirmButtonText: 'Got it',
confirmButtonWidth: 100,
confirmButtonClass: 'btn btn-lg',
}).then((result) => {
// location.reload();
})
}
callsweetalert();
";
wp_add_inline_script( 'wp_chatbot_bot-front-js', $script );
}
}
}
/**
* Display Notifications on specific criteria.
*
* @since 2.14
*/
public static function wpcommerce_inactive_notice_for_wp_chatbot()
{
if (current_user_can('activate_plugins')) :
if (!class_exists('wpCommerce')) :
deactivate_plugins(plugin_basename(__FILE__));
?>
',
' ',
esc_html( QCLD_wpCHATBOT_REQUIRED_wpCOMMERCE_VERSION )
);
?>
'.esc_html__( 'Re-Index Products', 'chatbot' ).''); ?>
has_cap( 'collation' ) ) {
if ( ! empty( $wpdb->charset ) ) {
$collate .= "DEFAULT CHARACTER SET $wpdb->charset";
}
if ( ! empty( $wpdb->collate ) ) {
$collate .= " COLLATE $wpdb->collate";
}
}
//Bot User Table
$table1 = $wpdb->prefix.'wpbot_sessions';
$sql_sliders_Table1 = "
CREATE TABLE IF NOT EXISTS `$table1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`session` int(11) NOT NULL,
PRIMARY KEY (`id`)
) $collate AUTO_INCREMENT=1 ";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql_sliders_Table1 );
//Bot Response Table
$table1 = $wpdb->prefix.'wpbot_response';
$sql_sliders_Table1 = "
CREATE TABLE IF NOT EXISTS `$table1` (
`id` INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
`query` TEXT NOT NULL,
`keyword` TEXT NOT NULL,
`response` TEXT NOT NULL,
`category` varchar(256) NOT NULL,
`intent` varchar(256) NOT NULL,
`custom` varchar(256) NOT NULL,
`lang` varchar(25) NULL,
FULLTEXT(`query`, `keyword`, `response`)
) $collate AUTO_INCREMENT=1 ENGINE=InnoDB";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql_sliders_Table1 );
//Bot Response Table
$table_rag_documents = $wpdb->prefix . "rag_documents";
$charset = $wpdb->get_charset_collate();
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
// phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange
$sql_rag_documents = "CREATE TABLE $table_rag_documents (
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
doc_id VARCHAR(100) DEFAULT NULL,
title VARCHAR(255) NOT NULL,
content LONGTEXT NOT NULL,
embedding LONGTEXT NOT NULL,
source_type VARCHAR(20) DEFAULT 'post',
source_url VARCHAR(255) DEFAULT NULL,
file_url TEXT DEFAULT NULL,
metadata LONGTEXT DEFAULT NULL,
status VARCHAR(50) DEFAULT 'complete',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
) $charset;";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta($sql_rag_documents);
// phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange
}
$table_report = $wpdb->prefix . 'wpbot_chat_report';
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
// phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange
$sql_report = "
CREATE TABLE `$table_report` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`conversation_id` int(11) DEFAULT NULL,
`message` longtext NOT NULL,
`feedback` varchar(20) DEFAULT NULL,
`meta_info` text DEFAULT NULL,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) $charset_collate AUTO_INCREMENT=1;
";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta( $sql_report );
// phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange
}
$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
if(empty($sqlqry)){
$query = 'Sample Question ?';
$response = 'Sample Answer';
$data = array('query' => $query, 'keyword' => '', 'response'=> $response, 'intent'=> '');
$format = array('%s','%s', '%s', '%s');
$wpdb->insert($table1,$data,$format); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, PluginCheck.Security.DirectDB.UnescapedDBParameter
}
$table = $wpdb->prefix . 'wpbot_subscription';
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
// phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange
$sql_sliders_Table = "
CREATE TABLE IF NOT EXISTS `$table` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(256) NOT NULL,
`email` varchar(256) NOT NULL,
`phone` varchar(256) NOT NULL,
`url` text NOT NULL,
`date` datetime NOT NULL,
`user_agent` text NOT NULL,
PRIMARY KEY (`id`)
) $collate AUTO_INCREMENT=1 ";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta($sql_sliders_Table);
// phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange
}
$url = get_site_url();
$url = wp_parse_url($url);
$domain = $url['host'];
//$admin_email = "admin@" . $domain;
$admin_email = get_option('admin_email');
if(!get_option('wp_chatbot_position_x')) {
update_option('wp_chatbot_position_x', 30);
}
if(!get_option('wp_chatbot_position_y')) {
update_option('wp_chatbot_position_y', 30);
}
if(!get_option('disable_wp_chatbot')) {
update_option('disable_wp_chatbot', '');
}
if(!get_option('disable_wp_chatbot_icon_animation')) {
update_option('disable_wp_chatbot_icon_animation', '');
}
if(!get_option('disable_wp_chatbot_on_mobile')) {
update_option('disable_wp_chatbot_on_mobile', '');
}
if(!get_option('qlcd_wp_chatbot_admin_email')) {
update_option('qlcd_wp_chatbot_admin_email', get_option('admin_email'));
}
if(!get_option('disable_wp_chatbot_product_search')) {
update_option('disable_wp_chatbot_product_search', '');
}
if(!get_option('disable_wp_chatbot_catalog')) {
update_option('disable_wp_chatbot_catalog', '');
}
if(!get_option('disable_wp_chatbot_order_status')) {
update_option('disable_wp_chatbot_order_status', '');
}
if(!get_option('enable_wp_chatbot_rtl')) {
update_option('enable_wp_chatbot_rtl', '');
}
if(!get_option('show_menu_after_greetings')) {
update_option('show_menu_after_greetings', 1);
}
if(!get_option('disable_back_to_start_menu')) {
update_option('disable_back_to_start_menu', '');
}
if(!get_option('disable_floating_button')) {
update_option('disable_floating_button', '');
}
if(!get_option('enable_chat_session')) {
update_option('enable_chat_session', '');
}
if(!get_option('enable_wp_chatbot_mobile_full_screen')) {
update_option('enable_wp_chatbot_mobile_full_screen', 1);
}
if(!get_option('wpbot_preloading_time')) {
update_option('wpbot_preloading_time', '800');
}
if(!get_option('disable_wp_chatbot_notification')) {
update_option('disable_wp_chatbot_notification', '1');
}
if(!get_option('disable_wp_chatbot_cart_item_number')) {
update_option('disable_wp_chatbot_cart_item_number', '');
}
if(!get_option('disable_wp_chatbot_featured_product')) {
update_option('disable_wp_chatbot_featured_product', '');
}
if(!get_option('disable_wp_chatbot_sale_product')) {
update_option('disable_wp_chatbot_sale_product', '');
}
if(!get_option('wp_chatbot_open_product_detail')) {
update_option('wp_chatbot_open_product_detail', '');
}
if(!get_option('qlcd_wp_chatbot_product_orderby')) {
update_option('qlcd_wp_chatbot_product_orderby', sanitize_text_field('title'));
}
if(!get_option('qlcd_wp_chatbot_product_order')) {
update_option('qlcd_wp_chatbot_product_order', sanitize_text_field('ASC'));
}
if(!get_option('qlcd_wp_chatbot_ppp')) {
update_option('qlcd_wp_chatbot_ppp', intval(6));
}
if(!get_option('wp_chatbot_exclude_stock_out_product')) {
update_option('wp_chatbot_exclude_stock_out_product', '');
}
if(!get_option('wp_chatbot_show_sub_category')) {
update_option('wp_chatbot_show_sub_category', '');
}
if(!get_option('wp_chatbot_vertical_custom')){
update_option('wp_chatbot_vertical_custom', 'Go To');
}
if(!get_option('wp_chatbot_show_home_page')) {
update_option('wp_chatbot_show_home_page', 'on');
}
if(!get_option('qc_wpbot_menu_order')) {
$site_search_label = get_option('qlcd_wp_chatbot_wildcard_site_search') != '' ? get_option('qlcd_wp_chatbot_wildcard_site_search') : 'Site Search';
$support_email_label = get_option('qlcd_wp_chatbot_support_email') != '' ? get_option('qlcd_wp_chatbot_support_email') : 'Send us Email.';
$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!';
$default_menu = '' . esc_attr($site_search_label) . ' ';
$default_menu .= '' . esc_attr($support_email_label) . ' ';
$default_menu .= '' . esc_attr($support_phone_label) . ' ';
update_option('qc_wpbot_menu_order', $default_menu);
}
if(!get_option('qcld_chatbot_avatar_location')) {
update_option('qcld_chatbot_avatar_location', 'side');
}
if(!get_option('wp_chatbot_show_posts')) {
update_option('wp_chatbot_show_posts', 'on');
}
if(!get_option('wp_chatbot_show_pages')){
update_option('wp_chatbot_show_pages', 'on');
}
if(!get_option('wp_chatbot_show_pages_list')) {
update_option('wp_chatbot_show_pages_list', maybe_serialize(array()));
}
if(!get_option('wp_chatbot_exclude_post_list')) {
update_option('wp_chatbot_exclude_post_list', maybe_serialize(array()));
}
if(!get_option('wp_chatbot_show_wpcommerce')) {
update_option('wp_chatbot_show_wpcommerce', 'on');
}
if(!get_option('qlcd_wp_chatbot_stop_words_name')) {
update_option('qlcd_wp_chatbot_stop_words_name', 'english');
}
if(!get_option('qlcd_wp_chatbot_stop_words')) {
update_option('qlcd_wp_chatbot_stop_words', "a,able,about,above,abst,accordance,according,accordingly,across,act,actually,added,adj,affected,affecting,affects,after,afterwards,again,against,ah,all,almost,alone,along,already,also,although,always,am,among,amongst,an,and,announce,another,any,anybody,anyhow,anymore,anyone,anything,anyway,anyways,anywhere,apparently,approximately,are,aren,arent,arise,around,as,aside,ask,asking,at,auth,available,away,awfully,b,back,be,became,because,become,becomes,becoming,been,before,beforehand,begin,beginning,beginnings,begins,behind,being,believe,below,beside,besides,between,beyond,biol,both,brief,briefly,but,by,c,ca,came,can,cannot,can't,cause,causes,certain,certainly,co,com,come,comes,contain,containing,contains,could,couldnt,d,date,did,didn't,different,do,does,doesn't,doing,done,don't,down,downwards,due,during,e,each,ed,edu,effect,eg,eight,eighty,either,else,elsewhere,end,ending,enough,especially,et,et-al,etc,even,ever,every,everybody,everyone,everything,everywhere,ex,except,f,far,few,ff,fifth,first,five,fix,followed,following,follows,for,former,formerly,forth,found,four,from,further,furthermore,g,gave,get,gets,getting,give,given,gives,giving,go,goes,gone,got,gotten,h,had,happens,hardly,has,hasn't,have,haven't,having,he,hed,hence,her,here,hereafter,hereby,herein,heres,hereupon,hers,herself,hes,hi,hid,him,himself,his,hither,home,how,howbeit,however,hundred,i,id,ie,if,i'll,im,immediate,immediately,importance,important,in,inc,indeed,index,information,instead,into,invention,inward,is,isn't,it,itd,it'll,its,itself,i've,j,just,k,keep,keeps,kept,kg,km,know,known,knows,l,largely,last,lately,later,latter,latterly,least,less,lest,let,lets,like,liked,likely,line,little,'ll,look,looking,looks,ltd,m,made,mainly,make,makes,many,may,maybe,me,mean,means,meantime,meanwhile,merely,mg,might,million,miss,ml,more,moreover,most,mostly,mr,mrs,much,mug,must,my,myself,n,na,name,namely,nay,nd,near,nearly,necessarily,necessary,need,needs,neither,never,nevertheless,new,next,nine,ninety,no,nobody,non,none,nonetheless,noone,nor,normally,nos,not,noted,nothing,now,nowhere,o,obtain,obtained,obviously,of,off,often,oh,ok,okay,old,omitted,on,once,one,ones,only,onto,or,ord,other,others,otherwise,ought,our,ours,ourselves,out,outside,over,overall,owing,own,p,page,pages,part,particular,particularly,past,per,perhaps,placed,please,plus,poorly,possible,possibly,potentially,pp,predominantly,present,previously,primarily,probably,promptly,proud,provides,put,q,que,quickly,quite,qv,r,ran,rather,rd,re,readily,really,recent,recently,ref,refs,regarding,regardless,regards,related,relatively,research,respectively,resulted,resulting,results,right,run,s,said,same,saw,say,saying,says,sec,section,see,seeing,seem,seemed,seeming,seems,seen,self,selves,sent,seven,several,shall,she,shed,she'll,shes,should,shouldn't,show,showed,shown,showns,shows,significant,significantly,similar,similarly,since,six,slightly,so,some,somebody,somehow,someone,somethan,something,sometime,sometimes,somewhat,somewhere,soon,sorry,specifically,specified,specify,specifying,still,stop,strongly,sub,substantially,successfully,such,sufficiently,suggest,sup,sure,t,take,taken,taking,tell,tends,th,than,thank,thanks,thanx,that,that'll,thats,that've,the,their,theirs,them,themselves,then,thence,there,thereafter,thereby,thered,therefore,therein,there'll,thereof,therere,theres,thereto,thereupon,there've,these,they,theyd,they'll,theyre,they've,think,this,those,thou,though,thoughh,thousand,throug,through,throughout,thru,thus,til,tip,to,together,too,took,toward,towards,tried,tries,truly,try,trying,ts,twice,two,u,un,under,unfortunately,unless,unlike,unlikely,until,unto,up,upon,ups,us,use,used,useful,usefully,usefulness,uses,using,usually,v,value,various,'ve,very,via,viz,vol,vols,vs,w,want,wants,was,wasnt,way,we,wed,welcome,we'll,went,were,werent,we've,what,whatever,what'll,whats,when,whence,whenever,where,whereafter,whereas,whereby,wherein,wheres,whereupon,wherever,whether,which,while,whim,whither,who,whod,whoever,whole,who'll,whom,whomever,whos,whose,why,widely,willing,wish,with,within,without,wont,words,world,would,wouldnt,www,x,y,yes,yet,you,youd,you'll,your,youre,yours,yourself,yourselves,you've,z,zero");
}
if(!get_option('qlcd_wp_chatbot_order_user')) {
update_option('qlcd_wp_chatbot_order_user', sanitize_text_field('login'));
}
if(!get_option('wp_chatbot_custom_agent_path')) {
update_option('wp_chatbot_custom_agent_path', '');
}
if(!get_option('wp_chatbot_custom_icon_path')) {
update_option('wp_chatbot_custom_icon_path', '');
}
if(!get_option('wp_chatbot_icon')) {
update_option('wp_chatbot_icon', sanitize_text_field('icon-13.png'));
}
if(!get_option('wp_chatbot_floatingiconbg_color')) {
update_option('wp_chatbot_floatingiconbg_color', '#fff');
}
if(!get_option('wp_chatbot_agent_image')){
update_option('wp_chatbot_agent_image',sanitize_text_field('agent-0.png'));
}
if(!get_option('qcld_wb_chatbot_theme')) {
update_option('qcld_wb_chatbot_theme', sanitize_text_field('template-00'));
}
if(!get_option('qcld_wb_chatbot_change_bg')) {
update_option('qcld_wb_chatbot_change_bg', '');
}
if(!get_option('wp_chatbot_custom_css')) {
update_option('wp_chatbot_custom_css', '');
}
if(!get_option('qlcd_wp_chatbot_host')) {
update_option('qlcd_wp_chatbot_host', stripslashes(sanitize_text_field('Our Website')));
}
if(!get_option('qlcd_wp_chatbot_agent')) {
update_option('qlcd_wp_chatbot_agent', stripslashes(sanitize_text_field('Carrie')));
}
if(!get_option('qlcd_wp_chatbot_host')) {
update_option('qlcd_wp_chatbot_host', stripslashes(sanitize_text_field('Our Website')));
}
if(!get_option('qlcd_wp_chatbot_shopper_demo_name')) {
update_option('qlcd_wp_chatbot_shopper_demo_name', stripslashes(sanitize_text_field('Amigo')));
}
if(!get_option('qlcd_wp_chatbot_yes')) {
update_option('qlcd_wp_chatbot_yes', stripslashes(sanitize_text_field('YES')));
}
if(!get_option('qlcd_wp_chatbot_no')) {
update_option('qlcd_wp_chatbot_no', stripslashes(sanitize_text_field('NO')));
}
if(!get_option('qlcd_wp_chatbot_or')) {
update_option('qlcd_wp_chatbot_or', stripslashes(sanitize_text_field('OR')));
}
if(!get_option('qlcd_wp_chatbot_sorry')) {
update_option('qlcd_wp_chatbot_sorry', stripslashes(sanitize_text_field('Sorry')));
}
if(!get_option('qlcd_wp_chatbot_dialogflow_project_id')) {
update_option('qlcd_wp_chatbot_dialogflow_project_id', '');
}
if(!get_option('wp_chatbot_df_api')) {
update_option('wp_chatbot_df_api', 'v1');
}
if(!get_option('qlcd_wp_chatbot_dialogflow_project_key')) {
update_option('qlcd_wp_chatbot_dialogflow_project_key', '');
}
if(!get_option('qlcd_wp_chatbot_agent_join')) {
update_option('qlcd_wp_chatbot_agent_join', maybe_serialize(array('has joined the conversation')));
}
if(!get_option('qlcd_wp_chatbot_welcome')) {
update_option('qlcd_wp_chatbot_welcome', maybe_serialize(array('Welcome to', 'Glad to have you at')));
}
if(!get_option('qlcd_wp_chatbot_back_to_start')) {
update_option('qlcd_wp_chatbot_back_to_start', maybe_serialize(array('Back to Start')));
}
if(!get_option('qlcd_wp_chatbot_hi_there')) {
update_option('qlcd_wp_chatbot_hi_there', maybe_serialize(array('Hi There!')));
}
if(!get_option('qlcd_wp_chatbot_hello')) {
update_option('qlcd_wp_chatbot_hello', maybe_serialize(array('Hi There!')));
}
if(!get_option('qlcd_wp_chatbot_welcome_back')) {
update_option('qlcd_wp_chatbot_welcome_back', maybe_serialize(array('Welcome back', 'Good to see your again')));
}
if(!get_option('qlcd_wp_chatbot_asking_name')) {
update_option('qlcd_wp_chatbot_asking_name', maybe_serialize(array('May I know your name?', 'What should I call you?')));
}
if(!get_option('qlcd_wp_chatbot_name_greeting')) {
update_option('qlcd_wp_chatbot_name_greeting', maybe_serialize(array('Nice to meet you')));
}
if(!get_option('qlcd_wp_chatbot_i_am')) {
update_option('qlcd_wp_chatbot_i_am', maybe_serialize(array('I am', 'This is')));
}
if(!get_option('qlcd_wp_chatbot_is_typing')) {
update_option('qlcd_wp_chatbot_is_typing', maybe_serialize(array('is typing...')));
}
if(!get_option('qlcd_wp_chatbot_send_a_msg')) {
update_option('qlcd_wp_chatbot_send_a_msg', maybe_serialize(array('Send a message.')));
}
if(!get_option('qlcd_wp_chatbot_choose_option')) {
update_option('qlcd_wp_chatbot_choose_option', maybe_serialize(array('Choose an option.')));
}
if(!get_option('qlcd_wp_chatbot_viewed_products')) {
update_option('qlcd_wp_chatbot_viewed_products', maybe_serialize(array('Recently viewed products')));
}
if(!get_option('qlcd_wp_chatbot_add_to_cart')) {
update_option('qlcd_wp_chatbot_add_to_cart', maybe_serialize(array('Add to Cart')));
}
if(!get_option('qlcd_wp_chatbot_cart_link')) {
update_option('qlcd_wp_chatbot_cart_link', maybe_serialize(array('Cart')));
}
if(!get_option('qlcd_wp_chatbot_checkout_link')) {
update_option('qlcd_wp_chatbot_checkout_link', maybe_serialize(array('Checkout')));
}
if(!get_option('qlcd_wp_chatbot_featured_product_welcome')) {
update_option('qlcd_wp_chatbot_featured_product_welcome', maybe_serialize(array('I have found following featured products')));
}
if(!get_option('qlcd_wp_chatbot_viewed_product_welcome')) {
update_option('qlcd_wp_chatbot_viewed_product_welcome', maybe_serialize(array('I have found following recently viewed products')));
}
if(!get_option('qlcd_wp_chatbot_latest_product_welcome')) {
update_option('qlcd_wp_chatbot_latest_product_welcome', maybe_serialize(array('I have found following latest products')));
}
if(!get_option('qlcd_wp_chatbot_cart_welcome')) {
update_option('qlcd_wp_chatbot_cart_welcome', maybe_serialize(array('I have found following items from Shopping Cart.')));
}
if(!get_option('qlcd_wp_chatbot_cart_title')) {
update_option('qlcd_wp_chatbot_cart_title', maybe_serialize(array('Title')));
}
if(!get_option('qlcd_wp_chatbot_cart_quantity')) {
update_option('qlcd_wp_chatbot_cart_quantity', maybe_serialize(array('Qty')));
}
if(!get_option('qlcd_wp_chatbot_cart_price')) {
update_option('qlcd_wp_chatbot_cart_price', maybe_serialize(array('Price')));
}
if(!get_option('qlcd_wp_chatbot_no_cart_items')) {
update_option('qlcd_wp_chatbot_no_cart_items', maybe_serialize(array('No items in the cart')));
}
if(!get_option('qlcd_wp_chatbot_cart_updating')) {
update_option('qlcd_wp_chatbot_cart_updating', maybe_serialize(array('Updating cart items ...')));
}
if(!get_option('qlcd_wp_chatbot_cart_removing')) {
update_option('qlcd_wp_chatbot_cart_removing', maybe_serialize(array('Removing cart items ...')));
}
if(!get_option('qlcd_wp_chatbot_wildcard_msg')) {
update_option('qlcd_wp_chatbot_wildcard_msg', maybe_serialize(array('I am here to find what you need. What are you looking for?')));
}
if(!get_option('qlcd_wp_chatbot_empty_filter_msg')) {
update_option('qlcd_wp_chatbot_empty_filter_msg', maybe_serialize(array('Sorry, I did not understand you.')));
}
if(!get_option('qlcd_wp_chatbot_did_you_mean')) {
update_option('qlcd_wp_chatbot_did_you_mean', maybe_serialize(array('Did you mean?')));
}
if(!get_option('qlcd_wp_chatbot_sys_key_help')) {
update_option('qlcd_wp_chatbot_sys_key_help', 'start');
}
if(!get_option('qlcd_wp_chatbot_sys_key_product')) {
update_option('qlcd_wp_chatbot_sys_key_product', 'product');
}
if(!get_option('qlcd_wp_chatbot_sys_key_catalog')) {
update_option('qlcd_wp_chatbot_sys_key_catalog', 'catalog');
}
if(!get_option('qlcd_wp_chatbot_sys_key_order')) {
update_option('qlcd_wp_chatbot_sys_key_order', 'order');
}
if(!get_option('qlcd_wp_chatbot_sys_key_support')) {
update_option('qlcd_wp_chatbot_sys_key_support', 'faq');
}
if(!get_option('qlcd_wp_chatbot_sys_key_reset')) {
update_option('qlcd_wp_chatbot_sys_key_reset', 'reset');
}
if(!get_option('qlcd_wp_chatbot_sys_key_email')) {
update_option('qlcd_wp_chatbot_sys_key_email', 'email');
}
if(!get_option('qlcd_wp_chatbot_help_welcome')) {
update_option('qlcd_wp_chatbot_help_welcome', maybe_serialize(array('Welcome to Help Section.')));
}
if(!get_option('qlcd_wp_chatbot_help_msg')) {
update_option('qlcd_wp_chatbot_help_msg', maybe_serialize(array('Type and Hit Enter start to Get back to the main menu. faq for FAQ. email to send eMail reset to restart the chat ')));
}
if(!get_option('qlcd_wp_chatbot_reset')) {
update_option('qlcd_wp_chatbot_reset', maybe_serialize(array('Do you want to clear our chat history and start over?')));
}
if(!get_option('qlcd_wp_chatbot_wildcard_product')) {
update_option('qlcd_wp_chatbot_wildcard_product', maybe_serialize(array('Product Search')));
}
if(!get_option('qlcd_wp_chatbot_wildcard_catalog')) {
update_option('qlcd_wp_chatbot_wildcard_catalog', maybe_serialize(array('Catalog')));
}
if(!get_option('qlcd_wp_chatbot_featured_products')) {
update_option('qlcd_wp_chatbot_featured_products', maybe_serialize(array('Featured Products')));
}
if(!get_option('qlcd_wp_chatbot_sale_products')) {
update_option('qlcd_wp_chatbot_sale_products', maybe_serialize(array('Products on Sale')));
}
if(!get_option('qlcd_wp_chatbot_wildcard_support')) {
update_option('qlcd_wp_chatbot_wildcard_support', 'FAQ');
}
if(!get_option('qlcd_wp_chatbot_wildcard_site_search')) {
update_option('qlcd_wp_chatbot_wildcard_site_search', 'Site Search');
}
if(!get_option('qlcd_wp_chatbot_messenger_label')) {
update_option('qlcd_wp_chatbot_messenger_label', maybe_serialize(array('Chat with Us on Facebook Messenger')));
}
if(!get_option('qlcd_wp_chatbot_product_success')) {
update_option('qlcd_wp_chatbot_product_success', maybe_serialize(array('Great! We have these products for', 'Found these products for')));
}
if(!get_option('qlcd_wp_chatbot_product_fail')) {
update_option('qlcd_wp_chatbot_product_fail', maybe_serialize(array('Sorry, I found nothing')));
}
if(!get_option('qlcd_wp_chatbot_product_asking')) {
update_option('qlcd_wp_chatbot_product_asking', maybe_serialize(array('What are you shopping for?')));
}
if(!get_option('qlcd_wp_chatbot_product_suggest')) {
update_option('qlcd_wp_chatbot_product_suggest', maybe_serialize(array('You can browse our extensive catalog. Just pick a category from below:')));
}
if(!get_option('qlcd_wp_chatbot_product_infinite')) {
update_option('qlcd_wp_chatbot_product_infinite', maybe_serialize(array('Too many choices? Let\'s try another search term', 'I may have something else for you. Why not search again?')));
}
if(!get_option('qlcd_wp_chatbot_load_more')) {
update_option('qlcd_wp_chatbot_load_more', maybe_serialize(array('Load More')));
}
if(!get_option('qlcd_wp_chatbot_wildcard_order')) {
update_option('qlcd_wp_chatbot_wildcard_order', maybe_serialize(array('Order Status')));
}
if(!get_option('qlcd_wp_chatbot_order_welcome')) {
update_option('qlcd_wp_chatbot_order_welcome', maybe_serialize(array('Welcome to Order status section!')));
}
if(!get_option('qlcd_wp_chatbot_order_username_asking')) {
update_option('qlcd_wp_chatbot_order_username_asking', maybe_serialize(array('Please type your username?')));
}
if(!get_option('qlcd_wp_chatbot_order_username_password')) {
update_option('qlcd_wp_chatbot_order_username_password', maybe_serialize(array('Please type your password')));
}
if(!get_option('qlcd_wp_chatbot_order_username_not_exist')) {
update_option('qlcd_wp_chatbot_order_username_not_exist', maybe_serialize(array('This username does not exist.')));
}
if(!get_option('qlcd_wp_chatbot_order_username_thanks')) {
update_option('qlcd_wp_chatbot_order_username_thanks', maybe_serialize(array('Thank you for the username')));
}
if(!get_option('qlcd_wp_chatbot_order_password_incorrect')) {
update_option('qlcd_wp_chatbot_order_password_incorrect', maybe_serialize(array('Sorry Password is not correct!')));
}
if(!get_option('qlcd_wp_chatbot_asking_email')) {
update_option('qlcd_wp_chatbot_asking_email', maybe_serialize(array('Please provide your email address')));
}
if(!get_option('qlcd_wp_chatbot_order_not_found')) {
update_option('qlcd_wp_chatbot_order_not_found', maybe_serialize(array('I did not find any order by you')));
}
if(!get_option('qlcd_wp_chatbot_order_found')) {
update_option('qlcd_wp_chatbot_order_found', maybe_serialize(array('I have found the following orders')));
}
if(!get_option('qlcd_wp_chatbot_order_email_support')) {
update_option('qlcd_wp_chatbot_order_email_support', maybe_serialize(array('Email our support center about your order.')));
}
if(!get_option('qlcd_wp_chatbot_support_welcome')) {
update_option('qlcd_wp_chatbot_support_welcome', maybe_serialize(array('Welcome to FAQ Section')));
}
if(!get_option('qlcd_wp_chatbot_support_email')) {
update_option('qlcd_wp_chatbot_support_email', 'Send us Email.');
}
if(!get_option('qlcd_wp_chatbot_asking_msg')) {
update_option('qlcd_wp_chatbot_asking_msg', maybe_serialize(array('Thank you for email address. Please write your message now.')));
}
if(!get_option('qlcd_wp_chatbot_no_result')) {
update_option('qlcd_wp_chatbot_no_result', maybe_serialize(array('Sorry, No result found!')));
}
if(!get_option('qlcd_wp_chatbot_invalid_email')) {
update_option('qlcd_wp_chatbot_invalid_email', maybe_serialize(array('Sorry, Email address is not valid! Please provide a valid email.')));
}
if(!get_option('qlcd_wp_chatbot_support_phone')) {
update_option('qlcd_wp_chatbot_support_phone', 'Leave your number. We will call you back!');
}
if(!get_option('qlcd_wp_chatbot_asking_phone')) {
update_option('qlcd_wp_chatbot_asking_phone', maybe_serialize(array('Please provide your Phone number')));
}
if(!get_option('qlcd_wp_chatbot_thank_for_phone')) {
update_option('qlcd_wp_chatbot_thank_for_phone', maybe_serialize(array('Thank you for Phone number')));
}
if(!get_option('qlcd_wp_chatbot_support_option_again')) {
update_option('qlcd_wp_chatbot_support_option_again', maybe_serialize(array('You may choose option from below.')));
}
if(!get_option('qlcd_wp_chatbot_admin_email')) {
update_option('qlcd_wp_chatbot_admin_email', $admin_email);
}
if(!get_option('qlcd_wp_chatbot_email_sub')) {
update_option('qlcd_wp_chatbot_email_sub', sanitize_text_field('WPBot Support Mail'));
}
if(!get_option('qlcd_wp_site_search')) {
update_option('qlcd_wp_site_search', sanitize_text_field('Site Search'));
}
if(!get_option('qlcd_wp_chatbot_email_sent')) {
update_option('qlcd_wp_chatbot_email_sent', sanitize_text_field('Your email was sent successfully.Thanks!'));
}
if(!get_option('qlcd_wp_chatbot_email_fail')) {
update_option('qlcd_wp_chatbot_email_fail', sanitize_text_field('Sorry! I could not send your mail! Please contact the webmaster.'));
}
if(!get_option('qlcd_wp_chatbot_relevant_post_link_openai')) {
update_option('qlcd_wp_chatbot_relevant_post_link_openai', sanitize_text_field('Check the relevant pages for more details and up to date information:'));
}
if(!get_option('qlcd_wp_chatbot_notification_interval')) {
update_option('qlcd_wp_chatbot_notification_interval', sanitize_text_field(5));
}
if(!get_option('qlcd_wp_chatbot_notifications')) {
update_option('qlcd_wp_chatbot_notifications', maybe_serialize(array('Welcome to WPBot')));
}
if(!get_option('support_query')) {
update_option('support_query', maybe_serialize(array('Sample Question?')));
}
if(!get_option('support_ans')) {
update_option('support_ans', maybe_serialize(array('Sample Answer')));
}
if(!get_option('qlcd_wp_chatbot_search_option')) {
update_option('qlcd_wp_chatbot_search_option', 'standard');
}
if(!get_option('wp_chatbot_index_count')) {
update_option('wp_chatbot_index_count', 0);
}
if(!get_option('wp_chatbot_app_pages')) {
update_option('wp_chatbot_app_pages', 0);
}
//messenger options.
if(!get_option('enable_wp_chatbot_messenger')) {
update_option('enable_wp_chatbot_messenger', '');
}
if(!get_option('enable_wp_chatbot_messenger_floating_icon')) {
update_option('enable_wp_chatbot_messenger_floating_icon', '');
}
if(!get_option('qlcd_wp_chatbot_fb_app_id')) {
update_option('qlcd_wp_chatbot_fb_app_id', '');
}
if(!get_option('qlcd_wp_chatbot_fb_page_id')) {
update_option('qlcd_wp_chatbot_fb_page_id', '');
}
if(!get_option('qlcd_wp_chatbot_fb_color')) {
update_option('qlcd_wp_chatbot_fb_color', '#0084ff');
}
if(!get_option('qlcd_wp_chatbot_fb_in_msg')) {
update_option('qlcd_wp_chatbot_fb_in_msg', 'Welcome to WPBot!');
}
if(!get_option('qlcd_wp_chatbot_fb_out_msg')) {
update_option('qlcd_wp_chatbot_fb_out_msg', 'You are not logged in');
}
//Skype option
if(!get_option('enable_wp_chatbot_skype_floating_icon')) {
update_option('enable_wp_chatbot_skype_floating_icon', '');
}
if(!get_option('enable_wp_chatbot_skype_id')) {
update_option('enable_wp_chatbot_skype_id', '');
}
//Whats App
if(!get_option('enable_wp_chatbot_whats')) {
update_option('enable_wp_chatbot_whats', '');
}
if(!get_option('qlcd_wp_chatbot_whats_label')) {
update_option('qlcd_wp_chatbot_whats_label', maybe_serialize(array('Chat with Us on WhatsApp')));
}
if(!get_option('enable_wp_chatbot_floating_whats')) {
update_option('enable_wp_chatbot_floating_whats', '');
}
if(!get_option('qlcd_wp_chatbot_whats_num')) {
update_option('qlcd_wp_chatbot_whats_num', '');
}
//Viber
if(!get_option('enable_wp_chatbot_floating_viber')) {
update_option('enable_wp_chatbot_floating_viber', '');
}
if(!get_option('qlcd_wp_chatbot_viber_acc')) {
update_option('qlcd_wp_chatbot_viber_acc', '');
}
//Integration others
if(!get_option('enable_wp_chatbot_floating_phone')) {
update_option('enable_wp_chatbot_floating_phone', '');
}
if(!get_option('qlcd_wp_chatbot_phone')) {
update_option('qlcd_wp_chatbot_phone', '');
}
if(!get_option('enable_wp_chatbot_floating_link')) {
update_option('enable_wp_chatbot_floating_link', '');
}
if(!get_option('qlcd_wp_chatbot_weblink')) {
update_option('qlcd_wp_chatbot_weblink', '');
}
//Re-Tagetting
if(!get_option('qlcd_wp_chatbot_ret_greet')) {
update_option('qlcd_wp_chatbot_ret_greet', 'Hello');
}
if(!get_option('enable_wp_chatbot_exit_intent')) {
update_option('enable_wp_chatbot_exit_intent', '');
}
if(!get_option('wp_chatbot_exit_intent_msg')) {
update_option('wp_chatbot_exit_intent_msg', 'WAIT, WE HAVE A SPECIAL OFFER FOR YOU! Get Your 50% Discount Now. Use Coupon Code QC50 during checkout.');
}
if(!get_option('wp_chatbot_exit_intent_once')) {
update_option('wp_chatbot_exit_intent_once', '');
}
if(!get_option('enable_wp_chatbot_scroll_open')) {
update_option('enable_wp_chatbot_scroll_open', '');
}
if(!get_option('wp_chatbot_scroll_open_msg')) {
update_option('wp_chatbot_scroll_open_msg', 'WE HAVE A VERY SPECIAL OFFER FOR YOU! Get Your 50% Discount Now. Use Coupon Code QC50 during checkout.');
}
if(!get_option('wp_chatbot_scroll_percent')) {
update_option('wp_chatbot_scroll_percent', 50);
}
if(!get_option('wp_chatbot_scroll_once')) {
update_option('wp_chatbot_scroll_once', '');
}
if(!get_option('enable_wp_chatbot_auto_open')) {
update_option('enable_wp_chatbot_auto_open', '');
}
if(!get_option('enable_wp_chatbot_ret_sound')) {
update_option('enable_wp_chatbot_ret_sound', '');
}
if(!get_option('enable_wp_chatbot_sound_initial')) {
update_option('enable_wp_chatbot_sound_initial', '');
}
if(!get_option('wp_chatbot_auto_open_msg')) {
update_option('wp_chatbot_auto_open_msg', 'A SPECIAL OFFER FOR YOU! Get Your 50% Discount Now. Use Coupon Code QC50 during checkout.');
}
if(!get_option('wp_chatbot_auto_open_time')) {
update_option('wp_chatbot_auto_open_time', 10);
}
if(!get_option('wp_chatbot_auto_open_once')) {
update_option('wp_chatbot_auto_open_once', '');
}
if(!get_option('wp_chatbot_inactive_once')) {
update_option('wp_chatbot_inactive_once', '');
}
//To complete checkout.
if(!get_option('enable_wp_chatbot_ret_user_show')) {
update_option('enable_wp_chatbot_ret_user_show', '');
}
if(!get_option('wp_chatbot_auto_open_msg')) {
update_option('wp_chatbot_checkout_msg', 'You have products in shopping cart, please complete your order.');
}
if(!get_option('wp_chatbot_inactive_time')) {
update_option('wp_chatbot_inactive_time', 300);
}
if(!get_option('enable_wp_chatbot_inactive_time_show')) {
update_option('enable_wp_chatbot_inactive_time_show', '');
}
if(!get_option('wp_chatbot_proactive_bg_color')) {
update_option('wp_chatbot_proactive_bg_color', '#ffffff');
}
if(!get_option('disable_wp_chatbot_feedback')) {
update_option('disable_wp_chatbot_feedback','');
}
if(!get_option('disable_wp_chatbot_faq')) {
update_option('disable_wp_chatbot_faq','');
}
if(!get_option('qlcd_wp_chatbot_feedback_label')) {
update_option('qlcd_wp_chatbot_feedback_label',maybe_serialize(array('Send Feedback')));
}
if(!get_option('enable_wp_chatbot_meta_title')) {
update_option('enable_wp_chatbot_meta_title','');
}
if(!get_option('qlcd_wp_chatbot_meta_label')) {
update_option('qlcd_wp_chatbot_meta_label','*New Messages');
}
if(!get_option('disable_wp_chatbot_call_gen')) {
update_option('disable_wp_chatbot_call_gen', '');
}
if(!get_option('disable_wp_chatbot_site_search')) {
update_option('disable_wp_chatbot_site_search', '');
}
if(!get_option('disable_wp_chatbot_call_sup')) {
update_option('disable_wp_chatbot_call_sup', '');
}
if(!get_option('qlcd_wp_chatbot_phone_sent')) {
update_option('qlcd_wp_chatbot_phone_sent', 'Thanks for your phone number. We will call you ASAP!');
}
if(!get_option('qlcd_wp_chatbot_phone_fail')) {
update_option('qlcd_wp_chatbot_phone_fail', 'Sorry! I could not collect your phone number!');
}
if(!get_option('qlcd_wp_chatbot_asking_search_keyword')){
update_option('qlcd_wp_chatbot_asking_search_keyword', 'Please enter your keyword for searching');
}
if(!get_option('qlcd_wp_chatbot_found_result')){
update_option('qlcd_wp_chatbot_found_result', 'We have found these results');
}
if(!get_option('enable_wp_chatbot_opening_hour')) {
update_option('enable_wp_chatbot_opening_hour', '');
}
if(!get_option('enable_wp_chatbot_opening_hour')) {
update_option('wpwbot_hours', array());
}
wpbot_free_set_content_height_defaults();
if(!get_option('enable_wp_chatbot_dailogflow')) {
update_option('enable_wp_chatbot_dailogflow', '');
}
if(!get_option('qlcd_wp_chatbot_dialogflow_client_token')) {
update_option('qlcd_wp_chatbot_dialogflow_client_token', '');
}
if(!get_option('qlcd_wp_chatbot_dialogflow_defualt_reply')) {
update_option('qlcd_wp_chatbot_dialogflow_defualt_reply', 'Sorry, I did not understand you. You may browse');
}
if(!get_option('openai_max_tokens')) {
update_option('openai_max_tokens', '200');
}
if(!get_option('qcld_openai_suffix')) {
update_option('qcld_openai_suffix', 'qcld');
}
if(!get_option('qlcd_wp_chatbot_dialogflow_agent_language')) {
update_option('qlcd_wp_chatbot_dialogflow_agent_language', 'en');
}
if(!get_option('enable_wp_chatbot_post_content')) {
update_option('enable_wp_chatbot_post_content', '1');
}
if(!get_option('openai_engines')) {
update_option('openai_engines', 'gpt-4o');
}
// if(!get_option('skip_wp_greetings')) {
update_option('skip_wp_greetings', '');
//}
set_transient( 'qcld_bot_clear_cache', 1, DAY_IN_SECONDS );
}
}
/*
* Reset Options will be insert as defualt data
*/
add_action('wp_ajax_qcld_wb_chatboot_delete_all_options', 'qcld_wb_chatboot_delete_all_options');
//add_action('wp_ajax_nopriv_qcld_wb_chatboot_delete_all_options', 'qcld_wb_chatboot_delete_all_options');
add_action('wp_ajax_qcld_save_ai_form', 'qcld_save_ai_form');
add_action('wp_ajax_nopriv_qcld_save_ai_form', 'qcld_save_ai_form');
function qcld_save_ai_form() {
check_ajax_referer('wp_chatbot', 'nonce');
if (isset($_POST['data'])) {
$data_string = stripslashes($_POST['data']);
$json_data = json_decode($data_string, true);
if ($json_data && isset($json_data['form_title'])) {
$post_title = sanitize_text_field($json_data['form_title']) . ' - ' . current_time('mysql');
$post_id = wp_insert_post(array(
'post_title' => $post_title,
'post_type' => 'wpbot_form_entry',
'post_status' => 'publish'
));
if ($post_id && isset($json_data['data']) && is_array($json_data['data'])) {
$email_body = "" . esc_html__('New AI Action Submission', 'chatbot') . " ";
$email_body .= "" . esc_html__('Action', 'chatbot') . ": " . sanitize_text_field($json_data['form_title']) . "
";
$email_body .= "";
// Extract user's email for Reply-To (not From, to avoid SMTP rejection)
$reply_to = '';
foreach ($json_data['data'] as $key => $value) {
update_post_meta($post_id, sanitize_text_field($key), sanitize_text_field($value));
$clean_key = ucwords(str_replace(array('-', '_'), ' ', sanitize_text_field($key)));
$email_body .= "" . esc_html($clean_key) . " " . esc_html(sanitize_text_field($value)) . " ";
// Extract email from value — handles plain, [bracketed], and combined answers
if (preg_match('/\[?([a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,})\]?/', $value, $email_match)) {
$candidate = sanitize_email(trim($email_match[1]));
if (is_email($candidate)) {
$reply_to = $candidate;
}
}
}
$email_body .= "
";
$email_enabled = true; // Default to true if not found for backwards compatibility
$per_action_emails = '';
$saved_forms = get_option('wpbot_ai_forms', array());
$ai_form_title = strtolower( trim( sanitize_text_field( $json_data['form_title'] ) ) );
if (is_array($saved_forms)) {
foreach ($saved_forms as $form) {
if ( strtolower( trim( $form['title'] ) ) === $ai_form_title ) {
if (isset($form['email'])) {
$email_enabled = $form['email'] == 1;
}
$per_action_emails = isset($form['email_addresses']) ? trim($form['email_addresses']) : '';
break;
}
}
}
if ($email_enabled) {
if (!empty($per_action_emails)) {
$to = array_map('trim', explode(',', $per_action_emails));
} else {
$default = get_option('qlcd_wp_chatbot_admin_email', '');
$to = !empty($default) ? array_map('trim', explode(',', $default)) : get_option('admin_email');
}
$subject = sanitize_text_field($json_data['form_title']) . " - " . esc_html__('New AI Action Submission', 'chatbot');
$headers = array('Content-Type: text/html; charset=UTF-8');
if (!empty($reply_to)) {
$headers[] = 'Reply-To: ' . $reply_to;
}
wp_mail($to, $subject, $email_body, $headers);
}
wp_send_json_success('Saved successfully');
}
}
}
wp_send_json_error('Failed to save');
}
add_action('wp_ajax_qcld_get_ai_form_entries', 'qcld_get_ai_form_entries');
function qcld_get_ai_form_entries() {
check_ajax_referer('wp_chatbot_ai_actions', 'nonce');
if (!current_user_can('manage_options')) {
wp_send_json_error('Unauthorized');
}
$form_title = isset($_POST['form_title']) ? sanitize_text_field($_POST['form_title']) : '';
if (empty($form_title)) {
wp_send_json_error('No title provided');
}
global $wpdb;
$post_ids = $wpdb->get_col( $wpdb->prepare(
"SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpbot_form_entry' AND post_status = 'publish' AND post_title LIKE %s",
$wpdb->esc_like( $form_title . ' - ' ) . '%'
) );
if ( empty($post_ids) ) {
$post_ids = array(0);
}
$args = array(
'post_type' => 'wpbot_form_entry',
'post_status' => 'publish',
'posts_per_page' => -1,
'post__in' => $post_ids
);
$query = new WP_Query($args);
ob_start();
if ($query->have_posts()) {
echo '';
echo 'Entry Data Date Action ';
echo '';
while ($query->have_posts()) {
$query->the_post();
$meta = get_post_meta(get_the_ID());
echo '';
echo '' . get_the_title() . ' ';
echo '';
foreach ($meta as $key => $values) {
if (strpos($key, '_') !== 0) { // skip hidden meta
echo '' . esc_html($key) . ': ' . esc_html($values[0]) . ' ';
}
}
echo ' ';
echo '' . get_the_date() . ' ' . get_the_time() . ' ';
echo 'Delete ';
echo ' ';
}
echo '
';
wp_reset_postdata();
} else {
echo 'No entries found for this form.
';
}
$html = ob_get_clean();
wp_send_json_success(array('html' => $html));
}
add_action('wp_ajax_qcld_delete_ai_form_entry', 'qcld_delete_ai_form_entry');
function qcld_delete_ai_form_entry() {
check_ajax_referer('wp_chatbot_ai_actions', 'nonce');
if (!current_user_can('manage_options')) {
wp_send_json_error('Unauthorized');
}
$entry_id = isset($_POST['entry_id']) ? intval($_POST['entry_id']) : 0;
if (empty($entry_id)) {
wp_send_json_error('No entry ID provided');
}
if (get_post_type($entry_id) === 'wpbot_form_entry') {
wp_delete_post($entry_id, true);
wp_send_json_success('Entry deleted successfully');
} else {
wp_send_json_error('Invalid entry');
}
}
//Jarvis all option will be delete during uninstlling.
if( !function_exists('qcld_wb_chatboot_delete_all_options') ){
function qcld_wb_chatboot_delete_all_options(){
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( 'Unauthorized access' );
}
if ( ! isset( $_POST['wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['wpnonce'] ) ), 'wp_chatbot' ) ) {
wp_die( 'No cheating' );
}
delete_option('disable_wp_chatbot');
delete_option('disable_wp_chatbot_icon_animation');
delete_option('disable_wp_chatbot_on_mobile');
delete_option('qlcd_wp_chatbot_admin_email');
delete_option('qlcd_wp_chatbot_from_email');
delete_option('disable_back_to_start_menu');
delete_option('disable_floating_button');
delete_option('disable_wp_chatbot_product_search');
delete_option('disable_wp_chatbot_catalog');
delete_option('disable_wp_chatbot_order_status');
delete_option('disable_wp_chatbot_notification');
delete_option('enable_wp_chatbot_rtl');
delete_option('show_menu_after_greetings');
delete_option('enable_chat_session');
delete_option('enable_wp_chatbot_mobile_full_screen');
delete_option('wpbot_preloading_time');
delete_option('disable_wp_chatbot_cart_item_number');
delete_option('disable_wp_chatbot_featured_product');
delete_option('disable_wp_chatbot_sale_product');
delete_option('wp_chatbot_open_product_detail');
delete_option('qlcd_wp_chatbot_product_orderby');
delete_option('qlcd_wp_chatbot_product_order');
delete_option('qlcd_wp_chatbot_ppp');
delete_option('wp_chatbot_show_parent_category');
delete_option('wp_chatbot_show_sub_category');
delete_option('wp_chatbot_exclude_stock_out_product');
delete_option('wp_chatbot_show_home_page');
delete_option('qc_wpbot_menu_order');
delete_option('wp_chatbot_show_posts');
delete_option('wp_chatbot_show_pages');
delete_option('wp_chatbot_show_pages_list');
delete_option('wp_chatbot_exclude_post_list');
delete_option('wp_chatbot_show_wpcommerce');
delete_option('qlcd_wp_chatbot_stop_words_name');
delete_option('qlcd_wp_chatbot_stop_words');
delete_option('qlcd_wp_chatbot_order_user');
delete_option('wp_chatbot_icon');
delete_option('wp_chatbot_floatingiconbg_color');
delete_option('wp_chatbot_agent_image');
delete_option('qcld_wb_chatbot_theme');
delete_option('qcld_wb_chatbot_change_bg');
delete_option('wp_chatbot_custom_css');
delete_option('qlcd_wp_chatbot_host');
delete_option('qlcd_wp_chatbot_agent');
delete_option('qlcd_wp_chatbot_yes');
delete_option('qlcd_wp_chatbot_no');
delete_option('qlcd_wp_chatbot_or');
delete_option('qlcd_wp_chatbot_sorry');
delete_option('qlcd_wp_chatbot_agent_join');
delete_option('qlcd_wp_chatbot_welcome');
delete_option('qlcd_wp_chatbot_back_to_start');
delete_option('qlcd_wp_chatbot_hi_there');
delete_option('qlcd_wp_chatbot_hello');
delete_option('qlcd_wp_chatbot_welcome_back');
delete_option('qlcd_wp_chatbot_asking_name');
delete_option('qlcd_wp_chatbot_name_greeting');
delete_option('qlcd_wp_chatbot_i_am');
delete_option('qlcd_wp_chatbot_wildcard_msg');
delete_option('qlcd_wp_chatbot_empty_filter_msg');
delete_option('qlcd_wp_chatbot_did_you_mean');
delete_option('qlcd_wp_chatbot_wildcard_product');
delete_option('qlcd_wp_chatbot_wildcard_catalog');
delete_option('qlcd_wp_chatbot_featured_products');
delete_option('qlcd_wp_chatbot_sale_products');
delete_option('qlcd_wp_chatbot_wildcard_support');
delete_option('qlcd_wp_chatbot_wildcard_site_search');
delete_option('qlcd_wp_chatbot_messenger_label');
delete_option('qlcd_wp_chatbot_product_success');
delete_option('qlcd_wp_chatbot_product_fail');
delete_option('qlcd_wp_chatbot_product_asking');
delete_option('qlcd_wp_chatbot_product_suggest');
delete_option('qlcd_wp_chatbot_product_infinite');
delete_option('qlcd_wp_chatbot_load_more');
delete_option('qlcd_wp_chatbot_wildcard_order');
delete_option('qlcd_wp_chatbot_order_welcome');
delete_option('qlcd_wp_chatbot_order_username_asking');
delete_option('qlcd_wp_chatbot_order_username_password');
delete_option('qlcd_wp_chatbot_support_welcome');
delete_option('qlcd_wp_chatbot_support_email');
delete_option('qlcd_wp_chatbot_asking_email');
delete_option('qlcd_wp_chatbot_asking_msg');
delete_option('qlcd_wp_chatbot_no_result');
delete_option('qlcd_wp_chatbot_admin_email');
delete_option('open_links_new_window');
delete_option('qlcd_wp_chatbot_email_sub');
delete_option('qlcd_wp_site_search');
delete_option('qlcd_wp_chatbot_email_sent');
delete_option('qlcd_wp_chatbot_support_phone');
delete_option('qlcd_wp_chatbot_asking_phone');
delete_option('qlcd_wp_chatbot_thank_for_phone');
delete_option('qlcd_wp_chatbot_sys_key_help');
delete_option('qlcd_wp_chatbot_sys_key_product');
delete_option('qlcd_wp_chatbot_sys_key_catalog');
delete_option('qlcd_wp_chatbot_sys_key_order');
delete_option('qlcd_wp_chatbot_sys_key_support');
delete_option('qlcd_wp_chatbot_sys_key_reset');
delete_option('qlcd_wp_chatbot_sys_key_email');
delete_option('qlcd_wp_chatbot_order_username_not_exist');
delete_option('qlcd_wp_chatbot_order_username_thanks');
delete_option('qlcd_wp_chatbot_order_password_incorrect');
delete_option('qlcd_wp_chatbot_order_not_found');
delete_option('qlcd_wp_chatbot_order_found');
delete_option('qlcd_wp_chatbot_order_email_support');
delete_option('qlcd_wp_chatbot_support_option_again');
delete_option('qlcd_wp_chatbot_invalid_email');
delete_option('qlcd_wp_chatbot_shopping_cart');
delete_option('qlcd_wp_chatbot_add_to_cart');
delete_option('qlcd_wp_chatbot_cart_link');
delete_option('qlcd_wp_chatbot_checkout_link');
delete_option('qlcd_wp_chatbot_cart_welcome');
delete_option('qlcd_wp_chatbot_featured_product_welcome');
delete_option('qlcd_wp_chatbot_viewed_product_welcome');
delete_option('qlcd_wp_chatbot_latest_product_welcome');
delete_option('qlcd_wp_chatbot_cart_title');
delete_option('qlcd_wp_chatbot_cart_quantity');
delete_option('qlcd_wp_chatbot_cart_price');
delete_option('qlcd_wp_chatbot_no_cart_items');
delete_option('qlcd_wp_chatbot_cart_updating');
delete_option('qlcd_wp_chatbot_cart_removing');
delete_option('qlcd_wp_chatbot_email_fail');
delete_option('qlcd_wp_chatbot_relevant_post_link_openai');
delete_option('support_query');
delete_option('support_ans');
delete_option('qlcd_wp_chatbot_notification_interval');
delete_option('qlcd_wp_chatbot_notifications');
delete_option( 'qlcd_wp_chatbot_search_option');
delete_option( 'wp_chatbot_index_count');
delete_option( 'wp_chatbot_app_pages');
//messenger option
delete_option( 'enable_wp_chatbot_messenger');
delete_option( 'enable_wp_chatbot_messenger_floating_icon');
delete_option( 'qlcd_wp_chatbot_fb_app_id');
delete_option( 'qlcd_wp_chatbot_fb_page_id');
delete_option( 'qlcd_wp_chatbot_fb_color');
delete_option( 'qlcd_wp_chatbot_fb_in_msg');
delete_option( 'qlcd_wp_chatbot_fb_out_msg');
//skype option
delete_option( 'enable_wp_chatbot_skype_floating_icon');
delete_option( 'enable_wp_chatbot_skype_id');
//whats app
delete_option( 'enable_wp_chatbot_whats');
delete_option( 'qlcd_wp_chatbot_whats_label');
delete_option( 'enable_wp_chatbot_floating_whats');
delete_option( 'qlcd_wp_chatbot_whats_num');
// Viber
delete_option( 'enable_wp_chatbot_floating_viber');
delete_option( 'qlcd_wp_chatbot_viber_acc');
//Integration others
delete_option( 'enable_wp_chatbot_floating_phone');
delete_option( 'qlcd_wp_chatbot_phone');
delete_option( 'enable_wp_chatbot_floating_link');
delete_option( 'qlcd_wp_chatbot_weblink');
//Re Targetting
delete_option( 'qlcd_wp_chatbot_ret_greet');
delete_option( 'enable_wp_chatbot_exit_intent');
delete_option( 'wp_chatbot_exit_intent_msg');
delete_option( 'wp_chatbot_exit_intent_once');
delete_option( 'enable_wp_chatbot_scroll_open');
delete_option( 'wp_chatbot_scroll_open_msg');
delete_option( 'wp_chatbot_scroll_percent');
delete_option( 'wp_chatbot_scroll_once');
delete_option( 'enable_wp_chatbot_auto_open');
delete_option( 'enable_wp_chatbot_ret_sound');
delete_option( 'enable_wp_chatbot_sound_initial');
delete_option( 'disable_wp_chatbot_feedback');
delete_option( 'disable_wp_chatbot_faq');
delete_option( 'qlcd_wp_chatbot_feedback_label');
delete_option( 'enable_wp_chatbot_meta_title');
delete_option( 'qlcd_wp_chatbot_meta_label');
delete_option( 'wp_chatbot_auto_open_msg');
delete_option( 'wp_chatbot_auto_open_time');
delete_option( 'wp_chatbot_auto_open_once');
delete_option( 'wp_chatbot_inactive_once');
delete_option( 'wp_chatbot_proactive_bg_color');
delete_option( 'qlcd_wp_chatbot_phone_sent');
delete_option( 'qlcd_wp_chatbot_phone_fail');
delete_option('qlcd_wp_chatbot_asking_search_keyword');
delete_option('qlcd_wp_chatbot_found_result');
delete_option( 'disable_wp_chatbot_call_gen');
delete_option( 'disable_wp_chatbot_site_search');
delete_option( 'enable_wp_chatbot_post_content');
delete_option( 'disable_wp_chatbot_call_sup');
delete_option( 'enable_wp_chatbot_ret_user_show');
delete_option( 'enable_wp_chatbot_inactive_time_show');
delete_option( 'wp_chatbot_inactive_time');
delete_option( 'wp_chatbot_checkout_msg');
delete_option( 'qlcd_wp_chatbot_shopper_demo_name');
delete_option( 'qlcd_wp_chatbot_is_typing');
delete_option( 'qlcd_wp_chatbot_send_a_msg');
delete_option( 'qlcd_wp_chatbot_choose_option');
delete_option( 'qlcd_wp_chatbot_viewed_products');
delete_option( 'qlcd_wp_chatbot_help_welcome');
delete_option( 'qlcd_wp_chatbot_help_msg');
delete_option( 'qlcd_wp_chatbot_reset');
delete_option( 'enable_wp_chatbot_opening_hour');
delete_option( 'wpwbot_hours');
delete_option( 'enable_wp_chatbot_dailogflow');
delete_option( 'qlcd_wp_chatbot_dialogflow_client_token');
delete_option( 'qlcd_wp_chatbot_dialogflow_defualt_reply');
delete_option( 'qlcd_wp_chatbot_dialogflow_agent_language');
delete_option( 'qlcd_wp_chatbot_dialogflow_project_id');
delete_option( 'wp_chatbot_df_api');
delete_option( 'qlcd_wp_chatbot_dialogflow_project_key');
delete_option( 'wp_chatbot_bot_msg_bg_color');
delete_option( 'wp_chatbot_bot_msg_text_color');
delete_option( 'wp_chatbot_user_msg_bg_color');
delete_option( 'wp_chatbot_user_msg_text_color');
delete_option( 'wp_chatbot_buttons_bg_color');
delete_option( 'wp_chatbot_buttons_text_color');
delete_option( 'wp_chatbot_buttons_bg_color_hover');
delete_option( 'wp_chatbot_buttons_text_color_hover');
delete_option( 'wp_chatbot_theme_secondary_color');
delete_option( 'wp_chatbot_theme_primary_color');
delete_option( 'wp_chatbot_header_background_color');
delete_option('wp_chatbot_font_size');
delete_option('wp_chat_user_font_family');
delete_option('wp_chat_bot_font_family');
delete_option('wp_chatbot_bot_font');
delete_option('wp_chatbot_user_font');
delete_option('qcld_chatbot_avatar_location');
set_transient( 'qcld_bot_clear_cache', 1, DAY_IN_SECONDS );
qcld_wb_chatboot_defualt_options();
$html='Reset all options to default successfully.';
wp_send_json($html);
}
}
if( !function_exists('wpbot_free_set_content_height_defaults') ){
function wpbot_free_set_content_height_defaults() {
$chatbot_content_max_height = get_option( 'chatbot_content_max_height', false );
if ( $chatbot_content_max_height === false || $chatbot_content_max_height === '' ) {
update_option( 'chatbot_content_max_height', '80' );
}
$chatbot_content_max_height_responsive = get_option( 'chatbot_content_max_height_responsive', false );
if ( $chatbot_content_max_height_responsive === false || $chatbot_content_max_height_responsive === '' ) {
update_option( 'chatbot_content_max_height_responsive', '90' );
}
}
}
if( !function_exists('wpbot_free_qc_upgrade_completed') ){
function wpbot_free_qc_upgrade_completed( $upgrader_object, $options ) {
// The path to our plugin's main file
$our_plugin = plugin_basename( __FILE__ );
// If an update has taken place and the updated type is plugins and the plugins element exists
if( $options['action'] == 'update' && $options['type'] == 'plugin' && isset( $options['plugins'] ) ) {
// Iterate through the plugins being updated and check if ours is there
foreach( $options['plugins'] as $plugin ) {
if( $plugin == $our_plugin ) {
set_transient( 'qcld_bot_clear_cache', 1, DAY_IN_SECONDS );
wpbot_free_set_content_height_defaults();
}
}
}
update_option( 'qcld_openai_relevant_post', ['post','page'] );
}
}
add_action( 'upgrader_process_complete', 'wpbot_free_qc_upgrade_completed', 10, 2 );
/**
*
* Open Ai integration
*
*/
if( !function_exists('wpbot_openAi_setting_func') ){
function wpbot_openAi_setting_func (){
require_once(QCLD_wpCHATBOT_PLUGIN_DIR_PATH."includes/admin/templates/ai-admin.php");
// require_once(QCLD_wpCHATBOT_PLUGIN_DIR_PATH."qcld-openai-bot.php");
}
}
if( !function_exists('wpbot_Ai_actions_func') ){
function wpbot_Ai_actions_func (){
require_once(QCLD_wpCHATBOT_PLUGIN_DIR_PATH."includes/admin/templates/ai-actions.php");
// require_once(QCLD_wpCHATBOT_PLUGIN_DIR_PATH."qcld-openai-bot.php");
}
}
/**
*
* Function to load translation files.
*
*/
if( !function_exists('wp_chatbot_lang_init') ){
function wp_chatbot_lang_init() {
load_plugin_textdomain( 'chatbot', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
}
add_action( 'plugins_loaded', 'wp_chatbot_lang_init');
$wpbot_feedback = new Qcld_Wp_Usage_Feedback(
__FILE__,
'plugins@quantumcloud.com',
false,
true
);
if( !function_exists('wpbot_help_page_callback_func') ){
function wpbot_help_page_callback_func(){
?>
has_cap( 'collation' ) ) {
if ( ! empty( $wpdb->charset ) ) {
$collate .= "DEFAULT CHARACTER SET $wpdb->charset";
}
if ( ! empty( $wpdb->collate ) ) {
$collate .= " COLLATE $wpdb->collate";
}
}
//Bot Response Table
$table1 = $wpdb->prefix.'wpbot_response';
$sql_sliders_Table1 = "
CREATE TABLE IF NOT EXISTS `$table1` (
`id` INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
`query` TEXT NOT NULL,
`keyword` TEXT NOT NULL,
`response` TEXT NOT NULL,
`category` varchar(256) NOT NULL,
`intent` varchar(256) NOT NULL,
`custom` varchar(256) NOT NULL,
`lang` varchar(25) NULL,
FULLTEXT(`query`, `keyword`, `response`)
) $collate AUTO_INCREMENT=1 ENGINE=InnoDB";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql_sliders_Table1 );
if(!get_option('qlcd_wp_chatbot_did_you_mean')) {
update_option('qlcd_wp_chatbot_did_you_mean', maybe_serialize(array('Did you mean?')));
}
if(!get_option('qlcd_wp_chatbot_did_you_mean')) {
update_option('qlcd_wp_chatbot_did_you_mean', maybe_serialize(array('Did you mean?')));
}
$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
if(empty($sqlqry)){
$query = 'Sample Question?';
$response = 'Sample Answer';
$data = array('query' => $query, 'keyword' => '', 'response'=> $response, 'intent'=> '');
$format = array('%s','%s', '%s', '%s');
$wpdb->insert($table1,$data,$format); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, PluginCheck.Security.DirectDB.UnescapedDBParameter
}
update_option('qc_wpb_simple_response_db_upgrade_free2', 'done');
}
if(!get_option('qc_wp_db_engine_update_free')){
$table1 = $wpdb->prefix.'wpbot_response';
// phpcs:ignore
$wpdb->query("ALTER TABLE $table1 ENGINE = InnoDB");
update_option('qc_wp_db_engine_update_free', 'done');
}
if(!get_option('qc_wp_db_engine_update_free_unassign')){
$table1 = $wpdb->prefix.'wpbot_response';
// phpcs:ignore
$wpdb->query("ALTER TABLE $table1 CHANGE `id` `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT;");
update_option('qc_wp_db_engine_update_free_unassign', 'done');
}
if(isset($_POST['qc_bot_str_query']) && $_POST['qc_bot_str_query']!='' && !class_exists('Qcld_str_pro')){
if ( ! isset( $_POST['str_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['str_nonce'] ) ), 'str-nonce' ) ) {
die( esc_html__( 'Security check failed', 'chatbot' ) );
}
$query = sanitize_text_field(wp_unslash($_POST['qc_bot_str_query']));
$keyword = sanitize_text_field(wp_unslash($_POST['qc_bot_str_keyword']));
$intent = sanitize_text_field(wp_unslash($_POST['qc_bot_str_intent']));
$category = '';
$response = wp_kses(wp_unslash($_POST['qc_bot_str_response']), 'post');
$table = $wpdb->prefix.'wpbot_response';
$data = array('query' => $query, 'keyword' => $keyword, 'response'=> $response, 'intent'=> $intent, 'category'=> $category);
$format = array('%s','%s', '%s', '%s', '%s');
if(isset($_POST['qc_bot_str_id']) && wp_unslash($_POST['qc_bot_str_id'])!=''){
$id = sanitize_text_field(wp_unslash($_POST['qc_bot_str_id']));
$where = array('id'=>$id);
$whereformat = array('%d');
$wpdb->update( $table, $data, $where, $format, $whereformat ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
}else{
$wpdb->insert($table,$data,$format); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
}
qcld_mysql_remove_existing_indexes();
// phpcs:ignore
$wpdb->query("ALTER TABLE $table ADD FULLTEXT(`query`, `keyword`, `response`)");
wp_safe_redirect(admin_url('admin.php?page=simple-text-response'));exit;
}
$table = $wpdb->prefix.'wpbot_response';
if(isset($_POST['qc-re-index'])){
qcld_mysql_remove_existing_indexes();
// phpcs:ignore
$wpdb->query("ALTER TABLE $table ADD FULLTEXT(`query`, `keyword`)");
add_action('admin_notices', 'general_admin_notice_str' );
}
if(isset($_POST['qc_bot_str_weight']) && wp_unslash($_POST['qc_bot_str_weight'])!=''){
$weight = sanitize_text_field(wp_unslash($_POST['qc_bot_str_weight']));
update_option('qc_bot_str_weight', $weight);
}
if(isset($_POST['qc_bot_str_remove_stopwords']) && wp_unslash($_POST['qc_bot_str_remove_stopwords'])!=''){
$stopwords = sanitize_text_field(wp_unslash($_POST['qc_bot_str_remove_stopwords']));
update_option('qc_bot_str_remove_stopwords', '1');
}
if ( isset($_POST['qc_bot_str_allow_author_editor']) && wp_unslash($_POST['qc_bot_str_allow_author_editor']) != '' ) {
$qc_bot_str_allow_author_editor = sanitize_text_field(wp_unslash($_POST['qc_bot_str_allow_author_editor']));
update_option( 'qc_bot_str_allow_author_editor', $qc_bot_str_allow_author_editor );
} else {
delete_option( 'qc_bot_str_allow_author_editor' );
}
if(isset($_POST['qc_bot_str_fields']) && !empty($_POST['qc_bot_str_fields'])){
$table = $wpdb->prefix.'wpbot_response';
$fields = rest_sanitize_array(wp_unslash($_POST['qc_bot_str_fields']));
$allowed_fields = array('query', 'keyword', 'response');
$valid_fields = array();
if(is_array($fields)){
foreach($fields as $field){
if(in_array($field, $allowed_fields)){
$valid_fields[] = $field;
}
}
}
$fields = $valid_fields;
update_option('qc_bot_str_fields', $fields);
qcld_mysql_remove_existing_indexes();
if($fields && !empty($fields)){
$safe_fields = array_map(function($f) { return '`' . $f . '`'; }, $fields);
// phpcs:ignore
$wpdb->query("ALTER TABLE $table ADD FULLTEXT(".implode(', ', $safe_fields).")");
}
}
if(!get_option('wpbot_preloading_time')) {
update_option('wpbot_preloading_time', '800');
}
}
}
}
}
if( !function_exists('general_admin_notice_str') ){
function general_admin_notice_str(){
if ( isset($_GET['page']) && $_GET['page'] == 'simple-text-response' ) {
echo '
Re-Indexing has been completed!
';
}
}
}
}
if( !function_exists('qcld_wpbot_simple_response_intent') ){
function qcld_wpbot_simple_response_intent(){
global $wpdb;
$table = $wpdb->prefix.'wpbot_response';
$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
$response = array();
if(!empty($results)){
foreach($results as $result){
$response[] = $result->intent;
}
}
return $response;
}
}
if( !function_exists('qcld_mysql_remove_existing_indexes') ){
function qcld_mysql_remove_existing_indexes(){
global $wpdb;
$table = $wpdb->prefix.'wpbot_response';
$results = $wpdb->get_results("SHOW INDEX FROM {$table}"); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter
$indexes = array();
foreach($results as $result){
if("PRIMARY" != $result->Key_name && !in_array($result->Key_name, $indexes)){
// phpcs:ignore
$wpdb->query("ALTER TABLE $table DROP INDEX `".$result->Key_name."`;");
$indexes[] = $result->Key_name;
}
}
}
}
add_action( 'activated_plugin', 'qc_wpbotfree_activation_redirect' );
if( !function_exists('qc_wpbotfree_activation_redirect') ){
function qc_wpbotfree_activation_redirect( $plugin ){
$screen = get_current_screen();
if( ( isset( $screen->base ) && $screen->base == 'plugins' ) && $plugin == plugin_basename( __FILE__ ) ) {
if( $plugin == plugin_basename( __FILE__ ) ) {
// phpcs:ignore
exit( wp_redirect( esc_url( admin_url('admin.php?page=wpbot') ) ) );
}
}
}
}