Skip to content

Commit 3f3d675

Browse files
V4.10.0 (#382)
* Fix fatal error with the WPForms plugin in rare cases. * Improve helper text for anonymous collection. * Improve helper text for anonymous collection. * Fix an error message at the first entry to the login page when Hide Login Errors in on. * Bump up the plugin version to 4.10.0-RC2. * Bump up the plugin version to 4.10.0-RC2. * Fix scrolling to the message on the General page. * Improve error messaging for hCaptcha verification. * Improve comments in Main. * Fix fatal error on install entity. * Fix the Integrations page when active plugin was deleted. * Fix error when hCaptcha is disabled for standard login but enabled for Tutor login. * Refactor CL login. * Fix error when hCaptcha is disabled for standard login but enabled for LearnPress login. * Refactor Profile Builder login. * Add support for hCaptcha in HTML Gravity Forms fields. * Update packages. * Fix default id in hCaptcha form. * Fix default id in hCaptcha form. * Add support for custom nonce action and name in the [hcaptcha] shortcode. * Tests for custom nonce in the [hcaptcha] shortcode. * Fix bug with changing shortcode args. * Tests for Autoverify and Gravity. * Fix bug in GF shortcode (via tests). * Add compatibility with Cookies and Content Security Policy * Add auto-verification of arbitrary forms in ajax. * Fix tests after adding auto-ajax. * Add support for wp_login_form() function and LoginOut block. * Bump up to RC4. * Fix IP detection in WP to sync with hCaptcha events info. * Add deletion of events on the Forms page. * Fix tests. * Add deletion of events on the Events page. * Fix tests. * Fix phpcs. * Fix phpcs. * Multiple layout fixes for Forms and Events pages on small screens. * Multiple layout fixes for Forms and Events pages on small screens. * Remove SVN from the deployment action as it is already included in the 10up action. * Cover Autoverify 100%. * Cover DB 100%. * Bump up to 4.10.0. * Apply suggestions from code review * Apply suggestions from code review --------- Co-authored-by: e271828- <[email protected]>
1 parent bcf1d7e commit 3f3d675

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2613
-1352
lines changed

.github/workflows/deploy-readme-assets-to-wp-org.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ jobs:
1111
- name: Checkout code
1212
uses: actions/checkout@v4
1313

14-
- name: Install SVN
15-
run: sudo apt-get update && sudo apt-get install -y subversion
16-
1714
- name: WordPress.org plugin asset/readme update
1815
uses: 10up/action-wordpress-plugin-asset-update@stable
1916
env:

.github/workflows/deploy-to-wp-org.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ jobs:
1515
- name: Checkout code
1616
uses: actions/checkout@v4
1717

18-
- name: Install SVN
19-
run: sudo apt-get update && sudo apt-get install -y subversion
20-
2118
- name: Install dependencies with caching
2219
uses: ramsey/composer-install@v3
2320
with:

.tests/js/assets-js-files/integrations.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import $ from 'jquery';
55
global.jQuery = $;
66
global.$ = $;
77

8+
require( '../../../assets/js/settings-base.js' );
89
require( '../../../assets/js/integrations.js' );
910

1011
// Mock HCaptchaIntegrationsObject

.tests/php/integration/AAAMainTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
use HCaptcha\WCWishlists\CreateList;
3535
use HCaptcha\WP\Comment;
3636
use HCaptcha\WP\Login;
37+
use HCaptcha\WP\LoginOut;
3738
use HCaptcha\WP\LostPassword;
3839
use HCaptcha\WP\PasswordProtected;
3940
use HCaptcha\WP\Register;
@@ -1295,7 +1296,7 @@ public function dp_test_load_modules(): array {
12951296
'Login Form' => [
12961297
[ 'wp_status', 'login' ],
12971298
'',
1298-
Login::class,
1299+
[ Login::class, LoginOut::class ],
12991300
],
13001301
'Lost Password Form' => [
13011302
[ 'wp_status', 'lost_pass' ],

.tests/php/integration/Admin/Events/EventsTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ public function test_get_forms(): void {
241241
'source' => '[]',
242242
'form_id' => '0',
243243
'served' => '2',
244+
'id' => '1',
244245
],
245246
],
246247
'total' => 1,

.tests/php/integration/AutoVerify/AutoVerifyTest.php

Lines changed: 44 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function test_init_and_init_hooks(): void {
4040
$subject = new AutoVerify();
4141
$subject->init();
4242

43-
self::assertSame( -PHP_INT_MAX, has_action( 'init', [ $subject, 'verify_form' ] ) );
43+
self::assertSame( -PHP_INT_MAX, has_action( 'init', [ $subject, 'verify' ] ) );
4444
self::assertSame( PHP_INT_MAX, has_filter( 'the_content', [ $subject, 'content_filter' ] ) );
4545
self::assertSame(
4646
PHP_INT_MAX,
@@ -62,8 +62,10 @@ public function test_content_filter(): void {
6262

6363
$subject = new AutoVerify();
6464

65+
$subject->init();
66+
6567
self::assertFalse( get_transient( $subject::TRANSIENT ) );
66-
self::assertSame( $content, $subject->content_filter( $content ) );
68+
apply_filters( 'the_content', $content );
6769
self::assertSame( $expected, get_transient( $subject::TRANSIENT ) );
6870
}
6971

@@ -82,8 +84,10 @@ public function test_widget_block_content_filter(): void {
8284

8385
$subject = new AutoVerify();
8486

87+
$subject->init();
88+
8589
self::assertFalse( get_transient( $subject::TRANSIENT ) );
86-
self::assertSame( $content, $subject->widget_block_content_filter( $content, [], $wp_widget_block ) );
90+
apply_filters( 'widget_block_content', $content, [], $wp_widget_block );
8791
self::assertSame( $expected, get_transient( $subject::TRANSIENT ) );
8892
}
8993

@@ -99,14 +103,16 @@ public function test_content_filter_with_action(): void {
99103
$content
100104
);
101105

102-
unset( $_SERVER['REQUEST_URI'] );
106+
$_SERVER['REQUEST_URI'] = 'some-uri';
103107

104108
$expected = $this->get_test_registered_forms();
105109

106110
$subject = new AutoVerify();
107111

112+
$subject->init();
113+
108114
self::assertFalse( get_transient( $subject::TRANSIENT ) );
109-
self::assertSame( $content, $subject->content_filter( $content ) );
115+
apply_filters( 'the_content', $content );
110116
self::assertSame( $expected, get_transient( $subject::TRANSIENT ) );
111117
}
112118

@@ -116,64 +122,15 @@ public function test_content_filter_with_action(): void {
116122
public function test_content_filter_without_form_action(): void {
117123
$content = $this->get_test_content();
118124

119-
unset( $_SERVER['REQUEST_URI'] );
120-
121-
$subject = new AutoVerify();
122-
123-
self::assertFalse( get_transient( $subject::TRANSIENT ) );
124-
self::assertSame( $content, $subject->content_filter( $content ) );
125-
self::assertSame( [], get_transient( $subject::TRANSIENT ) );
126-
}
127-
128-
/**
129-
* Test content_filter() when no input in form (really?).
130-
*/
131-
public function test_content_filter_without_form_inputs(): void {
132-
$request_uri = wp_parse_url( $this->get_test_request_uri(), PHP_URL_PATH );
133-
$content = $this->get_test_content();
134-
$content = preg_replace( '#<input[\S\s]+?>#', '', $content );
135-
$expected = $this->get_test_registered_forms();
136-
137-
$expected[ untrailingslashit( $request_uri ) ][0] = [];
138-
139-
$_SERVER['REQUEST_URI'] = $request_uri;
125+
$_SERVER['REQUEST_URI'] = '';
140126

141127
$subject = new AutoVerify();
142128

143-
self::assertFalse( get_transient( $subject::TRANSIENT ) );
144-
self::assertSame( $content, $subject->content_filter( $content ) );
145-
self::assertSame( $expected, get_transient( $subject::TRANSIENT ) );
146-
147-
// Test update existing transient.
148-
self::assertSame( $content, $subject->content_filter( $content ) );
149-
self::assertSame( $expected, get_transient( $subject::TRANSIENT ) );
150-
}
151-
152-
/**
153-
* Test content_filter() when no data-auto in form (really?).
154-
*/
155-
public function test_content_filter_without_form_data_auto(): void {
156-
$request_uri = $this->get_test_request_uri();
157-
$content = $this->get_test_content();
158-
$content = preg_replace( '#data-auto=".*?">#', '', $content );
159-
160-
$_SERVER['REQUEST_URI'] = $request_uri;
161-
162-
$subject = new AutoVerify();
129+
$subject->init();
163130

164131
self::assertFalse( get_transient( $subject::TRANSIENT ) );
165-
self::assertSame( $content, $subject->content_filter( $content ) );
132+
apply_filters( 'the_content', $content );
166133
self::assertSame( [], get_transient( $subject::TRANSIENT ) );
167-
168-
$registered_forms = $this->get_test_registered_forms();
169-
$expected = $registered_forms;
170-
171-
$expected[ untrailingslashit( wp_parse_url( $request_uri, PHP_URL_PATH ) ) ] = [];
172-
173-
// Test update existing transient.
174-
set_transient( AutoVerify::TRANSIENT, $registered_forms );
175-
self::assertSame( $content, $subject->content_filter( $content ) );
176-
self::assertSame( $expected, get_transient( $subject::TRANSIENT ) );
177134
}
178135

179136
/**
@@ -216,10 +173,10 @@ static function () {
216173
*/
217174
public function test_verify_form_when_not_post(): void {
218175
$subject = new AutoVerify();
219-
$subject->verify_form();
176+
$subject->verify();
220177

221178
$_SERVER['REQUEST_METHOD'] = 'GET';
222-
$subject->verify_form();
179+
$subject->verify();
223180
}
224181

225182
/**
@@ -231,7 +188,7 @@ public function test_verify_form_when_no_request_uri(): void {
231188
unset( $_SERVER['REQUEST_URI'] );
232189

233190
$subject = new AutoVerify();
234-
$subject->verify_form();
191+
$subject->verify();
235192
}
236193

237194
/**
@@ -244,7 +201,7 @@ public function test_verify_form_when_no_forms_are_registered(): void {
244201
$_SERVER['REQUEST_URI'] = $request_uri;
245202

246203
$subject = new AutoVerify();
247-
$subject->verify_form();
204+
$subject->verify();
248205
}
249206

250207
/**
@@ -263,7 +220,7 @@ public function test_verify_form_when_forms_on_another_uri_are_registered(): voi
263220
set_transient( AutoVerify::TRANSIENT, $registered_forms );
264221

265222
$subject = new AutoVerify();
266-
$subject->verify_form();
223+
$subject->verify();
267224
}
268225

269226
/**
@@ -282,7 +239,7 @@ public function test_verify_form_when_other_forms_on_the_same_uri_are_registered
282239
set_transient( AutoVerify::TRANSIENT, $registered_forms );
283240

284241
$subject = new AutoVerify();
285-
$subject->verify_form();
242+
$subject->verify();
286243
}
287244

288245
/**
@@ -319,7 +276,7 @@ static function ( $name ) use ( &$die_arr ) {
319276
);
320277

321278
$subject = new AutoVerify();
322-
$subject->verify_form();
279+
$subject->verify();
323280

324281
// phpcs:ignore WordPress.Security.NonceVerification.Missing
325282
self::assertSame( [], $_POST );
@@ -349,7 +306,7 @@ public function test_verify_form_when_success(): void {
349306
$this->prepare_hcaptcha_request_verify( $hcaptcha_response );
350307

351308
$subject = new AutoVerify();
352-
$subject->verify_form();
309+
$subject->verify();
353310

354311
$_POST[ HCAPTCHA_NONCE ] = $this->get_test_nonce();
355312

@@ -364,7 +321,7 @@ public function test_verify_form_in_admin(): void {
364321
set_current_screen( 'some-screen' );
365322

366323
$subject = new AutoVerify();
367-
$subject->verify_form();
324+
$subject->verify();
368325
}
369326

370327
/**
@@ -379,7 +336,7 @@ static function () {
379336
);
380337

381338
$subject = new AutoVerify();
382-
$subject->verify_form();
339+
$subject->verify();
383340
}
384341

385342
/**
@@ -394,7 +351,7 @@ public function test_verify_form_in_rest_case_3_and_4(): void {
394351
$_SERVER['REQUEST_URI'] = rest_url();
395352

396353
$subject = new AutoVerify();
397-
$subject->verify_form();
354+
$subject->verify();
398355

399356
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
400357
$GLOBALS['wp_rewrite'] = $old_wp_rewrite;
@@ -431,15 +388,7 @@ private function get_test_content(): string {
431388
<form method="post">
432389
<input type="text" name="test_input" id="test_input">
433390
<input type="submit" value="Send">
434-
<div
435-
class="h-captcha"
436-
data-sitekey="95d60c5a-68cf-4db1-a583-6a22bdd558f2"
437-
data-theme="light"
438-
data-size="normal"
439-
data-auto="true">
440-
</div>
441-
<input type="hidden" id="hcaptcha_nonce" name="hcaptcha_nonce" value="' . $nonce . '"/>
442-
<input type="hidden" name="_wp_http_referer" value="' . $request_uri . '"/>
391+
[hcaptcha auto="true"]
443392
</form>
444393
445394
<form role="search" method="get" action="http://test.test/"
@@ -463,11 +412,28 @@ class="wp-block-search__input" name="s" value="" placeholder=""
463412
private function get_test_registered_forms(): array {
464413
$request_uri = $this->get_test_request_uri();
465414
$request_uri = wp_parse_url( $request_uri, PHP_URL_PATH );
415+
$args = [
416+
'action' => 'hcaptcha_action',
417+
'name' => 'hcaptcha_nonce',
418+
'auto' => true,
419+
'ajax' => false,
420+
'force' => false,
421+
'theme' => '',
422+
'size' => '',
423+
'id' => [
424+
'source' => [],
425+
'form_id' => 0,
426+
],
427+
'protect' => true,
428+
];
466429

467430
return [
468431
untrailingslashit( $request_uri ) =>
469432
[
470-
[ 'test_input' ],
433+
[
434+
'inputs' => [ 'test_input' ],
435+
'args' => $args,
436+
],
471437
],
472438
];
473439
}

.tests/php/integration/CF7/CF7Test.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ static function ( $prefix, $more_entropy ) use ( $uniqid ) {
138138
data-theme="' . $hcaptcha_theme . '"
139139
data-size="' . $hcaptcha_size . '"
140140
data-auto="false"
141+
data-ajax="false"
141142
data-force="false">' . '
142143
</span>
143144
' . $nonce .

0 commit comments

Comments
 (0)