Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
no-captcha
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
CENTER-TBI
no-captcha
Commits
d055473a
Commit
d055473a
authored
Sep 27, 2017
by
Yerzhan Hn
Committed by
GitHub
Sep 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Explicit rendering after an onload callback
parent
cc0bacff
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
5 deletions
+25
-5
src/NoCaptcha.php
src/NoCaptcha.php
+25
-5
No files found.
src/NoCaptcha.php
View file @
d055473a
...
...
@@ -9,6 +9,8 @@ class NoCaptcha
{
const
CLIENT_API
=
'https://www.google.com/recaptcha/api.js'
;
const
VERIFY_URL
=
'https://www.google.com/recaptcha/api/siteverify'
;
const
ON_LOAD_CLASS
=
'onloadCallBack'
;
const
RENDER_TYPE
=
'explicit'
;
/**
* The recaptcha secret key.
...
...
@@ -47,14 +49,15 @@ class NoCaptcha
*
* @param array $attributes
* @param string $lang
* @param boolean $callback
*
* @return string
*/
public
function
display
(
$attributes
=
[],
$lang
=
null
)
public
function
display
(
$attributes
=
[],
$lang
=
null
,
$callback
=
false
,
$onLoadClass
=
'onloadCallBack'
)
{
$attributes
[
'data-sitekey'
]
=
$this
->
sitekey
;
$html
=
'<script src="'
.
$this
->
getJsLink
(
$lang
)
.
'" async defer></script>'
.
"
\n
"
;
$html
=
'<script src="'
.
$this
->
getJsLink
(
$lang
,
$callback
,
$onLoadClass
)
.
'" async defer></script>'
.
"
\n
"
;
$html
.=
'<div class="g-recaptcha"'
.
$this
->
buildAttributes
(
$attributes
)
.
'></div>'
;
return
$html
;
...
...
@@ -102,12 +105,29 @@ class NoCaptcha
* Get recaptcha js link.
*
* @param string $lang
*
* @param boolean $callback
* @param string $onLoadClass
* @return string
*/
public
function
getJsLink
(
$lang
=
null
)
public
function
getJsLink
(
$lang
=
null
,
$callback
=
false
,
$onLoadClass
=
'onloadCallBack'
)
{
$client_api
=
static
::
CLIENT_API
;
$params
=
[];
$callback
?
$this
->
setCallBackParams
(
$params
,
$onLoadClass
)
:
false
;
$lang
?
$params
[
'hl'
]
=
$lang
:
null
;
return
$client_api
.
'?'
.
http_build_query
(
$params
);
}
/**
* @param $params
* @param $onLoadClass
*/
protected
function
setCallBackParams
(
&
$params
,
$onLoadClass
)
{
return
$lang
?
static
::
CLIENT_API
.
'?hl='
.
$lang
:
static
::
CLIENT_API
;
$params
[
'render'
]
=
'explicit'
;
$params
[
'onload'
]
=
$onLoadClass
;
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment