results = $results; $this->capabilities = $capabilities; } public function render( bool $connected ): void { $this->render_notice(); $this->render_cron_notice(); $this->render_url_preview(); if ( ! $connected ) { return; } $this->render_run_action(); $this->render_error(); $summary = $this->results->last(); if ( $summary instanceof RunSummary ) { $this->render_summary( $summary ); } } private function render_cron_notice(): void { if ( ! defined( 'DISABLE_WP_CRON' ) || ! DISABLE_WP_CRON ) { return; } echo '
'; esc_html_e( 'WP-Cron is disabled. Configure a system cron request to wp-cron.php so 2UA checks can run and refresh.', '2ua-seo-release-guard' ); echo '
'; esc_html_e( 'The SEO check was scheduled. WordPress Cron will start it shortly.', '2ua-seo-release-guard' ); echo '
' . esc_html( home_url( '/' ) ) . ' ';
$this->render_device_badge( 'desktop' );
echo '
'; esc_html_e( 'Published posts, pages, and products are added to their release event automatically.', '2ua-seo-release-guard' ); echo '
'; } private function render_run_action(): void { echo ''; } private function render_error(): void { $message = $this->error_message( $this->results->last_error() ); if ( '' === $message ) { return; } echo '' . esc_html( $message ) . '
' . esc_html__( 'Status:', '2ua-seo-release-guard' ) . ' '; echo esc_html( $this->label( $summary->state->status ) ) . ' · '; echo '' . esc_html__( 'Verdict:', '2ua-seo-release-guard' ) . ' '; echo esc_html( $this->label( $summary->state->verdict ) ) . '
'; $this->render_counts( $summary->findings->counts ); $this->render_findings( $summary->findings ); $this->render_handoff( $summary ); if ( ! $summary->is_terminal() ) { echo ''; esc_html_e( '2UA is processing this check in the background. Refresh this page for the latest status.', '2ua-seo-release-guard' ); echo '
'; } } private function render_handoff( RunSummary $summary ): void { $capabilities = $this->capabilities->get(); $error_code = $this->results->last_error(); if ( ApiException::LIMIT === $error_code ) { $this->render_handoff_form( $summary->state->public_id, 'upgrade', __( 'Upgrade on 2UA', '2ua-seo-release-guard' ) ); return; } if ( $capabilities instanceof RunCapabilities && $capabilities->account->connected ) { $this->render_handoff_form( $summary->state->public_id, 'view_full_result', __( 'Open this result on 2UA', '2ua-seo-release-guard' ) ); return; } $this->render_handoff_form( $summary->state->public_id, 'connect_account', __( 'Email me and keep watching', '2ua-seo-release-guard' ) ); } private function render_handoff_form( string $run_id, string $purpose, string $label ): void { echo ''; } private function render_counts( RunFindingCounts $counts ): void { echo ''; echo esc_html__( 'Critical:', '2ua-seo-release-guard' ) . ' ' . esc_html( (string) $counts->critical ); echo ' · ' . esc_html__( 'Warnings:', '2ua-seo-release-guard' ) . ' '; echo esc_html( (string) $counts->warning ); echo ' · ' . esc_html__( 'Information:', '2ua-seo-release-guard' ) . ' '; echo esc_html( (string) $counts->info ) . '
'; } private function render_findings( RunFindings $findings ): void { if ( array() === $findings->items ) { return; } echo '| '; echo esc_html__( 'Severity', '2ua-seo-release-guard' ) . ' | '; echo esc_html__( 'Finding', '2ua-seo-release-guard' ) . ' | '; echo esc_html__( 'URL and profile', '2ua-seo-release-guard' ) . ' |
|---|
' . esc_html( $finding->location->url ) . ' ';
$this->render_device_badge( $finding->location->device_profile );
echo '