Plugin Directory

Changeset 3434522


Ignore:
Timestamp:
01/07/2026 04:56:52 PM (3 months ago)
Author:
simone88
Message:

update version 1.0.4

Location:
helloform/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • helloform/trunk/Readme.txt

    r3430600 r3434522  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 1.0.3
     7Stable tag: 1.0.4
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    5252== External Services ==
    5353
    54 This plugin uses **Google reCAPTCHA** (version v2 "I'm not a robot" checkbox) to protect the forms from spam and automated abuse. This feature is optional and disabled by default until configured by the user in the plugin settings.
     54This plugin uses **Google reCAPTCHA** (version v2 or v3) to protect the forms from spam. This feature is optional and disabled by default until configured by the user.
    5555
    5656**What data is sent and when:**
     
    7070
    7171== Changelog ==
     72
     73= 1.0.4 =
     74* **Feature:** Optimized script loading. reCAPTCHA scripts are now registered and enqueued ONLY when the shortcode is present on the page.
     75* **Fix:** Resolved layout conflicts (CSS/Flexbox) in search pages and global footers caused by reCAPTCHA script injection.
     76* **Performance:** Reduced global page weight by preventing unnecessary third-party script loading on pages without forms.
    7277
    7378= 1.0.3 =
     
    9297== Upgrade Notice ==
    9398
     99= 1.0.4 =
     100Critical update for layout stability and performance. Optimized reCAPTCHA loading to prevent theme conflicts. Recommended for all users.
     101
    94102= 1.0.3 =
    95103This update includes critical stability fixes for reCAPTCHA and new security options. Immediate update is highly recommended.
  • helloform/trunk/helloform.php

    r3430576 r3434522  
    33Plugin Name: HelloForm
    44Description: Customizable contact form for quote requests.
    5 Version: 1.0.3
     5Version: 1.0.4
    66Author: Simone Cipolletta
    77Author URI: https://github.com/simonecipolletta
     
    1616}
    1717/*definisco la versione */
    18 define('HELLOFORM_VERSION', '1.0.3');
     18define('HELLOFORM_VERSION', '1.0.4');
    1919
    2020// Definisci debug solo se non definita altrove
     
    8686
    8787function helloform_shortcode() {
     88    // Sveglia lo script registrato solo in questa pagina
     89    wp_enqueue_script('google-recaptcha');
     90   
    8891    ob_start();
    8992
     
    316319
    317320// Enqueue reCAPTCHA script in front-end se attivo con supporto v2/v3
    318 if (!function_exists('helloform_enqueue_recaptcha_script')) {
    319     function helloform_enqueue_recaptcha_script() {
    320         if (get_option('helloform_recaptcha_enabled') === '1') {
    321             $site_key = get_option('helloform_recaptcha_site');
    322             $version  = get_option('helloform_recaptcha_version', 'v2');
    323            
    324             $api_url = 'https://www.google.com/recaptcha/api.js';
    325            
    326             // Se è v3, aggiungiamo il parametro render con la site key
    327             if ($version === 'v3' && !empty($site_key)) {
    328                 $api_url .= '?render=' . esc_attr($site_key);
    329             }
    330 
    331             wp_enqueue_script(
    332                 'google-recaptcha',
    333                 $api_url,
    334                 [],
    335                 HELLOFORM_VERSION,
    336                 true
    337             );
    338         }
    339     }
    340     add_action('wp_enqueue_scripts', 'helloform_enqueue_recaptcha_script');
    341 }
     321if (!function_exists('helloform_register_recaptcha_script')) {
     322    function helloform_register_recaptcha_script() {
     323        // 1. Controllo se il reCAPTCHA è attivo nelle impostazioni
     324        if (get_option('helloform_recaptcha_enabled') !== '1') {
     325            return;
     326        }
     327
     328        $site_key = get_option('helloform_recaptcha_site');
     329        $version  = get_option('helloform_recaptcha_version', 'v2');
     330       
     331        // 2. Se manca la chiave, non serve registrare nulla (Early Return)
     332        if (empty($site_key)) {
     333            return;
     334        }
     335
     336        $api_url = 'https://www.google.com/recaptcha/api.js';
     337       
     338        if ($version === 'v3') {
     339            $api_url .= '?render=' . esc_attr($site_key);
     340        }
     341
     342        // 3. Registriamo lo script: è pronto, ma "dorme" finché lo shortcode non lo sveglia
     343        wp_register_script(
     344            'google-recaptcha',
     345            $api_url,
     346            [],
     347            HELLOFORM_VERSION,
     348            true
     349        );
     350    }
     351    add_action('wp_enqueue_scripts', 'helloform_register_recaptcha_script');
     352}
Note: See TracChangeset for help on using the changeset viewer.