Skip to content

Commit cd5b3b1

Browse files
author
hCaptcha GHA
committed
Rename the whitelisted to allowlisted.
1 parent 6a9fadb commit cd5b3b1

File tree

6 files changed

+31
-32
lines changed

6 files changed

+31
-32
lines changed

.tests/php/integration/AAAMainTest.php

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,14 @@ public function test_init_on_cron(): void {
153153
*
154154
* @param boolean $logged_in User is logged in.
155155
* @param string $hcaptcha_off_when_logged_in Option 'hcaptcha_off_when_logged_in' is set.
156-
* @param boolean|string $whitelisted Whether IP is whitelisted.
156+
* @param boolean|string $allowlisted Whether IP is allowlisted.
157157
* @param boolean $hcaptcha_active Plugin should be active.
158158
*
159159
* @dataProvider dp_test_init
160160
* @throws ReflectionException ReflectionException.
161161
* @noinspection PhpUnitTestsInspection
162-
* @noinspection UnusedFunctionResultInspection
163162
*/
164-
public function test_init_and_init_hooks( bool $logged_in, string $hcaptcha_off_when_logged_in, $whitelisted, bool $hcaptcha_active ): void {
163+
public function test_init_and_init_hooks( bool $logged_in, string $hcaptcha_off_when_logged_in, $allowlisted, bool $hcaptcha_active ): void {
165164
global $current_user;
166165

167166
$hcaptcha = hcaptcha();
@@ -180,8 +179,8 @@ public function test_init_and_init_hooks( bool $logged_in, string $hcaptcha_off_
180179

181180
add_filter(
182181
'hcap_whitelist_ip',
183-
static function () use ( $whitelisted ) {
184-
return $whitelisted;
182+
static function () use ( $allowlisted ) {
183+
return $allowlisted;
185184
}
186185
);
187186

@@ -223,7 +222,7 @@ static function () use ( $whitelisted ) {
223222
-PHP_INT_MAX,
224223
has_filter(
225224
'hcap_whitelist_ip',
226-
[ $subject, 'whitelist_ip' ]
225+
[ $subject, 'allowlist_ip' ]
227226
)
228227
);
229228

@@ -253,14 +252,14 @@ static function () use ( $whitelisted ) {
253252
*/
254253
public function dp_test_init(): array {
255254
return [
256-
'not logged in, not set, not whitelisted' => [ false, 'off', false, true ],
257-
'not logged in, set, not whitelisted' => [ false, 'on', false, true ],
258-
'logged in, not set, not whitelisted' => [ true, 'off', false, true ],
259-
'logged in, set, not whitelisted' => [ true, 'on', false, false ],
260-
'not logged in, not set, whitelisted' => [ false, 'off', true, false ],
261-
'not logged in, set, whitelisted' => [ false, 'on', true, false ],
262-
'logged in, not set, whitelisted' => [ true, 'off', true, false ],
263-
'logged in, set, whitelisted' => [ true, 'on', true, false ],
255+
'not logged in, not set, not allowlisted' => [ false, 'off', false, true ],
256+
'not logged in, set, not allowlisted' => [ false, 'on', false, true ],
257+
'logged in, not set, not allowlisted' => [ true, 'off', false, true ],
258+
'logged in, set, not allowlisted' => [ true, 'on', false, false ],
259+
'not logged in, not set, allowlisted' => [ false, 'off', true, false ],
260+
'not logged in, set, allowlisted' => [ false, 'on', true, false ],
261+
'logged in, not set, allowlisted' => [ true, 'off', true, false ],
262+
'logged in, set, allowlisted' => [ true, 'on', true, false ],
264263
];
265264
}
266265

@@ -320,7 +319,7 @@ static function () {
320319
-PHP_INT_MAX,
321320
has_filter(
322321
'hcap_whitelist_ip',
323-
[ $subject, 'whitelist_ip' ]
322+
[ $subject, 'allowlist_ip' ]
324323
)
325324
);
326325

@@ -1085,31 +1084,31 @@ public function dp_test_print_footer_scripts(): array {
10851084
}
10861085

10871086
/**
1088-
* Test whitelist_ip().
1087+
* Test allowlist_ip().
10891088
*
1090-
* @param mixed $whitelisted_ips Settings.
1089+
* @param mixed $allowlisted_ips Settings.
10911090
* @param string|false $client_ip Client IP.
10921091
* @param bool $expected Expected result.
10931092
*
1094-
* @dataProvider dp_test_whitelist_ip
1093+
* @dataProvider dp_test_allowlist_ip
10951094
* @return void
10961095
*/
1097-
public function test_whitelist_ip( $whitelisted_ips, $client_ip, bool $expected ): void {
1098-
update_option( 'hcaptcha_settings', [ 'whitelisted_ips' => $whitelisted_ips ] );
1096+
public function test_allowlist_ip( $allowlisted_ips, $client_ip, bool $expected ): void {
1097+
update_option( 'hcaptcha_settings', [ 'whitelisted_ips' => $allowlisted_ips ] );
10991098

11001099
$subject = new Main();
11011100

11021101
$subject->init_hooks();
11031102

1104-
self::assertSame( $expected, $subject->whitelist_ip( false, $client_ip ) );
1103+
self::assertSame( $expected, $subject->allowlist_ip( false, $client_ip ) );
11051104
}
11061105

11071106
/**
1108-
* Data provider for test_whitelist_ip().
1107+
* Data provider for test_allowlist_ip().
11091108
*
11101109
* @return array
11111110
*/
1112-
public function dp_test_whitelist_ip(): array {
1111+
public function dp_test_allowlist_ip(): array {
11131112
return [
11141113
'no settings, local ip' => [ '', false, false ],
11151114
'some ips, local ip' => [ " 4444444.777.2 \r\n 220.45.45.1 \r\n", false, false ],

.tests/php/unit/HCaptchaTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ protected function get_test_general_form_fields(): array {
685685
'helper' => 'Avoid specifying errors like "invalid username" or "invalid password" to limit information exposure to attackers.',
686686
],
687687
'whitelisted_ips' => [
688-
'label' => 'Whitelisted IPs',
688+
'label' => 'Allowlisted IPs',
689689
'type' => 'textarea',
690690
'section' => General::SECTION_OTHER,
691691
'helper' => 'Do not show hCaptcha for listed IP addresses. Please specify one IP address per line.',

.tests/php/unit/Settings/SystemInfoTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ public function test_get_system_info(): void {
303303
Backend:
304304
Turn Off When Logged In: Off
305305
Disable reCAPTCHA Compatibility: Off
306-
Whitelisted IPs: Not set
306+
Allowlisted IPs: Not set
307307
Login attempts before hCaptcha:
308308
Failed login attempts interval, min:
309309
Delay showing hCaptcha, ms:

src/php/Main.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public function init_hooks(): void {
189189
$this->load( Events::class );
190190

191191
add_action( 'plugins_loaded', [ $this, 'load_modules' ], self::LOAD_PRIORITY + 1 );
192-
add_filter( 'hcap_whitelist_ip', [ $this, 'whitelist_ip' ], -PHP_INT_MAX, 2 );
192+
add_filter( 'hcap_whitelist_ip', [ $this, 'allowlist_ip' ], -PHP_INT_MAX, 2 );
193193
add_action( 'before_woocommerce_init', [ $this, 'declare_wc_compatibility' ] );
194194

195195
$this->active = $this->activate_hcaptcha();
@@ -259,7 +259,7 @@ private function activate_hcaptcha(): bool {
259259
/**
260260
* Filters the user IP to check whether it is allowlisted.
261261
*
262-
* @param bool $whitelisted IP is allowlisted.
262+
* @param bool $allowlisted IP is allowlisted.
263263
* @param string|false $ip IP string or false for local addresses.
264264
*/
265265
apply_filters( 'hcap_whitelist_ip', false, hcap_get_user_ip() ) ||
@@ -764,12 +764,12 @@ public function declare_wc_compatibility(): void {
764764
* Filter user IP to check if it is allowlisted.
765765
* For allowlisted IPs, hCaptcha will not be shown.
766766
*
767-
* @param bool|mixed $whitelisted Whether IP is allowlisted.
767+
* @param bool|mixed $allowlisted Whether IP is allowlisted.
768768
* @param string|false $client_ip Client IP.
769769
*
770770
* @return bool|mixed
771771
*/
772-
public function whitelist_ip( $whitelisted, $client_ip ) {
772+
public function allowlist_ip( $allowlisted, $client_ip ) {
773773
$ips = explode(
774774
"\n",
775775
$this->settings()->get( 'whitelisted_ips' )
@@ -804,7 +804,7 @@ static function ( $ip ) {
804804
return true;
805805
}
806806

807-
return $whitelisted;
807+
return $allowlisted;
808808
}
809809

810810
/**

src/php/Settings/General.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ public function init_form_fields(): void {
534534
'helper' => __( 'On multisite, use same settings for all sites of the network.', 'hcaptcha-for-forms-and-more' ),
535535
],
536536
'whitelisted_ips' => [
537-
'label' => __( 'Whitelisted IPs', 'hcaptcha-for-forms-and-more' ),
537+
'label' => __( 'Allowlisted IPs', 'hcaptcha-for-forms-and-more' ),
538538
'type' => 'textarea',
539539
'section' => self::SECTION_OTHER,
540540
'helper' => __( 'Do not show hCaptcha for listed IP addresses. Please specify one IP address per line.', 'hcaptcha-for-forms-and-more' ),

src/php/Settings/SystemInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ private function hcaptcha_info(): string {
186186
// Other section.
187187
$data .= $this->data( 'Turn Off When Logged In', $this->is_on( 'off_when_logged_in' ) );
188188
$data .= $this->data( 'Disable reCAPTCHA Compatibility', $this->is_on( 'recaptcha_compat_off' ) );
189-
$data .= $this->data( 'Whitelisted IPs', $this->is_empty( $settings->get( 'whitelisted_ips' ) ) );
189+
$data .= $this->data( 'Allowlisted IPs', $this->is_empty( $settings->get( 'whitelisted_ips' ) ) );
190190
$data .= $this->data( 'Login attempts before hCaptcha', $settings->get( 'login_limit' ) );
191191
$data .= $this->data( 'Failed login attempts interval, min', $settings->get( 'login_interval' ) );
192192
$data .= $this->data( 'Delay showing hCaptcha, ms', $settings->get( 'delay' ) );

0 commit comments

Comments
 (0)