Files
peptide-repo-core/includes/admin/class-pr-core-admin-columns.php
peptiderepo 808b2509d8 feat: initial peptide-repo-core plugin (v0.1.0) — canonical schema sprint
Implements ADR-0002: canonical peptide schema as shared data layer for
the peptiderepo.com ecosystem. All Tier 1 tools (Reconstitution Calculator,
Dosage Reference, Legal Status Tracker, PSA enhancements) build on this.

Includes:
- pr_peptide CPT with REST, taxonomies, 11 meta fields
- 3 custom tables: pr_dosing_rows, pr_legal_cells, pr_ai_candidate_queue
- Sequential migration runner with schema versioning
- 4 typed DTOs and 4 repository classes (full CRUD)
- REST API (pr-core/v1): 6 endpoints (read public, write auth-gated)
- Admin UI: 3 meta boxes, custom columns, AI candidate queue page
- Shared disclaimer component (shortcode + static API)
- JSON-LD Drug schema emission on single peptide pages
- Seed data fixture (3 peptides, 10 dosing rows, 5 legal cells)
- Full teardown in uninstall.php
- CI: PHP lint 8.0-8.2, PHPCS WordPress, 300-line check

All 22 PHP files under 300 lines. Highest: peptide-cpt at 265.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-17 07:36:12 +07:00

64 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
/**
* Custom admin list-table columns for the pr_peptide CPT.
*
* What: Adds evidence strength, editorial status, and dosing count columns.
* Who calls it: PR_Core_Admin via manage_posts_columns and custom_column hooks.
* Dependencies: PR_Core_Dosing_Repository for row counts.
*
* @see admin/class-pr-core-admin.php — Registers column hooks.
*/
class PR_Core_Admin_Columns {
/**
* Add custom columns to the peptide list table.
*
* @param array<string, string> $columns Existing columns.
* @return array<string, string> Modified columns.
*/
public function add_columns( array $columns ): array {
$new = [];
foreach ( $columns as $key => $label ) {
$new[ $key ] = $label;
// Insert custom columns after the title column.
if ( 'title' === $key ) {
$new['pr_evidence'] = __( 'Evidence', 'peptide-repo-core' );
$new['pr_editorial'] = __( 'Editorial', 'peptide-repo-core' );
$new['pr_dosing'] = __( 'Dosing Rows', 'peptide-repo-core' );
}
}
return $new;
}
/**
* Render custom column content for a peptide row.
*
* @param string $column Column key.
* @param int $post_id Post ID.
* @return void
*/
public function render_column( string $column, int $post_id ): void {
switch ( $column ) {
case 'pr_evidence':
$strength = get_post_meta( $post_id, 'evidence_strength', true ) ?: 'preclinical';
$label = apply_filters( 'pr_core_evidence_strength_label', $strength, $strength );
echo esc_html( $label );
break;
case 'pr_editorial':
$status = get_post_meta( $post_id, 'editorial_review_status', true ) ?: 'draft';
echo esc_html( ucfirst( str_replace( '-', ' ', $status ) ) );
break;
case 'pr_dosing':
$count = ( new PR_Core_Dosing_Repository() )->count_by_peptide( $post_id );
echo esc_html( (string) $count );
break;
}
}
}