item( 'c7wp', __( 'Commerce7 integration connected', '7labs-debug-branding-for-commerce7' ), C7DBT_Helpers::is_c7wp_active(), __( 'Connect your Commerce7 tenant in your site’s Commerce7 settings, then return here.', '7labs-debug-branding-for-commerce7' ) ); $structure = get_option( 'permalink_structure' ); $items[] = $this->item( 'permalinks', __( 'Pretty permalinks enabled', '7labs-debug-branding-for-commerce7' ), ! empty( $structure ), __( 'Settings → Permalinks → Post name → Save.', '7labs-debug-branding-for-commerce7' ) ); $items[] = $this->item( 'collection_slug', __( 'Default collection slug set', '7labs-debug-branding-for-commerce7' ), (bool) $slug, __( 'Open Shop & Redirects and enter your collection slug (e.g. wines).', '7labs-debug-branding-for-commerce7' ) ); $items[] = $this->item( 'redirect', __( '/collection redirects to live shop', '7labs-debug-branding-for-commerce7' ), ! empty( $settings['redirect_collection_root'] ) && (bool) $slug, __( 'Enable collection root redirect on Shop & Redirects.', '7labs-debug-branding-for-commerce7' ) ); $shop_ok = false; if ( $slug ) { $shop_ok = (bool) get_page_by_path( 'collection' ); } $items[] = $this->item( 'collection_page', __( 'Collection route page exists', '7labs-debug-branding-for-commerce7' ), $shop_ok, __( 'Create a published /collection page with the Commerce7 default content block.', '7labs-debug-branding-for-commerce7' ) ); foreach ( array( 'cart', 'checkout' ) as $req ) { $items[] = $this->item( 'page_' . $req, sprintf( /* translators: %s: page slug */ __( '/%s page exists', '7labs-debug-branding-for-commerce7' ), $req ), (bool) get_page_by_path( $req ), __( 'Create a published page with that slug and the Commerce7 default content block.', '7labs-debug-branding-for-commerce7' ) ); } $menu_issues = ( new C7DBT_Menu_Scanner() )->find_issues(); $items[] = $this->item( 'menus', __( 'No empty shop links in menus', '7labs-debug-branding-for-commerce7' ), 0 === count( $menu_issues ), __( 'Open Menus & Conflicts and click Fix all menu links.', '7labs-debug-branding-for-commerce7' ) ); $content_issues = ( new C7DBT_Content_Scanner() )->find_issues(); $items[] = $this->item( 'content_links', __( 'No empty shop links in page content', '7labs-debug-branding-for-commerce7' ), 0 === count( $content_issues ), __( 'Open Menus & Conflicts and review flagged page content.', '7labs-debug-branding-for-commerce7' ) ); $checkout = get_page_by_path( 'checkout' ); $el_bad = false; if ( $checkout ) { $el_bad = 'builder' === get_post_meta( $checkout->ID, '_elementor_edit_mode', true ); } $items[] = $this->item( 'checkout_builder', __( 'Checkout is not Elementor full-builder', '7labs-debug-branding-for-commerce7' ), ! $el_bad, __( 'Elementor on checkout often breaks C7 modals — use block editor + default content.', '7labs-debug-branding-for-commerce7' ), false, true ); $plugin_conflicts = array_filter( ( new C7DBT_Conflicts() )->find_issues(), static function ( $issue ) { return ! empty( $issue['type'] ) && in_array( $issue['type'], array( 'cache_plugin', 'redirect_plugin', 'multilingual', 'consent_gate' ), true ); } ); $items[] = $this->item( 'plugin_conflicts', __( 'No cache/redirect/multilingual plugin conflicts', '7labs-debug-branding-for-commerce7' ), 0 === count( $plugin_conflicts ), __( 'Open Menus & Conflicts — cache, SEO redirects, multilingual, or consent plugins may need developer configuration.', '7labs-debug-branding-for-commerce7' ), true, count( $plugin_conflicts ) > 0 ); $brand_on = ! empty( $settings['branding_enabled'] ); $filled = 0; foreach ( $settings['brand'] as $v ) { if ( '' !== (string) $v ) { ++$filled; } } $items[] = $this->item( 'branding', __( 'Brand Kit has overrides (optional but recommended)', '7labs-debug-branding-for-commerce7' ), $brand_on && $filled > 0, __( 'Match theme colors so Add to Cart buttons don’t clash with Elementor.', '7labs-debug-branding-for-commerce7' ), true ); $visual = ( new C7DBT_Visual_Match() )->get_conflicts(); $mismatches = array_filter( $visual, static function ( $i ) { return 'mismatch' === $i['status']; } ); $items[] = $this->item( 'visual', __( 'No critical visual mismatches', '7labs-debug-branding-for-commerce7' ), 0 === count( $mismatches ), __( 'Open Design and match theme colors.', '7labs-debug-branding-for-commerce7' ), true ); $passed = 0; $failed = 0; foreach ( $items as $item ) { if ( $item['pass'] ) { ++$passed; } elseif ( empty( $item['optional'] ) ) { ++$failed; } } return array( 'passed' => $passed, 'failed' => $failed, 'items' => $items, 'ready' => 0 === $failed, ); } /** * Build checklist item. * * @param string $id ID. * @param string $label Label. * @param bool $pass Pass. * @param string $fix Fix hint. * @param bool $optional Optional. * @param bool $needs_dev Usually needs a developer. * @return array */ private function item( $id, $label, $pass, $fix, $optional = false, $needs_dev = false ) { return array( 'id' => $id, 'label' => $label, 'pass' => (bool) $pass, 'fix' => $fix, 'optional' => (bool) $optional, 'needs_dev' => (bool) $needs_dev, ); } /** * Dashboard status. * * @return array */ public function status() { $report = $this->run(); if ( $report['ready'] ) { return array( 'status' => 'ok', 'label' => __( 'Ready to launch', '7labs-debug-branding-for-commerce7' ), 'detail' => sprintf( /* translators: %d: passed checks */ __( '%d checks passed. Safe to send campaign traffic.', '7labs-debug-branding-for-commerce7' ), $report['passed'] ), ); } return array( 'status' => 'warn', 'label' => __( 'Not ready to launch', '7labs-debug-branding-for-commerce7' ), 'detail' => sprintf( /* translators: %d: failed checks */ _n( '%d required check failed.', '%d required checks failed.', $report['failed'], '7labs-debug-branding-for-commerce7' ), $report['failed'] ), 'count' => $report['failed'], ); } }