Download the PHP package expl0it3r/kirby-uniform-recaptcha without Composer
On this page you can find all versions of the php package expl0it3r/kirby-uniform-recaptcha. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download expl0it3r/kirby-uniform-recaptcha
More information about expl0it3r/kirby-uniform-recaptcha
Files in expl0it3r/kirby-uniform-recaptcha
Package kirby-uniform-recaptcha
Short Description Kirby 3 reCAPTCHA guard for the Uniform plugin
License MIT
Informations about the package kirby-uniform-recaptcha
Uniform reCAPTCHA
A Kirby 3, 4 & 5 plugin implementing a Google reCAPTCHA v3 guard for the Uniform plugin.
Installation
Download
- Download the repository
- Extract the content to
site/plugins/uniform-recaptcha
Git Submodule
Add the plugin as Git submodule:
Composer
Add the plugin to your repository:
Configuration
Set the configuration in your config.php file:
siteKey&secretKeycan be found on the reCAPTCHA admin pageacceptableScoreis the minimum score in range0.0to1.0(default0.5) required to accept the form submission, see the reCAPTCHA documentationhostnameis optional (default empty / disabled). When set, the guard additionally checks that thehostnamereturned by Google matches this value.
Usage
Template
reCAPTCHA v3 runs invisibly and requires the form submission to happen through JavaScript.
Add the recaptchaField() helper inside your <form> and the recaptchaScript() helper somewhere on the page (e.g. before </body>):
recaptchaField() outputs a hidden input and a small script that, on submit, obtains a reCAPTCHA token and resubmits the form. It binds to its own form via the submit event, so:
- It works no matter how the form is submitted (button click or the Enter key).
- You keep full control over your markup — use any
<button type="submit">you like. - No form
idis required, and it can be used for multiple forms on the same page. - The original submit button's
name/valueis preserved (viarequestSubmit()), so server-side form routing keeps working.
In order for reCAPTCHA to work, you need to load the reCAPTCHA JavaScript file from Google.
Either include the script yourself (with the render parameter set to your site key) or use the helper function recaptchaScript().
Example
Deprecated:
recaptchaButton('Submit', 'btn', 'ContactForm')is still available for backwards compatibility but no longer recommended. It relies on reCAPTCHA'sdata-callbackflow, which does not trigger on Enter-key submits and requires knowing the formid. UserecaptchaField()instead.
Controller
In your controller you can use the magic method recaptchaGuard() to enable the reCAPTCHA guard:
Credits
- Thanks to Johannes Pichler for the Kirby 2 plugin!
- A million thanks to the whole Kirby Team! ❤