( new C7DBT_Shop_Routes() )->status(), 'redirects' => ( new C7DBT_Redirects() )->status(), 'menus' => ( new C7DBT_Menu_Scanner() )->status(), 'content' => ( new C7DBT_Content_Scanner() )->status(), 'conflicts' => ( new C7DBT_Conflicts() )->status(), 'branding' => ( new C7DBT_Brand_Kit() )->status(), 'visual' => ( new C7DBT_Visual_Match() )->status(), 'prelaunch' => ( new C7DBT_Prelaunch() )->status(), 'site_qa' => ( new C7DBT_Site_QA() )->status(), 'security' => ( new C7DBT_Security() )->status(), ); $cards = array( 'shop' => $this->aggregate_card( __( 'Shop Setup', '7labs-debug-branding-for-commerce7' ), array( $raw['shop'], $raw['redirects'] ), __( 'Collection slug, shop link, and live shop URL.', '7labs-debug-branding-for-commerce7' ) ), 'site' => $this->aggregate_card( __( 'Menus & Fixes', '7labs-debug-branding-for-commerce7' ), array( $raw['menus'], $raw['content'], $raw['conflicts'] ), __( 'Navigation links, content scan, and integration conflicts.', '7labs-debug-branding-for-commerce7' ) ), 'design' => $this->aggregate_card( __( 'Design', '7labs-debug-branding-for-commerce7' ), array( $raw['branding'], $raw['visual'] ), __( 'Brand Kit overrides and theme color match.', '7labs-debug-branding-for-commerce7' ) ), 'launch' => $this->aggregate_card( __( 'Launch & QA', '7labs-debug-branding-for-commerce7' ), array( $raw['prelaunch'], $raw['site_qa'], $raw['security'] ), __( 'Pre-launch checklist, live HTTP smoke tests, and security basics.', '7labs-debug-branding-for-commerce7' ) ), ); $score = 100; foreach ( $cards as $card ) { if ( 'error' === $card['status'] ) { $score -= 15; } elseif ( 'warn' === $card['status'] ) { $score -= 8; } } $score = max( 0, min( 100, $score ) ); $overall = 'ok'; if ( $score < 55 ) { $overall = 'error'; } elseif ( $score < 85 ) { $overall = 'warn'; } return array( 'score' => $score, 'overall' => $overall, 'cards' => $cards, 'raw' => $raw, 'c7wp' => C7DBT_Helpers::is_c7wp_active(), ); } /** * Merge multiple status arrays into one dashboard card. * * @param string $label Card title. * @param array $statuses Status arrays. * @param string $ok_detail Detail when all OK. * @return array */ private function aggregate_card( $label, array $statuses, $ok_detail ) { $priority = array( 'error' => 3, 'warn' => 2, 'ok' => 1, ); $worst = 'ok'; $issues = array(); foreach ( $statuses as $status ) { if ( empty( $status['status'] ) ) { continue; } $current = $status['status']; if ( isset( $priority[ $current ] ) && $priority[ $current ] > $priority[ $worst ] ) { $worst = $current; } if ( 'ok' !== $current ) { $issues[] = isset( $status['label'] ) ? $status['label'] : ''; } } $issues = array_filter( array_unique( $issues ) ); if ( empty( $issues ) ) { $detail = $ok_detail; } else { $detail = implode( ' ยท ', $issues ); } return array( 'status' => $worst, 'label' => $label, 'detail' => $detail, ); } }