send_summary_email( $findings, $new_findings ); } private function send_summary_email( array $all_findings, array $new_findings ) { $to = get_option( 'admin_email' ); $site = get_bloginfo( 'name' ); $subject = sprintf( '[%s] Weekly security scan: %d open issue(s)', $site, count( $all_findings ) ); if ( empty( $all_findings ) ) { $body = "Good news — your weekly scan found no open security issues on {$site}.\n"; } else { $body = sprintf( "Your weekly scan of %s found %d open issue(s).\n\n", $site, count( $all_findings ) ); if ( ! empty( $new_findings ) ) { $body .= "NEW since last scan:\n"; foreach ( $new_findings as $finding ) { $body .= sprintf( "- [%s] %s\n", strtoupper( $finding['severity'] ), $finding['title'] ); } $body .= "\n"; } $body .= sprintf( "View the full report and fix steps: %s\n", admin_url( 'admin.php?page=clarityguard' ) ); } wp_mail( $to, $subject, $body ); } }