PluginProbe
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services / 8.8.0
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services v8.8.0
8.8.0 8.7.9 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 All 536 releases
← All changes | includes/chat-sessions/wpbot-chat-sessions.php +105 -60 8.7.4 → 8.8.0 View file →
@@ -49,74 +49,110 @@
49 49
50 50 // ─── Admin Menu ───────────────────────────────────────────────────────────────
51 51 add_action( 'admin_menu', 'qcwp_chat_session_menu_fnc_free' );
52 52
53 -function qcwp_chat_session_menu_fnc_free() {
53 + function qcwp_chat_session_menu_fnc_free() {
54 + // All menu registration is now handled by chatbot (qcld-wpwbot.php)
55 + // We no longer register submenus here to keep the sidebar clean.
56 + }
54 57
55 - $capability = function_exists( 'qcld_wpbot_get_menu_capability' ) ? qcld_wpbot_get_menu_capability( 'sessions' ) : 'manage_options';
58 + function qc_wpbot_cs_tabbed_wrapper() {
59 + $active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : 'sessions';
56 60
57 - if ( current_user_can( $capability ) ) {
61 + $tabs = array(
62 + 'sessions' => array(
63 + 'label' => __( 'Chat Sessions', 'wpbot-chat-history' ),
64 + 'icon' => 'dashicons-format-chat',
65 + ),
66 + 'not-answered' => array(
67 + 'label' => __( 'Questions Not Answered', 'wpbot-chat-history' ),
68 + 'icon' => 'dashicons-editor-help',
69 + ),
70 + 'ai-insight' => array(
71 + 'label' => __( 'AI Insight', 'wpbot-chat-history' ),
72 + 'icon' => 'dashicons-lightbulb',
73 + ),
74 + );
58 75
59 - add_menu_page(
60 - 'WPBot - Sessions & Analytics',
61 - 'WPBot - Sessions & Analytics',
62 - $capability,
63 - 'wbcs-botsessions-page',
64 - 'qc_wpbot_cs_menu_page_callback_func',
65 - 'dashicons-chart-bar',
66 - '9'
67 - );
76 + if ( function_exists( 'qcpdcs_is_woowbot_active' ) && qcpdcs_is_woowbot_active() ) {
77 + $tabs['woowbot-sessions'] = array(
78 + 'label' => __( 'ChatBot Sessions', 'wpbot-chat-history' ),
79 + 'icon' => 'dashicons-cart',
80 + );
81 + }
68 82
69 - add_submenu_page(
70 - 'wbcs-botsessions-page',
71 - 'Questions Not Answered',
72 - 'Questions Not Answered',
73 - $capability,
74 - 'wbcs-botsessions-notansweredpage',
75 - 'qcld_wpbot_not_answered_question'
76 - );
83 + ?>
84 + <div class="wrap qcld-main-wrapper qcld-chat-sessions-wrap">
85 + <h1 style="display:none"><?php esc_html_e( 'Chat Sessions', 'wpbot-chat-history' ); ?></h1>
77 86
78 - add_submenu_page(
79 - 'wbcs-botsessions-page',
80 - 'AI Insight',
81 - 'AI Insight',
82 - $capability,
83 - 'wbcs-schedule-session-reporting',
84 - 'qcld_wpbot_schedule_session_reporting'
85 - );
87 + <div class="qcld-wp-chatbot-wrap-header">
88 + <div class="qcld-wp-chatbot-wrap-header-logo">
89 + <a href="#" class="qcld-wp-chatbot-wrap-site__logo">
90 + <img src="<?php echo esc_url( QCLD_wpCHATBOT_IMG_URL . '/chatbot.png' ); ?>" alt="WPBot"> WPBot Control Panel
91 + </a>
92 + <p><strong>Core Version:</strong> v<?php echo esc_html( QCLD_wpCHATBOT_VERSION ); ?></p>
93 + </div>
94 + <ul class="qcld-wp-chatbot-wrap-version-wrapper">
95 + <li>
96 + <a class="wpchatbot-Upgrade" href="https://www.wpbot.pro/" target="_blank"><?php esc_html_e( 'Upgrade To Pro', 'chatbot' ); ?></a>
97 + </li>
98 + </ul>
99 + </div>
100 +
101 + <div class="qcld-wp-chatbot-wrap-header_inn qcld-chat-sessions-header">
102 + <div class="qcld-wp-chatbot-wrap-header_inn_heading">
103 + <h1 class="wp-heading-inline"><?php esc_html_e( 'Sessions & Analytics', 'wpbot-chat-history' ); ?></h1>
104 + </div>
105 + <nav class="nav-tab-wrapper qcld-chat-sessions-tabs">
106 + <?php foreach ( $tabs as $tab_id => $tab ) : ?>
107 + <a href="<?php echo esc_url( admin_url( 'admin.php?page=wbcs-botsessions-page&tab=' . rawurlencode( $tab_id ) ) ); ?>" class="nav-tab <?php echo $active_tab === $tab_id ? 'nav-tab-active' : ''; ?>">
108 + <span class="dashicons <?php echo esc_attr( $tab['icon'] ); ?>"></span>
109 + <span><?php echo esc_html( $tab['label'] ); ?></span>
110 + </a>
111 + <?php endforeach; ?>
112 + </nav>
113 + </div>
114 +
115 + <div class="qcld-chat-sessions-tab-content">
116 + <?php
117 + switch ( $active_tab ) {
118 + case 'not-answered':
119 + if ( function_exists( 'qcld_wpbot_not_answered_question' ) ) {
120 + qcld_wpbot_not_answered_question();
121 + }
122 + break;
123 + case 'ai-insight':
124 + if ( function_exists( 'qcld_wpbot_schedule_session_reporting' ) ) {
125 + qcld_wpbot_schedule_session_reporting();
126 + }
127 + break;
128 + case 'woowbot-sessions':
129 + if ( function_exists( 'woowbot_cs_menu_page_callback_func' ) ) {
130 + woowbot_cs_menu_page_callback_func();
131 + }
132 + break;
133 + case 'sessions':
134 + default:
135 + if ( function_exists( 'qc_wpbot_cs_menu_page_callback_func' ) ) {
136 + qc_wpbot_cs_menu_page_callback_func();
137 + }
138 + break;
139 + }
140 + ?>
141 + </div>
142 + </div>
143 + <?php
86 144 }
87 -}
88 145
89 146 // ─── Admin Scripts & Styles ───────────────────────────────────────────────────
90 147 add_action( 'admin_enqueue_scripts', 'qcld_wb_chatbot_session_admin_scripts_free' );
91 148
92 149 function qcld_wb_chatbot_session_admin_scripts_free( $hook ) {
93 - // WordPress generates hook suffixes as follows:
94 - // top-level page → toplevel_page_{slug}
95 - // sub-pages → {parent-menu-title}_page_{slug} (title, lowercased, spaces→hyphens)
96 - // Our parent title is "WPBot Sessions & Analytics" → "wpbot-sessions-analytics"
97 - $session_hooks = array(
98 - 'toplevel_page_wbcs-botsessions-page',
99 - 'wpbot-sessions-analytics_page_wbcs-botsessions-notansweredpage',
100 - 'wpbot-sessions-analytics_page_wbcs-botsessions-reports',
101 - 'wpbot-sessions-analytics_page_wbcs-schedule-session-reporting',
102 - );
103 - $is_session_page = false;
104 - foreach ( $session_hooks as $session_hook ) {
105 - if ( strpos( $hook, $session_hook ) !== false || ( isset( $_GET['page'] ) && $_GET['page'] === str_replace( 'toplevel_page_', '', $session_hook ) ) ) {
106 - $is_session_page = true;
107 - break;
150 + // Only enqueue on our specific sessions page
151 + if ( ! isset( $_GET['page'] ) || 'wbcs-botsessions-page' !== $_GET['page'] ) {
152 + return;
108 153 }
109 - }
110 -
111 - if ( isset( $_GET['page'] ) && in_array( $_GET['page'], array( 'wbcs-botsessions-page', 'wbcs-botsessions-notansweredpage', 'wbcs-botsessions-reports', 'wbcs-schedule-session-reporting' ) ) ) {
112 - $is_session_page = true;
113 - }
114 154
115 - if ( ! $is_session_page ) {
116 - return;
117 - }
118 -
119 155 wp_register_style( 'qlcd-wp-bootstrap-cs', QCLD_CHATBOT_FREE_SESSION_PLUGIN_URL . 'css/qlcd-wp-bootstrap.css', array(), QCLD_wpCHATBOT_VERSION, 'screen' );
120 156 wp_enqueue_style( 'qlcd-wp-bootstrap-cs' );
121 157
122 158 wp_register_style( 'qlcd-wp-bootstrap-icons-cs', QCLD_CHATBOT_FREE_SESSION_PLUGIN_URL . 'css/qlcd-wp-bootstrap-icons.css', array(), QCLD_wpCHATBOT_VERSION, 'screen' );
@@ -127,8 +163,11 @@
127 163
128 164 wp_register_style( 'qlcd-wp-session-style-cs', QCLD_CHATBOT_FREE_SESSION_PLUGIN_URL . 'reports/view/assets/style.css', array(), QCLD_wpCHATBOT_VERSION, 'screen' );
129 165 wp_enqueue_style( 'qlcd-wp-session-style-cs' );
130 166
167 + wp_register_style( 'qcld-wp-chatbot-history-style', QCLD_CHATBOT_FREE_SESSION_PLUGIN_URL . 'css/history-style.css', array( 'qlcd-wp-chatbot-admin-style' ), QCLD_wpCHATBOT_VERSION, 'screen' );
168 + wp_enqueue_style( 'qcld-wp-chatbot-history-style' );
169 +
131 170 // SweetAlert2 — used by admin.js for Swal.fire() and Swal.showLoading()
132 171 wp_register_script( 'qcld-wp-chatbot-sweetalrt-cs', QCLD_wpCHATBOT_PLUGIN_URL . 'js/sweetalrt.js', array( 'jquery' ), QCLD_wpCHATBOT_VERSION, true );
133 172 wp_enqueue_script( 'qcld-wp-chatbot-sweetalrt-cs' );
134 173
@@ -365,9 +404,9 @@
365 404 ?>
366 405 </div>
367 406
368 407
369 - <form id="wpcs_form_sessions" action="<?php echo esc_url( $mainurl ); ?>" method="POST" style="width:98%">
408 + <form id="wpcs_form_sessions" action="<?php echo esc_url( $mainurl ); ?>" method="POST">
370 409 <?php wp_nonce_field( 'wpcs_bulk_action' ); ?>
371 410 <input type="hidden" name="wpbot_session_remove" />
372 411
373 412 <?php if ( ! empty( $result ) ) : ?>
@@ -500,14 +539,20 @@
500 539
501 540 global $wpdb;
502 541 $tableuser = $wpdb->prefix . 'wpbot_user';
503 542 $table_sql = esc_sql( $tableuser );
504 - $user_exists = $wpdb->get_var(
505 - $wpdb->prepare(
506 - 'SELECT id FROM `' . $table_sql . '` WHERE email = %s LIMIT 1', // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
507 - $to
508 - )
509 - ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
543 + $cache_key = 'wpbot_user_email_' . md5( $to );
544 + $user_exists = wp_cache_get( $cache_key, 'wpbot' );
545 + if ( false === $user_exists ) {
546 + $user_exists = $wpdb->get_var( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
547 + $wpdb->prepare(
548 + 'SELECT id FROM `' . $table_sql . '` WHERE email = %s LIMIT 1', // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
549 + $to
550 + )
551 + );
552 + wp_cache_set( $cache_key, $user_exists, 'wpbot', 60 );
553 + }
554 +
510 555 $admin_email = get_option('admin_email');
511 556 if ( ! $user_exists && $to !== $admin_email ) {
512 557 wp_send_json( array( 'status' => 'fail', 'message' => 'Invalid recipient address. Email must be a stored session email or admin email.' ) );
513 558 }