Plugin Directory

Changeset 3236032


Ignore:
Timestamp:
02/06/2025 01:07:13 PM (14 months ago)
Author:
clearoutio
Message:

Minor Enhancements

Location:
clearout-email-validator
Files:
19 added
3 edited

Legend:

Unmodified
Added
Removed
  • clearout-email-validator/trunk/plugin.php

    r3184424 r3236032  
    44 * Plugin URL:   https://developer.wordpress.org/plugins/clearout-email-validator
    55 * Description:  This plugin seamlessly integrated with all major forms to validate the user's given email address in real-time. Under the hood, this plugin use Clearout API to perform 20+ refined validation checks to determine the status of the email address, and thus helps capturing only the valid leads to maintain high quality mailing list.
    6  * Version:      3.1.6
     6 * Version:      3.1.7
    77 * Author:       Clearout.io
    88 * Author URI:   https://clearout.io
     
    1414
    1515// plugin version.
    16 define( 'CLEAROUT_PLUGIN_VERSION', '3.1.6' );
     16define( 'CLEAROUT_PLUGIN_VERSION', '3.1.7' );
    1717define( 'CLEAROUT_RESULT_CACHED_TIMEOUT', 3600 );
    1818define( 'CLEAROUT_BASE_API_URL', 'https://api.clearout.io/v2/' );
  • clearout-email-validator/trunk/readme.txt

    r3184424 r3236032  
    55Requires at least: 4.6
    66Tested up to: 6.5.5
    7 Stable tag: 3.1.6
     7Stable tag: 3.1.7
    88License: GPLv2 or later
    99Block invalid emails like temporary, disposable, etc. with our real-time email verification. Verify email address during form-fill and stop form spam.
     
    356356= 3.1.6 =
    357357* Minor Fixes
     358= 3.1.7 =
     359* Improved WooCommerce hooks
  • clearout-email-validator/trunk/src/clearout-validator.php

    r3184424 r3236032  
    159159    try {
    160160        global $wp;
    161        
     161
    162162        // Get Clients IP
    163163        $client_ip = _get_user_ip();
     
    286286    // the Strpos check is introduced to make sure even if Rest API is called from admin page it shud not trigger EV
    287287    // Use the custom is_admin_request() function to check if in the admin context
    288     if ( is_admin_request()  && CLEAROUT_TEST_PLUGIN_SOURCE != $clearout_form_source ) {
     288    if ( is_admin_request() && CLEAROUT_TEST_PLUGIN_SOURCE != $clearout_form_source ) {
    289289        return $clearout_validation_result;
    290290    }
     
    358358    if ( ( isset( $clearout_options['sts_on_off'] ) && 'on' == $clearout_options['sts_on_off'] ) ) {
    359359        $is_sts = _co_is_sts( $email_result );
    360         if ( !$is_sts ) {
     360        if ( ! $is_sts ) {
    361361            $clearout_validation_result['status'] = false;
    362362            $clearout_validation_result['reason'] = 'sts_email';
     
    882882}
    883883
     884// checkoutFields reference: https://woocommerce.github.io/code-reference/classes/WC-Checkout.html#method_get_checkout_fields
    884885/**
    885886 * Woocommerce Checkout Forms.
     
    890891function clearout_woocom_checkout_validate_email( $fields, $errors ) {
    891892    $clearout_form_source = 'woochkfrm';
    892 
    893     if ( isset( $fields['billing_email'] ) ) {
    894         $email = $fields['billing_email'];
    895 
    896         // Get option settings to know which validator is been called.
    897         $clearout_options = get_option( 'clearout_email_validator' );
    898         $is_valid_email   = true;
    899         if ( ( ! ( '' == $clearout_options['api_key'] ) ) && ( '' != $email ) ) {
    900             // do the email validation.
    901             $validation_result = _co_email_validation( $email, $clearout_options, $clearout_form_source );
    902             if ( ( is_array( $validation_result ) ) && array_key_exists( 'status', $validation_result ) ) {
    903                 if ( false == $validation_result['status'] ) {
    904                     $is_valid_email = false;
    905                     // if any validation errors.
    906                     // remove all of them.
    907                     foreach ( $errors->get_error_codes() as $code ) {
    908                         $errors->remove( $code );
    909                     }
    910 
    911                     if ( _check_custom_error_msg_exist( $clearout_options ) ) {
    912                         $errors->add( 'validation', $clearout_options['custom_invalid_error'] );
     893    $checkout_fields      = WC()->checkout()->get_checkout_fields();
     894
     895
     896    foreach ( $fields as $key => $value ) {
     897        if ( strpos( $key, '_email' ) !== false ) {
     898            $email = $value;
     899
     900            // if the field's class has clearout skip validation identifier, dont validate
     901            $class_array = [];
     902            foreach ( $checkout_fields as $section => $section_fields ) {
     903                if ( isset( $section_fields[ $key ]['class'] ) ) {
     904                    $class_array = $section_fields[ $key ]['class'];
     905                    break;
     906                }
     907            }
     908
     909            // if the clearout skip validation class is set for this field, skip it.
     910            if ( ! empty( preg_grep( CLEAROUT_IGNORE_VALIDATION_IDENTIFIER_REGEX, $class_array ) ) ) {
     911                continue;
     912            }
     913
     914            // Get option settings to know which validator is been called.
     915            $clearout_options = get_option( 'clearout_email_validator' );
     916            $is_valid_email   = true;
     917            if ( ( ! ( '' == $clearout_options['api_key'] ) ) && ( '' != $email ) ) {
     918                // do the email validation.
     919                $validation_result = _co_email_validation( $email, $clearout_options, $clearout_form_source );
     920                if ( ( is_array( $validation_result ) ) && array_key_exists( 'status', $validation_result ) ) {
     921                    if ( false == $validation_result['status'] ) {
     922                        $is_valid_email = false;
     923                        // if any validation errors.
     924                        // remove all of them.
     925                        foreach ( $errors->get_error_codes() as $code ) {
     926                            $errors->remove( $code );
     927                        }
     928
     929                        if ( _check_custom_error_msg_exist( $clearout_options ) ) {
     930                            $errors->add( 'validation', $clearout_options['custom_invalid_error'] );
     931                            return;
     932                        }
     933                        $error_message = _get_error_message( $validation_result['reason'] );
     934                        $errors->add( 'validation', $error_message );
    913935                        return;
    914936                    }
    915                     $error_message = _get_error_message( $validation_result['reason'] );
    916                     $errors->add( 'validation', $error_message );
    917                 }
    918             }
     937                }
     938            }
     939
    919940        }
    920941    }
Note: See TracChangeset for help on using the changeset viewer.