nonce_action = $nonce_action; } /** * Render a toggle switch * * @param string $name Input name * @param bool $checked Whether checked * @param string $label Label text (optional) * @param array $args Additional args (id, class, disabled, description) */ private function render_toggle( $name, $checked, $label = '', $args = array() ) { $id = isset( $args['id'] ) ? $args['id'] : $name; $class = isset( $args['class'] ) ? ' ' . $args['class'] : ''; $disabled = ! empty( $args['disabled'] ) ? ' disabled' : ''; $data_attr = isset( $args['data'] ) ? ' data-feature="' . esc_attr( $args['data'] ) . '"' : ''; echo '
' . esc_html( $args['description'] ) . '
'; } } /** * Render the settings & security page */ public function render() { if ( ! current_user_can( 'manage_options' ) ) { return; } $notice = isset( $_GET['gp_notice'] ) ? sanitize_text_field( wp_unslash( $_GET['gp_notice'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- capability-gated read (current_user_can manage_options above); read-only notice key for display // Get settings $gp_settings = class_exists( 'GuardPress_Settings' ) ? GuardPress_Settings::get() : array(); // Get login security data $login_settings = class_exists( 'GuardPress_Login_Security' ) ? GuardPress_Login_Security::get_settings() : array(); $login_stats = class_exists( 'GuardPress_Login_Security' ) ? GuardPress_Login_Security::get_stats() : array(); $blocked_ips = class_exists( 'GuardPress_Login_Security' ) ? GuardPress_Login_Security::get_blocked_ips() : array(); $suspicious = class_exists( 'GuardPress_Login_Security' ) ? GuardPress_Login_Security::get_suspicious_ips() : array(); $blacklist = class_exists( 'GuardPress_Login_Security' ) ? GuardPress_Login_Security::get_blacklist() : array(); $whitelist = class_exists( 'GuardPress_Login_Security' ) ? GuardPress_Login_Security::get_whitelist() : array(); $login_log = class_exists( 'GuardPress_Login_Security' ) ? GuardPress_Login_Security::get_log( 20 ) : array(); $current_ip = class_exists( 'GuardPress_Login_Security' ) ? GuardPress_Login_Security::get_admin_ip() : ''; echo '๐ก ' . esc_html__( 'Don\'t forget to click "Save Settings" after making changes!', 'ai-cyberguard' ) . '
'; echo '' . esc_html__( 'Automatic scans run in the background, alert you when files change, and check every changed file for malware. Recommended: Enable with "Twice daily" for most sites.', 'ai-cyberguard' ) . '
'; echo '| ' . esc_html__( 'Enable Scheduled Scans', 'ai-cyberguard' ) . ' | '; $this->render_toggle( 'gp_scheduled_enabled', $enabled, __( 'Run automatic scans', 'ai-cyberguard' ), array( 'description' => __( 'Scans run via WordPress cron. Make sure your site has regular traffic or set up a server cron job.', 'ai-cyberguard' ) ) ); echo ' |
|---|---|
| ' . esc_html__( 'Frequency', 'ai-cyberguard' ) . ' | ';
echo '';
// -- Next scan time --
if ( $enabled ) {
$next_ts = wp_next_scheduled( 'guardpress_cron_scan_v1' );
if ( $next_ts ) {
$next_local = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $next_ts ), 'H:i' );
echo ' '; echo ''; /* translators: %s is the local time of the next scheduled scan */ echo esc_html( sprintf( __( 'Next scan: %s', 'ai-cyberguard' ), $next_local ) ); echo ' '; } else { echo ''; echo ''; echo esc_html__( 'No scan scheduled โ save settings to schedule.', 'ai-cyberguard' ); echo ' '; } } echo ' |
| ' . esc_html__( 'Preferred time', 'ai-cyberguard' ) . ' | ';
echo '';
echo ' ' . esc_html__( 'For Daily / Twice-daily schedules, the scan starts around this time in your site timezone โ pick a quiet, low-traffic hour. WordPress runs scheduled tasks on visitor traffic, so it runs close to this time, not exactly on the clock.', 'ai-cyberguard' ) . ' '; echo ' |
| ' . esc_html__( 'Scan Mode', 'ai-cyberguard' ) . ' | ';
echo '';
echo ' ' . esc_html__( 'Regular scans check PHP, JS, and config files. Full scans check everything including images and backups.', 'ai-cyberguard' ) . ' '; echo ' |
'; echo ''; echo esc_html__( 'Scan results are displayed on the main Dashboard page. After each scheduled scan, you can view the results and receive email alerts (if enabled).', 'ai-cyberguard' ); echo '
'; echo '' . esc_html__( 'Get notified by email when files change โ and immediately if a scheduled scan finds malware.', 'ai-cyberguard' ) . '
'; echo '| ' . esc_html__( 'Enable Email Alerts', 'ai-cyberguard' ) . ' | '; $this->render_toggle( 'gp_email_enabled', $enabled, __( 'Send email when changes are detected', 'ai-cyberguard' ) ); echo ' |
|---|---|
| ' . esc_html__( 'Recipients', 'ai-cyberguard' ) . ' | ';
echo '';
echo ' ' . esc_html__( 'Comma-separated emails. Leave empty to use the site admin email.', 'ai-cyberguard' ) . ' '; echo ' |
| ' . esc_html__( 'Subject Prefix', 'ai-cyberguard' ) . ' | ';
echo '';
echo ' ' . esc_html__( 'Optional prefix for filtering emails in your inbox. Example: [MyCompany-Security]', 'ai-cyberguard' ) . ' '; echo ' |
| ' . esc_html__( 'Rate Limit', 'ai-cyberguard' ) . ' | ';
echo '';
// ACG-149-138: state the exemption. Someone choosing "every 24 hours" must not be left believing a
// backdoor alert could sit unsent for a day โ it cannot; only file-change alerts are throttled.
echo ' ' . esc_html__( 'Prevent email overload during large updates. "No limit" is fine for most sites. Confirmed malware alerts are always sent immediately and ignore this limit.', 'ai-cyberguard' ) . ' '; echo ' |
| ' . esc_html__( 'Noise Control', 'ai-cyberguard' ) . ' | ';
$this->render_toggle( 'gp_alert_only_risky', $alert_only_risky, __( 'Only alert on risky file types (PHP, JS, config files)', 'ai-cyberguard' ), array(
'description' => __( 'Reduces alerts for harmless changes like images or CSS files.', 'ai-cyberguard' )
) );
echo ' ';
$this->render_toggle( 'gp_include_plugin_updates', $include_plugin_updates, __( 'Include available plugin updates in alerts', 'ai-cyberguard' ) );
echo ' ';
echo ' |
' . esc_html__( 'Reduce false positives by excluding known-changing files like cache folders and logs.', 'ai-cyberguard' ) . '
'; // Warning echo 'โ ๏ธ ' . esc_html__( 'Security Trade-off:', 'ai-cyberguard' ) . ' ' . esc_html__( 'Excluded folders are not scanned at all. Only exclude folders you trust completely.', 'ai-cyberguard' ) . '
'; echo '| ' . esc_html__( 'Allowed Change Patterns', 'ai-cyberguard' ) . ' (โ Safe) | ';
echo '';
echo ' ' . wp_kses_post( __( 'One pattern per line. Use ' . esc_html__( 'Common examples:', 'ai-cyberguard' ) . ' '; echo 'wp-content/cache/* wp-content/wflogs/* wp-content/debug.log'; echo ' |
|---|---|
| ' . esc_html__( 'Excluded Directories', 'ai-cyberguard' ) . ' (โ Not Scanned) | ';
echo '';
echo ' ' . esc_html__( 'These folders are completely ignored. Use only for non-sensitive folders like backup archives.', 'ai-cyberguard' ) . ' '; echo '' . esc_html__( 'Common examples:', 'ai-cyberguard' ) . ' '; echo 'wp-content/cache wp-content/updraft wp-content/ai1wm-backups'; echo ' |
' . esc_html__( 'Send a test message to verify your email configuration.', 'ai-cyberguard' ) . '
'; GuardPress_Partial_Buttons::render_form_button( array( 'cmd' => 'send_test_email', 'label' => __( 'Send Test Email', 'ai-cyberguard' ), 'icon' => 'email', 'class' => 'secondary', 'size' => '', 'nonce' => $this->nonce_action, ) ); echo ''; echo esc_html__( 'When enabled, AI Analysis sends code excerpts from detected file changes to an external AI service (Claude by Anthropic) for security analysis. Alongside each excerpt it also sends the file name, its path relative to your site root, the file type, and your WordPress version (never the absolute server path or a username). Sensitive data like passwords, API keys, and database credentials are automatically redacted before sending.', 'ai-cyberguard' ); echo '
'; echo ''; echo esc_html__( 'AI Analysis is currently disabled. Enable it to get intelligent security insights.', 'ai-cyberguard' ); echo '
'; echo ''; echo ''; echo esc_html__( 'By enabling, you consent to sending code excerpts to an external AI service for analysis.', 'ai-cyberguard' ); echo '
'; echo ''; if ( $is_pro_user ) { /* translators: %d is the number of PRO AI analyses remaining this year */ echo sprintf( esc_html__( '%d PRO analyses remaining this year', 'ai-cyberguard' ), esc_html( $stats['remaining'] ) ); } else { /* translators: %d is the number of free AI analyses remaining */ echo sprintf( esc_html__( '%d free analyses remaining', 'ai-cyberguard' ), esc_html( $stats['remaining'] ) ); } echo '
'; echo ''; echo esc_html__( 'AI CyberGuard automatically downloads the latest malware signatures and threat patterns from our security database. This keeps your scanner updated with new threats as they are discovered.', 'ai-cyberguard' ); echo '
'; echo ''; echo esc_html__( 'AI CyberGuard respects your privacy. All external connections to GuardPress servers are disabled by default. You have full control over what data is shared. Enable the features below to get the most out of the plugin.', 'ai-cyberguard' ); echo '
'; // Recommendations box echo ''; echo esc_html__( 'These advanced security features are available in the PRO version.', 'ai-cyberguard' ); echo '
'; } else { echo ''; echo esc_html__( 'Configure each feature from its dedicated settings page. Click on any feature below to manage its settings.', 'ai-cyberguard' ); echo '
'; } // Define PRO features with their pages $pro_features = array( // === Core Security === array( 'id' => 'waf', 'title' => __( 'Advanced WAF (Real-Time)', 'ai-cyberguard' ), 'icon' => 'shield-alt', 'description' => __( 'Always-on real-time firewall โ upgrades the basic firewall already in FREE', 'ai-cyberguard' ), 'setting_key' => 'waf_enabled', 'page' => 'guardpress-waf', ), array( 'id' => 'country_blocking', 'title' => __( 'Country Blocking', 'ai-cyberguard' ), 'icon' => 'admin-site-alt3', 'description' => __( 'Block or allow traffic from specific countries', 'ai-cyberguard' ), 'setting_key' => 'country_block_enabled', 'page' => 'guardpress-waf', ), array( 'id' => 'two_factor', 'title' => __( 'Full 2FA (Org-Wide)', 'ai-cyberguard' ), 'icon' => 'lock', 'description' => __( 'Org-wide enforcement, per-role rules & trusted devices โ beyond the per-user 2FA in FREE', 'ai-cyberguard' ), 'setting_key' => 'two_factor_enabled', 'page' => 'guardpress-login-protection', ), array( 'id' => 'realtime_protection', 'title' => __( 'Real-Time File Protection', 'ai-cyberguard' ), 'icon' => 'visibility', 'description' => __( 'Monitor file changes instantly as they happen', 'ai-cyberguard' ), 'setting_key' => 'realtime_enabled', 'page' => 'guardpress-realtime', ), // === Backup & Recovery === array( 'id' => 'cloud_backup', 'title' => __( 'Cloud Backup', 'ai-cyberguard' ), 'icon' => 'cloud-upload', 'description' => __( 'Automatic backups to Google Drive, Dropbox, or S3', 'ai-cyberguard' ), 'setting_key' => 'backup_enabled', 'page' => 'guardpress-backup', ), array( 'id' => 'quarantine', 'title' => __( 'Quarantine & Auto-Restore', 'ai-cyberguard' ), 'icon' => 'trash', 'description' => __( 'Isolate suspicious files, auto-restore from baseline', 'ai-cyberguard' ), 'setting_key' => 'quarantine_enabled', 'page' => 'guardpress-quarantine', ), array( 'id' => 'time_machine', 'title' => __( 'Security Time Machine', 'ai-cyberguard' ), 'icon' => 'backup', 'description' => __( 'Browse and restore any file version from history', 'ai-cyberguard' ), 'setting_key' => 'time_machine_enabled', 'page' => 'guardpress-time-machine', ), // === Notifications === array( 'id' => 'notifications', 'title' => __( 'Instant Notifications', 'ai-cyberguard' ), 'icon' => 'smartphone', 'description' => __( 'SMS, WhatsApp, Telegram, Slack alerts', 'ai-cyberguard' ), 'setting_key' => 'notify_sms', 'page' => 'guardpress-notifications', ), array( 'id' => 'voice_alerts', 'title' => __( 'Voice Call Alerts', 'ai-cyberguard' ), 'icon' => 'phone', 'description' => __( 'Receive phone calls for critical security events', 'ai-cyberguard' ), 'setting_key' => 'voice_alerts_enabled', 'page' => 'guardpress-notifications', ), // === AI Intelligence === array( 'id' => 'ai_assistant', 'title' => __( 'AI Security Assistant', 'ai-cyberguard' ), 'icon' => 'format-chat', 'description' => __( 'Chat with AI about your security status and threats', 'ai-cyberguard' ), 'setting_key' => 'ai_assistant_enabled', 'page' => 'guardpress-ai-assistant', ), array( 'id' => 'predictive_threat', 'title' => __( 'Predictive Threat Score', 'ai-cyberguard' ), 'icon' => 'chart-area', 'description' => __( 'AI predicts potential vulnerabilities before attacks', 'ai-cyberguard' ), 'setting_key' => 'predictive_enabled', 'page' => 'guardpress-ai-intelligence', ), array( 'id' => 'login_anomaly', 'title' => __( 'Login Anomaly Intelligence', 'ai-cyberguard' ), 'icon' => 'admin-users', 'description' => __( 'Detect unusual login patterns and suspicious behavior', 'ai-cyberguard' ), 'setting_key' => 'login_anomaly_enabled', 'page' => 'guardpress-login-protection', ), array( 'id' => 'attack_replay', 'title' => __( 'Attack Replay Analysis', 'ai-cyberguard' ), 'icon' => 'controls-play', 'description' => __( 'Visualize attack timeline and understand threat vectors', 'ai-cyberguard' ), 'setting_key' => 'attack_replay_enabled', 'page' => 'guardpress-attack-replay', ), // === Unique Features === array( 'id' => 'honeypot', 'title' => __( 'Hacker Trap (Honeypots)', 'ai-cyberguard' ), 'icon' => 'warning', 'description' => __( 'Deploy decoy files to detect and trap attackers', 'ai-cyberguard' ), 'setting_key' => 'honeypot_enabled', 'page' => 'guardpress-hardening', ), array( 'id' => 'code_dna', 'title' => __( 'Code DNA Fingerprinting', 'ai-cyberguard' ), 'icon' => 'screenoptions', 'description' => __( 'Advanced code analysis beyond simple hash matching', 'ai-cyberguard' ), 'setting_key' => 'code_dna_enabled', 'page' => 'guardpress-advanced', ), array( 'id' => 'git_integration', 'title' => __( 'Git Integration', 'ai-cyberguard' ), 'icon' => 'media-code', 'description' => __( 'Compare files with Git repositories for integrity', 'ai-cyberguard' ), 'setting_key' => 'git_enabled', 'page' => 'guardpress-git', ), // === Compliance & Reports === array( 'id' => 'compliance', 'title' => __( 'Compliance Dashboard', 'ai-cyberguard' ), 'icon' => 'clipboard', 'description' => __( 'GDPR, PCI-DSS compliance reports and audit logs', 'ai-cyberguard' ), 'setting_key' => 'compliance_enabled', 'page' => 'guardpress-compliance', ), array( 'id' => 'gamification', 'title' => __( 'Security Gamification', 'ai-cyberguard' ), 'icon' => 'awards', 'description' => __( 'Achievements, streaks, leaderboard & score history', 'ai-cyberguard' ), 'setting_key' => 'gamification_pro_enabled', 'page' => 'guardpress-gamification', ), // === Monitoring === array( 'id' => 'uptime', 'title' => __( 'Uptime Monitoring', 'ai-cyberguard' ), 'icon' => 'chart-line', 'description' => __( 'Get alerted when your site goes down', 'ai-cyberguard' ), 'setting_key' => 'uptime_enabled', 'page' => 'guardpress-monitoring', ), ); // Render feature cards echo '' . esc_html( $feature['description'] ) . '
'; // Action button if ( $is_locked ) { echo ''; echo ''; echo esc_html__( 'Unlock with PRO', 'ai-cyberguard' ); echo ''; } else { echo ''; echo ''; echo esc_html__( 'Configure', 'ai-cyberguard' ); echo ''; } echo '