Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

+ Add theme option #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Set the configuration in your `config.php` file:
return [
'anselmh.uniform-turnstile.siteKey' => 'my-site-key',
'anselmh.uniform-turnstile.secretKey' => 'my-secret-key',
'anselmh.uniform-turnstile.theme' => 'auto(default)|light|dark',
];
```

Expand Down
6 changes: 6 additions & 0 deletions i18n/fr.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

return [
'uniform-turnstile-empty' => 'Le challenge Cloudflare Turnstile n\'a pas été résolu.',
'uniform-turnstile-invalid' => 'La réponse au défi Cloudflare Turnstile n\'est pas valide.'
];
3 changes: 2 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
Kirby::plugin('anselmh/uniform-turnstile', [
'options' => [
'siteKey' => '',
'secretKey' => ''
'secretKey' => '',
'theme' => ''
],
'translations' => [
'en' => @include_once __DIR__.'/i18n/en.php',
Expand Down
13 changes: 12 additions & 1 deletion src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,22 @@ function turnstileField(): string
{
$siteKey = option('anselmh.uniform-turnstile.siteKey');

switch (option('anselmh.uniform-turnstile.theme')) {
case 'light':
$theme = 'light';
break;
case 'dark':
$theme = 'dark';
break;
default:
$theme = 'auto';
}

if (empty($siteKey)) {
throw new UniformException('The Turnstile sitekey for Uniform is not configured');
}

return '<div class="cf-turnstile" data-sitekey="'.$siteKey.'" data-callback="javascriptCallback"></div>';
return '<div class="cf-turnstile" data-sitekey="' . $siteKey . '" data-theme="' . $theme . '" data-callback="javascriptCallback"></div>';
}
}

Expand Down