Last active
July 21, 2020 07:30
-
-
Save shivapoudel/75e6d6167af25ee61d46fc27534609ab to your computer and use it in GitHub Desktop.
Everest Forms - Support reCAPTCHA v2 Language code. (Updated for 1.7.0)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // Do not include this if already open! | |
/** | |
* Code goes in theme functions.php. | |
*/ | |
add_filter( 'everest_forms_frontend_recaptcha_url', 'evf_recaptcha_lang_code', 10, 2 ); | |
/** | |
* Language code support for reCAPTCHA v2. | |
* | |
* @param string $recaptcha_url reCAPTCHA Url. | |
* @param string $recaptcha_type reCAPTCHA type. | |
* | |
* @return string Modified url with language code. | |
*/ | |
function evf_recaptcha_lang_code( $recaptcha_url, $recaptcha_type ) { | |
if ( 'v2' === $recaptcha_type ) { | |
/** | |
* Forces the widget to render in a specific language. | |
* Additionally, uuto-detects the user's language if unspecified. | |
* | |
* @see https://developers.google.com/recaptcha/docs/display#config | |
*/ | |
$recaptcha_url = add_query_arg( 'hl', 'id', $recaptcha_url ); | |
} | |
return $recaptcha_url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment