'
. esc_html__( 'π New here? Run a Malware Scan (above) first, then click βCreate Baseline.β The baseline records your current files as the clean reference, so the scanner can spot anything that changes later.', 'ai-cyberguard' ) . '
'; // #gp-scan-progress-container
// Add spinner animation CSS
echo '';
// Add batch scan JavaScript
self::render_batch_scan_js();
}
/**
* Render batch scan JavaScript
*/
private static function render_batch_scan_js() {
?>
';
// UX (2026-06-19): the #1 source of confusion was "I ran a Malware Scan and it
// was clean, so why does Regular Scan show files?" β because these are two
// DIFFERENT scans. Spell out the difference in plain language before the
// per-button list, so a changed file is not mistaken for malware (and vice-versa).
echo '
';
echo '' . esc_html__( 'Two different scans β whatβs the difference?', 'ai-cyberguard' ) . ' ';
echo esc_html__( 'The Malware Scan (purple box above) looks for known malicious code inside your files. The scans below β Regular Scan and Full Scan β do something different: they compare your files against your saved Baseline and report any file that was changed, added, or removed. Most file changes are completely harmless (WordPress, plugin or theme updates), so a file listed here is NOT necessarily malware β it simply changed since your baseline. The two scans work together: malware scanning catches known bad code, and file-change scanning catches tampering even when the code is not yet a known signature.', 'ai-cyberguard' );
echo '
';
echo '
';
echo '' . esc_html__( 'Create Baseline', 'ai-cyberguard' ) . ' β ' . esc_html__( 'records your current files as the clean reference β do this once, ideally right after a clean Malware Scan.', 'ai-cyberguard' ) . ' ';
echo '' . esc_html__( 'Refresh Baseline', 'ai-cyberguard' ) . ' β ' . esc_html__( 'click this after legitimate WordPress, plugin, or theme updates, so the scanner learns the new files and stops flagging them as changes (avoids false alarms).', 'ai-cyberguard' ) . ' ';
echo '' . esc_html__( 'Regular Scan', 'ai-cyberguard' ) . ' β ' . esc_html__( 'checks only risky file types (PHP, JS, configs). Fast and recommended.', 'ai-cyberguard' ) . ' ';
echo '' . esc_html__( 'Full Scan', 'ai-cyberguard' ) . ' β ' . esc_html__( 'checks every file (slower). Use only if you suspect your site was hacked.', 'ai-cyberguard' ) . '
';
echo '';
}
/**
* Render Malware Scan Section (above baseline buttons)
*
* @param string $nonce Batch scan nonce
*/
public static function render_malware_scan_section( $nonce ) {
// Get signature stats
$sig_stats = array( 'total' => 50 );
if ( class_exists( 'GuardPress_Malware_Scanner' ) ) {
$sig_stats = GuardPress_Malware_Scanner::get_signature_stats();
}
// Check if we have last scan results
$last_scan = null;
if ( class_exists( 'GuardPress_Malware_Scanner' ) ) {
$last_scan = GuardPress_Malware_Scanner::get_last_scan();
}
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// ACG-149-R36-E (pre-release audit 2026-07-27) β SHOW WHAT THE SCHEDULED SCAN FOUND.
//
// The scheduled scan malware-scans the files it finds changed, and it does find webshells.
// Until now that verdict reached the user through exactly one channel: the alert email. And
// `email_enabled` ships as 0, so on a DEFAULT install the product positively identified a
// backdoor and then had nowhere to put it β the dashboard went on saying "1 file change
// detected". The persistence layer for this was written last round and had NO CALLER
// anywhere in the plugin, so the behaviour was still fully live.
//
// Rendered ABOVE the scan card and separately from it, because it answers a different
// question: the card reports the last scan the USER ran, this reports what ran on its own
// while they were away. Deliberately not merged into the card's tri-state β the two have
// different coverage (whole site vs changed files only) and merging them would let one
// scan's coverage claim describe the other's findings, which is the cross-surface
// contradiction ACG-138-R2-03 exists to prevent.
$gp_sched = ( class_exists( 'GuardPress_Malware_Scanner' )
&& method_exists( 'GuardPress_Malware_Scanner', 'get_scheduled_findings' ) )
? GuardPress_Malware_Scanner::get_scheduled_findings()
: array();
$gp_sched_files = ( is_array( $gp_sched ) && ! empty( $gp_sched['files'] ) && is_array( $gp_sched['files'] ) )
? $gp_sched['files']
: array();
// ACG-149-R37-P: every row is reduced to two plain strings before anything renders. The record
// is persisted state; a corrupt or hostile value (an object) previously reached a `(string)` cast
// mid-render and threw an uncaught Error β a white screen after the opening
gnp.php" RENDERS as "harmlessphp.png" β the admin reads an
// image and moves on, while the file on disk is a PHP webshell. Unterminated, it
// also reverses the signature name and the remaining rows.
//
// This plugin's own detector already strips exactly this range when matching
// core-file impersonation (class-malware-scanner.php), i.e. we defend against the
// trick in the engine and then hand it to the user in the UI. Stripped here so the
// displayed name is the name, and on the owner's Hebrew (RTL) admin β where
// reordered text does not look anomalous at all β it still is.
$gp_strip_bidi = static function ( $s ) {
$out = preg_replace( '/[\x{200B}-\x{200F}\x{202A}-\x{202E}\x{2066}-\x{2069}\x{2060}\x{FEFF}]/u', '', (string) $s );
return ( null === $out ) ? (string) $s : $out; // invalid UTF-8 -> preg returns null
};
$gp_sf_shown = 0;
foreach ( $gp_rows as $gp_sf ) {
if ( $gp_sf_shown >= 10 ) { break; }
$gp_sf_shown++;
echo '
' . esc_html( sprintf(
/* translators: %d is the number of additional files not listed. */
_n( 'and %d more file.', 'and %d more files.', count( $gp_rows ) - $gp_sf_shown, 'ai-cyberguard' ),
count( $gp_rows ) - $gp_sf_shown
) ) . '
';
}
// ACG-149-R37-A: the record's own 50-row cap, surfaced rather than hidden.
if ( ! empty( $gp_sched['files_dropped'] ) ) {
echo '
' . esc_html( sprintf(
/* translators: %d is the number of infected files beyond the list limit. */
_n(
'and %d further infected file that did not fit in this list.',
'and %d further infected files that did not fit in this list.',
(int) $gp_sched['files_dropped'],
'ai-cyberguard'
),
(int) $gp_sched['files_dropped']
) ) . '
0 leaves total_threats at 0 β
// a modified core file carries no signature match) fell through to
// "No malware β 1 item to review" while the status banner said
// "WordPress core files have changed" and the results panel said
// "CRITICAL: Reinstall WordPress immediately". Three surfaces, same
// scan, one of them calling a hacked core an optional review item.
// The reviewer's objection: a customer cannot tell those three
// statements apart, and the contradiction is trivial to screenshot.
// The arms below now follow the SAME severity order as the ladder in
// generate_summary() β malware > core integrity > coverage > review β
// so the card can no longer rank a core issue below a benign extract().
$gp_s = $last_scan['summary'];
$gp_t = (int) ( $gp_s['total_threats'] ?? 0 );
$gp_rv = (int) ( $gp_s['review_total'] ?? 0 );
$gp_cm = (int) ( $gp_s['core_modified'] ?? 0 );
$gp_cu = (int) ( $gp_s['core_unknown'] ?? 0 );
if ( $gp_t > 0 ) {
printf(
/* translators: %d is the number of confirmed malware threats found by the scan */
esc_html( _n( '%d threat found', '%d threats found', $gp_t, 'ai-cyberguard' ) ),
esc_html( $gp_t )
);
} elseif ( $gp_cm > 0 ) {
esc_html_e( 'WordPress core files have changed β reinstall WordPress', 'ai-cyberguard' );
} elseif ( ( $gp_pi = (int) ( $gp_s['potential_items'] ?? 0 ) ) > 0 ) {
// ACG-138-R2-03: the flagship case. A HIGH/CRITICAL suspicious finding read
// exactly like a benign extract() in a premium plugin ("No malware β 1 item
// to review"), which is the understatement ACG-116-T1/ACG-122 exist to stop.
// ACG-138-R2-03-adv (adversarial review, 2026-07-17): potential_items comes
// BEFORE core_unknown here, to match generate_summary()'s ladder EXACTLY. The
// arms were previously swapped (core_unknown first), so a scan with BOTH
// core_unknown>0 AND potential_items>0 showed the core-unknown headline on the
// card while the results panel led with potential_items β the very
// cross-surface contradiction R2-03 exists to prevent.
printf(
/* translators: %d is the number of serious items shown as potential threats */
esc_html( _n( 'No confirmed malware β %d item needs checking now', 'No confirmed malware β %d items need checking now', $gp_pi, 'ai-cyberguard' ) ),
esc_html( $gp_pi )
);
} elseif ( $gp_cu > 0 ) {
esc_html_e( 'A file in your WordPress core folders is not part of the official release', 'ai-cyberguard' );
} elseif ( empty( $gp_s['coverage_complete'] ) ) {
esc_html_e( 'No malware found β but the scan was incomplete', 'ai-cyberguard' );
} elseif ( $gp_rv > 0 ) {
printf(
/* translators: %d is the number of items that need review (not confirmed malware) */
esc_html( _n( 'No malware β %d item to review', 'No malware β %d items to review', $gp_rv, 'ai-cyberguard' ) ),
esc_html( $gp_rv )
);
} else {
esc_html_e( 'Scan complete β review the results', 'ai-cyberguard' );
}
}
?>
π‘
0 ) {
$days_since = floor( ( time() - $last_threat_update ) / 86400 );
if ( $days_since > 0 ) {
$update_info = sprintf(
/* translators: %d is the number of days since threat signatures were last updated */
__( 'Threat signatures last updated %d days ago.', 'ai-cyberguard' ),
$days_since
);
} else {
$update_info = __( 'Threat signatures updated today.', 'ai-cyberguard' );
}
} else {
$update_info = __( 'Threat signatures never updated. Click "Refresh" in Threat Intelligence section below.', 'ai-cyberguard' );
}
?>