>, required_done: int, required_total: int, done: int, total: int} */ public static function steps(): array { $options = \AiRankSuite\Kernel::service( Options::class ); try { $ai = \AiRankSuite\Kernel::service( \AiRankSuite\Modules\Ai\Services\AiClient::class )->has_key(); } catch ( \Throwable $e ) { $ai = false; } $schema = (array) $options->get( 'schema', array() ); $local = (array) $options->get( 'local_seo', array() ); $identity = (array) ( $schema['identity'] ?? array() ); $business = '' !== trim( (string) ( $schema['org_name'] ?? '' ) ) || '' !== trim( (string) ( $identity['description'] ?? '' ) ) || '' !== trim( (string) ( $local['name'] ?? '' ) ); $gsc = is_array( get_option( 'airanksuite_gsc_tokens' ) ); $analytics = (array) $options->get( 'analytics', array() ); $has_ga = '' !== trim( (string) ( $analytics['ga4_id'] ?? $analytics['measurement_id'] ?? '' ) ); $bing = is_array( get_option( 'airanksuite_bing_tokens' ) ) || '' !== trim( (string) ( ( (array) $options->get( 'bing', array() ) )['api_key'] ?? '' ) ); $audit_run = (string) get_option( 'airanksuite_audit_last', '' ); $link_run = get_option( 'airanksuite_linkscan_last' ); $scored = (int) \AiRankSuite\Support\Inventory::counts()['analyzed']; $first_scan = '' !== $audit_run || $scored > 0; $providers = (array) $options->get( 'seo_apis', array() ); $connected_providers = 0; foreach ( $providers as $value ) { if ( is_array( $value ) && ! empty( $value['api_key'] ) ) { ++$connected_providers; } } $steps = array( array( 'id' => 'business', 'tier' => 'required', 'label' => __( 'Describe the business', 'ai-rank-suite' ), 'why' => __( 'Name, description and location are what an assistant repeats when it recommends you. Everything else builds on this.', 'ai-rank-suite' ), 'done' => $business, 'route' => '#/schema/identity', ), array( 'id' => 'ai', 'tier' => 'required', 'label' => __( 'Connect an AI model', 'ai-rank-suite' ), 'why' => __( 'Descriptions, FAQs, the autopilot and every answer simulation need a key. One key switches all of them on.', 'ai-rank-suite' ), 'done' => (bool) $ai, 'route' => '#/ai', ), array( 'id' => 'scan', 'tier' => 'required', 'label' => __( 'Run the first full scan', 'ai-rank-suite' ), 'why' => __( 'The audit and the content analysis are what every score, finding and recommendation is computed from.', 'ai-rank-suite' ), 'done' => $first_scan, 'route' => '#/audit/site', ), array( 'id' => 'review', 'tier' => 'required', 'label' => __( 'Review the findings', 'ai-rank-suite' ), 'why' => __( 'The first run always finds something. Fixing the criticals is where the score actually moves.', 'ai-rank-suite' ), 'done' => $first_scan && ( '' !== $audit_run ), 'route' => '#/audit/site', ), array( 'id' => 'gsc', 'tier' => 'recommended', 'label' => __( 'Authorise Search Console', 'ai-rank-suite' ), 'why' => __( 'Real impressions, clicks and positions — the only source of what Google actually does with your pages.', 'ai-rank-suite' ), 'done' => $gsc, 'route' => '#/search-console', ), array( 'id' => 'analytics', 'tier' => 'recommended', 'label' => __( 'Connect Analytics', 'ai-rank-suite' ), 'why' => __( 'Traffic from AI assistants is separated out here; without it that traffic is invisible.', 'ai-rank-suite' ), 'done' => $has_ga, 'route' => '#/analytics', ), array( 'id' => 'links', 'tier' => 'recommended', 'label' => __( 'Check the links', 'ai-rank-suite' ), 'why' => __( 'A dead link is the cheapest fault to fix and the one crawlers punish first.', 'ai-rank-suite' ), 'done' => is_array( $link_run ) && ! empty( $link_run['run_id'] ) || ( is_array( $link_run ) && isset( $link_run['run_id'] ) ), 'route' => '#/links/checker', ), array( 'id' => 'bing', 'tier' => 'optional', 'label' => __( 'Connect Bing', 'ai-rank-suite' ), 'why' => __( 'Bing feeds Copilot. Worth it if that audience matters to you.', 'ai-rank-suite' ), 'done' => (bool) $bing, 'route' => '#/bing', ), array( 'id' => 'providers', 'tier' => 'optional', 'label' => __( 'Add external SEO data', 'ai-rank-suite' ), 'why' => __( 'Backlinks, keyword volumes and competitor data come from third parties; the plugin works fully without them.', 'ai-rank-suite' ), 'done' => $connected_providers > 0, 'route' => '#/seo-apis', 'note' => sprintf( /* translators: %d: number of connected providers. */ _n( '%d provider connected', '%d providers connected', $connected_providers, 'ai-rank-suite' ), $connected_providers ), ), array( 'id' => 'visibility', 'tier' => 'optional', 'label' => __( 'Simulate AI answers', 'ai-rank-suite' ), 'why' => __( 'Ask your model the questions your customers ask, and see whether it names you. A simulation, not a live measurement.', 'ai-rank-suite' ), 'done' => count( (array) ( (array) $options->get( 'ai_visibility', array( 'prompts' => array() ) )['prompts'] ?? array() ) ) > 0, 'route' => '#/ai-visibility', ), ); $required = array_filter( $steps, static fn( array $s ): bool => 'required' === $s['tier'] ); return array( 'steps' => array_values( $steps ), 'required_total' => count( $required ), 'required_done' => count( array_filter( $required, static fn( array $s ): bool => ! empty( $s['done'] ) ) ), 'total' => count( $steps ), 'done' => count( array_filter( $steps, static fn( array $s ): bool => ! empty( $s['done'] ) ) ), ); } }