@@ -76,7 +76,7 @@ public function init(): void {
76
76
parent ::init ();
77
77
78
78
$ this ->settings = get_option ('gravityformsaddon_ ' . $ this ->_slug . '_settings ' );
79
- $ this ->getDenylist ();
79
+ $ this ->denylist = $ this -> getDenylist ();
80
80
}
81
81
82
82
/**
@@ -215,8 +215,6 @@ public function gform_editor_js(): void
215
215
*/
216
216
public function gform_validation (array $ validation_result ): array
217
217
{
218
- $ denylist = $ this ->denylist ;
219
-
220
218
// Collect form results.
221
219
$ form = $ validation_result ['form ' ];
222
220
@@ -234,8 +232,10 @@ public function gform_validation(array $validation_result): array
234
232
235
233
// Collect banned domains from the form and clean up.
236
234
if (! empty ($ field ['email_filtering ' ])) {
237
- $ denylist = $ field ['email_filtering ' ];
238
- }
235
+ $ denylist = $ this ->getDenylist ($ field ['email_filtering ' ]);
236
+ } else {
237
+ $ denylist = $ this ->denylist ;
238
+ }
239
239
240
240
// Get the domain from user entered email.
241
241
$ email = $ this ->clean_string (rgpost ("input_ {$ field ['id ' ]}" ));
@@ -258,9 +258,10 @@ public function gform_validation(array $validation_result): array
258
258
}
259
259
260
260
// Create array of banned domains.
261
- $ denylist = explode (', ' , $ denylist );
262
- $ denylist = str_replace ('* ' , '' , $ denylist );
263
- $ denylist = array_map ([$ this , 'clean_string ' ], $ denylist );
261
+ $ denylist = array_map (function ($ item ) {
262
+ return str_replace ('* ' , '' , $ item );
263
+ }, $ denylist );
264
+
264
265
$ denylist = array_filter ($ denylist );
265
266
266
267
// No filtered emails, skip.
@@ -327,13 +328,14 @@ public function saveDenylist(Textarea $field, string $setting): string {
327
328
}
328
329
329
330
/**
330
- * Set the denylist in an array.
331
+ * Get the denylist in an array.
331
332
*/
332
- public function getDenylist (): void {
333
- $ denylist = $ this ->settings ['default_email_denylist ' ] ?? '' ;
333
+ public function getDenylist (string $ denylist = '' ): array {
334
+ $ denylist = $ denylist ?: $ this ->settings ['default_email_denylist ' ];
334
335
$ denylist = str_replace (', ' , "\r\n" , $ denylist );
335
336
$ denylist = explode ("\r\n" , $ denylist );
336
- $ this ->denylist = array_map ([$ this , 'clean_string ' ], $ denylist );
337
+
338
+ return array_map ([$ this , 'clean_string ' ], $ denylist );
337
339
}
338
340
339
341
/**
0 commit comments