-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.php
99 lines (87 loc) · 4.02 KB
/
config.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
97
98
99
<?php
use WPD\Recaptcha;
return [
'wpd.recaptcha.path' => plugin_dir_path( __FILE__ ),
'wpd.recaptcha.key' => WPD_RECAPTCHA_KEY,
'wpd.recaptcha.secret' => WPD_RECAPTCHA_SECRET,
'wpd.recaptcha.allowed_ips' => array_filter(
explode( ',', WPD_RECAPTCHA_ALLOWED_IPS )
),
'wpd.recaptcha.admin_page' => 'wpd_recaptcha',
'wpd.recaptcha.allowed_ips_option' => 'wpd_recaptcha_allowed_ips',
'wpd.recaptcha.type' => preg_match( '/^\dx/', WPD_RECAPTCHA_KEY )
? 'turnstile'
: 'recaptcha',
'wpd.recaptcha.provider.script_url' => static fn ( DI\Container $container ): string =>
$container->get( 'wpd.recaptcha.type' ) === 'turnstile'
? 'https://challenges.cloudflare.com/turnstile/v0/api.js?onload=onloadTurnstileCallback'
: 'https://www.google.com/recaptcha/api.js',
'wpd.recaptcha.validation.url' => static fn ( DI\Container $container ): string =>
$container->get( 'wpd.recaptcha.type' ) === 'turnstile'
? 'https://challenges.cloudflare.com/turnstile/v0'
: 'https://www.google.com/recaptcha/api',
'wpd.recaptcha.challenge_ttl' => 300,
Recaptcha\Providers\Provider::class => DI\autowire()
->constructor(
DI\get( 'wpd.recaptcha.key' ),
DI\get( 'wpd.recaptcha.provider.script_url' )
),
Recaptcha\Providers\Service::class => static fn ( DI\Container $container ): Recaptcha\Providers\Service =>
$container->get( 'wpd.recaptcha.type' ) === 'turnstile'
? $container->get( Recaptcha\Providers\Turnstile::class )
: $container->get( Recaptcha\Providers\ReCaptcha::class ),
'WPD\Recaptcha\Whip' => DI\autowire( Vectorface\Whip\Whip::class ),
Recaptcha\AllowedLists\Permanent::class => DI\autowire()
->constructor( DI\get( 'wpd.recaptcha.allowed_ips' ) ),
Recaptcha\AllowedLists\Configurable::class => DI\autowire()
->constructor( DI\get( 'wpd.recaptcha.allowed_ips_option' ) ),
Recaptcha\Firewall::class => DI\autowire()
->constructor(
[
DI\get( Recaptcha\AllowedLists\Permanent::class ),
DI\get( Recaptcha\AllowedLists\Configurable::class ),
]
),
'WPD\Recaptcha\Validation\Url' => DI\autowire( Recaptcha\Misc\Url::class )
->constructor( DI\get( 'wpd.recaptcha.validation.url' ) ),
'WPD\Recaptcha\Validation\HttpClient' => DI\create( Recaptcha\Misc\HttpClient::class )
->constructor( DI\get( 'WPD\Recaptcha\Validation\Url' ) ),
Recaptcha\Validation::class => DI\autowire()
->constructor( DI\get( 'WPD\Recaptcha\Validation\HttpClient' ) ),
Recaptcha\View::class => static fn ( DI\Container $container ): Recaptcha\View =>
new Recaptcha\View( $container->get( 'wpd.recaptcha.path' ) . 'resources/views' ),
Recaptcha\Controller::class => DI\autowire()
->constructorParameter( 'secret_key', DI\get( 'wpd.recaptcha.secret' ) )
->constructorParameter( 'whip', DI\get( 'WPD\Recaptcha\Whip' ) )
->constructorParameter( 'challenge_ttl', DI\get( 'wpd.recaptcha.challenge_ttl' ) ),
Recaptcha\FormsRepository::class => DI\autowire()
->constructor(
[
DI\get( Recaptcha\Forms\Login::class ),
DI\get( Recaptcha\Forms\LostPassword::class ),
DI\get( Recaptcha\Forms\RetrievePassword::class ),
]
),
'WPD\Recaptcha\Settings\AllowedIps' => DI\autowire( Recaptcha\Misc\Setting::class )
->constructor(
DI\get( 'wpd.recaptcha.allowed_ips_option' ),
__( 'Allowed IPs', 'wpd-recaptcha' ),
'sanitize_textarea_field',
[
'type' => 'textarea',
'class' => '',
'rows' => 5,
'cols' => 45,
'description' => __( 'One IP per line.', 'wpd-recaptcha' ),
]
),
Recaptcha\Settings::class => DI\autowire()
->constructor(
DI\get( 'wpd.recaptcha.admin_page' ),
[
DI\get( 'WPD\Recaptcha\Settings\AllowedIps' ),
]
),
Recaptcha\Plugin::class => DI\autowire()
->constructorParameter( 'admin_page', DI\get( 'wpd.recaptcha.admin_page' ) ),
];