-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRegisterGlobalSettings.php
96 lines (88 loc) · 2.6 KB
/
RegisterGlobalSettings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
namespace GiveCloudflareTurnstile\Settings\Actions;
use GiveCloudflareTurnstile\Settings\ValueObjects\SettingKeys;
/**
* @since 1.0.0
*/
class RegisterGlobalSettings
{
/**
* @since 1.0.0
*/
public function __invoke(array $settings): array
{
if ('cloudflare_turnstile' !== give_get_current_setting_section()) {
return $settings;
}
return $this->getSettings();
}
/**
* @since 1.0.0
*/
protected function getSettings(): array
{
return [
[
'id' => 'give_title_settings_cloudflare_turnstile_1',
'type' => 'title',
],
$this->getEnableSettings(),
$this->getApiSiteKeySettings(),
$this->getApiSecretKeySettings(),
[
'id' => 'give_title_settings_cloudflare_turnstile_1',
'type' => 'sectionend',
],
];
}
/**
* @since 1.0.0
*/
public function getEnableSettings(): array
{
return [
'name' => __('Enable Cloudflare Turnstile', 'give-cloudflare-turnstile'),
'desc' => __(
'If enabled, this option will add a Cloudflare Turnstile widget to all donation forms',
'give-cloudflare-turnstile'
),
'id' => SettingKeys::ENABLED,
'type' => 'radio_inline',
'default' => 'disabled',
'options' => [
'enabled' => __('Enabled', 'give-cloudflare-turnstile'),
'disabled' => __('Disabled', 'give-cloudflare-turnstile'),
],
];
}
/**
* @since 1.0.0
*/
public function getApiSiteKeySettings(): array
{
return [
'id' => SettingKeys::SITE_KEY,
'name' => __('Cloudflare Turnstile Site Key', 'give-cloudflare-turnstile'),
'desc' => __(
'Enter your Cloudflare Site Key here. This key is required to connect to the Cloudflare API.',
'give-cloudflare-turnstile'
),
'type' => 'api_key',
];
}
/**
* @since 1.0.0
*/
public function getApiSecretKeySettings(): array
{
return [
'id' => SettingKeys::SECRET_KEY,
'name' => __('Cloudflare Turnstile Secret Key', 'give-cloudflare-turnstile'),
'desc' => __(
'Enter your Cloudflare Turnstile Secret key here. This key is required to connect to the Cloudflare API.',
'give-cloudflare-turnstile'
),
'type' => 'api_key',
];
}
}