Making WordPress.org


Ignore:
Timestamp:
11/07/2022 04:35:22 AM (4 years ago)
Author:
dd32
Message:

Login: Bypass reCaptcha requirements for local environment installs where the constants are not defined.

File:
1 edited

Legend:

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

    r12206 r12214  
    8888                return;
    8989        }
     90
     91        wp_register_script( 'wporg-registration', get_template_directory_uri() . '/js/registration.js', array( 'recaptcha-api', 'jquery' ), filemtime( __DIR__ . '/js/registration.js' ) );
     92        wp_localize_script( 'wporg-registration', 'wporg_registration', array(
     93                'rest_url' => esc_url_raw( rest_url( 'wporg/v1' ) )
     94        ) );
     95
     96        // Local environments do not need reCaptcha.
     97        if ( 'local' === wp_get_environment_type() && ! defined( 'RECAPTCHA_V3_PUBKEY' ) ) {
     98                wp_register_script( 'recaptcha-api', false ); // Empty script to satisfy wporg-registration requirements.
     99                return;
     100        }
     101
    90102
    91103        wp_register_script( 'recaptcha-api', 'https://www.google.com/recaptcha/api.js', array(), '2' );
    … …  
    109121                }'
    110122        );
    111 
    112         wp_register_script( 'wporg-registration', get_template_directory_uri() . '/js/registration.js', array( 'recaptcha-api', 'jquery' ), filemtime( __DIR__ . '/js/registration.js' ) );
    113         wp_localize_script( 'wporg-registration', 'wporg_registration', array(
    114                 'rest_url' => esc_url_raw( rest_url( 'wporg/v1' ) )
    115         ) );
    116123
    117124        // reCaptcha v3 is loaded on all login pages, not just the registration flow.
Note: See TracChangeset for help on using the changeset viewer.