id, 'aica-smart-ai-commerce-assistant-indexer' ) !== false ) { wp_enqueue_script( 'aica-admin-indexer', AICA_PLUGIN_URL . 'assets/js/admin-indexer.js', array( 'jquery' ), AICA_VERSION, true ); wp_localize_script( 'aica-admin-indexer', 'aicaIndexer', array( 'nonce' => wp_create_nonce( 'aica_indexer' ), 'i18n' => array( 'indexing' => __( 'Indexing...', 'aica-smart-ai-commerce-assistant' ), 'starting' => __( 'Starting indexing process...', 'aica-smart-ai-commerce-assistant' ), 'reindex' => __( 'Re-index Products', 'aica-smart-ai-commerce-assistant' ), 'unknownError' => __( 'Unknown error occurred', 'aica-smart-ai-commerce-assistant' ), 'startIndexing' => __( 'Start Indexing', 'aica-smart-ai-commerce-assistant' ), 'connectionFail' => __( 'Connection failed. Please check your internet connection.', 'aica-smart-ai-commerce-assistant' ), ), ) ); } // Analytics Page if ( strpos( $screen->id, 'aica-smart-ai-commerce-assistant-analytics' ) !== false ) { wp_enqueue_script( 'aica-admin-analytics', AICA_PLUGIN_URL . 'assets/js/admin-analytics.js', array( 'jquery' ), AICA_VERSION, true ); wp_localize_script( 'aica-admin-analytics', 'aicaAnalytics', array( 'adminUrl' => admin_url( 'admin.php?page=aica-smart-ai-commerce-assistant-analytics' ), ) ); wp_enqueue_style( 'aica-admin-analytics', AICA_PLUGIN_URL . 'assets/css/admin-analytics.css', array(), AICA_VERSION ); } } /** * Register the admin menu and submenus * * @return void */ public function register_menu() { $icon_svg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48cGF0aCBmaWxsPSJjdXJyZW50Q29sb3IiIGQ9Ik0xMjMuNiAzOTEuM2MxMi45LTkuNCAyOS42LTExLjggNDQuNi02LjRjMjYuNSA5LjYgNTYuMiAxNS4xIDg3LjggMTUuMWMxMjQuNyAwIDIwOC04MC41IDIwOC0xNjBzLTgzLjMtMTYwLTIwOC0xNjBTNDggMTYwLjUgNDggMjQwYzAgMzIgMTIuNCA2Mi44IDM1LjEgODguOWMxMC4zIDExLjggMTIuOCAyOC41IDYuNCA0My4xYy02LjEgMTQtMTQuOCAyNi43LTI1LjkgMzguMWMtOC45IDkuMS0xMi43IDIxLjYtMTAuMyAzNHMxMiAyMS45IDI0LjMgMjUuMWM1NC43IDE0LjEgMTAwLjItMi4xIDEzMy40LTE4LjRjMS4xLS41IDIuMi0xIDMuMi0xLjV6TTI1NiA0MDBjLTMzLjEgMC02NC4zLTYuMi05Mi43LTE3LjVjLTMuMS0xLjItNi41LTEuNC05LjctLjZjLTMxIDcuNi02My41IDE0LjUtOTUuMyAxNy41YzEwLjEtMjQuMyAyMC4zLTUxLjUgMjUuNC04MC4xYzEtNS43LTEuMS0xMS40LTUuNS0xNUMzOC41IDI3MS40IDE2IDIzMC4xIDE2IDE4NS42QzE2IDEwMC4zIDEyMC4zIDMyIDI0OC42IDMyUzQ4MS4xIDEwMC4zIDQ4MS4xIDE4NS42QzQ4MS4xIDI3MC45IDM3Ni44IDMzOS4yIDI0OC42IDMzOS4yek0xNjAgMTkyYTMyIDMyIDAgMSAxIDY0IDAgMzIgMzIgMCAxIDEgLTY0IDB6bTk2IDMyYTMyIDMyIDAgMSAxIDAtNjQgMzIgMzIgMCAxIDEgMCA2NHptMTI4LTMyYTMyIDMyIDAgMSAxIC02NCAwIDMyIDMyIDAgMSAxIDY0IDB6Ii8+PC9zdmc+'; add_menu_page( __( 'AICA Assistant', 'aica-smart-ai-commerce-assistant' ), __( 'AICA Assistant', 'aica-smart-ai-commerce-assistant' ), 'manage_options', 'aica-smart-ai-commerce-assistant', array( $this, 'render_dashboard' ), $icon_svg, 58 ); add_submenu_page( 'aica-smart-ai-commerce-assistant', __( 'Dashboard', 'aica-smart-ai-commerce-assistant' ), __( 'Dashboard', 'aica-smart-ai-commerce-assistant' ), 'manage_options', 'aica-smart-ai-commerce-assistant', array( $this, 'render_dashboard' ) ); add_submenu_page( 'aica-smart-ai-commerce-assistant', __( 'Settings', 'aica-smart-ai-commerce-assistant' ), __( 'Settings', 'aica-smart-ai-commerce-assistant' ), 'manage_options', 'aica-smart-ai-commerce-assistant-settings', array( AICA_Admin_Settings::get_instance(), 'render_settings_page' ) ); add_submenu_page( 'aica-smart-ai-commerce-assistant', __( 'Index Products', 'aica-smart-ai-commerce-assistant' ), __( 'Index Products', 'aica-smart-ai-commerce-assistant' ), 'manage_options', 'aica-smart-ai-commerce-assistant-indexer', array( $this, 'render_indexer_page' ) ); add_submenu_page( 'aica-smart-ai-commerce-assistant', __( 'Analytics', 'aica-smart-ai-commerce-assistant' ), __( 'Analytics', 'aica-smart-ai-commerce-assistant' ), 'manage_options', 'aica-smart-ai-commerce-assistant-analytics', array( $this, 'render_analytics_page' ) ); } /** * Add Support & Hire Me menu (separate hook with priority 99 to ensure it's last). * * @return void */ public function add_support_menu() { add_submenu_page( 'aica-smart-ai-commerce-assistant', __( 'Support & Hire Me', 'aica-smart-ai-commerce-assistant' ), __( 'Support & Hire Me', 'aica-smart-ai-commerce-assistant' ), 'manage_options', 'aica-smart-ai-commerce-assistant-support', array( $this, 'render_support_page' ) ); } /** * Render dashboard page */ public function render_dashboard() { global $wpdb; // Get stats with caching $cached_stats = wp_cache_get( 'aica_dashboard_summary_stats', 'aica_admin' ); if ( false === $cached_stats ) { // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $total_conversations = $wpdb->get_var( "SELECT COUNT(DISTINCT session_id) FROM {$wpdb->prefix}aica_conversations" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $total_messages = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}aica_conversations" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $indexed_products = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}aica_indexed_products" ); $cached_stats = array( 'total_conversations' => $total_conversations, 'total_messages' => $total_messages, 'indexed_products' => $indexed_products, ); wp_cache_set( 'aica_dashboard_summary_stats', $cached_stats, 'aica_admin', HOUR_IN_SECONDS ); } $total_conversations = $cached_stats['total_conversations']; $total_messages = $cached_stats['total_messages']; $indexed_products = $cached_stats['indexed_products']; ?>

👋

💬

✉️

📦

⚡

⚙️ 🔄 📊

🚀

🔄

get_stats(); ?>

📊

%

⚡

💡

get_dashboard_stats( $period ); $engagement = $analytics->get_engagement_metrics( $period ); $top_products = $analytics->get_top_products( 5, $period ); $popular_queries = $analytics->get_popular_queries( 10, $period ); ?>

📊

💬

✉️

📦

🛒

%

⏱️

m

🏆

📦

📉

💡

""

💬

👋

💼

  • ✓
  • ✓
  • ✓
  • ✓
  • ✓
✉️

caruzza@tiscali.it

💳

🔵

⭐

🚀

💡

🛠️

🤝

→