Skip to content

Commit

Permalink
fixed google uri
Browse files Browse the repository at this point in the history
  • Loading branch information
skaparate committed Jun 17, 2020
1 parent ede8721 commit 54c581c
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions includes/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

/**
* The main functionalaty of this plugin.
*
* @version 1.0.1
*/
class Core
{
Expand All @@ -15,13 +17,25 @@ class Core
* if the $handle doesn't match with the one defined by contact forms 7.
*/
public function getScriptSrc($src, $handle)
{
{
if ($handle !== 'google-recaptcha') {
return $src;
}
return 'https://google.com/recaptcha/api.js?hl=' . strtolower(pll_current_language());

$lang = strtolower(pll_current_language());
if ('en' === $lang) {
return $src;
}
if (false !== strpos($src, '&hl=')) {
return str_replace('/&hl=../', "&hl=$lang", $src);
}
if (false !== strpos($src, '?hl=')) {
return str_replace('/\\?hl=../', "?hl=$lang", $src);
}

return $src . '&hl=' . $lang;
}

public function run()
{
$this->loadLang();
Expand Down

0 comments on commit 54c581c

Please sign in to comment.