Skip to content
This repository was archived by the owner on Jun 10, 2024. It is now read-only.

Commit 059a232

Browse files
committed
helpers.php changed
1 parent 9aa2799 commit 059a232

File tree

1 file changed

+96
-46
lines changed

1 file changed

+96
-46
lines changed

src/helpers.php

Lines changed: 96 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -11,56 +11,56 @@
1111
use Biscolab\ReCaptcha\Facades\ReCaptcha;
1212

1313
if (!function_exists('recaptcha')) {
14-
/**
15-
* @return Biscolab\ReCaptcha\ReCaptchaBuilder
16-
*/
17-
function recaptcha()
18-
{
19-
20-
return app('recaptcha');
21-
}
14+
/**
15+
* @return Biscolab\ReCaptcha\ReCaptchaBuilder|\Biscolab\ReCaptcha\ReCaptchaBuilderV2|\Biscolab\ReCaptcha\ReCaptchaBuilderInvisible|\Biscolab\ReCaptcha\ReCaptchaBuilderV3
16+
*/
17+
function recaptcha(): \Biscolab\ReCaptcha\ReCaptchaBuilder
18+
{
19+
20+
return app('recaptcha');
21+
}
2222
}
2323

2424
/**
2525
* call ReCaptcha::htmlScriptTagJsApi()
2626
* Write script HTML tag in you HTML code
2727
* Insert before </head> tag
2828
*
29-
* @param $formId required if you are using invisible ReCaptcha
29+
* @param $config ['form_id'] required if you are using invisible ReCaptcha
3030
*/
3131
if (!function_exists('htmlScriptTagJsApi')) {
3232

33-
/**
34-
* @param string $formId
35-
*
36-
* @return string
37-
*/
38-
function htmlScriptTagJsApi($formId = ''): string
39-
{
33+
/**
34+
* @param array|null $config
35+
*
36+
* @return string
37+
*/
38+
function htmlScriptTagJsApi(?array $config = []): string
39+
{
4040

41-
return ReCaptcha::htmlScriptTagJsApi($formId);
42-
}
41+
return ReCaptcha::htmlScriptTagJsApi($config);
42+
}
4343
}
4444

4545
/**
4646
* call ReCaptcha::htmlScriptTagJsApi()
4747
* Write script HTML tag in you HTML code
4848
* Insert before </head> tag
4949
*
50-
* @param $formId required if you are using invisible ReCaptcha
5150
*/
5251
if (!function_exists('htmlScriptTagJsApiV3')) {
5352

54-
/**
55-
* @param array $config
56-
*
57-
* @return string
58-
*/
59-
function htmlScriptTagJsApiV3($config = []): string
60-
{
61-
62-
return ReCaptcha::htmlScriptTagJsApiV3($config);
63-
}
53+
/**
54+
* @param array $config
55+
*
56+
* @return string
57+
* @deprecated
58+
*/
59+
function htmlScriptTagJsApiV3(?array $config = []): string
60+
{
61+
62+
return ReCaptcha::htmlScriptTagJsApiV3($config);
63+
}
6464
}
6565

6666
/**
@@ -74,16 +74,17 @@ function htmlScriptTagJsApiV3($config = []): string
7474
*/
7575
if (!function_exists('htmlFormButton')) {
7676

77-
/**
78-
* @param null|string $buttonInnerHTML
79-
*
80-
* @return string
81-
*/
82-
function htmlFormButton(?string $buttonInnerHTML = 'Submit'): string
83-
{
84-
85-
return ReCaptcha::htmlFormButton($buttonInnerHTML);
86-
}
77+
/**
78+
* @param null|string $button_label
79+
* @param array|null $properties
80+
*
81+
* @return string
82+
*/
83+
function htmlFormButton(?string $button_label = 'Submit', ?array $properties = []): string
84+
{
85+
86+
return ReCaptcha::htmlFormButton($button_label, $properties);
87+
}
8788
}
8889

8990
/**
@@ -95,13 +96,62 @@ function htmlFormButton(?string $buttonInnerHTML = 'Submit'): string
9596
*/
9697
if (!function_exists('htmlFormSnippet')) {
9798

98-
/**
99-
* @return string
100-
*/
101-
function htmlFormSnippet(): string
102-
{
99+
/**
100+
* @return string
101+
*/
102+
function htmlFormSnippet(): string
103+
{
104+
105+
return ReCaptcha::htmlFormSnippet();
106+
}
107+
}
108+
109+
/**
110+
* call ReCaptcha::getFormId()
111+
* return the form ID
112+
* Warning! Using only with ReCAPTCHA invisible
113+
*/
114+
if (!function_exists('getFormId')) {
115+
116+
/**
117+
* @return string
118+
*/
119+
function getFormId(): string
120+
{
121+
122+
return ReCaptcha::getFormId();
123+
}
124+
}
125+
126+
/**
127+
* return ReCaptchaBuilder::DEFAULT_RECAPTCHA_RULE_NAME value ("recaptcha")
128+
* Use V2 (checkbox and invisible)
129+
*/
130+
if (!function_exists('recaptchaRuleName')) {
131+
132+
/**
133+
* @return string
134+
*/
135+
function recaptchaRuleName(): string
136+
{
137+
138+
return \Biscolab\ReCaptcha\ReCaptchaBuilder::DEFAULT_RECAPTCHA_RULE_NAME;
139+
}
140+
}
141+
142+
/**
143+
* return ReCaptchaBuilder::DEFAULT_RECAPTCHA_FIELD_NAME value "g-recaptcha-response"
144+
* Use V2 (checkbox and invisible)
145+
*/
146+
if (!function_exists('recaptchaFieldName')) {
147+
148+
/**
149+
* @return string
150+
*/
151+
function recaptchaFieldName(): string
152+
{
103153

104-
return ReCaptcha::htmlFormSnippet();
105-
}
154+
return \Biscolab\ReCaptcha\ReCaptchaBuilder::DEFAULT_RECAPTCHA_FIELD_NAME;
155+
}
106156
}
107157

0 commit comments

Comments
 (0)