'; echo ''; echo ''; echo ''; echo '' . esc_html__( 'Enabled', 'pr-vision' ) . ''; echo ''; echo '' . esc_html__( 'Test (point-in-time)', 'pr-vision' ) . ''; echo '' . esc_html__( 'Actions', 'pr-vision' ) . ''; echo ''; foreach ( $models as $m ) { $this->render_model_row( $m ); } echo ''; echo '
'; $this->render_add_model_form(); echo '
'; } /** * Render a single model table row. * * @param array $m Model object from PRV_Model_Registry. * * @return void */ private function render_model_row( array $m ): void { $id = esc_attr( (string) ( $m['id'] ?? '' ) ); $slug = esc_html( (string) ( $m['slug'] ?? '' ) ); $prov = esc_html( (string) ( $m['provider'] ?? '' ) ); $enabled = ! empty( $m['enabled'] ); $health = (string) ( $m['health_status'] ?? 'unknown' ); $retired = 'retired' === $health; $note = esc_html( (string) ( $m['note'] ?? '' ) ); $row_class = $retired ? 'prv-row-retired' : ''; echo ''; // Provider. echo '' . esc_html( $prov ) . ''; // Slug (monospace). echo '' . esc_html( $slug ) . ''; if ( $note ) { echo '
' . esc_html( $note ) . ''; } echo ''; // Enabled toggle. echo ''; $form_name = 'prv_enable_' . $id; echo '
'; echo ''; echo ''; echo ''; echo ''; wp_nonce_field( PRV_Settings_Page::NONCE_MODEL, 'prv_nonce' ); // Disabled toggle for retired models. $toggle_attrs = $retired ? ' disabled aria-disabled="true"' : ''; $checked_attr = $enabled ? ' checked' : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $checked_attr and $toggle_attrs are hard-coded attribute strings; $enabled is a boolean cast. echo ''; echo '
'; if ( $retired ) { echo '' . esc_html__( 'Retired', 'pr-vision' ) . ''; } echo ''; // Run health. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- render_health_badge() returns pre-escaped HTML markup. echo '' . $this->render_health_badge( $m ) . ''; // Test button + chip. $chip_id = 'prv-test-chip-' . $id; echo ''; echo ''; echo ' '; echo ''; // Actions: remove. echo ''; echo '
'; echo ''; echo ''; wp_nonce_field( PRV_Settings_Page::NONCE_MODEL, 'prv_nonce' ); echo ''; echo '
'; echo ''; echo ''; } /** * Render a health badge for a model. * * @param array $m Model object. * * @return string HTML badge (pre-escaped). */ private function render_health_badge( array $m ): string { $status = (string) ( $m['health_status'] ?? 'unknown' ); $probed = (int) ( $m['health_probed'] ?? 0 ); $errors = (int) ( $m['health_errors'] ?? 0 ); switch ( $status ) { case 'healthy': return '● Healthy (' . esc_html( (string) $probed ) . ' rows)'; case 'retired': return '● Retired? (0 rows · ' . esc_html( (string) $errors ) . ' errors)'; case 'disabled': return '● Off · retired'; default: return '● Unknown'; } } /** * Render the Add model form below the table. * * @return void */ private function render_add_model_form(): void { echo '
'; echo '+ ' . esc_html__( 'Add model', 'pr-vision' ) . ''; echo '
'; echo ''; wp_nonce_field( PRV_Settings_Page::NONCE_MODEL, 'prv_nonce' ); echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo '
'; } }