From 85ecea4f612c687fd3baddd86e9eb13e07495466 Mon Sep 17 00:00:00 2001 From: Inani El Houssain Date: Mon, 30 Jan 2017 19:39:57 +0000 Subject: [PATCH 1/3] Not loading the JS file for every time --- src/NoCaptcha.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/NoCaptcha.php b/src/NoCaptcha.php index 63cd00e..36bae13 100644 --- a/src/NoCaptcha.php +++ b/src/NoCaptcha.php @@ -29,6 +29,17 @@ class NoCaptcha */ protected $http; + /** + * @var \GuzzleHttp\Client + */ + protected $http; + + /** + * Check if the JS file is imported. + * + * @var bool + */ + private static $imported = false; /** * NoCaptcha. * @@ -53,10 +64,12 @@ public function __construct($secret, $sitekey) public function display($attributes = [], $lang = null) { $attributes['data-sitekey'] = $this->sitekey; + $html =''; - $html = ''."\n"; + !static::$imported && $html = ''."\n"; $html .= '
buildAttributes($attributes).'>
'; + static::$imported = true; return $html; } From 3e4d4b172b9a73f521074941ef07672decb2af3f Mon Sep 17 00:00:00 2001 From: Inani El Houssain Date: Tue, 31 Jan 2017 10:43:50 +0000 Subject: [PATCH 2/3] Update NoCaptcha.php --- src/NoCaptcha.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/NoCaptcha.php b/src/NoCaptcha.php index 36bae13..d867477 100644 --- a/src/NoCaptcha.php +++ b/src/NoCaptcha.php @@ -66,10 +66,13 @@ public function display($attributes = [], $lang = null) $attributes['data-sitekey'] = $this->sitekey; $html =''; - !static::$imported && $html = ''."\n"; - $html .= '
buildAttributes($attributes).'>
'; + if (!static::$imported) { + $html = ''."\n"; + static::$imported = true; + } - static::$imported = true; + $html .= '
buildAttributes($attributes).'>
'; + return $html; } From abf85a96fb8bf4f9c1ab47989d1d6e5771c82625 Mon Sep 17 00:00:00 2001 From: Inani El Houssain Date: Tue, 31 Jan 2017 11:02:06 +0000 Subject: [PATCH 3/3] Update NoCaptcha.php --- src/NoCaptcha.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/NoCaptcha.php b/src/NoCaptcha.php index d867477..466d71b 100644 --- a/src/NoCaptcha.php +++ b/src/NoCaptcha.php @@ -29,11 +29,6 @@ class NoCaptcha */ protected $http; - /** - * @var \GuzzleHttp\Client - */ - protected $http; - /** * Check if the JS file is imported. * @@ -66,10 +61,8 @@ public function display($attributes = [], $lang = null) $attributes['data-sitekey'] = $this->sitekey; $html =''; - if (!static::$imported) { - $html = ''."\n"; - static::$imported = true; - } + !static::$imported && $html = ''."\n"; + static::$imported = true; $html .= '
buildAttributes($attributes).'>
';