PluginProbe
Vigilant – 100% Free Security Suite: Firewall, 2FA, Login, Headers, Scanner… / 2.9.9
Vigilant – 100% Free Security Suite: Firewall, 2FA, Login, Headers, Scanner… v2.9.9
3.0.0 2.11.12 2.11.11 2.11.10 2.11.9 2.11.7 2.11.8 2.11.6 2.11.5 2.11.4 2.11.3 2.11.1 2.11.2 2.11.0 2.10.5 2.10.4 2.10.3 2.10.2 2.10.1 2.10.0 2.9.9 2.9.8 2.9.6 2.9.7 2.9.5 All 88 releases
vigilante / admin / class-admin-audit-alerts-ajax.php

class-admin-audit-alerts-ajax.php in Vigilant – 100% Free Security Suite: Firewall, 2FA, Login, Headers, Scanner… 2.9.9, at admin/class-admin-audit-alerts-ajax.php

66 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Audit Alerts AJAX handlers
4 *
5 * Kept in a separate trait (same pattern as class-admin-analyzer-ajax.php) so
6 * the main class-admin-ajax.php does not keep growing. Settings are saved
7 * through the generic ajax_save_settings handler (data-section="audit_alerts");
8 * this trait only adds the "Send test email" endpoint.
9 *
10 * @package Vigilante
11 */
12
13 // Prevent direct access.
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 /**
19 * Trait Vigilante_Admin_Audit_Alerts_Ajax
20 */
21 trait Vigilante_Admin_Audit_Alerts_Ajax {
22
23 /**
24 * Send a test email to the configured recipients.
25 *
26 * Shared by the "Send test email" button in Notification settings, File
27 * Integrity and Audit Alerts.
28 */
29 public function ajax_send_test_email() {
30 check_ajax_referer( 'vigilante_admin_nonce', 'nonce' );
31
32 if ( ! current_user_can( 'manage_options' ) ) {
33 wp_send_json_error( array( 'message' => __( 'Permission denied.', 'vigilante' ) ) );
34 }
35
36 $recipients = Vigilante_Email_Template::get_admin_recipients();
37 if ( empty( $recipients ) ) {
38 wp_send_json_error(
39 array(
40 'message' => __( 'No notification recipients are configured. Set them in Settings & Tools.', 'vigilante' ),
41 )
42 );
43 }
44
45 $sent = Vigilante_Email_Template::send_test();
46
47 if ( $sent ) {
48 wp_send_json_success(
49 array(
50 'message' => sprintf(
51 /* translators: %s: comma-separated list of recipient email addresses */
52 __( 'Test email sent to %s.', 'vigilante' ),
53 implode( ', ', $recipients )
54 ),
55 )
56 );
57 }
58
59 wp_send_json_error(
60 array(
61 'message' => __( 'WordPress could not send the email. Check your site mail configuration.', 'vigilante' ),
62 )
63 );
64 }
65 }
66