style: auto-fix PHPCS violations via phpcbf

This commit is contained in:
peptiderepo
2026-06-16 15:26:16 +00:00
parent 08d7696444
commit b9158d7dca
45 changed files with 1018 additions and 658 deletions

View File

@@ -19,7 +19,7 @@ class PR_Core_Admin_Columns {
* @return array<string, string> Modified columns.
*/
public function add_columns( array $columns ): array {
$new = [];
$new = array();
foreach ( $columns as $key => $label ) {
$new[ $key ] = $label;

View File

@@ -25,22 +25,22 @@ class PR_Core_Admin {
*/
public function register_hooks(): void {
$metaboxes = new PR_Core_Peptide_Metaboxes();
add_action( 'add_meta_boxes', [ $metaboxes, 'add_meta_boxes' ] );
add_action( 'save_post_' . PR_Core_Peptide_CPT::POST_TYPE, [ $metaboxes, 'save_meta' ], 10, 2 );
add_action( 'add_meta_boxes', array( $metaboxes, 'add_meta_boxes' ) );
add_action( 'save_post_' . PR_Core_Peptide_CPT::POST_TYPE, array( $metaboxes, 'save_meta' ), 10, 2 );
add_action( 'add_meta_boxes', [ PR_Core_Verification_Metabox::class, 'register' ] );
add_action( 'add_meta_boxes', array( PR_Core_Verification_Metabox::class, 'register' ) );
$columns = new PR_Core_Admin_Columns();
add_filter( 'manage_' . PR_Core_Peptide_CPT::POST_TYPE . '_posts_columns', [ $columns, 'add_columns' ] );
add_action( 'manage_' . PR_Core_Peptide_CPT::POST_TYPE . '_posts_custom_column', [ $columns, 'render_column' ], 10, 2 );
add_filter( 'manage_' . PR_Core_Peptide_CPT::POST_TYPE . '_posts_columns', array( $columns, 'add_columns' ) );
add_action( 'manage_' . PR_Core_Peptide_CPT::POST_TYPE . '_posts_custom_column', array( $columns, 'render_column' ), 10, 2 );
// Repo Daily meta boxes.
$repo_daily_metaboxes = new PR_Core_Repo_Daily_Metaboxes();
add_action( 'add_meta_boxes', [ $repo_daily_metaboxes, 'add_meta_boxes' ] );
add_action( 'save_post_' . PR_Core_Repo_Daily_CPT::POST_TYPE, [ $repo_daily_metaboxes, 'save_meta' ], 10, 2 );
add_action( 'add_meta_boxes', array( $repo_daily_metaboxes, 'add_meta_boxes' ) );
add_action( 'save_post_' . PR_Core_Repo_Daily_CPT::POST_TYPE, array( $repo_daily_metaboxes, 'save_meta' ), 10, 2 );
add_action( 'admin_menu', [ $this, 'add_admin_pages' ] );
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_styles' ] );
add_action( 'admin_menu', array( $this, 'add_admin_pages' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
}
/**
@@ -60,7 +60,7 @@ class PR_Core_Admin {
__( 'Candidate Queue', 'peptide-repo-core' ) . $badge,
PR_Core_Peptide_CPT::CAPABILITY,
'pr-core-candidates',
[ new PR_Core_Candidate_Queue_Page(), 'render' ]
array( new PR_Core_Candidate_Queue_Page(), 'render' )
);
}
@@ -79,7 +79,7 @@ class PR_Core_Admin {
wp_enqueue_style(
'pr-core-admin',
PR_CORE_PLUGIN_URL . 'assets/css/admin.css',
[],
array(),
PR_CORE_VERSION
);
}

View File

@@ -47,7 +47,7 @@ class PR_Core_Ajax_Handlers {
// Recompute status to 'current'.
update_post_meta( $post_id, '_pr_verification_status', 'current' );
wp_send_json_success( [ 'message' => 'Marked verified' ] );
wp_send_json_success( array( 'message' => 'Marked verified' ) );
}
/**
@@ -74,6 +74,6 @@ class PR_Core_Ajax_Handlers {
// Run scan.
PR_Core_Verification_Scanner::run_scan();
wp_send_json_success( [ 'message' => 'Scan complete' ] );
wp_send_json_success( array( 'message' => 'Scan complete' ) );
}
}

View File

@@ -71,11 +71,21 @@ class PR_Core_Candidate_Queue_Page {
$confidence_pct = number_format( $c->extraction_confidence * 100, 0 ) . '%';
$approve_url = wp_nonce_url(
add_query_arg( [ 'action' => 'pr_core_approve', 'candidate_id' => $c->id ] ),
add_query_arg(
array(
'action' => 'pr_core_approve',
'candidate_id' => $c->id,
)
),
'pr_core_queue_action'
);
$reject_url = wp_nonce_url(
add_query_arg( [ 'action' => 'pr_core_reject', 'candidate_id' => $c->id ] ),
add_query_arg(
array(
'action' => 'pr_core_reject',
'candidate_id' => $c->id,
)
),
'pr_core_queue_action'
);
@@ -109,7 +119,7 @@ class PR_Core_Candidate_Queue_Page {
private function handle_actions(): void {
$action = sanitize_text_field( $_GET['action'] ?? '' );
if ( ! in_array( $action, [ 'pr_core_approve', 'pr_core_reject' ], true ) ) {
if ( ! in_array( $action, array( 'pr_core_approve', 'pr_core_reject' ), true ) ) {
return;
}
@@ -128,15 +138,21 @@ class PR_Core_Candidate_Queue_Page {
if ( 'pr_core_approve' === $action ) {
$dosing_id = $repo->approve( $candidate_id, $reviewer_id );
if ( $dosing_id > 0 ) {
add_action( 'admin_notices', static function () {
echo '<div class="notice notice-success is-dismissible"><p>' . esc_html__( 'Candidate approved and added to dosing data.', 'peptide-repo-core' ) . '</p></div>';
} );
add_action(
'admin_notices',
static function () {
echo '<div class="notice notice-success is-dismissible"><p>' . esc_html__( 'Candidate approved and added to dosing data.', 'peptide-repo-core' ) . '</p></div>';
}
);
}
} else {
$repo->reject( $candidate_id, $reviewer_id );
add_action( 'admin_notices', static function () {
echo '<div class="notice notice-warning is-dismissible"><p>' . esc_html__( 'Candidate rejected.', 'peptide-repo-core' ) . '</p></div>';
} );
add_action(
'admin_notices',
static function () {
echo '<div class="notice notice-warning is-dismissible"><p>' . esc_html__( 'Candidate rejected.', 'peptide-repo-core' ) . '</p></div>';
}
);
}
}
}

View File

@@ -22,7 +22,7 @@ class PR_Core_Peptide_Metaboxes {
add_meta_box(
'pr-core-identifiers',
__( 'Scientific Identifiers', 'peptide-repo-core' ),
[ $this, 'render_identifiers_box' ],
array( $this, 'render_identifiers_box' ),
PR_Core_Peptide_CPT::POST_TYPE,
'normal',
'high'
@@ -31,7 +31,7 @@ class PR_Core_Peptide_Metaboxes {
add_meta_box(
'pr-core-dosing',
__( 'Dosing Data', 'peptide-repo-core' ),
[ $this, 'render_dosing_box' ],
array( $this, 'render_dosing_box' ),
PR_Core_Peptide_CPT::POST_TYPE,
'normal',
'default'
@@ -40,7 +40,7 @@ class PR_Core_Peptide_Metaboxes {
add_meta_box(
'pr-core-legal',
__( 'Legal Status by Country', 'peptide-repo-core' ),
[ $this, 'render_legal_box' ],
array( $this, 'render_legal_box' ),
PR_Core_Peptide_CPT::POST_TYPE,
'normal',
'default'
@@ -56,7 +56,7 @@ class PR_Core_Peptide_Metaboxes {
public function render_identifiers_box( \WP_Post $post ): void {
wp_nonce_field( 'pr_core_save_meta', 'pr_core_meta_nonce' );
$fields = [
$fields = array(
'display_name' => __( 'Display Name', 'peptide-repo-core' ),
'aliases' => __( 'Aliases (JSON array)', 'peptide-repo-core' ),
'molecular_formula' => __( 'Molecular Formula', 'peptide-repo-core' ),
@@ -64,7 +64,7 @@ class PR_Core_Peptide_Metaboxes {
'cas_number' => __( 'CAS Number', 'peptide-repo-core' ),
'drugbank_id' => __( 'DrugBank ID', 'peptide-repo-core' ),
'chembl_id' => __( 'ChEMBL ID', 'peptide-repo-core' ),
];
);
echo '<table class="form-table pr-core-meta-table">';
foreach ( $fields as $key => $label ) {

View File

@@ -29,7 +29,7 @@ class PR_Core_Repo_Daily_Metaboxes {
add_meta_box(
'pr-core-repo-daily-meta',
__( 'Article Settings', 'peptide-repo-core' ),
[ $this, 'render_meta_box' ],
array( $this, 'render_meta_box' ),
PR_Core_Repo_Daily_CPT::POST_TYPE,
'normal',
'default'
@@ -45,7 +45,7 @@ class PR_Core_Repo_Daily_Metaboxes {
public function render_meta_box( \WP_Post $post ): void {
wp_nonce_field( 'pr_core_repo_daily_meta', 'pr_core_repo_daily_nonce' );
$author = sanitize_text_field(
$author = sanitize_text_field(
get_post_meta( $post->ID, '_repo_daily_author', true ) ?: self::DEFAULT_AUTHOR
);
$requires_review = get_post_meta( $post->ID, '_repo_daily_clinical_review_required', true );

View File

@@ -48,7 +48,7 @@ class PR_Core_Settings {
__( 'Settings', 'peptide-repo-core' ),
'manage_options',
'pr-core-settings',
[ __CLASS__, 'render_page' ]
array( __CLASS__, 'render_page' )
);
}
@@ -83,7 +83,7 @@ class PR_Core_Settings {
public static function register_settings(): void {
self::register_related_articles_section();
self::register_verification_section();
add_action( 'update_option_' . self::SCAN_CADENCE, [ __CLASS__, 'reschedule_cron' ], 10, 2 );
add_action( 'update_option_' . self::SCAN_CADENCE, array( __CLASS__, 'reschedule_cron' ), 10, 2 );
}
// ── Related Articles ─────────────────────────────────────────────────
@@ -94,12 +94,28 @@ class PR_Core_Settings {
* @return void
*/
private static function register_related_articles_section(): void {
register_setting( self::OPTION_GROUP, self::RELATED_ENABLED, [ 'type' => 'boolean', 'default' => true, 'sanitize_callback' => 'rest_sanitize_boolean' ] );
register_setting( self::OPTION_GROUP, self::RELATED_LIMIT, [ 'type' => 'integer', 'default' => 3, 'sanitize_callback' => [ __CLASS__, 'sanitize_limit' ] ] );
register_setting(
self::OPTION_GROUP,
self::RELATED_ENABLED,
array(
'type' => 'boolean',
'default' => true,
'sanitize_callback' => 'rest_sanitize_boolean',
)
);
register_setting(
self::OPTION_GROUP,
self::RELATED_LIMIT,
array(
'type' => 'integer',
'default' => 3,
'sanitize_callback' => array( __CLASS__, 'sanitize_limit' ),
)
);
add_settings_section( 'pr_core_related_articles', __( 'Related Articles', 'peptide-repo-core' ), '__return_false', self::OPTION_GROUP );
add_settings_field( self::RELATED_ENABLED, __( 'Enable Related Articles', 'peptide-repo-core' ), [ __CLASS__, 'render_enabled_field' ], self::OPTION_GROUP, 'pr_core_related_articles' );
add_settings_field( self::RELATED_LIMIT, __( 'Number of Articles', 'peptide-repo-core' ), [ __CLASS__, 'render_limit_field' ], self::OPTION_GROUP, 'pr_core_related_articles' );
add_settings_field( self::RELATED_ENABLED, __( 'Enable Related Articles', 'peptide-repo-core' ), array( __CLASS__, 'render_enabled_field' ), self::OPTION_GROUP, 'pr_core_related_articles' );
add_settings_field( self::RELATED_LIMIT, __( 'Number of Articles', 'peptide-repo-core' ), array( __CLASS__, 'render_limit_field' ), self::OPTION_GROUP, 'pr_core_related_articles' );
}
/** @return void */
@@ -141,16 +157,48 @@ class PR_Core_Settings {
* @return void
*/
private static function register_verification_section(): void {
register_setting( self::OPTION_GROUP, self::SCAN_CADENCE, [ 'type' => 'string', 'default' => 'weekly', 'sanitize_callback' => [ __CLASS__, 'sanitize_cadence' ] ] );
register_setting( self::OPTION_GROUP, self::DEFAULT_THRESHOLD, [ 'type' => 'integer', 'default' => 180, 'sanitize_callback' => 'absint' ] );
register_setting( self::OPTION_GROUP, self::HIGH_VELOCITY_THRESHOLD, [ 'type' => 'integer', 'default' => 60, 'sanitize_callback' => 'absint' ] );
register_setting( self::OPTION_GROUP, self::VERIFICATION_EMAIL, [ 'type' => 'string', 'default' => '', 'sanitize_callback' => [ __CLASS__, 'sanitize_emails' ] ] );
register_setting(
self::OPTION_GROUP,
self::SCAN_CADENCE,
array(
'type' => 'string',
'default' => 'weekly',
'sanitize_callback' => array( __CLASS__, 'sanitize_cadence' ),
)
);
register_setting(
self::OPTION_GROUP,
self::DEFAULT_THRESHOLD,
array(
'type' => 'integer',
'default' => 180,
'sanitize_callback' => 'absint',
)
);
register_setting(
self::OPTION_GROUP,
self::HIGH_VELOCITY_THRESHOLD,
array(
'type' => 'integer',
'default' => 60,
'sanitize_callback' => 'absint',
)
);
register_setting(
self::OPTION_GROUP,
self::VERIFICATION_EMAIL,
array(
'type' => 'string',
'default' => '',
'sanitize_callback' => array( __CLASS__, 'sanitize_emails' ),
)
);
add_settings_section( 'pr_core_verification', __( 'Verification', 'peptide-repo-core' ), [ __CLASS__, 'render_verification_section' ], self::OPTION_GROUP );
add_settings_field( self::SCAN_CADENCE, __( 'Scan cadence', 'peptide-repo-core' ), [ __CLASS__, 'render_cadence_field' ], self::OPTION_GROUP, 'pr_core_verification' );
add_settings_field( self::DEFAULT_THRESHOLD, __( 'Default staleness threshold (days)', 'peptide-repo-core' ), [ __CLASS__, 'render_threshold_field' ], self::OPTION_GROUP, 'pr_core_verification' );
add_settings_field( self::HIGH_VELOCITY_THRESHOLD, __( 'High-velocity threshold (days)', 'peptide-repo-core' ), [ __CLASS__, 'render_high_velocity_field' ], self::OPTION_GROUP, 'pr_core_verification' );
add_settings_field( self::VERIFICATION_EMAIL, __( 'Notification email(s)', 'peptide-repo-core' ), [ __CLASS__, 'render_email_field' ], self::OPTION_GROUP, 'pr_core_verification' );
add_settings_section( 'pr_core_verification', __( 'Verification', 'peptide-repo-core' ), array( __CLASS__, 'render_verification_section' ), self::OPTION_GROUP );
add_settings_field( self::SCAN_CADENCE, __( 'Scan cadence', 'peptide-repo-core' ), array( __CLASS__, 'render_cadence_field' ), self::OPTION_GROUP, 'pr_core_verification' );
add_settings_field( self::DEFAULT_THRESHOLD, __( 'Default staleness threshold (days)', 'peptide-repo-core' ), array( __CLASS__, 'render_threshold_field' ), self::OPTION_GROUP, 'pr_core_verification' );
add_settings_field( self::HIGH_VELOCITY_THRESHOLD, __( 'High-velocity threshold (days)', 'peptide-repo-core' ), array( __CLASS__, 'render_high_velocity_field' ), self::OPTION_GROUP, 'pr_core_verification' );
add_settings_field( self::VERIFICATION_EMAIL, __( 'Notification email(s)', 'peptide-repo-core' ), array( __CLASS__, 'render_email_field' ), self::OPTION_GROUP, 'pr_core_verification' );
}
/** @return void */
@@ -162,7 +210,11 @@ class PR_Core_Settings {
public static function render_cadence_field(): void {
$current = get_option( self::SCAN_CADENCE, 'weekly' );
echo '<select name="' . esc_attr( self::SCAN_CADENCE ) . '">';
foreach ( [ 'daily' => 'Daily', 'weekly' => 'Weekly', 'monthly' => 'Monthly' ] as $val => $label ) {
foreach ( array(
'daily' => 'Daily',
'weekly' => 'Weekly',
'monthly' => 'Monthly',
) as $val => $label ) {
printf( '<option value="%s"%s>%s</option>', esc_attr( $val ), selected( $current, $val, false ), esc_html( $label ) );
}
echo '</select>';
@@ -195,7 +247,7 @@ class PR_Core_Settings {
* @return string
*/
public static function sanitize_cadence( string $value ): string {
return in_array( $value, [ 'daily', 'weekly', 'monthly' ], true ) ? $value : 'weekly';
return in_array( $value, array( 'daily', 'weekly', 'monthly' ), true ) ? $value : 'weekly';
}
/**

View File

@@ -21,7 +21,7 @@ class PR_Core_Verification_Metabox {
add_meta_box(
'pr-core-verification',
__( 'Verification Status', 'peptide-repo-core' ),
[ __CLASS__, 'render' ],
array( __CLASS__, 'render' ),
PR_Core_Peptide_CPT::POST_TYPE,
'side',
'default'
@@ -47,7 +47,11 @@ class PR_Core_Verification_Metabox {
echo '<p><strong>' . esc_html__( 'Verification Velocity', 'peptide-repo-core' ) . ':</strong><br />';
echo '<select name="pr_core__pr_verification_velocity" style="width:100%;">';
foreach ( [ 'low' => 'Low', 'medium' => 'Medium', 'high' => 'High' ] as $val => $label ) {
foreach ( array(
'low' => 'Low',
'medium' => 'Medium',
'high' => 'High',
) as $val => $label ) {
printf(
'<option value="%s"%s>%s</option>',
esc_attr( $val ),
@@ -58,7 +62,7 @@ class PR_Core_Verification_Metabox {
echo '</select></p>';
echo '<p><strong>' . esc_html__( 'Status', 'peptide-repo-core' ) . ':</strong><br />';
$badge_class = match( $status ) {
$badge_class = match ( $status ) {
'due' => 'style="background:#ff9800;color:white;padding:4px 8px;border-radius:3px;"',
'overdue' => 'style="background:#f44336;color:white;padding:4px 8px;border-radius:3px;"',
default => 'style="background:#4caf50;color:white;padding:4px 8px;border-radius:3px;"',

View File

@@ -23,7 +23,7 @@ class PR_Core_Verification_Widget {
wp_add_dashboard_widget(
'pr_core_verification_status',
__( 'Monographs Needing Review', 'peptide-repo-core' ),
[ __CLASS__, 'render' ]
array( __CLASS__, 'render' )
);
}
@@ -33,35 +33,38 @@ class PR_Core_Verification_Widget {
* @return void
*/
public static function render(): void {
$repo = new PR_Core_Peptide_Repository();
$peptides = $repo->find_all( [ 'status' => 'publish' ] );
$repo = new PR_Core_Peptide_Repository();
$peptides = $repo->find_all( array( 'status' => 'publish' ) );
$due_overdue = [];
$due_overdue = array();
foreach ( $peptides as $dto ) {
$status = get_post_meta( $dto->id, '_pr_verification_status', true ) ?: 'current';
if ( in_array( $status, [ 'due', 'overdue' ], true ) ) {
if ( in_array( $status, array( 'due', 'overdue' ), true ) ) {
$last_verified = get_post_meta( $dto->id, '_pr_last_source_verified', true );
$days_since = $last_verified
? (int) ( ( time() - strtotime( $last_verified ) ) / DAY_IN_SECONDS )
: 999;
$due_overdue[] = [
'id' => $dto->id,
'title' => $dto->title,
'status' => $status,
'velocity' => get_post_meta( $dto->id, '_pr_verification_velocity', true ) ?: 'medium',
$due_overdue[] = array(
'id' => $dto->id,
'title' => $dto->title,
'status' => $status,
'velocity' => get_post_meta( $dto->id, '_pr_verification_velocity', true ) ?: 'medium',
'last_verified' => $last_verified,
'days_since' => $days_since,
];
'days_since' => $days_since,
);
}
}
// Sort by days_since descending (most overdue first).
usort( $due_overdue, static function ( $a, $b ) {
return $b['days_since'] <=> $a['days_since'];
} );
usort(
$due_overdue,
static function ( $a, $b ) {
return $b['days_since'] <=> $a['days_since'];
}
);
if ( empty( $due_overdue ) ) {
echo '<p>' . esc_html__( 'All monographs are current. ', 'peptide-repo-core' );