22
33namespace CF7_AntiSpam \Admin ;
44
5- use CF7_AntiSpam \Core \CF7_AntiSpam ;
6- use CF7_AntiSpam \Core \CF7_AntiSpam_Filters ;
7- use CF7_AntiSpam \Core \CF7_AntiSpam_Flamingo ;
8- use CF7_AntiSpam \Engine \CF7_AntiSpam_Uninstaller ;
9-
105/**
116 * The plugin admin tools
127 *
@@ -23,17 +18,20 @@ class CF7_AntiSpam_Admin_Tools {
2318 /**
2419 * It sets a transient with the name of `cf7a_notice` and the value of the notice
2520 *
26- * @param string $message The message you want to display.
27- * @param string $type error, warning, success, info.
21+ * @param string $message The message you want to display.
22+ * @param string $type error, warning, success, info.
2823 * @param boolean $dismissible when the notice needs the close button.
2924 */
30- public static function cf7a_push_notice ( $ message = 'generic ' , $ type = 'error ' , $ dismissible = true ) {
25+ public static function cf7a_push_notice ( string $ message = 'generic ' , string $ type = 'error ' , bool $ dismissible = true ) {
3126 $ class = "notice notice- $ type " ;
3227 $ class .= $ dismissible ? ' is-dismissible ' : '' ;
3328 $ notice = sprintf ( '<div class="%s"><p>%s</p></div> ' , esc_attr ( $ class ), esc_html ( $ message ) );
3429 set_transient ( 'cf7a_notice ' , $ notice );
3530 }
3631
32+ /**
33+ * It exports the blacklist
34+ */
3735 public static function cf7a_export_blacklist () {
3836 global $ wpdb ;
3937 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
@@ -67,4 +65,38 @@ public function cf7a_handle_actions() {
6765 exit ();
6866 }
6967 }
68+
69+ /**
70+ * It sends an email to the admin
71+ *
72+ * @param string $subject the mail message subject
73+ * @param string $recipient the mail recipient
74+ * @param string $body the mail message content
75+ * @param string $sender the mail message sender
76+ */
77+ public function send_email_to_admin ( string $ subject , string $ recipient , string $ body , string $ sender ) {
78+ /**
79+ * Filter cf7-antispam before resend an email who was spammed
80+ *
81+ * @param string $body the mail message content
82+ * @param string $sender the mail message sender
83+ * @param string $subject the mail message subject
84+ * @param string $recipient the mail recipient
85+ *
86+ * @returns string the mail body content
87+ */
88+ $ body = apply_filters ( 'cf7a_before_resend_email ' , $ body , $ sender , $ subject , $ recipient );
89+
90+ // Set up headers correctly
91+ $ site_name = get_bloginfo ( 'name ' );
92+ $ from_email = get_option ( 'admin_email ' );
93+
94+ $ headers = "From: {$ site_name } < {$ from_email }> \n" ;
95+ $ headers .= "Content-Type: text/html \n" ;
96+ $ headers .= "X-WPCF7-Content-Type: text/html \n" ;
97+ $ headers .= "Reply-To: {$ sender }\n" ;
98+
99+ /* send the email */
100+ return wp_mail ( $ recipient , $ subject , $ body , $ headers );
101+ }
70102}
0 commit comments