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

V4.10.0 #382

Merged
merged 45 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
d0fe68c
Fix fatal error with the WPForms plugin in rare cases.
kagg-design Jan 1, 2025
2094883
Improve helper text for anonymous collection.
kagg-design Jan 1, 2025
d5b866a
Improve helper text for anonymous collection.
kagg-design Jan 1, 2025
5e6812e
Fix an error message at the first entry to the login page when Hide L…
kagg-design Jan 2, 2025
7ed3488
Bump up the plugin version to 4.10.0-RC2.
kagg-design Jan 2, 2025
6a53c12
Bump up the plugin version to 4.10.0-RC2.
kagg-design Jan 2, 2025
cf3c520
Fix scrolling to the message on the General page.
kagg-design Jan 2, 2025
2de7dc2
Improve error messaging for hCaptcha verification.
kagg-design Jan 3, 2025
fcffbd0
Improve comments in Main.
kagg-design Jan 10, 2025
d451686
Fix fatal error on install entity.
kagg-design Jan 14, 2025
0a93fcc
Merge remote-tracking branch 'origin/v4.10.0' into v4.10.0
kagg-design Jan 14, 2025
86bea2e
Fix the Integrations page when active plugin was deleted.
kagg-design Jan 14, 2025
24e303e
Fix error when hCaptcha is disabled for standard login but enabled fo…
kagg-design Jan 15, 2025
52a4cd6
Refactor CL login.
kagg-design Jan 15, 2025
f8a878d
Fix error when hCaptcha is disabled for standard login but enabled fo…
kagg-design Jan 15, 2025
8b1b00b
Refactor Profile Builder login.
kagg-design Jan 15, 2025
d90f428
Add support for hCaptcha in HTML Gravity Forms fields.
kagg-design Jan 21, 2025
c7b35b0
Update packages.
kagg-design Jan 23, 2025
7768486
Fix default id in hCaptcha form.
kagg-design Jan 25, 2025
3076cd8
Fix default id in hCaptcha form.
kagg-design Jan 25, 2025
87f3b15
Add support for custom nonce action and name in the [hcaptcha] shortc…
kagg-design Jan 25, 2025
5868e5d
Tests for custom nonce in the [hcaptcha] shortcode.
kagg-design Jan 25, 2025
6202f01
Fix bug with changing shortcode args.
kagg-design Jan 25, 2025
288f986
Tests for Autoverify and Gravity.
kagg-design Jan 25, 2025
616eeb1
Fix bug in GF shortcode (via tests).
kagg-design Jan 25, 2025
b02094a
Add compatibility with Cookies and Content Security Policy
kagg-design Jan 26, 2025
ce55091
Add auto-verification of arbitrary forms in ajax.
kagg-design Jan 28, 2025
5079a67
Fix tests after adding auto-ajax.
kagg-design Jan 28, 2025
7aed0e9
Add support for wp_login_form() function and LoginOut block.
kagg-design Jan 28, 2025
fffe7f2
Bump up to RC4.
kagg-design Jan 28, 2025
9b5860d
Fix IP detection in WP to sync with hCaptcha events info.
kagg-design Jan 29, 2025
89b4f9b
Add deletion of events on the Forms page.
kagg-design Jan 31, 2025
2ed0fed
Fix tests.
kagg-design Jan 31, 2025
24583a3
Add deletion of events on the Events page.
kagg-design Feb 1, 2025
9cd6ddd
Fix tests.
kagg-design Feb 1, 2025
4176e9c
Fix phpcs.
kagg-design Feb 1, 2025
a891f27
Fix phpcs.
kagg-design Feb 1, 2025
df6f9dd
Multiple layout fixes for Forms and Events pages on small screens.
kagg-design Feb 1, 2025
0fb14bf
Multiple layout fixes for Forms and Events pages on small screens.
kagg-design Feb 1, 2025
b413942
Remove SVN from the deployment action as it is already included in th…
kagg-design Feb 1, 2025
264be3c
Cover Autoverify 100%.
kagg-design Feb 1, 2025
a3dfe6e
Cover DB 100%.
kagg-design Feb 1, 2025
f2cc801
Bump up to 4.10.0.
kagg-design Feb 1, 2025
d55aa64
Apply suggestions from code review
e271828- Feb 1, 2025
37bb6de
Apply suggestions from code review
e271828- Feb 1, 2025
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
3 changes: 0 additions & 3 deletions .github/workflows/deploy-readme-assets-to-wp-org.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Install SVN
run: sudo apt-get update && sudo apt-get install -y subversion

- name: WordPress.org plugin asset/readme update
uses: 10up/action-wordpress-plugin-asset-update@stable
env:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/deploy-to-wp-org.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Install SVN
run: sudo apt-get update && sudo apt-get install -y subversion

- name: Install dependencies with caching
uses: ramsey/composer-install@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .tests/js/assets-js-files/integrations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import $ from 'jquery';
global.jQuery = $;
global.$ = $;

require( '../../../assets/js/settings-base.js' );
require( '../../../assets/js/integrations.js' );

// Mock HCaptchaIntegrationsObject
Expand Down
3 changes: 2 additions & 1 deletion .tests/php/integration/AAAMainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use HCaptcha\WCWishlists\CreateList;
use HCaptcha\WP\Comment;
use HCaptcha\WP\Login;
use HCaptcha\WP\LoginOut;
use HCaptcha\WP\LostPassword;
use HCaptcha\WP\PasswordProtected;
use HCaptcha\WP\Register;
Expand Down Expand Up @@ -1295,7 +1296,7 @@ public function dp_test_load_modules(): array {
'Login Form' => [
[ 'wp_status', 'login' ],
'',
Login::class,
[ Login::class, LoginOut::class ],
],
'Lost Password Form' => [
[ 'wp_status', 'lost_pass' ],
Expand Down
1 change: 1 addition & 0 deletions .tests/php/integration/Admin/Events/EventsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public function test_get_forms(): void {
'source' => '[]',
'form_id' => '0',
'served' => '2',
'id' => '1',
],
],
'total' => 1,
Expand Down
122 changes: 44 additions & 78 deletions .tests/php/integration/AutoVerify/AutoVerifyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function test_init_and_init_hooks(): void {
$subject = new AutoVerify();
$subject->init();

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

$subject = new AutoVerify();

$subject->init();

self::assertFalse( get_transient( $subject::TRANSIENT ) );
self::assertSame( $content, $subject->content_filter( $content ) );
apply_filters( 'the_content', $content );
self::assertSame( $expected, get_transient( $subject::TRANSIENT ) );
}

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

$subject = new AutoVerify();

$subject->init();

self::assertFalse( get_transient( $subject::TRANSIENT ) );
self::assertSame( $content, $subject->widget_block_content_filter( $content, [], $wp_widget_block ) );
apply_filters( 'widget_block_content', $content, [], $wp_widget_block );
self::assertSame( $expected, get_transient( $subject::TRANSIENT ) );
}

Expand All @@ -99,14 +103,16 @@ public function test_content_filter_with_action(): void {
$content
);

unset( $_SERVER['REQUEST_URI'] );
$_SERVER['REQUEST_URI'] = 'some-uri';

$expected = $this->get_test_registered_forms();

$subject = new AutoVerify();

$subject->init();

self::assertFalse( get_transient( $subject::TRANSIENT ) );
self::assertSame( $content, $subject->content_filter( $content ) );
apply_filters( 'the_content', $content );
self::assertSame( $expected, get_transient( $subject::TRANSIENT ) );
}

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

unset( $_SERVER['REQUEST_URI'] );

$subject = new AutoVerify();

self::assertFalse( get_transient( $subject::TRANSIENT ) );
self::assertSame( $content, $subject->content_filter( $content ) );
self::assertSame( [], get_transient( $subject::TRANSIENT ) );
}

/**
* Test content_filter() when no input in form (really?).
*/
public function test_content_filter_without_form_inputs(): void {
$request_uri = wp_parse_url( $this->get_test_request_uri(), PHP_URL_PATH );
$content = $this->get_test_content();
$content = preg_replace( '#<input[\S\s]+?>#', '', $content );
$expected = $this->get_test_registered_forms();

$expected[ untrailingslashit( $request_uri ) ][0] = [];

$_SERVER['REQUEST_URI'] = $request_uri;
$_SERVER['REQUEST_URI'] = '';

$subject = new AutoVerify();

self::assertFalse( get_transient( $subject::TRANSIENT ) );
self::assertSame( $content, $subject->content_filter( $content ) );
self::assertSame( $expected, get_transient( $subject::TRANSIENT ) );

// Test update existing transient.
self::assertSame( $content, $subject->content_filter( $content ) );
self::assertSame( $expected, get_transient( $subject::TRANSIENT ) );
}

/**
* Test content_filter() when no data-auto in form (really?).
*/
public function test_content_filter_without_form_data_auto(): void {
$request_uri = $this->get_test_request_uri();
$content = $this->get_test_content();
$content = preg_replace( '#data-auto=".*?">#', '', $content );

$_SERVER['REQUEST_URI'] = $request_uri;

$subject = new AutoVerify();
$subject->init();

self::assertFalse( get_transient( $subject::TRANSIENT ) );
self::assertSame( $content, $subject->content_filter( $content ) );
apply_filters( 'the_content', $content );
self::assertSame( [], get_transient( $subject::TRANSIENT ) );

$registered_forms = $this->get_test_registered_forms();
$expected = $registered_forms;

$expected[ untrailingslashit( wp_parse_url( $request_uri, PHP_URL_PATH ) ) ] = [];

// Test update existing transient.
set_transient( AutoVerify::TRANSIENT, $registered_forms );
self::assertSame( $content, $subject->content_filter( $content ) );
self::assertSame( $expected, get_transient( $subject::TRANSIENT ) );
}

/**
Expand Down Expand Up @@ -216,10 +173,10 @@ static function () {
*/
public function test_verify_form_when_not_post(): void {
$subject = new AutoVerify();
$subject->verify_form();
$subject->verify();

$_SERVER['REQUEST_METHOD'] = 'GET';
$subject->verify_form();
$subject->verify();
}

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

$subject = new AutoVerify();
$subject->verify_form();
$subject->verify();
}

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

$subject = new AutoVerify();
$subject->verify_form();
$subject->verify();
}

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

$subject = new AutoVerify();
$subject->verify_form();
$subject->verify();
}

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

$subject = new AutoVerify();
$subject->verify_form();
$subject->verify();
}

/**
Expand Down Expand Up @@ -319,7 +276,7 @@ static function ( $name ) use ( &$die_arr ) {
);

$subject = new AutoVerify();
$subject->verify_form();
$subject->verify();

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

$subject = new AutoVerify();
$subject->verify_form();
$subject->verify();

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

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

$subject = new AutoVerify();
$subject->verify_form();
$subject->verify();
}

/**
Expand All @@ -379,7 +336,7 @@ static function () {
);

$subject = new AutoVerify();
$subject->verify_form();
$subject->verify();
}

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

$subject = new AutoVerify();
$subject->verify_form();
$subject->verify();

// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
$GLOBALS['wp_rewrite'] = $old_wp_rewrite;
Expand Down Expand Up @@ -431,15 +388,7 @@ private function get_test_content(): string {
<form method="post">
<input type="text" name="test_input" id="test_input">
<input type="submit" value="Send">
<div
class="h-captcha"
data-sitekey="95d60c5a-68cf-4db1-a583-6a22bdd558f2"
data-theme="light"
data-size="normal"
data-auto="true">
</div>
<input type="hidden" id="hcaptcha_nonce" name="hcaptcha_nonce" value="' . $nonce . '"/>
<input type="hidden" name="_wp_http_referer" value="' . $request_uri . '"/>
[hcaptcha auto="true"]
</form>

<form role="search" method="get" action="http://test.test/"
Expand All @@ -463,11 +412,28 @@ class="wp-block-search__input" name="s" value="" placeholder=""
private function get_test_registered_forms(): array {
$request_uri = $this->get_test_request_uri();
$request_uri = wp_parse_url( $request_uri, PHP_URL_PATH );
$args = [
'action' => 'hcaptcha_action',
'name' => 'hcaptcha_nonce',
'auto' => true,
'ajax' => false,
'force' => false,
'theme' => '',
'size' => '',
'id' => [
'source' => [],
'form_id' => 0,
],
'protect' => true,
];

return [
untrailingslashit( $request_uri ) =>
[
[ 'test_input' ],
[
'inputs' => [ 'test_input' ],
'args' => $args,
],
],
];
}
Expand Down
1 change: 1 addition & 0 deletions .tests/php/integration/CF7/CF7Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ static function ( $prefix, $more_entropy ) use ( $uniqid ) {
data-theme="' . $hcaptcha_theme . '"
data-size="' . $hcaptcha_size . '"
data-auto="false"
data-ajax="false"
data-force="false">' . '
</span>
' . $nonce .
Expand Down
Loading