Making WordPress.org

Changeset 11615


Ignore:
Timestamp:
02/25/2022 06:51:15 AM (3 years ago)
Author:
dd32
Message:

Login: Attach the reCaptcha v3 results to the correct form. Take Two.

In [11486] I used the wrong selector function, which resulted in Javascript warnings on some pages.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/functions.php

    r11486 r11615  
    9696        'recaptcha-api',
    9797        'function onSubmit(token) {
    98             var form = document.getElementById("registerform");
    99 
     98            var form = document.querySelector( "#registerform, form:not(#language-switcher)" );
     99
     100            if ( ! form ) {
     101                return;
     102            }
     103
     104            // This is used for the interaction with the invisible v3 recaptcha.
    100105            if ( form.dataset.submitReady ) {
    101106                form.submit();
     
    131136                // Add the token to the "primary" form
    132137                var input = document.createElement( "input" ),
    133                     form = document.getElementById( "registerform" );
     138                    form = document.querySelector( "#registerform, form:not(#language-switcher)" );
    134139
    135140                if ( ! form ) {
    136                     form = document.querySelectorAll( "form:not(#language-switcher)" );
     141                    return;
    137142                }
    138143
     
    143148                form.appendChild( input );
    144149
     150                // If the visual reCaptcha v2 is not loaded, this data point will never be used.
    145151                if ( form.dataset.submitReady ) {
    146152                    form.submit();
Note: See TracChangeset for help on using the changeset viewer.