';
if(!get_option('seoai_site_token','')){
echo '
Connect this website to see its search performance, keyword visibility, SEO health and AI presence.
Connect AI4Ranks';return;
}
$data=AI4Ranks_Overview::data();
AI4Ranks_Overview::optimization_button($data);
if(!is_array($data) || !isset($data['cards']) || !is_array($data['cards'])){
echo 'Reports are temporarily unavailable. Your saved settings are unchanged.
Open Overview →';return;
}
$cards=array_slice($data['cards'],0,4);$ready=0;
foreach($cards as $card)if(isset($card['value']) && is_numeric($card['value']))$ready++;
echo ''.esc_html(wp_parse_url(home_url(),PHP_URL_HOST)).''.esc_html($ready.' / '.count($cards).' reports').'
';
if(!empty($data['demo_data']))echo 'Demo data
';
echo ''.esc_html($ready===0?'Connect your data sources to start monitoring this website.':($ready===count($cards)?'All four reports are available. Review the latest signals below.':'Some reports are available. Complete the remaining connections for a fuller picture.')).'
';
$allowed=array('/dashboard/performance','/dashboard/keywords','/dashboard/site-audit','/dashboard/llm-visibility');
foreach($cards as $card){
$value=$card['value']??null;$valid=null!==$value && is_numeric($value);
$path=in_array($card['path']??'', $allowed,true)?$card['path']:'/dashboard';
echo '
'.esc_html($card['label']??'Website metric').'
'.($valid?esc_html(number_format_i18n((float)$value,floor((float)$value)==(float)$value?0:1).($card['suffix']??'')):'—').''.esc_html($card['detail']??'Report not available yet.').'
'.($valid?'View report':'Set up report').' ↗';
}
echo '
';
}
}
AI4Ranks_Dashboard_Widget::init();