run(); $redirect = add_query_arg( array( 'page' => self::MENU_SLUG, 'pgm_run_done' => 1, 'pgm_probed' => (int) $counts['probed'], 'pgm_skipped' => (int) ( $counts['skipped_budget'] + $counts['skipped_error'] ), ), admin_url( 'admin.php' ) ); wp_safe_redirect( $redirect ); exit; } /** * Render the full GEO Monitor admin page. * * Side effects: Outputs HTML directly. * * @return void */ public function render_page(): void { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'Insufficient permissions.', 'peptide-geo-monitor' ) ); } echo '
'; echo '

' . esc_html__( 'GEO Monitor — AI Visibility', 'peptide-geo-monitor' ) . '

'; $this->render_run_done_notice(); // "Run now" button form. echo '
'; echo ''; wp_nonce_field( self::NONCE_ACTION, self::NONCE_FIELD ); submit_button( __( 'Run now', 'peptide-geo-monitor' ), 'secondary', 'pgm_run_now_btn', false ); echo '
'; $registry = PGM_Collector_Registry::instance(); foreach ( $registry->get_collectors() as $key => $collector ) { $panel = $registry->get_panel( $key ); if ( null === $panel ) { continue; } $data = $collector->collect(); $panel->render( $data ); } echo '
'; } /** * Render a success or partial notice after a Run now redirect. * * @return void */ private function render_run_done_notice(): void { // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( empty( $_GET['pgm_run_done'] ) ) { return; } // phpcs:ignore WordPress.Security.NonceVerification.Recommended $probed = (int) ( $_GET['pgm_probed'] ?? 0 ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended $skipped = (int) ( $_GET['pgm_skipped'] ?? 0 ); echo '

'; echo esc_html( sprintf( /* translators: 1: probed count, 2: skipped count */ __( 'Run complete: %1$d probes collected, %2$d skipped (budget or error).', 'peptide-geo-monitor' ), $probed, $skipped ) ); echo '

'; } }