From 74d21309ee82563888fd13e137a3e56a50ab6d8b Mon Sep 17 00:00:00 2001 From: Matt Harrison Date: Thu, 28 Sep 2023 19:51:46 -0400 Subject: [PATCH] reset the blacklist to default on each field so it doesn't carry over from previous fields --- includes/class-gfemailblacklist.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/includes/class-gfemailblacklist.php b/includes/class-gfemailblacklist.php index 25c7d63..27b2dc2 100644 --- a/includes/class-gfemailblacklist.php +++ b/includes/class-gfemailblacklist.php @@ -207,11 +207,11 @@ public function gf_emailblacklist_gform_editor_js() { public function gf_emailblacklist_validation( $validation_result ) { // Collect global settings. - $blacklist = get_option( 'gravityformsaddon_' . $this->_slug . '_settings' ); - if ( is_array( $blacklist ) && ! empty( $blacklist['default_emailblacklist'] ) ) { - $blacklist = $blacklist['default_emailblacklist']; + $default_blacklist = get_option( 'gravityformsaddon_' . $this->_slug . '_settings' ); + if ( is_array( $default_blacklist ) && ! empty( $default_blacklist['default_emailblacklist'] ) ) { + $default_blacklist = $default_blacklist['default_emailblacklist']; } else { - $blacklist = ''; + $default_blacklist = ''; } // Collect form results. @@ -231,6 +231,7 @@ public function gf_emailblacklist_validation( $validation_result ) { } // Collect banned domains from backend and clean up. + $blacklist = $default_blacklist; if ( ! empty( $field['email_blacklist'] ) ) { // collect per form settings. $blacklist = $field['email_blacklist']; } @@ -256,7 +257,9 @@ public function gf_emailblacklist_validation( $validation_result ) { } // Create array of banned domains. - $blacklist = explode( ',', $blacklist ); + if ( ! is_array( $blacklist ) ) { + $blacklist = explode( ',', $blacklist ); + } $blacklist = str_replace( '*', '', $blacklist ); $blacklist = array_map( array( $this, 'gf_emailblacklist_clean' ), $blacklist ); $blacklist = array_filter( $blacklist );