- 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
92 lines
2.4 KiB
PHP
92 lines
2.4 KiB
PHP
<?php
|
|
/**
|
|
* Ajax Handlers.
|
|
*
|
|
* @package Peptide_Repo_Core
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Handles mark-verified and scan-now admin-ajax actions
|
|
*
|
|
* @package Peptide_Repo_Core
|
|
*/
|
|
|
|
/**
|
|
* AJAX handlers for verification scanner actions.
|
|
*
|
|
* What: Handles mark-verified and scan-now admin-ajax actions.
|
|
* Who calls it: PR_Core::init() registers the wp_ajax hooks.
|
|
* Dependencies: None.
|
|
*
|
|
* @see admin/class-pr-core-peptide-metaboxes.php — "Mark verified today" button in sidebar.
|
|
* @see admin/class-pr-core-verification-widget.php — "Scan now" button in dashboard widget.
|
|
*/
|
|
class PR_Core_Ajax_Handlers {
|
|
|
|
/**
|
|
* Handle mark-verified AJAX action.
|
|
*
|
|
* Updates _pr_last_source_verified to today, saves notes, recomputes status.
|
|
*
|
|
* Side effects: Updates post meta, returns JSON.
|
|
*
|
|
* @return void
|
|
*/
|
|
public static function handle_mark_verified(): void {
|
|
// Verify nonce.
|
|
$nonce = sanitize_text_field( wp_unslash( $_POST['nonce'] ?? '' ) );
|
|
if ( ! wp_verify_nonce( $nonce, 'wp_nonce' ) ) {
|
|
wp_send_json_error( 'Invalid nonce' );
|
|
}
|
|
|
|
// Get post ID and verify capability.
|
|
$post_id = absint( wp_unslash( $_POST['post_id'] ?? 0 ) );
|
|
if ( ! $post_id || ! current_user_can( PR_Core_Peptide_CPT::CAPABILITY ) ) {
|
|
wp_send_json_error( 'Unauthorized' );
|
|
}
|
|
|
|
// Update verified date.
|
|
update_post_meta( $post_id, '_pr_last_source_verified', current_time( 'mysql' ) );
|
|
|
|
// Save notes if provided.
|
|
$notes = sanitize_textarea_field( wp_unslash( $_POST['notes'] ?? '' ) );
|
|
if ( $notes ) {
|
|
update_post_meta( $post_id, '_pr_verification_notes', $notes );
|
|
}
|
|
|
|
// Recompute status to 'current'.
|
|
update_post_meta( $post_id, '_pr_verification_status', 'current' );
|
|
|
|
wp_send_json_success( array( 'message' => 'Marked verified' ) );
|
|
}
|
|
|
|
/**
|
|
* Handle scan-now AJAX action.
|
|
*
|
|
* Runs verification scanner immediately.
|
|
*
|
|
* Side effects: Runs scan, returns JSON.
|
|
*
|
|
* @return void
|
|
*/
|
|
public static function handle_scan_now(): void {
|
|
// Verify nonce.
|
|
$nonce = sanitize_text_field( wp_unslash( $_POST['nonce'] ?? '' ) );
|
|
if ( ! wp_verify_nonce( $nonce, 'pr_core_scan_now' ) ) {
|
|
wp_send_json_error( 'Invalid nonce' );
|
|
}
|
|
|
|
// Verify capability.
|
|
if ( ! current_user_can( 'manage_options' ) ) {
|
|
wp_send_json_error( 'Unauthorized' );
|
|
}
|
|
|
|
// Run scan.
|
|
PR_Core_Verification_Scanner::run_scan();
|
|
|
|
wp_send_json_success( array( 'message' => 'Scan complete' ) );
|
|
}
|
|
}
|