PluginProbe
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services / 8.0.0
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services v8.0.0
8.7.8 8.7.7 8.7.6 8.7.5 8.7.4 8.7.3 8.7.2 8.7.1 8.7.0 8.6.9 8.6.8 8.6.7 8.6.6 8.6.5 8.6.4 8.6.2 8.6.1 8.6.0 8.5.9 8.5.8 8.5.7 8.5.6 8.5.5 8.5.4 8.5.3 All 534 releases
← All changes | functions.php +72 -211 8.7.08.0.0 View file →
@@ -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 }
@@ -58,62 +58,8 @@
58 58 });
59 59 </script>
60 60 <?php
61 61 }
62 -/**
63 - * Extract a YouTube video ID from common URL formats.
64 - *
65 - * @param string $url YouTube watch, embed, short, or youtu.be URL.
66 - * @return string Video ID or empty string.
67 - */
68 -if ( ! function_exists( 'qcld_wpbot_extract_youtube_id' ) ) {
69 - function qcld_wpbot_extract_youtube_id( $url ) {
70 - $url = trim( (string) $url );
71 - if ( $url === '' ) {
72 - return '';
73 - }
74 -
75 - if ( preg_match( '/(?:youtube\.com\/(?:embed\/|shorts\/|live\/|watch\?(?:.*&)?v=)|youtu\.be\/)([A-Za-z0-9_-]{11})/', $url, $matches ) ) {
76 - return $matches[1];
77 - }
78 -
79 - $path = (string) wp_parse_url( $url, PHP_URL_PATH );
80 - $base = basename( $path );
81 - if ( preg_match( '/^[A-Za-z0-9_-]{11}$/', $base ) ) {
82 - return $base;
83 - }
84 -
85 - return '';
86 - }
87 -}
88 -if ( ! function_exists( 'qcld_wpbot_youtube_icon_embed_src' ) ) {
89 - function qcld_wpbot_youtube_icon_embed_src( $url ) {
90 - $video_id = qcld_wpbot_extract_youtube_id( $url );
91 - if ( $video_id === '' ) {
92 - return '';
93 - }
94 -
95 - return add_query_arg(
96 - array(
97 - 'autoplay' => '1',
98 - 'mute' => '1',
99 - 'loop' => '1',
100 - 'playlist' => $video_id,
101 - 'controls' => '0',
102 - 'showinfo' => '0',
103 - 'rel' => '0',
104 - 'fs' => '0',
105 - 'iv_load_policy' => '3',
106 - 'cc_load_policy' => '0',
107 - 'disablekb' => '1',
108 - 'playsinline' => '1',
109 - 'modestbranding' => '1',
110 - 'color' => 'white',
111 - ),
112 - 'https://www.youtube.com/embed/' . rawurlencode( $video_id )
113 - );
114 - }
115 -}
116 62 function wp_chatbot_load_footer_html(){
117 63 if ( get_option('disable_wp_chatbot') != 1 && wp_chatbot_load_controlling() === true) {
118 64
119 65 ?>
@@ -119,9 +65,9 @@
119 65 ?>
120 66 <style>
121 67 <?php if(get_option('wp_chatbot_custom_css')!="") {
122 68
123 - 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');
124 70 }
125 71 ?>
126 72 </style>
127 73
@@ -209,9 +155,9 @@
209 155 }
210 156 ?>
211 157 <div class="wp-chatbot-notification-agent-profile">
212 158 <div class="wp-chatbot-notification-widget-avatar" ><img
213 - 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>
214 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>
215 161 </div>
216 162 <?php
217 163 //update_option('qlcd_wp_chatbot_notifications','Welcome to WpBot');
@@ -234,72 +180,14 @@
234 180 $wp_chatbot_custom_icon_path = QCLD_wpCHATBOT_IMG_URL . get_option('wp_chatbot_icon');
235 181 } else {
236 182 $wp_chatbot_custom_icon_path = QCLD_wpCHATBOT_IMG_URL . 'custom.png';
237 183 }
238 - $_wpbot_icon_video = get_option('wp_chatbot_icon_video', '');
239 - $_wpbot_video_is_youtube = ( strpos( $_wpbot_icon_video, 'youtube.com' ) !== false || strpos( $_wpbot_icon_video, 'youtu.be' ) !== false );
240 - $_wpbot_youtube_embed_src = $_wpbot_video_is_youtube ? qcld_wpbot_youtube_icon_embed_src( $_wpbot_icon_video ) : '';
241 - $_wpbot_video_delay_ms = absint( get_option( 'wp_chatbot_icon_video_delay', 0 ) ) * 1000;
242 -
243 - $wp_chatbot_ball_is_youtube = ($_wpbot_icon_video !== '' && (strpos($_wpbot_icon_video, 'youtube.com') !== false || strpos($_wpbot_icon_video, 'youtu.be') !== false));
244 - $wp_chatbot_ball_is_video = ($_wpbot_icon_video !== '' && !$wp_chatbot_ball_is_youtube);
245 - $wp_chatbot_ball_has_video = ($wp_chatbot_ball_is_youtube || $wp_chatbot_ball_is_video);
246 184 ?>
247 185 <img src="<?php echo esc_url($wp_chatbot_custom_icon_path); ?>"
248 - alt="wpChatIcon" qcld_agent="<?php echo esc_url($wp_chatbot_custom_icon_path); ?>"
249 - id="wp-chatbot-ball-icon-img"
250 - <?php if ($wp_chatbot_ball_has_video) { echo 'style="display:none;"'; } ?> >
251 - <?php if ( $_wpbot_icon_video !== '' ) : ?>
252 - <?php if ( $_wpbot_video_is_youtube && $_wpbot_youtube_embed_src !== '' ) : ?>
253 - <iframe class="wpbot-icon-video" src="<?php echo $_wpbot_video_delay_ms > 0 ? 'about:blank' : esc_url( $_wpbot_youtube_embed_src ); ?>" data-wpbot-yt-src="<?php echo esc_url( $_wpbot_youtube_embed_src ); ?>" frameborder="0" allow="autoplay; fullscreen; encrypted-media; picture-in-picture"></iframe>
254 - <?php elseif ( ! $_wpbot_video_is_youtube ) : ?>
255 - <video class="wpbot-icon-video" src="<?php echo esc_url( $_wpbot_icon_video ); ?>" autoplay muted loop playsinline preload="auto"></video>
256 - <?php endif; ?>
257 - <?php endif; ?>
186 + alt="wpChatIcon" qcld_agent="<?php echo esc_url($wp_chatbot_custom_icon_path); ?>" >
187 +
258 188 </div>
259 -
260 189 </div>
261 - <?php
262 - if ( $_wpbot_icon_video !== '' ) :
263 - ?>
264 - <script>
265 - (function(){
266 - var wpbotDelay = <?php echo (int) $_wpbot_video_delay_ms; ?>;
267 - function wpbotForcePlay(){
268 - var v = document.querySelector('#wp-chatbot-ball video.wpbot-icon-video');
269 - if( v ){
270 - v.muted = true;
271 - v.volume = 0;
272 - v.loop = true;
273 - var tries = 0, maxTries = 30;
274 - var timer = setInterval(function(){
275 - tries++;
276 - v.play().then(function(){ clearInterval(timer); }).catch(function(){});
277 - if( tries >= maxTries ) clearInterval(timer);
278 - }, 300);
279 - }
280 - var yt = document.querySelector('#wp-chatbot-ball iframe.wpbot-icon-video');
281 - if( yt ){
282 - var ytSrc = yt.getAttribute('data-wpbot-yt-src');
283 - if( ytSrc && ( !yt.getAttribute('src') || yt.getAttribute('src') === 'about:blank' || yt.getAttribute('src').indexOf('autoplay=1') === -1 ) ){
284 - yt.setAttribute('src', ytSrc);
285 - }
286 - }
287 - }
288 - function wpbotDelayedPlay(){
289 - setTimeout(wpbotForcePlay, wpbotDelay);
290 - }
291 - if( document.readyState === 'loading' ){
292 - document.addEventListener('DOMContentLoaded', wpbotDelayedPlay);
293 - } else {
294 - wpbotDelayedPlay();
295 - }
296 - window.addEventListener('load', function(){
297 - setTimeout(wpbotForcePlay, wpbotDelay);
298 - });
299 - })();
300 - </script>
301 - <?php endif; ?>
302 190 <?php
303 191 $fb_app_id = get_option('qlcd_wp_chatbot_fb_app_id');
304 192 $fb_page_id = get_option('qlcd_wp_chatbot_fb_page_id');
305 193 $fb_mgs_color = get_option('qlcd_wp_chatbot_fb_color') != '' ? get_option('qlcd_wp_chatbot_fb_color') : '#0084ff';
@@ -425,10 +313,10 @@
425 313 }
426 314 }
427 315 //Checking wpwbot opening hour
428 316 function wp_chatbot_check_opening_hours(){
429 - $curent_day=strtolower(gmdate('l',strtotime(current_time( 'mysql' ))));
430 - $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')));
431 319 $is_wpwbot_open =false;
432 320 if(get_option('wpwbot_hours')) {
433 321 $wpwbot_times = wp_kses_post(unserialize(get_option('wpwbot_hours')));
434 322 if (isset($wpwbot_times[$curent_day])) {
@@ -450,16 +338,9 @@
450 338 */
451 339 add_action('wp_ajax_qcld_wb_chatbot_keyword', 'qcld_wb_chatbot_keyword');
452 340 add_action('wp_ajax_nopriv_qcld_wb_chatbot_keyword', 'qcld_wb_chatbot_keyword');
453 341 function qcld_wb_chatbot_keyword(){
454 - // Verify nonce for security
455 - $nonce = isset($_POST['security']) ? sanitize_text_field(wp_unslash($_POST['security'])) : (isset($_POST['nonce']) ? sanitize_text_field(wp_unslash($_POST['nonce'])) : '');
456 - if ( ! wp_verify_nonce( $nonce, 'wp_chatbot' ) && ! wp_verify_nonce( $nonce, 'qcsecretbotnonceval123qc' ) ) {
457 - wp_send_json_error( array( 'status' => 'fail', 'message' => 'Security check failed.' ) );
458 - wp_die();
459 - }
460 -
461 - $keyword = sanitize_text_field(wp_unslash($_POST['keyword']));
342 + $keyword = sanitize_text_field($_POST['keyword']);
462 343 $product_per_page = get_option('qlcd_wp_chatbot_ppp') != '' ? get_option('qlcd_wp_chatbot_ppp') : 10;
463 344 if (get_option('qlcd_wp_chatbot_search_option') == 'standard') {
464 345 $product_orderby = sanitize_text_field(get_option('qlcd_wp_chatbot_product_orderby') != '' ? get_option('qlcd_wp_chatbot_product_orderby') : 'title');
465 346 $product_order = sanitize_text_field(get_option('qlcd_wp_chatbot_product_order') != '' ? get_option('qlcd_wp_chatbot_product_order') : 'ASC');
@@ -505,9 +386,9 @@
505 386 endwhile;
506 387 wp_reset_postdata();
507 388 $html .= '</ul>';
508 389 if ($total_product_num > $product_per_page && $product_per_page > 0 ) {
509 - $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>';
510 391 }
511 392 }
512 393 $html .= '</div>';
513 394 } else if (get_option('qlcd_wp_chatbot_search_option') == 'advanced') {
@@ -535,9 +416,9 @@
535 416 }
536 417 }
537 418 $html .= '</ul>';
538 419 if ($total_product_num > $product_per_page && $product_per_page > 0) {
539 - $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>';
540 421 }
541 422 }
542 423 $html .= '</div>';
543 424 }
@@ -552,15 +433,16 @@
552 433 add_action('wp_ajax_nopriv_qcld_wb_chatbot_category', 'qcld_wb_chatbot_category');
553 434 function qcld_wb_chatbot_category(){
554 435 $category_type="common";
555 436 if (get_option('wp_chatbot_show_parent_category') != "") {
556 - $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 +
557 439 } else {
558 - $terms = get_terms( array( 'taxonomy' => 'product_cat', 'hide_empty' => true, 'fields' => 'all' ) );
440 + $terms = get_terms('product_cat', array('hide_empty' => true, 'fields' => 'all'));
559 441 }
560 442 $html = "";
561 443 foreach ($terms as $term) {
562 - $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'));
563 445 if(get_option('wp_chatbot_show_sub_category')==1 && count($child_terms) >0){
564 446 $category_type="hasChilds";
565 447 }
566 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>';
@@ -573,10 +455,10 @@
573 455 */
574 456 add_action('wp_ajax_qcld_wb_chatbot_sub_category', 'qcld_wb_chatbot_sub_category');
575 457 add_action('wp_ajax_nopriv_qcld_wb_chatbot_sub_category', 'qcld_wb_chatbot_sub_category');
576 458 function qcld_wb_chatbot_sub_category(){
577 - $parent_id = intval( wp_unslash( $_POST['parent_id'] ) );
578 - $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'));
579 461 $html = "";
580 462 foreach ($terms as $term) {
581 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>';
582 464 }
@@ -588,9 +470,9 @@
588 470 */
589 471 add_action('wp_ajax_qcld_wb_chatbot_category_products', 'qcld_wb_chatbot_category_products');
590 472 add_action('wp_ajax_nopriv_qcld_wb_chatbot_category_products', 'qcld_wb_chatbot_category_products');
591 473 function qcld_wb_chatbot_category_products(){
592 - $category_id = intval( wp_unslash( $_POST['category'] ) );
474 + $category_id = stripslashes($_POST['category']);
593 475 $product_per_page = sanitize_text_field(get_option('qlcd_wp_chatbot_ppp') != '' ? get_option('qlcd_wp_chatbot_ppp') : 10);
594 476 $product_orderby = sanitize_text_field(get_option('qlcd_wp_chatbot_product_orderby') != '' ? get_option('qlcd_wp_chatbot_product_orderby') : 'title');
595 477 $product_order = sanitize_text_field(get_option('qlcd_wp_chatbot_product_order') != '' ? get_option('qlcd_wp_chatbot_product_order') : 'ASC');
596 478 //Merging all query together.
@@ -827,11 +709,11 @@
827 709 //load more
828 710 add_action('wp_ajax_qcld_wb_chatbot_load_more', 'qcld_wb_chatbot_load_more');
829 711 add_action('wp_ajax_nopriv_qcld_wb_chatbot_load_more', 'qcld_wb_chatbot_load_more');
830 712 function qcld_wb_chatbot_load_more(){
831 - $offset = intval( wp_unslash( $_POST['offset'] ) );
832 - $search_type = sanitize_text_field( wp_unslash( $_POST['search_type'] ) );
833 - $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']);
834 716 $product_per_page = sanitize_text_field(get_option('qlcd_wp_chatbot_ppp') != '' ? get_option('qlcd_wp_chatbot_ppp') : 10);
835 717 $product_orderby = sanitize_text_field(get_option('qlcd_wp_chatbot_product_orderby') != '' ? get_option('qlcd_wp_chatbot_product_orderby') : 'title');
836 718 $product_order = sanitize_text_field(get_option('qlcd_wp_chatbot_product_order') != '' ? get_option('qlcd_wp_chatbot_product_order') : 'ASC');
837 719 $next_offset = intval($product_per_page + $offset);
@@ -962,9 +844,9 @@
962 844 //product details
963 845 add_action('wp_ajax_qcld_wb_chatbot_product_details', 'qcld_wb_chatbot_product_details');
964 846 add_action('wp_ajax_nopriv_qcld_wb_chatbot_product_details', 'qcld_wb_chatbot_product_details');
965 847 function qcld_wb_chatbot_product_details(){
966 - $product_id = intval( wp_unslash( $_POST['wp_chatbot_pid'] ) );
848 + $product_id = stripslashes($_POST['wp_chatbot_pid']);
967 849 //Tracking product view from chat board
968 850 wp_chatbot_view_track_product_by_id($product_id);
969 851 //wpcommerce product factory
970 852 $wc_pf = new WC_Product_Factory();
@@ -1037,11 +919,10 @@
1037 919 $variations .= '<label for="' . sanitize_title($name) . '">' . $title . '</label>';
1038 920 $variations .= '<select id="' . esc_attr(sanitize_title($name)) . '" name="attribute_' . sanitize_title($name) . '" data-attribute_name="attribute_' . sanitize_title($name) . '" class="each_attribute">';
1039 921 $variations .= '<option value="">' . wp_kses_post(wpb_randmom_message_handle(unserialize(get_option('qlcd_wp_chatbot_choose_option')))) . '</option>';
1040 922 foreach ($values as $value) {
1041 - $attr_key = 'attribute_' . sanitize_title( $name );
1042 - if ( isset( $_REQUEST[ $attr_key ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
1043 - $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)];
1044 925 } else {
1045 926 $selected_value = '';
1046 927 }
1047 928 $variations .= '<option value="' . esc_attr(strtolower($value)) . '"' . selected($selected_value, $value, false) . '>' . apply_filters('wpcommerce_variation_option_name', $value) . '</option>';
@@ -1065,12 +946,12 @@
1065 946 //Add to cart for variable product.
1066 947 add_action('wp_ajax_qcld_variable_add_to_cart', 'qcld_variable_add_to_cart');
1067 948 add_action('wp_ajax_nopriv_qcld_variable_add_to_cart', 'qcld_variable_add_to_cart');
1068 949 function qcld_variable_add_to_cart(){
1069 - $product_id = intval( wp_unslash( $_POST['p_id'] ) );
1070 - $quantity = intval( wp_unslash( $_POST['quantity'] ) );
1071 - $variations_id = intval( wp_unslash( $_POST['variations_id'] ) );
1072 - $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']);
1073 954 //echo wp_send_json(array('p_id'=>$product_id,'qnty'=>$quantity,'id'=>$variations_id,'att'=>$attrs));
1074 955 $attributes = array();
1075 956 foreach ($attrs as $attr) {
1076 957 $single = explode("#", $attr);
@@ -1090,10 +971,10 @@
1090 971 //Add to cart for simple product.
1091 972 add_action('wp_ajax_qcld_wb_chatbot_add_to_cart', 'qcld_wb_chatbot_add_to_cart');
1092 973 add_action('wp_ajax_nopriv_qcld_wb_chatbot_add_to_cart', 'qcld_wb_chatbot_add_to_cart');
1093 974 function qcld_wb_chatbot_add_to_cart(){
1094 - $product_id = intval( wp_unslash( $_POST['product_id'] ) );
1095 - $product_quantity = intval( wp_unslash( $_POST['quantity'] ) );
975 + $product_id = stripslashes($_POST['product_id']);
976 + $product_quantity = stripslashes($_POST['quantity']);
1096 977 global $wpcommerce;
1097 978 $result = $wpcommerce->cart->add_to_cart($product_id, $product_quantity);
1098 979 if ($result != false) {
1099 980 wp_send_json('simple');
@@ -1104,19 +985,15 @@
1104 985 //Support part
1105 986 add_action('wp_ajax_qcld_wb_chatbot_support_email', 'qcld_wb_chatbot_support_email');
1106 987 add_action('wp_ajax_nopriv_qcld_wb_chatbot_support_email', 'qcld_wb_chatbot_support_email');
1107 988 function qcld_wb_chatbot_support_email(){
1108 - $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : '';
1109 - if ( ! wp_verify_nonce( $nonce, 'qcsecretbotnonceval123qc' ) ) {
1110 - wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid nonce verification.', 'chatbot' ) ) );
1111 - }
1112 - $name = trim(sanitize_text_field(wp_unslash($_POST['name'])));
1113 - $email = sanitize_email(wp_unslash($_POST['email']));
1114 - $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']);
1115 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');
1116 993 //Extract Domain
1117 994 $url = get_site_url();
1118 - $url = wp_parse_url($url);
995 + $url = parse_url($url);
1119 996 $domain = $url['host'];
1120 997 //$admin_email = "admin@" . $domain;
1121 998 $admin_email = sanitize_email(get_option('admin_email'));
1122 999 $toEmail = sanitize_email(get_option('qlcd_wp_chatbot_admin_email') != '' ? get_option('qlcd_wp_chatbot_admin_email') : $admin_email);
@@ -1126,8 +1003,9 @@
1126 1003 $fromEmail = get_option('qlcd_wp_chatbot_from_email');
1127 1004 }else{
1128 1005 $fromEmail = "wordpress@" . $domain;
1129 1006 }
1007 +
1130 1008 //Starting messaging and status.
1131 1009 $response['status'] = 'fail';
1132 1010 $response['message'] = str_replace('\\', '',wp_kses_post(get_option('qlcd_wp_chatbot_email_fail')));
1133 1011 if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
@@ -1161,15 +1039,14 @@
1161 1039 //Support Phone
1162 1040 add_action('wp_ajax_qcld_wb_chatbot_support_phone', 'qcld_wb_chatbot_support_phone');
1163 1041 add_action('wp_ajax_nopriv_qcld_wb_chatbot_support_phone', 'qcld_wb_chatbot_support_phone');
1164 1042 function qcld_wb_chatbot_support_phone(){
1165 - check_ajax_referer('qcsecretbotnonceval123qc', 'nonce');
1166 - $name = trim(sanitize_text_field(wp_unslash($_POST['name'])));
1167 - $phone =sanitize_text_field(wp_unslash($_POST['phone']));
1043 + $name = trim(sanitize_text_field($_POST['name']));
1044 + $phone =sanitize_text_field($_POST['phone']);
1168 1045 $subject = 'WPBot Support Mail Request for Call Back';
1169 1046 //Extract Domain
1170 1047 $url = get_site_url();
1171 - $url = wp_parse_url($url);
1048 + $url = parse_url($url);
1172 1049 $domain = $url['host'];
1173 1050 //$admin_email = "admin@" . $domain;
1174 1051 $admin_email = get_option('admin_email');
1175 1052 $toEmail = sanitize_email(get_option('qlcd_wp_chatbot_admin_email') != '' ? get_option('qlcd_wp_chatbot_admin_email') : $admin_email);
@@ -1207,9 +1084,9 @@
1207 1084 }
1208 1085 // Order Status part. removed
1209 1086
1210 1087 function wpb_randmom_message_handle($items){
1211 - return $items[wp_rand(0, count($items) - 1)];
1088 + return $items[rand(0, count($items) - 1)];
1212 1089 }
1213 1090 function qcld_wb_chatbot_func_str_replace($messages = array()){
1214 1091 $refined_mesgses = array();
1215 1092 foreach ($messages as $message) {
@@ -1224,10 +1101,10 @@
1224 1101 // First check the nonce, if it fails the function will break
1225 1102 check_ajax_referer('wpwbot-order-nonce', 'security');
1226 1103 // Nonce is checked, get the POST data and sign user on
1227 1104 $info = array();
1228 - $info['user_login'] = trim(sanitize_text_field(wp_unslash($_POST['user_name'])));
1229 - $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']));
1230 1107 $info['remember'] = true;
1231 1108 $user_signon = wp_signon($info, false);
1232 1109 $response = array();
1233 1110 if (is_wp_error($user_signon)) {
@@ -1283,9 +1160,9 @@
1283 1160 $order_url = '<a href="' . get_url(get_permalink(get_option('wpcommerce_myaccount_page_id')) . '/view-order/' . $order->ID) . '" target="_blank" >' . $order->ID . '</a>';
1284 1161 }
1285 1162 $order_html .= '<div class="wp-chatbot-orders-single">
1286 1163 <div class="order-id"> ' . $order_url . '</div>
1287 - <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>
1288 1165 <div class="order-items">';
1289 1166 $singleOrder = new WC_Order($order->ID);
1290 1167 $items = $singleOrder->get_items();
1291 1168 foreach ($items as $item) {
@@ -1385,9 +1262,9 @@
1385 1262 $html .= get_the_post_thumbnail(get_the_ID(), 'shop_catalog') . '
1386 1263 <div class="wp-chatbot-product-summary">
1387 1264 <div class="wp-chatbot-product-table">
1388 1265 <div class="wp-chatbot-product-table-cell">
1389 - <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>
1390 1267 <div class="price">' . $product->get_price_html() . '</div>';
1391 1268 $html .= ' </div>
1392 1269 </div>
1393 1270 </div></a>
@@ -1456,9 +1333,9 @@
1456 1333 $html .= get_the_post_thumbnail(get_the_ID(), 'shop_catalog') . '
1457 1334 <div class="wp-chatbot-product-summary">
1458 1335 <div class="wp-chatbot-product-table">
1459 1336 <div class="wp-chatbot-product-table-cell">
1460 - <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>
1461 1338 <div class="price">' . $product->get_price_html() . '</div>';
1462 1339 $html .= ' </div>
1463 1340 </div>
1464 1341 </div></a>
@@ -1632,12 +1509,11 @@
1632 1509 //Updating the cart items.
1633 1510 add_action('wp_ajax_qcld_wb_chatbot_update_cart_item_number', 'qcld_wb_chatbot_update_cart_item_number');
1634 1511 add_action('wp_ajax_nopriv_qcld_wb_chatbot_update_cart_item_number', 'qcld_wb_chatbot_update_cart_item_number');
1635 1512 function qcld_wb_chatbot_update_cart_item_number(){
1636 - check_ajax_referer( 'wp_chatbot', 'nonce' );
1637 1513 //getting cart items n
1638 - $cart_item_key = sanitize_text_field(wp_unslash($_POST['cart_item_key']));
1639 - $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']);
1640 1516 global $wpcommerce;
1641 1517 $result = $wpcommerce->cart->set_quantity($cart_item_key, $qnty);
1642 1518 wp_send_json($result);
1643 1519 }
@@ -1644,11 +1520,10 @@
1644 1520 //Show item after removing from cart page.
1645 1521 add_action('wp_ajax_qcld_wb_chatbot_cart_item_remove', 'qcld_wb_chatbot_cart_item_remove');
1646 1522 add_action('wp_ajax_nopriv_qcld_wb_chatbot_cart_item_remove', 'qcld_wb_chatbot_cart_item_remove');
1647 1523 function qcld_wb_chatbot_cart_item_remove(){
1648 - check_ajax_referer( 'wp_chatbot', 'nonce' );
1649 1524 //getting cart items n
1650 - $cart_item_key = sanitize_text_field(wp_unslash($_POST['cart_item']));
1525 + $cart_item_key = sanitize_text_field($_POST['cart_item']);
1651 1526 global $wpcommerce;
1652 1527 $result = $wpcommerce->cart->remove_cart_item($cart_item_key);
1653 1528 wp_send_json($result);
1654 1529 }
@@ -1704,9 +1579,9 @@
1704 1579
1705 1580 if(class_exists('Qcformbuilder_Forms_Admin')){
1706 1581
1707 1582
1708 - $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
1709 1584
1710 1585 if(!empty($results)){
1711 1586
1712 1587 foreach($results as $result){
@@ -1731,10 +1606,10 @@
1731 1606 // function qcld_wb_chatbot_checkout_user_login(){
1732 1607 // // Nonce is checked, get the POST data and sign user on
1733 1608 // $info = array();
1734 1609 // //$info['nonce'] = $_POST['nonce_val'];
1735 -// $info['user_login'] = trim(sanitize_text_field(wp_unslash($_POST['user_name'])));
1736 -// $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']));
1737 1612 // $info['remember'] = true;
1738 1613 // $user_signon = wp_signon($info, false);
1739 1614 // // $response=$info;
1740 1615 // $response = array();
@@ -1775,16 +1650,15 @@
1775 1650 add_action('init', 'wp_chatbot_create_app_checkout_thankyou_page');
1776 1651 function wp_chatbot_create_app_checkout_thankyou_page(){
1777 1652 if (get_option('wp_chatbot_app_pages') == 1) {
1778 1653 //Mobile App page create
1779 - $existing_app = new WP_Query( array( 'post_type' => 'page', 'name' => 'wpwbot-mobile-app', 'post_status' => 'publish', 'posts_per_page' => 1 ) );
1780 - if ( ! $existing_app->have_posts() ) {
1654 + if (get_page_by_title('wpwBot Mobile App') == NULL) {
1781 1655 //post status and options
1782 1656 $app_page = array(
1783 1657 'comment_status' => 'closed',
1784 1658 'ping_status' => 'closed',
1785 1659 'post_author' => get_current_user_id(),
1786 - 'post_date' => gmdate('Y-m-d H:i:s'),
1660 + 'post_date' => date('Y-m-d H:i:s'),
1787 1661 'post_status' => 'publish',
1788 1662 'post_title' => 'wpwBot Mobile App',
1789 1663 'post_name' => 'wpwbot-mobile-app',
1790 1664 'post_type' => 'page',
@@ -1794,16 +1668,15 @@
1794 1668 //save the id in the database
1795 1669 update_option('wp_chatbot_app_checkout', $wpwbot_app);
1796 1670 }
1797 1671 //App checkout page create
1798 - $existing_checkout = new WP_Query( array( 'post_type' => 'page', 'name' => 'wpwbot-app-checkout', 'post_status' => 'publish', 'posts_per_page' => 1 ) );
1799 - if ( ! $existing_checkout->have_posts() ) {
1672 + if (get_page_by_title('wpwBot App Checkout') == NULL) {
1800 1673 //post status and options
1801 1674 $checkout_page = array(
1802 1675 'comment_status' => 'closed',
1803 1676 'ping_status' => 'closed',
1804 1677 'post_author' => get_current_user_id(),
1805 - 'post_date' => gmdate('Y-m-d H:i:s'),
1678 + 'post_date' => date('Y-m-d H:i:s'),
1806 1679 'post_status' => 'publish',
1807 1680 'post_title' => 'wpwBot App Checkout',
1808 1681 'post_name' => 'wpwbot-app-checkout',
1809 1682 'post_type' => 'page',
@@ -1813,16 +1686,15 @@
1813 1686 //save the id in the database
1814 1687 update_option('wp_chatbot_app_checkout', $app_checkout);
1815 1688 }
1816 1689 //App Order thank you page create
1817 - $existing_thankyou = new WP_Query( array( 'post_type' => 'page', 'name' => 'wpwbot-app-order-thankyou', 'post_status' => 'publish', 'posts_per_page' => 1 ) );
1818 - if ( ! $existing_thankyou->have_posts() ) {
1690 + if (get_page_by_title('wpwBot App Order Thank You') == NULL) {
1819 1691 //post status and options
1820 1692 $thankyou_page = array(
1821 1693 'comment_status' => 'closed',
1822 1694 'ping_status' => 'closed',
1823 1695 'post_author' => get_current_user_id(),
1824 - 'post_date' => gmdate('Y-m-d H:i:s'),
1696 + 'post_date' => date('Y-m-d H:i:s'),
1825 1697 'post_status' => 'publish',
1826 1698 'post_title' => 'wpwBot App Order Thank You',
1827 1699 'post_name' => 'wpwbot-app-order-thankyou',
1828 1700 'post_type' => 'page',
@@ -1833,9 +1705,9 @@
1833 1705 update_option('wp_chatbot_app_order_thankyou', $app_order_thankyou);
1834 1706 }
1835 1707 }
1836 1708 //Keep tracking from App by cookies
1837 - 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') {
1838 1710 if (!isset($_COOKIE['from_app'])) {
1839 1711 setcookie('from_app', 'yes', (time() + 3600), '/');
1840 1712 }
1841 1713 }
@@ -1849,9 +1721,9 @@
1849 1721 global $wp;
1850 1722 if (is_checkout() && !empty($wp->query_vars['order-received'])) {
1851 1723 $thanks_page_id = get_option('wp_chatbot_app_order_thankyou');
1852 1724 $thanks_parmanlink = esc_url(get_permalink($thanks_page_id));
1853 - wp_safe_redirect($thanks_parmanlink . '?order_id=' . $order_get_id);
1725 + wp_redirect($thanks_parmanlink . '?order_id=' . $order_get_id);
1854 1726 exit;
1855 1727 }
1856 1728 } else {
1857 1729 remove_action('wpcommerce_thankyou', 'qcld_wb_chatbot__redirect_after_purchase');
@@ -1859,12 +1731,9 @@
1859 1731 }
1860 1732 }
1861 1733
1862 1734 function qcld_choose_random($array){
1863 - if (is_array($array) && !empty($array)) {
1864 - return $array[array_rand($array)];
1865 - }
1866 - return $array;
1735 + return $array[array_rand($array)];
1867 1736 }
1868 1737
1869 1738 //User session count
1870 1739 add_action('wp_ajax_qcld_wb_chatbot_session_count', 'qcld_wb_chatbot_session_count');
@@ -1877,22 +1746,22 @@
1877 1746 $tableuser = $wpdb->prefix.'wpbot_sessions';
1878 1747 $response = array();
1879 1748
1880 1749
1881 - $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
1882 1751
1883 1752 if(empty($session_exists)){
1884 - $wpdb->insert( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
1753 + $wpdb->insert(
1885 1754 $tableuser,
1886 1755 array(
1887 1756 'session' => 1,
1888 1757 )
1889 - );
1758 + ); //DB Call OK, No Caching OK
1890 1759 }else{
1891 1760
1892 1761 $session_id = $session_exists->id;
1893 1762
1894 - $wpdb->update( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
1763 + $wpdb->update(
1895 1764 $tableuser,
1896 1765 array(
1897 1766 'session'=>($session_exists->session+1),
1898 1767 ),
@@ -1900,9 +1769,9 @@
1900 1769 array(
1901 1770 '%d',
1902 1771 ),
1903 1772 array('%d')
1904 - );
1773 + ); //DB Call OK, No Caching OK
1905 1774
1906 1775 }
1907 1776
1908 1777 wp_send_json($response);
@@ -1910,9 +1779,9 @@
1910 1779
1911 1780 /* WPBot Chat History Addon check */
1912 1781 function qcld_wpbot_is_active_chat_history(){
1913 1782
1914 - 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' ) ){
1915 1784 return 1;
1916 1785 }else{
1917 1786 return 0;
1918 1787 }
@@ -1927,11 +1796,9 @@
1927 1796 return $data;
1928 1797 }
1929 1798 add_action('wp_ajax_qcld_small_talk_import', 'qcld_small_talk_import');
1930 1799 function qcld_small_talk_import(){
1931 - if ( ! current_user_can( 'manage_options' ) ) {
1932 - wp_die();
1933 - }
1800 +
1934 1801 global $wpdb;
1935 1802
1936 1803 $table = $wpdb->prefix.'wpbot_response';
1937 1804
@@ -1938,10 +1805,9 @@
1938 1805 $csvFile = file(QCLD_wpCHATBOT_PLUGIN_DIR_PATH . 'small_talk.csv');
1939 1806
1940 1807 foreach ($csvFile as $line) {
1941 1808 $line = str_getcsv($line, ',', '"');
1942 - $wpdb->insert( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
1943 - $table, array(
1809 + $wpdb->insert($table, array(
1944 1810 'query' => $line[0],
1945 1811 'keyword' => $line[1],
1946 1812 'response' => $line[2],
1947 1813 'category'=> $line[3],
@@ -1946,17 +1812,16 @@
1946 1812 'response' => $line[2],
1947 1813 'category'=> $line[3],
1948 1814 'intent'=> '',
1949 1815 //'lang'=> 'en_US',
1950 - ));
1816 + )); //DB Call OK, No Caching OK
1951 1817 }
1952 1818
1953 1819 $table2 = $wpdb->prefix.'wpbot_response_category';
1954 1820
1955 - $wpdb->insert( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
1956 - $table2, array(
1821 + $wpdb->insert($table2, array(
1957 1822 'name' => 'smalltalk',
1958 - ));
1823 + )); //DB Call OK, No Caching OK
1959 1824
1960 1825 update_option( 'qcld_small_talk_imported', 'yes' );
1961 1826
1962 1827 }
@@ -1984,15 +1849,11 @@
1984 1849 function qcld_change_language_from_center() {
1985 1850 if ( ! current_user_can( 'manage_options' ) ) {
1986 1851 wp_send_json_error( array( 'message' => 'Unauthorized.' ) );
1987 1852 }
1988 - $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : '';
1989 - if ( ! wp_verify_nonce( $nonce, 'wp_chatbot' ) ) {
1990 - wp_send_json_error( array( 'message' => 'Invalid nonce.' ) );
1991 - }
1992 1853 $plugin_path = plugin_dir_path( __FILE__ );
1993 1854 include $plugin_path . 'includes/admin/settings-fields.php';
1994 - $json_file_path = $plugin_path . 'includes/language-center.json';
1855 + $json_file_path = $plugin_path . 'includes/language center.json'; // Adjust path as needed
1995 1856
1996 1857 $json_string = file_get_contents( $json_file_path );
1997 1858 if ( isset( $_POST['language'] ) ) {
1998 1859 $language = sanitize_text_field( wp_unslash( $_POST['language'] ) );
@@ -2003,5 +1864,5 @@
2003 1864 wp_send_json_error( array( 'message' => 'Language not specified.' ) );
2004 1865
2005 1866 }
2006 1867 }
2007 -}
1868 +}