Plugin Directory

Changeset 3496225


Ignore:
Timestamp:
04/01/2026 06:56:06 AM (3 days ago)
Author:
konceptwise
Message:

Improved: Performance improvement.

Location:
authyo-otp-for-wpforms/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • authyo-otp-for-wpforms/trunk/assets/js/frontend.js

    r3458936 r3496225  
    138138    }
    139139
    140     function getTargetValue(wrapOrObj) {
     140    function getTargetValue(wrapOrObj, stripZero = true) {
    141141        let wrap, container;
    142142        if (wrapOrObj && wrapOrObj.wrap) {
     
    156156            const countrySelect = container.querySelector('.authyo-country-code');
    157157            if (countrySelect) {
    158                 const dialCode = (countrySelect.options[countrySelect.selectedIndex].dataset.dialCode || '').replace(/\D/g, '');
     158                const dialCode = (countrySelect.options[countrySelect.selectedIndex].dataset.dialCode || '');
    159159                let cleanPhone = val.replace(/\D/g, '');
    160160
    161                 // If phone already starts with dial code, don't double-prefix
    162                 if (dialCode && cleanPhone.startsWith(dialCode)) {
    163                     val = cleanPhone;
     161                // Ensure leading zero is stripped for delivery if requested
     162                if (val.startsWith('+')) {
     163                    val = '+' + cleanPhone;
    164164                } else {
    165                     val = dialCode + cleanPhone;
     165                    const cleanVal = stripZero ? val.replace(/\D/g, '').replace(/^0+/, '') : val.replace(/\D/g, '');
     166                    const displayDialCode = dialCode.startsWith('+') ? dialCode : '+' + dialCode;
     167                    val = displayDialCode + cleanVal;
    166168                }
    167169            }
     
    835837                if (verifiedInput) verifiedInput.value = '1';
    836838
    837                 const targetInput = getTargetInput({ wrap: wrap, container: container });
    838                 const verifiedValue = targetInput ? targetInput.value.trim() : '';
     839                const verifiedValue = getTargetValue({ wrap: wrap, container: container }, false);
    839840
    840841                hide($('.authyo-otp-input-row', wrap));
     
    949950            checkedFieldIds.add(fieldId);
    950951
    951             // Handle phone number prefixing before validation
     952            // Handle phone number prefixing before validation (fallback for unverified fields)
    952953            if (fieldContainer.classList.contains('wpforms-field-authyo-phone')) {
    953954                const countryCode = fieldContainer.querySelector('.authyo-country-code');
    954955                const phoneInput = fieldContainer.querySelector('.wpforms-field-authyo-phone-input');
    955                 const isVerified = fieldContainer.querySelector('.authyo-verified')?.value === '1';
    956 
    957                 if (countryCode && phoneInput && !isVerified) {
     956                const isVerified = (fieldContainer.querySelector('.authyo-verified')?.value === '1') || fieldContainer.classList.contains('authyo-verified');
     957
     958                // If already verified or manual input starts with +, skip this auto-prefixing
     959                if (countryCode && phoneInput && !isVerified && !phoneInput.value.startsWith('+')) {
    958960                    const dial = countryCode.options[countryCode.selectedIndex].dataset.dialCode || '';
    959961                    const cleanDial = dial.replace(/\D/g, '');
  • authyo-otp-for-wpforms/trunk/assets/js/smart-field.js

    r3495366 r3496225  
    406406            // LOW BALANCE BYPASS LOGIC
    407407            if (resp.bypass === true) {
     408                if (input) {
     409                    input.value = target;
     410                }
    408411                showVerifiedState(wrap, channel, target); // Pass target as verified value
    409412                return;
     
    516519                    const dialCode = dialOptions ? dialOptions.dataset.dialCode : '';
    517520                    if (verifiedValue && !verifiedValue.startsWith('+') && dialCode) {
    518                         verifiedValue = dialCode + verifiedValue.replace(/^0+/, '');
     521                        const displayDialCode = dialCode.startsWith('+') ? dialCode : '+' + dialCode;
     522                        verifiedValue = displayDialCode + verifiedValue;
    519523                    }
    520524                }
     
    541545        const verifiedInput = $('.authyo-verified', wrap);
    542546        if (verifiedInput) verifiedInput.value = '1';
     547
     548        const input = $('.wpforms-field-authyo-smart-input', wrap);
     549        if (input) {
     550            input.value = verifiedValue;
     551        }
    543552
    544553        let verifiedUI = $('.authyo-verified-state', wrap);
  • authyo-otp-for-wpforms/trunk/authyo-otp-for-wpforms.php

    r3495366 r3496225  
    44 * Plugin URI:  https://wordpress.org/plugins/authyo-otp-for-wpforms/
    55 * Description: Adds email and phone number OTP verification to WPForms with support for SMS, WhatsApp, and Voice.
    6  * Version:     1.0.9
     6 * Version:     1.0.10
    77 * Author:      Authyo
    88 * Author URI:  https://authyo.io/
     
    1717    exit;
    1818
    19 define('AUTHYO_WPFORMS_VERSION', '1.0.9');
     19define('AUTHYO_WPFORMS_VERSION', '1.0.10');
    2020define('AUTHYO_WPFORMS_FILE', __FILE__);
    2121define('AUTHYO_WPFORMS_PATH', plugin_dir_path(__FILE__));
  • authyo-otp-for-wpforms/trunk/readme.txt

    r3495366 r3496225  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 1.0.9
     7Stable tag: 1.0.10
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    6868== Changelog ==
    6969
     70= 1.0.10 =
     71* Improved: Finalized international phone formatting consistency.
     72* Fixed: Double-prefixing bug in Authyo Phone field.
     73* Added: Preserved leading zero and + prefix in all form entries.
     74* Improved: Performance improvement.
     75
    7076= 1.0.9 =
    7177* Improved: Performance improvement
Note: See TracChangeset for help on using the changeset viewer.