Files
peptide-repo-core/includes/admin/class-pr-core-admin-columns.php
peptiderepo 53c71dca12 fix: move file docblocks to immediately after <?php (before declare)
PHPCS Squiz.Commenting.FileComment requires the file docblock to be the
FIRST token after the opening <?php tag. Having declare(strict_types=1)
before the docblock means PHPCS sees no file docblock at all.

Fix: in every includes/*.php file, insert a minimal /** @package ... */
docblock immediately after <?php (no blank line = satisfies SpacingAfterOpen)
with a blank line after it (satisfies SpacingAfterComment), then declare()
then the class docblock.

Also fixes peptide-repo-core.php SpacingAfterOpen/SpacingAfterComment
by removing the blank line between <?php and the existing file docblock
and ensuring one blank line after it.

Agent-Session: claude-adopt-ci-20260616
2026-06-16 16:06:11 +00:00

74 lines
2.1 KiB
PHP

<?php
/**
* @package Peptide_Repo_Core
*/
declare(strict_types=1);
/**
* Adds evidence strength, editorial status, and dosing count columns
*
* @package Peptide_Repo_Core
*/
/**
* Custom admin list-table columns for the 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 = array();
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'; // phpcs:ignore Universal.Operators.DisallowShortTernary.Found
$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'; // phpcs:ignore Universal.Operators.DisallowShortTernary.Found
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;
}
}
}