- : ' . esc_html($aiflt_alert['speed']) . 's' ); ?>
class_exists('AIFTAC_Logic'), 'aiftpo' => class_exists('AIFTPO_Logic'), 'aiftas' => class_exists('AIFTAS_Logic'), 'aiftal' => class_exists('AIFTAL_Logic'), 'aiftrp' => class_exists('AIFTRP_Logic'), 'aiftcr' => class_exists('AIFTCR_Logic'), 'aiftco' => class_exists('AIFTCO_Logic'), ]; $active_growth_count = count(array_filter($aiflt_growth_modules)); // Conditionally load data and set defaults if WooCommerce is inactive. if ($aiflt_is_wc_active) { // Load all necessary data from logic classes $aiflt_dashboard_metrics = AIFLT_Funnel_Analyzer_Logic::get_dashboard_metrics(); $aiflt_top_drop_off_metrics = AIFLT_Funnel_Analyzer_Logic::get_top_drop_off_metrics(); // --- REVISED: Load the correct report based on addon status --- if ($aiflt_is_ai_analysis_addon_active) { $aiflt_ai_report = get_transient('aiftaa_latest_full_report'); } else { $aiflt_ai_report = [ 'report' => __('Full AI analysis is available as an advanced feature. The free dashboard now provides local priority checks without requiring an API key.', 'ai-flash-tune'), 'next_available' => 0, ]; } $aiflt_low_performing_products = AIFLT_Products_Logic::get_low_performing_products_for_dashboard(); $aiflt_has_products = AIFLT_Products_Logic::has_any_products(); // ---> Check if products exist. $aiflt_checkout_detector_data = AIFLT_Funnel_Analyzer_Logic::get_checkout_field_data(); $aiflt_funnel_data = AIFLT_Funnel_Analyzer_Logic::get_funnel_data(); // Fetch initial funnel data $aiflt_page_speed_data = AIFLT_Funnel_Analyzer_Logic::get_page_speed_alerts(); } else { // If WooCommerce is inactive, provide safe, default values to prevent warnings. $aiflt_dashboard_metrics = [ 'total_sessions' => 'N/A', 'conversion_rate' => 'N/A', 'abandoned_carts' => 'N/A', 'page_speed' => 'N/A', 'last_updated' => __('WooCommerce is inactive', 'ai-flash-tune'), ]; $aiflt_top_drop_off_metrics = [ 'page_name' => 'N/A', 'drop_off_rate' => '0', 'ai_insights' => __('Activate WooCommerce to get AI insights.', 'ai-flash-tune'), 'rage_clicks' => '0', 'scroll_stops' => '0', 'quick_bounces' => '0', 'basic_suggestion' => __('Suggestions require live data from WooCommerce. Please activate the plugin to get started.', 'ai-flash-tune'), // ---> This line was already added, ensure it's present. ]; $aiflt_ai_report = [ 'report' => __('AI report requires live data from WooCommerce.', 'ai-flash-tune'), 'next_available' => '0', ]; $aiflt_low_performing_products = []; $aiflt_has_products = false; // ---> NEW: Set default for has_products. $aiflt_checkout_detector_data = [ 'css_class' => 'ai-flash-tune-text-gray-500', 'icon_class' => 'fas fa-question-circle', 'message' => __('Requires WooCommerce', 'ai-flash-tune'), 'status' => 'N/A', ]; $aiflt_funnel_data = ['is_empty' => true]; $aiflt_page_speed_data = ['status' => 'no_data', 'alerts' => []]; // 'no_data' status prevents the warning box from showing. } // Free-version insight layer: local guidance without requiring any external AI service. $aiflt_free_store_health = class_exists('AIFLT_Free_Insights_Logic') ? AIFLT_Free_Insights_Logic::get_store_health_score($aiflt_dashboard_metrics, $aiflt_funnel_data, $aiflt_page_speed_data, $aiflt_checkout_detector_data, $aiflt_low_performing_products) : ['score' => 0, 'label' => __('Unavailable', 'ai-flash-tune'), 'tone' => 'notice', 'summary' => '', 'factors' => []]; $aiflt_priority_checks = class_exists('AIFLT_Free_Insights_Logic') ? AIFLT_Free_Insights_Logic::get_priority_checks($aiflt_dashboard_metrics, $aiflt_funnel_data, $aiflt_page_speed_data, $aiflt_checkout_detector_data, $aiflt_low_performing_products) : []; $aiflt_tracking_health = class_exists('AIFLT_Free_Insights_Logic') ? AIFLT_Free_Insights_Logic::get_tracking_health() : ['items' => [], 'ready_count' => 0, 'total_count' => 0]; $aiflt_top_abandoned_products = ($aiflt_is_wc_active && class_exists('AIFLT_Free_Insights_Logic')) ? AIFLT_Free_Insights_Logic::get_top_abandoned_products(5, 30) : []; $aiflt_data_confidence = class_exists('AIFLT_Free_Insights_Logic') ? AIFLT_Free_Insights_Logic::get_data_confidence($aiflt_dashboard_metrics, $aiflt_funnel_data) : ['level' => __('Unavailable', 'ai-flash-tune'), 'tone' => 'notice', 'summary' => '', 'is_ready' => false, 'sessions' => 0, 'min_sessions' => 20, 'progress' => 0]; $aiflt_local_insight_snapshot = class_exists('AIFLT_Free_Insights_Logic') ? AIFLT_Free_Insights_Logic::get_local_insight_snapshot($aiflt_priority_checks, $aiflt_dashboard_metrics, $aiflt_funnel_data) : __('AI Flash Tune is collecting local conversion signals.', 'ai-flash-tune'); $aiflt_weekly_snapshot = class_exists('AIFLT_Free_Insights_Logic') ? AIFLT_Free_Insights_Logic::get_weekly_snapshot($aiflt_dashboard_metrics, $aiflt_funnel_data, $aiflt_page_speed_data) : ['title' => __('Weekly Store Snapshot', 'ai-flash-tune'), 'text' => '', 'tone' => 'notice']; $aiflt_tracking_test_steps = class_exists('AIFLT_Free_Insights_Logic') ? AIFLT_Free_Insights_Logic::get_tracking_test_steps() : []; $aiflt_top_priority = !empty($aiflt_priority_checks[0]) ? $aiflt_priority_checks[0] : [ 'title' => __('Run a clean funnel tracking test', 'ai-flash-tune'), 'description' => __('Visit product, cart, and checkout once so AI Flash Tune can confirm tracking quality before suggesting changes.', 'ai-flash-tune'), 'action_url' => admin_url('admin.php?page=funnelanalysis'), 'action_label' => __('Open Funnel Analysis', 'ai-flash-tune'), 'tone' => 'notice', 'icon' => 'fas fa-route', ]; $aiflt_command_actions = [ [ 'label' => __('Review funnel leaks', 'ai-flash-tune'), 'url' => admin_url('admin.php?page=funnelanalysis'), 'icon' => 'fas fa-route', ], [ 'label' => __('Optimize products', 'ai-flash-tune'), 'url' => admin_url('admin.php?page=products'), 'icon' => 'fas fa-box-open', ], [ 'label' => __('Recover carts', 'ai-flash-tune'), 'url' => admin_url('admin.php?page=abandonedcarts'), 'icon' => 'fas fa-shopping-cart', ], ]; ?>