Skip to content

Instantly share code, notes, and snippets.

@shivapoudel
Last active July 21, 2020 07:30
Show Gist options
  • Save shivapoudel/75e6d6167af25ee61d46fc27534609ab to your computer and use it in GitHub Desktop.
Save shivapoudel/75e6d6167af25ee61d46fc27534609ab to your computer and use it in GitHub Desktop.

Revisions

  1. shivapoudel revised this gist Jul 21, 2020. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion functions.php
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,8 @@
    /**
    * Language code support for reCAPTCHA v2.
    *
    * @param string $recaptcha_url reCAPTCHA Url.
    * @param string $recaptcha_url reCAPTCHA Url.
    * @param string $recaptcha_type reCAPTCHA type.
    *
    * @return string Modified url with language code.
    */
  2. shivapoudel revised this gist Jul 21, 2020. 1 changed file with 10 additions and 17 deletions.
    27 changes: 10 additions & 17 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    /**
    * Code goes in theme functions.php.
    */
    add_filter( 'everest_forms_frontend_recaptcha_url', 'evf_recaptcha_lang_code' );
    add_filter( 'everest_forms_frontend_recaptcha_url', 'evf_recaptcha_lang_code', 10, 2 );

    /**
    * Language code support for reCAPTCHA v2.
    @@ -12,22 +12,15 @@
    *
    * @return string Modified url with language code.
    */
    function evf_recaptcha_lang_code( $recaptcha_url ) {
    $query_args = array();
    $query_string = wp_parse_url( $recaptcha_url, PHP_URL_QUERY );

    if ( is_string( $query_string ) ) {
    parse_str( $query_string, $query_args );

    if ( isset( $query_args['onload'] ) && 'EVFRecaptchaLoad' === $query_args['onload'] ) {
    /**
    * 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 );
    }
    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;
  3. shivapoudel revised this gist Jul 11, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion functions.php
    Original file line number Diff line number Diff line change
    @@ -31,4 +31,4 @@ function evf_recaptcha_lang_code( $recaptcha_url ) {
    }

    return $recaptcha_url;
    }
    }
  4. shivapoudel created this gist Jul 11, 2020.
    34 changes: 34 additions & 0 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    <?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' );

    /**
    * Language code support for reCAPTCHA v2.
    *
    * @param string $recaptcha_url reCAPTCHA Url.
    *
    * @return string Modified url with language code.
    */
    function evf_recaptcha_lang_code( $recaptcha_url ) {
    $query_args = array();
    $query_string = wp_parse_url( $recaptcha_url, PHP_URL_QUERY );

    if ( is_string( $query_string ) ) {
    parse_str( $query_string, $query_args );

    if ( isset( $query_args['onload'] ) && 'EVFRecaptchaLoad' === $query_args['onload'] ) {
    /**
    * 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;
    }