| @@ -14,9 +14,9 @@ | ||
| 14 | 14 | $wp_chatbot_custom_agent_path = QCLD_wpCHATBOT_IMG_URL . get_option('wp_chatbot_agent_image'); |
| 15 | 15 | } else { |
| 16 | 16 | $wp_chatbot_custom_agent_path = QCLD_wpCHATBOT_IMG_URL . 'custom-agent.png'; |
| 17 | 17 | } |
| 18 | - $hidden_field = '<a class="wp-chatbot qc_wpbot_chat_link" id="wp-chatbot-search-btn" data-search-type="product" data-search-term="" style="max-height: 50px; margin-left: 10px;padding: 0 !important;position: absolute;top: -9px;right: -60px;"><img src="'. esc_url($wp_chatbot_custom_agent_path) .'" alt=""></a>'; | |
| 18 | + $hidden_field = '<a class="wp-chatbot qc_wpbot_chat_link" id="wp-chatbot-search-btn" data-search-type="product" data-search-term="" style="max-height: 50px; margin-left: 10px;padding: 0 !important;position: absolute;top: -9px;right: -60px;"><img src="'. esc_attr($wp_chatbot_custom_agent_path) .'" alt=""></a>'; | |
| 19 | 19 | $block_content = str_replace( '</form>', $hidden_field . '</form>', $form ); |
| 20 | 20 | return $block_content; |
| 21 | 21 | } |
| 22 | 22 | if(get_option('wpbot_enable_on_search') == 1 && (get_option('disable_floating_button') != '1') && get_option('disable_wp_chatbot') != 1 ){ |
| @@ -33,9 +33,9 @@ | ||
| 33 | 33 | $wp_chatbot_custom_agent_path = QCLD_wpCHATBOT_IMG_URL . get_option('wp_chatbot_agent_image'); |
| 34 | 34 | } else { |
| 35 | 35 | $wp_chatbot_custom_agent_path = QCLD_wpCHATBOT_IMG_URL . 'custom-agent.png'; |
| 36 | 36 | } |
| 37 | - $hidden_field = '<button type="button" class="wp-chatbot qc_wpbot_chat_link" id="wp-chatbot-search-btn" data-search-type="product" data-search-term="" style="max-height: 50px; margin-left: 10px;padding: 0 !important"><img src="'. esc_url($wp_chatbot_custom_agent_path) .'" alt=""></button>'; | |
| 37 | + $hidden_field = '<button type="button" class="wp-chatbot qc_wpbot_chat_link" id="wp-chatbot-search-btn" data-search-type="product" data-search-term="" style="max-height: 50px; margin-left: 10px;padding: 0 !important"><img src="'. esc_attr($wp_chatbot_custom_agent_path) .'" alt=""></button>'; | |
| 38 | 38 | // Inject the hidden field before the closing </form> tag |
| 39 | 39 | $block_content = str_replace( '</div></form>', $hidden_field . '</div></form>', $block_content ); |
| 40 | 40 | return $block_content; |
| 41 | 41 | } |
| @@ -65,9 +65,9 @@ | ||
| 65 | 65 | ?> |
| 66 | 66 | <style> |
| 67 | 67 | <?php if(get_option('wp_chatbot_custom_css')!="") { |
| 68 | 68 | |
| 69 | - echo wp_strip_all_tags( get_option('wp_chatbot_custom_css') );// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 69 | + echo get_option('wp_chatbot_custom_css'); | |
| 70 | 70 | } |
| 71 | 71 | ?> |
| 72 | 72 | </style> |
| 73 | 73 | |
| @@ -155,9 +155,9 @@ | ||
| 155 | 155 | } |
| 156 | 156 | ?> |
| 157 | 157 | <div class="wp-chatbot-notification-agent-profile"> |
| 158 | 158 | <div class="wp-chatbot-notification-widget-avatar" ><img |
| 159 | - src="<?php echo esc_url($wp_chatbot_custom_agent_path); ?>" alt=""></div> | |
| 159 | + src="<?php echo esc_attr($wp_chatbot_custom_agent_path); ?>" alt=""></div> | |
| 160 | 160 | <div class="wp-chatbot-notification-welcome"><?php echo wp_kses_post(wpb_randmom_message_handle(maybe_unserialize(get_option('qlcd_wp_chatbot_welcome')))) . ' <strong>' . esc_html(get_option('qlcd_wp_chatbot_host')) . '</strong>'; ?></div> |
| 161 | 161 | </div> |
| 162 | 162 | <?php |
| 163 | 163 | //update_option('qlcd_wp_chatbot_notifications','Welcome to WpBot'); |
| @@ -313,10 +313,10 @@ | ||
| 313 | 313 | } |
| 314 | 314 | } |
| 315 | 315 | //Checking wpwbot opening hour |
| 316 | 316 | function wp_chatbot_check_opening_hours(){ |
| 317 | - $curent_day=strtolower(gmdate('l',strtotime(current_time( 'mysql' )))); | |
| 318 | - $current_time=gmdate('H:i',strtotime(current_time( 'mysql'))); | |
| 317 | + $curent_day=strtolower(date('l',strtotime(current_time( 'mysql' )))); | |
| 318 | + $current_time=date('H:i',strtotime(current_time( 'mysql'))); | |
| 319 | 319 | $is_wpwbot_open =false; |
| 320 | 320 | if(get_option('wpwbot_hours')) { |
| 321 | 321 | $wpwbot_times = wp_kses_post(unserialize(get_option('wpwbot_hours'))); |
| 322 | 322 | if (isset($wpwbot_times[$curent_day])) { |
| @@ -338,16 +338,9 @@ | ||
| 338 | 338 | */ |
| 339 | 339 | add_action('wp_ajax_qcld_wb_chatbot_keyword', 'qcld_wb_chatbot_keyword'); |
| 340 | 340 | add_action('wp_ajax_nopriv_qcld_wb_chatbot_keyword', 'qcld_wb_chatbot_keyword'); |
| 341 | 341 | function qcld_wb_chatbot_keyword(){ |
| 342 | - // Verify nonce for security | |
| 343 | - $nonce = isset($_POST['security']) ? sanitize_text_field(wp_unslash($_POST['security'])) : (isset($_POST['nonce']) ? sanitize_text_field(wp_unslash($_POST['nonce'])) : ''); | |
| 344 | - if ( ! wp_verify_nonce( $nonce, 'wp_chatbot' ) && ! wp_verify_nonce( $nonce, 'qcsecretbotnonceval123qc' ) ) { | |
| 345 | - wp_send_json_error( array( 'status' => 'fail', 'message' => 'Security check failed.' ) ); | |
| 346 | - wp_die(); | |
| 347 | - } | |
| 348 | - | |
| 349 | - $keyword = sanitize_text_field(wp_unslash($_POST['keyword'])); | |
| 342 | + $keyword = sanitize_text_field($_POST['keyword']); | |
| 350 | 343 | $product_per_page = get_option('qlcd_wp_chatbot_ppp') != '' ? get_option('qlcd_wp_chatbot_ppp') : 10; |
| 351 | 344 | if (get_option('qlcd_wp_chatbot_search_option') == 'standard') { |
| 352 | 345 | $product_orderby = sanitize_text_field(get_option('qlcd_wp_chatbot_product_orderby') != '' ? get_option('qlcd_wp_chatbot_product_orderby') : 'title'); |
| 353 | 346 | $product_order = sanitize_text_field(get_option('qlcd_wp_chatbot_product_order') != '' ? get_option('qlcd_wp_chatbot_product_order') : 'ASC'); |
| @@ -393,9 +386,9 @@ | ||
| 393 | 386 | endwhile; |
| 394 | 387 | wp_reset_postdata(); |
| 395 | 388 | $html .= '</ul>'; |
| 396 | 389 | if ($total_product_num > $product_per_page && $product_per_page > 0 ) { |
| 397 | - $html .= '<p style="text-align: center"><button type="button" id="wp-chatbot-loadmore" data-offset="' . $product_per_page . '" data-search-type="product" data-search-term="' . esc_attr($keyword) . '" >' . wp_kses_post(wpb_randmom_message_handle(unserialize(get_option('qlcd_wp_chatbot_load_more')))) . ' <span id="wp-chatbot-loadmore-loader"></span></button> </p>'; | |
| 390 | + $html .= '<p style="text-align: center"><button type="button" id="wp-chatbot-loadmore" data-offset="' . $product_per_page . '" data-search-type="product" data-search-term="' . $keyword . '" >' . wp_kses_post(wpb_randmom_message_handle(unserialize(get_option('qlcd_wp_chatbot_load_more')))) . ' <span id="wp-chatbot-loadmore-loader"></span></button> </p>'; | |
| 398 | 391 | } |
| 399 | 392 | } |
| 400 | 393 | $html .= '</div>'; |
| 401 | 394 | } else if (get_option('qlcd_wp_chatbot_search_option') == 'advanced') { |
| @@ -423,9 +416,9 @@ | ||
| 423 | 416 | } |
| 424 | 417 | } |
| 425 | 418 | $html .= '</ul>'; |
| 426 | 419 | if ($total_product_num > $product_per_page && $product_per_page > 0) { |
| 427 | - $html .= '<p style="text-align: center"><button type="button" id="wp-chatbot-loadmore" data-offset="' . $product_per_page . '" data-search-type="product" data-search-term="' . esc_attr($more_product_ids) . '" >' . wp_kses_post(wpb_randmom_message_handle(unserialize(get_option('qlcd_wp_chatbot_load_more')))) . ' <span id="wp-chatbot-loadmore-loader"></span></button> </p>'; | |
| 420 | + $html .= '<p style="text-align: center"><button type="button" id="wp-chatbot-loadmore" data-offset="' . $product_per_page . '" data-search-type="product" data-search-term="' . $more_product_ids . '" >' . wp_kses_post(wpb_randmom_message_handle(unserialize(get_option('qlcd_wp_chatbot_load_more')))) . ' <span id="wp-chatbot-loadmore-loader"></span></button> </p>'; | |
| 428 | 421 | } |
| 429 | 422 | } |
| 430 | 423 | $html .= '</div>'; |
| 431 | 424 | } |
| @@ -440,15 +433,16 @@ | ||
| 440 | 433 | add_action('wp_ajax_nopriv_qcld_wb_chatbot_category', 'qcld_wb_chatbot_category'); |
| 441 | 434 | function qcld_wb_chatbot_category(){ |
| 442 | 435 | $category_type="common"; |
| 443 | 436 | if (get_option('wp_chatbot_show_parent_category') != "") { |
| 444 | - $terms = get_terms( array( 'taxonomy' => 'product_cat', 'parent' => 0, 'hide_empty' => true, 'fields' => 'all' ) ); | |
| 437 | + $terms = get_terms('product_cat', array('parent' => 0, 'hide_empty' => true, 'fields' => 'all')); | |
| 438 | + | |
| 445 | 439 | } else { |
| 446 | - $terms = get_terms( array( 'taxonomy' => 'product_cat', 'hide_empty' => true, 'fields' => 'all' ) ); | |
| 440 | + $terms = get_terms('product_cat', array('hide_empty' => true, 'fields' => 'all')); | |
| 447 | 441 | } |
| 448 | 442 | $html = ""; |
| 449 | 443 | foreach ($terms as $term) { |
| 450 | - $child_terms=get_terms( array( 'taxonomy' => 'product_cat', 'parent' => $term->term_id, 'hide_empty' => true, 'fields' => 'all' ) ); | |
| 444 | + $child_terms=get_terms('product_cat', array('parent' => $term->term_id, 'hide_empty' => true, 'fields' => 'all')); | |
| 451 | 445 | if(get_option('wp_chatbot_show_sub_category')==1 && count($child_terms) >0){ |
| 452 | 446 | $category_type="hasChilds"; |
| 453 | 447 | } |
| 454 | 448 | $html .= '<span class="qcld-chatbot-product-category" data-category-type="' . $category_type . '" data-category-slug="' . $term->slug . '" data-category-id="' . $term->term_id . '">' . $term->name . '</span>'; |
| @@ -461,10 +455,10 @@ | ||
| 461 | 455 | */ |
| 462 | 456 | add_action('wp_ajax_qcld_wb_chatbot_sub_category', 'qcld_wb_chatbot_sub_category'); |
| 463 | 457 | add_action('wp_ajax_nopriv_qcld_wb_chatbot_sub_category', 'qcld_wb_chatbot_sub_category'); |
| 464 | 458 | function qcld_wb_chatbot_sub_category(){ |
| 465 | - $parent_id = intval( wp_unslash( $_POST['parent_id'] ) ); | |
| 466 | - $terms = get_terms( array( 'taxonomy' => 'product_cat', 'parent' => $parent_id, 'hide_empty' => true, 'fields' => 'all' ) ); | |
| 459 | + $parent_id = stripslashes($_POST['parent_id']); | |
| 460 | + $terms = get_terms('product_cat', array('parent' => $parent_id, 'hide_empty' => true, 'fields' => 'all')); | |
| 467 | 461 | $html = ""; |
| 468 | 462 | foreach ($terms as $term) { |
| 469 | 463 | $html .= '<span class="qcld-chatbot-product-category" data-category-type="common" data-category-slug="' . $term->slug . '" data-category-id="' . $term->term_id . '">' . $term->name . '</span>'; |
| 470 | 464 | } |
| @@ -476,9 +470,9 @@ | ||
| 476 | 470 | */ |
| 477 | 471 | add_action('wp_ajax_qcld_wb_chatbot_category_products', 'qcld_wb_chatbot_category_products'); |
| 478 | 472 | add_action('wp_ajax_nopriv_qcld_wb_chatbot_category_products', 'qcld_wb_chatbot_category_products'); |
| 479 | 473 | function qcld_wb_chatbot_category_products(){ |
| 480 | - $category_id = intval( wp_unslash( $_POST['category'] ) ); | |
| 474 | + $category_id = stripslashes($_POST['category']); | |
| 481 | 475 | $product_per_page = sanitize_text_field(get_option('qlcd_wp_chatbot_ppp') != '' ? get_option('qlcd_wp_chatbot_ppp') : 10); |
| 482 | 476 | $product_orderby = sanitize_text_field(get_option('qlcd_wp_chatbot_product_orderby') != '' ? get_option('qlcd_wp_chatbot_product_orderby') : 'title'); |
| 483 | 477 | $product_order = sanitize_text_field(get_option('qlcd_wp_chatbot_product_order') != '' ? get_option('qlcd_wp_chatbot_product_order') : 'ASC'); |
| 484 | 478 | //Merging all query together. |
| @@ -715,11 +709,11 @@ | ||
| 715 | 709 | //load more |
| 716 | 710 | add_action('wp_ajax_qcld_wb_chatbot_load_more', 'qcld_wb_chatbot_load_more'); |
| 717 | 711 | add_action('wp_ajax_nopriv_qcld_wb_chatbot_load_more', 'qcld_wb_chatbot_load_more'); |
| 718 | 712 | function qcld_wb_chatbot_load_more(){ |
| 719 | - $offset = intval( wp_unslash( $_POST['offset'] ) ); | |
| 720 | - $search_type = sanitize_text_field( wp_unslash( $_POST['search_type'] ) ); | |
| 721 | - $search_term = sanitize_text_field( wp_unslash( $_POST['search_term'] ) ); | |
| 713 | + $offset = stripslashes($_POST['offset']); | |
| 714 | + $search_type = stripslashes($_POST['search_type']); | |
| 715 | + $search_term = stripslashes($_POST['search_term']); | |
| 722 | 716 | $product_per_page = sanitize_text_field(get_option('qlcd_wp_chatbot_ppp') != '' ? get_option('qlcd_wp_chatbot_ppp') : 10); |
| 723 | 717 | $product_orderby = sanitize_text_field(get_option('qlcd_wp_chatbot_product_orderby') != '' ? get_option('qlcd_wp_chatbot_product_orderby') : 'title'); |
| 724 | 718 | $product_order = sanitize_text_field(get_option('qlcd_wp_chatbot_product_order') != '' ? get_option('qlcd_wp_chatbot_product_order') : 'ASC'); |
| 725 | 719 | $next_offset = intval($product_per_page + $offset); |
| @@ -850,9 +844,9 @@ | ||
| 850 | 844 | //product details |
| 851 | 845 | add_action('wp_ajax_qcld_wb_chatbot_product_details', 'qcld_wb_chatbot_product_details'); |
| 852 | 846 | add_action('wp_ajax_nopriv_qcld_wb_chatbot_product_details', 'qcld_wb_chatbot_product_details'); |
| 853 | 847 | function qcld_wb_chatbot_product_details(){ |
| 854 | - $product_id = intval( wp_unslash( $_POST['wp_chatbot_pid'] ) ); | |
| 848 | + $product_id = stripslashes($_POST['wp_chatbot_pid']); | |
| 855 | 849 | //Tracking product view from chat board |
| 856 | 850 | wp_chatbot_view_track_product_by_id($product_id); |
| 857 | 851 | //wpcommerce product factory |
| 858 | 852 | $wc_pf = new WC_Product_Factory(); |
| @@ -925,11 +919,10 @@ | ||
| 925 | 919 | $variations .= '<label for="' . sanitize_title($name) . '">' . $title . '</label>'; |
| 926 | 920 | $variations .= '<select id="' . esc_attr(sanitize_title($name)) . '" name="attribute_' . sanitize_title($name) . '" data-attribute_name="attribute_' . sanitize_title($name) . '" class="each_attribute">'; |
| 927 | 921 | $variations .= '<option value="">' . wp_kses_post(wpb_randmom_message_handle(unserialize(get_option('qlcd_wp_chatbot_choose_option')))) . '</option>'; |
| 928 | 922 | foreach ($values as $value) { |
| 929 | - $attr_key = 'attribute_' . sanitize_title( $name ); | |
| 930 | - if ( isset( $_REQUEST[ $attr_key ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification | |
| 931 | - $selected_value = sanitize_text_field( wp_unslash( $_REQUEST[ $attr_key ] ) ); | |
| 923 | + if (isset($_REQUEST['attribute_' . sanitize_title($name)])) { | |
| 924 | + $selected_value = $_REQUEST['attribute_' . sanitize_title($name)]; | |
| 932 | 925 | } else { |
| 933 | 926 | $selected_value = ''; |
| 934 | 927 | } |
| 935 | 928 | $variations .= '<option value="' . esc_attr(strtolower($value)) . '"' . selected($selected_value, $value, false) . '>' . apply_filters('wpcommerce_variation_option_name', $value) . '</option>'; |
| @@ -953,12 +946,12 @@ | ||
| 953 | 946 | //Add to cart for variable product. |
| 954 | 947 | add_action('wp_ajax_qcld_variable_add_to_cart', 'qcld_variable_add_to_cart'); |
| 955 | 948 | add_action('wp_ajax_nopriv_qcld_variable_add_to_cart', 'qcld_variable_add_to_cart'); |
| 956 | 949 | function qcld_variable_add_to_cart(){ |
| 957 | - $product_id = intval( wp_unslash( $_POST['p_id'] ) ); | |
| 958 | - $quantity = intval( wp_unslash( $_POST['quantity'] ) ); | |
| 959 | - $variations_id = intval( wp_unslash( $_POST['variations_id'] ) ); | |
| 960 | - $attrs = isset( $_POST['attributes'] ) ? array_map( 'sanitize_text_field', wp_unslash( (array) $_POST['attributes'] ) ) : array(); | |
| 950 | + $product_id = stripslashes($_POST['p_id']); | |
| 951 | + $quantity = stripslashes($_POST['quantity']); | |
| 952 | + $variations_id = stripslashes($_POST['variations_id']); | |
| 953 | + $attrs = stripslashes($_POST['attributes']); | |
| 961 | 954 | //echo wp_send_json(array('p_id'=>$product_id,'qnty'=>$quantity,'id'=>$variations_id,'att'=>$attrs)); |
| 962 | 955 | $attributes = array(); |
| 963 | 956 | foreach ($attrs as $attr) { |
| 964 | 957 | $single = explode("#", $attr); |
| @@ -978,10 +971,10 @@ | ||
| 978 | 971 | //Add to cart for simple product. |
| 979 | 972 | add_action('wp_ajax_qcld_wb_chatbot_add_to_cart', 'qcld_wb_chatbot_add_to_cart'); |
| 980 | 973 | add_action('wp_ajax_nopriv_qcld_wb_chatbot_add_to_cart', 'qcld_wb_chatbot_add_to_cart'); |
| 981 | 974 | function qcld_wb_chatbot_add_to_cart(){ |
| 982 | - $product_id = intval( wp_unslash( $_POST['product_id'] ) ); | |
| 983 | - $product_quantity = intval( wp_unslash( $_POST['quantity'] ) ); | |
| 975 | + $product_id = stripslashes($_POST['product_id']); | |
| 976 | + $product_quantity = stripslashes($_POST['quantity']); | |
| 984 | 977 | global $wpcommerce; |
| 985 | 978 | $result = $wpcommerce->cart->add_to_cart($product_id, $product_quantity); |
| 986 | 979 | if ($result != false) { |
| 987 | 980 | wp_send_json('simple'); |
| @@ -992,19 +985,15 @@ | ||
| 992 | 985 | //Support part |
| 993 | 986 | add_action('wp_ajax_qcld_wb_chatbot_support_email', 'qcld_wb_chatbot_support_email'); |
| 994 | 987 | add_action('wp_ajax_nopriv_qcld_wb_chatbot_support_email', 'qcld_wb_chatbot_support_email'); |
| 995 | 988 | function qcld_wb_chatbot_support_email(){ |
| 996 | - $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : ''; | |
| 997 | - if ( ! wp_verify_nonce( $nonce, 'qcsecretbotnonceval123qc' ) ) { | |
| 998 | - wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid nonce verification.', 'chatbot' ) ) ); | |
| 999 | - } | |
| 1000 | - $name = trim(sanitize_text_field(wp_unslash($_POST['name']))); | |
| 1001 | - $email = sanitize_email(wp_unslash($_POST['email'])); | |
| 1002 | - $message = sanitize_text_field(wp_unslash($_POST['message'])); | |
| 989 | + $name = trim(sanitize_text_field($_POST['name'])); | |
| 990 | + $email = sanitize_email($_POST['email']); | |
| 991 | + $message = sanitize_text_field($_POST['message']); | |
| 1003 | 992 | $subject = sanitize_text_field(get_option('qlcd_wp_chatbot_email_sub') != '' ? get_option('qlcd_wp_chatbot_email_sub') : 'Support Email from wpWBot by Client'); |
| 1004 | 993 | //Extract Domain |
| 1005 | 994 | $url = get_site_url(); |
| 1006 | - $url = wp_parse_url($url); | |
| 995 | + $url = parse_url($url); | |
| 1007 | 996 | $domain = $url['host']; |
| 1008 | 997 | //$admin_email = "admin@" . $domain; |
| 1009 | 998 | $admin_email = sanitize_email(get_option('admin_email')); |
| 1010 | 999 | $toEmail = sanitize_email(get_option('qlcd_wp_chatbot_admin_email') != '' ? get_option('qlcd_wp_chatbot_admin_email') : $admin_email); |
| @@ -1014,8 +1003,9 @@ | ||
| 1014 | 1003 | $fromEmail = get_option('qlcd_wp_chatbot_from_email'); |
| 1015 | 1004 | }else{ |
| 1016 | 1005 | $fromEmail = "wordpress@" . $domain; |
| 1017 | 1006 | } |
| 1007 | + | |
| 1018 | 1008 | //Starting messaging and status. |
| 1019 | 1009 | $response['status'] = 'fail'; |
| 1020 | 1010 | $response['message'] = str_replace('\\', '',wp_kses_post(get_option('qlcd_wp_chatbot_email_fail'))); |
| 1021 | 1011 | if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) { |
| @@ -1049,15 +1039,14 @@ | ||
| 1049 | 1039 | //Support Phone |
| 1050 | 1040 | add_action('wp_ajax_qcld_wb_chatbot_support_phone', 'qcld_wb_chatbot_support_phone'); |
| 1051 | 1041 | add_action('wp_ajax_nopriv_qcld_wb_chatbot_support_phone', 'qcld_wb_chatbot_support_phone'); |
| 1052 | 1042 | function qcld_wb_chatbot_support_phone(){ |
| 1053 | - check_ajax_referer('qcsecretbotnonceval123qc', 'nonce'); | |
| 1054 | - $name = trim(sanitize_text_field(wp_unslash($_POST['name']))); | |
| 1055 | - $phone =sanitize_text_field(wp_unslash($_POST['phone'])); | |
| 1043 | + $name = trim(sanitize_text_field($_POST['name'])); | |
| 1044 | + $phone =sanitize_text_field($_POST['phone']); | |
| 1056 | 1045 | $subject = 'WPBot Support Mail Request for Call Back'; |
| 1057 | 1046 | //Extract Domain |
| 1058 | 1047 | $url = get_site_url(); |
| 1059 | - $url = wp_parse_url($url); | |
| 1048 | + $url = parse_url($url); | |
| 1060 | 1049 | $domain = $url['host']; |
| 1061 | 1050 | //$admin_email = "admin@" . $domain; |
| 1062 | 1051 | $admin_email = get_option('admin_email'); |
| 1063 | 1052 | $toEmail = sanitize_email(get_option('qlcd_wp_chatbot_admin_email') != '' ? get_option('qlcd_wp_chatbot_admin_email') : $admin_email); |
| @@ -1095,9 +1084,9 @@ | ||
| 1095 | 1084 | } |
| 1096 | 1085 | // Order Status part. removed |
| 1097 | 1086 | |
| 1098 | 1087 | function wpb_randmom_message_handle($items){ |
| 1099 | - return $items[wp_rand(0, count($items) - 1)]; | |
| 1088 | + return $items[rand(0, count($items) - 1)]; | |
| 1100 | 1089 | } |
| 1101 | 1090 | function qcld_wb_chatbot_func_str_replace($messages = array()){ |
| 1102 | 1091 | $refined_mesgses = array(); |
| 1103 | 1092 | foreach ($messages as $message) { |
| @@ -1112,10 +1101,10 @@ | ||
| 1112 | 1101 | // First check the nonce, if it fails the function will break |
| 1113 | 1102 | check_ajax_referer('wpwbot-order-nonce', 'security'); |
| 1114 | 1103 | // Nonce is checked, get the POST data and sign user on |
| 1115 | 1104 | $info = array(); |
| 1116 | - $info['user_login'] = trim(sanitize_text_field(wp_unslash($_POST['user_name']))); | |
| 1117 | - $info['user_password'] = trim(sanitize_text_field(wp_unslash($_POST['user_pass']))); | |
| 1105 | + $info['user_login'] = trim(sanitize_text_field($_POST['user_name'])); | |
| 1106 | + $info['user_password'] = trim(sanitize_text_field($_POST['user_pass'])); | |
| 1118 | 1107 | $info['remember'] = true; |
| 1119 | 1108 | $user_signon = wp_signon($info, false); |
| 1120 | 1109 | $response = array(); |
| 1121 | 1110 | if (is_wp_error($user_signon)) { |
| @@ -1171,9 +1160,9 @@ | ||
| 1171 | 1160 | $order_url = '<a href="' . get_url(get_permalink(get_option('wpcommerce_myaccount_page_id')) . '/view-order/' . $order->ID) . '" target="_blank" >' . $order->ID . '</a>'; |
| 1172 | 1161 | } |
| 1173 | 1162 | $order_html .= '<div class="wp-chatbot-orders-single"> |
| 1174 | 1163 | <div class="order-id"> ' . $order_url . '</div> |
| 1175 | - <div class="order-date"> <p>' . gmdate("m/d/Y", strtotime($order->post_date)) . '</p> </div> | |
| 1164 | + <div class="order-date"> <p>' . date("m/d/Y", strtotime($order->post_date)) . '</p> </div> | |
| 1176 | 1165 | <div class="order-items">'; |
| 1177 | 1166 | $singleOrder = new WC_Order($order->ID); |
| 1178 | 1167 | $items = $singleOrder->get_items(); |
| 1179 | 1168 | foreach ($items as $item) { |
| @@ -1273,9 +1262,9 @@ | ||
| 1273 | 1262 | $html .= get_the_post_thumbnail(get_the_ID(), 'shop_catalog') . ' |
| 1274 | 1263 | <div class="wp-chatbot-product-summary"> |
| 1275 | 1264 | <div class="wp-chatbot-product-table"> |
| 1276 | 1265 | <div class="wp-chatbot-product-table-cell"> |
| 1277 | - <h3 class="wp-chatbot-product-title">' . esc_html($product->post->post_title) . '</h3> | |
| 1266 | + <h3 class="wp-chatbot-product-title">' . $product->post->post_title . '</h3> | |
| 1278 | 1267 | <div class="price">' . $product->get_price_html() . '</div>'; |
| 1279 | 1268 | $html .= ' </div> |
| 1280 | 1269 | </div> |
| 1281 | 1270 | </div></a> |
| @@ -1344,9 +1333,9 @@ | ||
| 1344 | 1333 | $html .= get_the_post_thumbnail(get_the_ID(), 'shop_catalog') . ' |
| 1345 | 1334 | <div class="wp-chatbot-product-summary"> |
| 1346 | 1335 | <div class="wp-chatbot-product-table"> |
| 1347 | 1336 | <div class="wp-chatbot-product-table-cell"> |
| 1348 | - <h3 class="wp-chatbot-product-title">' . esc_html($product->post->post_title) . '</h3> | |
| 1337 | + <h3 class="wp-chatbot-product-title">' . $product->post->post_title . '</h3> | |
| 1349 | 1338 | <div class="price">' . $product->get_price_html() . '</div>'; |
| 1350 | 1339 | $html .= ' </div> |
| 1351 | 1340 | </div> |
| 1352 | 1341 | </div></a> |
| @@ -1520,12 +1509,11 @@ | ||
| 1520 | 1509 | //Updating the cart items. |
| 1521 | 1510 | add_action('wp_ajax_qcld_wb_chatbot_update_cart_item_number', 'qcld_wb_chatbot_update_cart_item_number'); |
| 1522 | 1511 | add_action('wp_ajax_nopriv_qcld_wb_chatbot_update_cart_item_number', 'qcld_wb_chatbot_update_cart_item_number'); |
| 1523 | 1512 | function qcld_wb_chatbot_update_cart_item_number(){ |
| 1524 | - check_ajax_referer( 'wp_chatbot', 'nonce' ); | |
| 1525 | 1513 | //getting cart items n |
| 1526 | - $cart_item_key = sanitize_text_field(wp_unslash($_POST['cart_item_key'])); | |
| 1527 | - $qnty = sanitize_text_field(wp_unslash($_POST['qnty'])); | |
| 1514 | + $cart_item_key = sanitize_text_field($_POST['cart_item_key']); | |
| 1515 | + $qnty = sanitize_text_field($_POST['qnty']); | |
| 1528 | 1516 | global $wpcommerce; |
| 1529 | 1517 | $result = $wpcommerce->cart->set_quantity($cart_item_key, $qnty); |
| 1530 | 1518 | wp_send_json($result); |
| 1531 | 1519 | } |
| @@ -1532,11 +1520,10 @@ | ||
| 1532 | 1520 | //Show item after removing from cart page. |
| 1533 | 1521 | add_action('wp_ajax_qcld_wb_chatbot_cart_item_remove', 'qcld_wb_chatbot_cart_item_remove'); |
| 1534 | 1522 | add_action('wp_ajax_nopriv_qcld_wb_chatbot_cart_item_remove', 'qcld_wb_chatbot_cart_item_remove'); |
| 1535 | 1523 | function qcld_wb_chatbot_cart_item_remove(){ |
| 1536 | - check_ajax_referer( 'wp_chatbot', 'nonce' ); | |
| 1537 | 1524 | //getting cart items n |
| 1538 | - $cart_item_key = sanitize_text_field(wp_unslash($_POST['cart_item'])); | |
| 1525 | + $cart_item_key = sanitize_text_field($_POST['cart_item']); | |
| 1539 | 1526 | global $wpcommerce; |
| 1540 | 1527 | $result = $wpcommerce->cart->remove_cart_item($cart_item_key); |
| 1541 | 1528 | wp_send_json($result); |
| 1542 | 1529 | } |
| @@ -1592,9 +1579,9 @@ | ||
| 1592 | 1579 | |
| 1593 | 1580 | if(class_exists('Qcformbuilder_Forms_Admin')){ |
| 1594 | 1581 | |
| 1595 | 1582 | |
| 1596 | - $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 | |
| 1583 | + $results = $wpdb->get_results($wpdb->prepare("SELECT * FROM ". $wpdb->prefix."wfb_forms WHERE type= %s",'primary')); //DB Call OK, No Caching OK | |
| 1597 | 1584 | |
| 1598 | 1585 | if(!empty($results)){ |
| 1599 | 1586 | |
| 1600 | 1587 | foreach($results as $result){ |
| @@ -1619,10 +1606,10 @@ | ||
| 1619 | 1606 | // function qcld_wb_chatbot_checkout_user_login(){ |
| 1620 | 1607 | // // Nonce is checked, get the POST data and sign user on |
| 1621 | 1608 | // $info = array(); |
| 1622 | 1609 | // //$info['nonce'] = $_POST['nonce_val']; |
| 1623 | -// $info['user_login'] = trim(sanitize_text_field(wp_unslash($_POST['user_name']))); | |
| 1624 | -// $info['user_password'] = trim(sanitize_text_field(wp_unslash($_POST['user_pass']))); | |
| 1610 | +// $info['user_login'] = trim(sanitize_text_field($_POST['user_name'])); | |
| 1611 | +// $info['user_password'] = trim(sanitize_text_field($_POST['user_pass'])); | |
| 1625 | 1612 | // $info['remember'] = true; |
| 1626 | 1613 | // $user_signon = wp_signon($info, false); |
| 1627 | 1614 | // // $response=$info; |
| 1628 | 1615 | // $response = array(); |
| @@ -1663,16 +1650,15 @@ | ||
| 1663 | 1650 | add_action('init', 'wp_chatbot_create_app_checkout_thankyou_page'); |
| 1664 | 1651 | function wp_chatbot_create_app_checkout_thankyou_page(){ |
| 1665 | 1652 | if (get_option('wp_chatbot_app_pages') == 1) { |
| 1666 | 1653 | //Mobile App page create |
| 1667 | - $existing_app = new WP_Query( array( 'post_type' => 'page', 'name' => 'wpwbot-mobile-app', 'post_status' => 'publish', 'posts_per_page' => 1 ) ); | |
| 1668 | - if ( ! $existing_app->have_posts() ) { | |
| 1654 | + if (get_page_by_title('wpwBot Mobile App') == NULL) { | |
| 1669 | 1655 | //post status and options |
| 1670 | 1656 | $app_page = array( |
| 1671 | 1657 | 'comment_status' => 'closed', |
| 1672 | 1658 | 'ping_status' => 'closed', |
| 1673 | 1659 | 'post_author' => get_current_user_id(), |
| 1674 | - 'post_date' => gmdate('Y-m-d H:i:s'), | |
| 1660 | + 'post_date' => date('Y-m-d H:i:s'), | |
| 1675 | 1661 | 'post_status' => 'publish', |
| 1676 | 1662 | 'post_title' => 'wpwBot Mobile App', |
| 1677 | 1663 | 'post_name' => 'wpwbot-mobile-app', |
| 1678 | 1664 | 'post_type' => 'page', |
| @@ -1682,16 +1668,15 @@ | ||
| 1682 | 1668 | //save the id in the database |
| 1683 | 1669 | update_option('wp_chatbot_app_checkout', $wpwbot_app); |
| 1684 | 1670 | } |
| 1685 | 1671 | //App checkout page create |
| 1686 | - $existing_checkout = new WP_Query( array( 'post_type' => 'page', 'name' => 'wpwbot-app-checkout', 'post_status' => 'publish', 'posts_per_page' => 1 ) ); | |
| 1687 | - if ( ! $existing_checkout->have_posts() ) { | |
| 1672 | + if (get_page_by_title('wpwBot App Checkout') == NULL) { | |
| 1688 | 1673 | //post status and options |
| 1689 | 1674 | $checkout_page = array( |
| 1690 | 1675 | 'comment_status' => 'closed', |
| 1691 | 1676 | 'ping_status' => 'closed', |
| 1692 | 1677 | 'post_author' => get_current_user_id(), |
| 1693 | - 'post_date' => gmdate('Y-m-d H:i:s'), | |
| 1678 | + 'post_date' => date('Y-m-d H:i:s'), | |
| 1694 | 1679 | 'post_status' => 'publish', |
| 1695 | 1680 | 'post_title' => 'wpwBot App Checkout', |
| 1696 | 1681 | 'post_name' => 'wpwbot-app-checkout', |
| 1697 | 1682 | 'post_type' => 'page', |
| @@ -1701,16 +1686,15 @@ | ||
| 1701 | 1686 | //save the id in the database |
| 1702 | 1687 | update_option('wp_chatbot_app_checkout', $app_checkout); |
| 1703 | 1688 | } |
| 1704 | 1689 | //App Order thank you page create |
| 1705 | - $existing_thankyou = new WP_Query( array( 'post_type' => 'page', 'name' => 'wpwbot-app-order-thankyou', 'post_status' => 'publish', 'posts_per_page' => 1 ) ); | |
| 1706 | - if ( ! $existing_thankyou->have_posts() ) { | |
| 1690 | + if (get_page_by_title('wpwBot App Order Thank You') == NULL) { | |
| 1707 | 1691 | //post status and options |
| 1708 | 1692 | $thankyou_page = array( |
| 1709 | 1693 | 'comment_status' => 'closed', |
| 1710 | 1694 | 'ping_status' => 'closed', |
| 1711 | 1695 | 'post_author' => get_current_user_id(), |
| 1712 | - 'post_date' => gmdate('Y-m-d H:i:s'), | |
| 1696 | + 'post_date' => date('Y-m-d H:i:s'), | |
| 1713 | 1697 | 'post_status' => 'publish', |
| 1714 | 1698 | 'post_title' => 'wpwBot App Order Thank You', |
| 1715 | 1699 | 'post_name' => 'wpwbot-app-order-thankyou', |
| 1716 | 1700 | 'post_type' => 'page', |
| @@ -1721,9 +1705,9 @@ | ||
| 1721 | 1705 | update_option('wp_chatbot_app_order_thankyou', $app_order_thankyou); |
| 1722 | 1706 | } |
| 1723 | 1707 | } |
| 1724 | 1708 | //Keep tracking from App by cookies |
| 1725 | - if ( isset( $_GET['from'] ) && sanitize_text_field( wp_unslash( $_GET['from'] ) ) === 'app' ) { // phpcs:ignore WordPress.Security.NonceVerification | |
| 1709 | + if (isset($_GET['from']) && $_GET['from'] == 'app') { | |
| 1726 | 1710 | if (!isset($_COOKIE['from_app'])) { |
| 1727 | 1711 | setcookie('from_app', 'yes', (time() + 3600), '/'); |
| 1728 | 1712 | } |
| 1729 | 1713 | } |
| @@ -1737,9 +1721,9 @@ | ||
| 1737 | 1721 | global $wp; |
| 1738 | 1722 | if (is_checkout() && !empty($wp->query_vars['order-received'])) { |
| 1739 | 1723 | $thanks_page_id = get_option('wp_chatbot_app_order_thankyou'); |
| 1740 | 1724 | $thanks_parmanlink = esc_url(get_permalink($thanks_page_id)); |
| 1741 | - wp_safe_redirect($thanks_parmanlink . '?order_id=' . $order_get_id); | |
| 1725 | + wp_redirect($thanks_parmanlink . '?order_id=' . $order_get_id); | |
| 1742 | 1726 | exit; |
| 1743 | 1727 | } |
| 1744 | 1728 | } else { |
| 1745 | 1729 | remove_action('wpcommerce_thankyou', 'qcld_wb_chatbot__redirect_after_purchase'); |
| @@ -1762,22 +1746,22 @@ | ||
| 1762 | 1746 | $tableuser = $wpdb->prefix.'wpbot_sessions'; |
| 1763 | 1747 | $response = array(); |
| 1764 | 1748 | |
| 1765 | 1749 | |
| 1766 | - $session_exists = $wpdb->get_row($wpdb->prepare("select * from {$tableuser} where 1 and id = %d",1)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter | |
| 1750 | + $session_exists = $wpdb->get_row($wpdb->prepare("select * from $tableuser where 1 and id = %d",1)); //DB Call OK, No Caching OK | |
| 1767 | 1751 | |
| 1768 | 1752 | if(empty($session_exists)){ |
| 1769 | - $wpdb->insert( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery | |
| 1753 | + $wpdb->insert( | |
| 1770 | 1754 | $tableuser, |
| 1771 | 1755 | array( |
| 1772 | 1756 | 'session' => 1, |
| 1773 | 1757 | ) |
| 1774 | - ); | |
| 1758 | + ); //DB Call OK, No Caching OK | |
| 1775 | 1759 | }else{ |
| 1776 | 1760 | |
| 1777 | 1761 | $session_id = $session_exists->id; |
| 1778 | 1762 | |
| 1779 | - $wpdb->update( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | |
| 1763 | + $wpdb->update( | |
| 1780 | 1764 | $tableuser, |
| 1781 | 1765 | array( |
| 1782 | 1766 | 'session'=>($session_exists->session+1), |
| 1783 | 1767 | ), |
| @@ -1785,9 +1769,9 @@ | ||
| 1785 | 1769 | array( |
| 1786 | 1770 | '%d', |
| 1787 | 1771 | ), |
| 1788 | 1772 | array('%d') |
| 1789 | - ); | |
| 1773 | + ); //DB Call OK, No Caching OK | |
| 1790 | 1774 | |
| 1791 | 1775 | } |
| 1792 | 1776 | |
| 1793 | 1777 | wp_send_json($response); |
| @@ -1795,9 +1779,9 @@ | ||
| 1795 | 1779 | |
| 1796 | 1780 | /* WPBot Chat History Addon check */ |
| 1797 | 1781 | function qcld_wpbot_is_active_chat_history(){ |
| 1798 | 1782 | |
| 1799 | - if(function_exists('qcwp_chat_session_menu_fnc') || function_exists('qcwp_chat_session_menu_fnc_free') || function_exists( 'qcpdcs_chat_session_menu_fnc' ) ){ | |
| 1783 | + if(function_exists('qcwp_chat_session_menu_fnc') || function_exists( 'qcpdcs_chat_session_menu_fnc' ) ){ | |
| 1800 | 1784 | return 1; |
| 1801 | 1785 | }else{ |
| 1802 | 1786 | return 0; |
| 1803 | 1787 | } |
| @@ -1812,11 +1796,9 @@ | ||
| 1812 | 1796 | return $data; |
| 1813 | 1797 | } |
| 1814 | 1798 | add_action('wp_ajax_qcld_small_talk_import', 'qcld_small_talk_import'); |
| 1815 | 1799 | function qcld_small_talk_import(){ |
| 1816 | - if ( ! current_user_can( 'manage_options' ) ) { | |
| 1817 | - wp_die(); | |
| 1818 | - } | |
| 1800 | + | |
| 1819 | 1801 | global $wpdb; |
| 1820 | 1802 | |
| 1821 | 1803 | $table = $wpdb->prefix.'wpbot_response'; |
| 1822 | 1804 | |
| @@ -1823,10 +1805,9 @@ | ||
| 1823 | 1805 | $csvFile = file(QCLD_wpCHATBOT_PLUGIN_DIR_PATH . 'small_talk.csv'); |
| 1824 | 1806 | |
| 1825 | 1807 | foreach ($csvFile as $line) { |
| 1826 | 1808 | $line = str_getcsv($line, ',', '"'); |
| 1827 | - $wpdb->insert( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery | |
| 1828 | - $table, array( | |
| 1809 | + $wpdb->insert($table, array( | |
| 1829 | 1810 | 'query' => $line[0], |
| 1830 | 1811 | 'keyword' => $line[1], |
| 1831 | 1812 | 'response' => $line[2], |
| 1832 | 1813 | 'category'=> $line[3], |
| @@ -1831,17 +1812,16 @@ | ||
| 1831 | 1812 | 'response' => $line[2], |
| 1832 | 1813 | 'category'=> $line[3], |
| 1833 | 1814 | 'intent'=> '', |
| 1834 | 1815 | //'lang'=> 'en_US', |
| 1835 | - )); | |
| 1816 | + )); //DB Call OK, No Caching OK | |
| 1836 | 1817 | } |
| 1837 | 1818 | |
| 1838 | 1819 | $table2 = $wpdb->prefix.'wpbot_response_category'; |
| 1839 | 1820 | |
| 1840 | - $wpdb->insert( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery | |
| 1841 | - $table2, array( | |
| 1821 | + $wpdb->insert($table2, array( | |
| 1842 | 1822 | 'name' => 'smalltalk', |
| 1843 | - )); | |
| 1823 | + )); //DB Call OK, No Caching OK | |
| 1844 | 1824 | |
| 1845 | 1825 | update_option( 'qcld_small_talk_imported', 'yes' ); |
| 1846 | 1826 | |
| 1847 | 1827 | } |
| @@ -1869,15 +1849,11 @@ | ||
| 1869 | 1849 | function qcld_change_language_from_center() { |
| 1870 | 1850 | if ( ! current_user_can( 'manage_options' ) ) { |
| 1871 | 1851 | wp_send_json_error( array( 'message' => 'Unauthorized.' ) ); |
| 1872 | 1852 | } |
| 1873 | - $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : ''; | |
| 1874 | - if ( ! wp_verify_nonce( $nonce, 'wp_chatbot' ) ) { | |
| 1875 | - wp_send_json_error( array( 'message' => 'Invalid nonce.' ) ); | |
| 1876 | - } | |
| 1877 | 1853 | $plugin_path = plugin_dir_path( __FILE__ ); |
| 1878 | 1854 | include $plugin_path . 'includes/admin/settings-fields.php'; |
| 1879 | - $json_file_path = $plugin_path . 'includes/language-center.json'; | |
| 1855 | + $json_file_path = $plugin_path . 'includes/language center.json'; // Adjust path as needed | |
| 1880 | 1856 | |
| 1881 | 1857 | $json_string = file_get_contents( $json_file_path ); |
| 1882 | 1858 | if ( isset( $_POST['language'] ) ) { |
| 1883 | 1859 | $language = sanitize_text_field( wp_unslash( $_POST['language'] ) ); |
| @@ -1888,5 +1864,5 @@ | ||
| 1888 | 1864 | wp_send_json_error( array( 'message' => 'Language not specified.' ) ); |
| 1889 | 1865 | |
| 1890 | 1866 | } |
| 1891 | 1867 | } |
| 1892 | -} | |
| 1868 | +} | |