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 ); } } public function add_menu() { // Main menu add_menu_page( __( 'AI Assistant', 'aica-smart-ai-commerce-assistant' ), __( 'AI Assistant', 'aica-smart-ai-commerce-assistant' ), 'manage_options', 'aica-smart-ai-commerce-assistant', array( $this, 'render_dashboard' ), 'dashicons-format-chat', 58 ); // Dashboard submenu 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' ) ); // Settings submenu 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' ) ); // Index Products submenu 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' ) ); // Analytics submenu 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() { // Support & Hire Me submenu (last position) 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' ) ); } 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 ); ?>

📊

Conversations

💬

Messages Sent

✉️

Avg: per conv.

Recommended

📦

Products shown to users

Cart Additions

🛒

%

⏱️

m

🏆

📦

📉

💡

""

💬

👋

💼

  • ✓
  • ✓
  • ✓
  • ✓
  • ✓
💼

💳

🔵

⭐

🚀

💡

🛠️

🤝

→