- All 49 PHP includes files: expand minimal file docblocks to include a short description (satisfies Generic.Commenting.DocComment.MissingShort) Format: <?php\n/**\n * Filename-derived description.\n *\n * @package ...\n */ - settings.php delegation stubs: add compact docblocks to all 8 render_* methods (Squiz.Commenting.FunctionComment.Missing, lines 93-231) - settings.php: compress mirrored @var constant docblocks to single-line; remove redundant intermediate class docblock → 273 lines (was 315) - rest-controller.php: compress 1 mirrored @var docblock → 298 lines - migration-0004: compress 4 property docblocks → 288 lines - verification-widget.php line 111: cast days_since to int + phpcs:ignore - verification-metabox.php line 80: phpcs:ignore on hardcoded badge_class - peptide-metaboxes.php line 86: phpcs:ignore EscapeOutput (esc_attr'd above) - peptide-metaboxes.php lines 147/148: Yoda null !== dose_min/dose_max - peptide-metaboxes.php line 248: phpcs:ignore InputNotSanitized (isset only) - peptide-metaboxes.php line 259: wrap pr_core_editorial_review_status in wp_unslash() - peptide-metaboxes.php line 262: Yoda 'published' !== old_status Agent-Session: claude-adopt-ci-20260616
108 lines
4.0 KiB
PHP
108 lines
4.0 KiB
PHP
<?php
|
|
/**
|
|
* Verification Metabox.
|
|
*
|
|
* @package Peptide_Repo_Core
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Renders and saves verification status sidebar meta box
|
|
*
|
|
* @package Peptide_Repo_Core
|
|
*/
|
|
|
|
/**
|
|
* Verification status meta box for peptide edit screen.
|
|
*
|
|
* What: Renders and saves verification status sidebar meta box.
|
|
* Who calls it: PR_Core_Admin via add_meta_boxes and save_post hooks.
|
|
* Dependencies: None.
|
|
*
|
|
* @see admin/class-pr-core-peptide-metaboxes.php — Other edit-screen meta boxes.
|
|
*/
|
|
class PR_Core_Verification_Metabox {
|
|
|
|
/**
|
|
* Register the verification meta box.
|
|
*
|
|
* @return void
|
|
*/
|
|
public static function register(): void {
|
|
add_meta_box(
|
|
'pr-core-verification',
|
|
__( 'Verification Status', 'peptide-repo-core' ),
|
|
array( __CLASS__, 'render' ),
|
|
PR_Core_Peptide_CPT::POST_TYPE,
|
|
'side',
|
|
'default'
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Render the verification status meta box (sidebar).
|
|
*
|
|
* @param \WP_Post $post Current post.
|
|
* @return void
|
|
*/
|
|
public static function render( \WP_Post $post ): void {
|
|
wp_nonce_field( 'pr_core_verification_nonce', 'pr_core_verification_nonce' );
|
|
|
|
$last_verified = get_post_meta( $post->ID, '_pr_last_source_verified', true );
|
|
$velocity = get_post_meta( $post->ID, '_pr_verification_velocity', true ) ?: 'medium'; // phpcs:ignore Universal.Operators.DisallowShortTernary.Found
|
|
$status = get_post_meta( $post->ID, '_pr_verification_status', true ) ?: 'current'; // phpcs:ignore Universal.Operators.DisallowShortTernary.Found
|
|
$notes = get_post_meta( $post->ID, '_pr_verification_notes', true ) ?: ''; // phpcs:ignore Universal.Operators.DisallowShortTernary.Found
|
|
|
|
echo '<p><strong>' . esc_html__( 'Last Verified', 'peptide-repo-core' ) . ':</strong><br />';
|
|
echo '<code style="color: #666;">' . esc_html( $last_verified ?: '—' ) . '</code></p>'; // phpcs:ignore Universal.Operators.DisallowShortTernary.Found
|
|
|
|
echo '<p><strong>' . esc_html__( 'Verification Velocity', 'peptide-repo-core' ) . ':</strong><br />';
|
|
echo '<select name="pr_core__pr_verification_velocity" style="width:100%;">';
|
|
foreach ( array(
|
|
'low' => 'Low',
|
|
'medium' => 'Medium',
|
|
'high' => 'High',
|
|
) as $val => $label ) {
|
|
printf(
|
|
'<option value="%s"%s>%s</option>',
|
|
esc_attr( $val ),
|
|
selected( $velocity, $val, false ),
|
|
esc_html( $label )
|
|
);
|
|
}
|
|
echo '</select></p>';
|
|
|
|
echo '<p><strong>' . esc_html__( 'Status', 'peptide-repo-core' ) . ':</strong><br />';
|
|
$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;"',
|
|
};
|
|
echo '<span ' . $badge_class . '>' . esc_html( ucfirst( $status ) ) . '</span></p>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- badge_class is a hardcoded match expression
|
|
|
|
echo '<p><strong>' . esc_html__( 'Verification Notes', 'peptide-repo-core' ) . ':</strong><br />';
|
|
printf(
|
|
'<textarea name="pr_core__pr_verification_notes" rows="3" style="width:100%;">%s</textarea>',
|
|
esc_textarea( $notes )
|
|
);
|
|
echo '</p>';
|
|
|
|
echo '<button type="button" class="button button-primary" id="pr-core-mark-verified">' . esc_html__( 'Mark Verified Today', 'peptide-repo-core' ) . '</button>';
|
|
|
|
echo '<script>
|
|
document.getElementById("pr-core-mark-verified").addEventListener("click", function() {
|
|
const data = new FormData();
|
|
data.append("action", "pr_core_mark_verified");
|
|
data.append("post_id", ' . (int) $post->ID . ');
|
|
data.append("nonce", document.querySelector("[name=\'_wpnonce\']").value);
|
|
data.append("notes", document.querySelector("[name=\'pr_core__pr_verification_notes\']").value);
|
|
fetch(ajaxurl, { method: "POST", body: data })
|
|
.then(r => r.json())
|
|
.then(d => { if(d.success) { location.reload(); } else { alert("Error: " + (d.data || "Unknown")); }})
|
|
.catch(e => { alert("Error: " + e); });
|
|
});
|
|
</script>';
|
|
}
|
|
}
|