Plugin Directory

Changeset 3193531


Ignore:
Timestamp:
11/20/2024 10:55:32 PM (15 months ago)
Author:
DeveloperWil
Message:
  • Added check for empty blacklist when getting the field and at the start of the foreach loop for each item
Location:
email-blacklist-for-elementor-forms
Files:
7 added
2 edited

Legend:

Unmodified
Added
Removed
  • email-blacklist-for-elementor-forms/trunk/email-blacklist-for-elementor-forms.php

    r3082898 r3193531  
    44 * Plugin URI: https://zeropointdevelopment.com
    55 * Description: Adds a text area control called "Blacklist" to the Elementor Forms control. Blocks outgoing emails if they match with any on the blacklist.
    6  * Version: 1.0.1
     6 * Version: 1.0.2
    77 * Author: Wil Brown
    88 * Author URI: https://zeropointdevelopment.com/about
     
    7979    $settings = $record->get( 'form_settings' );
    8080    $blacklist = sanitize_textarea_field( $settings['blacklist'] );
     81    if ( empty( $blacklist ) ) {
     82        return;
     83    }
    8184    $blacklist_values = explode( ',', $blacklist );
    8285
    8386    $blocked_email_msg = "that email or domain";
    8487    $has_blocked_email = false;
    85     // Loop through the block list and match with outgoing email value
    86     foreach( $blacklist_values as $blacklist_value ){
    87         if( ( strpos( $field['value'], trim( $blacklist_value) ) || ( $field['value'] === trim( $blacklist_value ) ) ) && !$has_blocked_email){
    88             $has_blocked_email = true;
    89             $blocked_email_msg = '"'. trim( $blacklist_value ) . '"';
    90         }
    91     }
     88    // Loop through the block list and match with outgoing email value
     89    foreach( $blacklist_values as $blacklist_value ) {
     90        $blacklist_value = trim($blacklist_value); // Trim spaces
     91        if ( empty($blacklist_value) ) {
     92            continue; // Skip empty blacklist values
     93        }
     94        if ( strpos( $field['value'], $blacklist_value ) !== false || $field['value'] === $blacklist_value ) {
     95            $has_blocked_email = true;
     96            $blocked_email_msg = '"' . $blacklist_value . '"';
     97            break; // Stop further checking once a match is found
     98        }
     99    }
    92100
    93101    //If there's a match on the blacklist, show an error.
  • email-blacklist-for-elementor-forms/trunk/readme.txt

    r3112017 r3193531  
    44Requires at least: 6.0
    55Requires PHP: 8.1
    6 Tested up to: 6.6
    7 Stable tag: 1.0.1
     6Tested up to: 6.7
     7Stable tag: 1.0.2
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset for help on using the changeset viewer.