Skip to content

Commit 02af3b9

Browse files
kagg-designhCaptcha GHAe271828-
authored
V4.21.0 (#444)
* Update ci.yml. * Fix tests for running with WP 6.9. * Fix weird cron bug in tests with WP 6.9. * Update changelog from readme.txt * Remove the test line from readme.txt. * Update changelog from readme.txt * Bump up the version to 4.21.0. * [zip] Update create-zip.yml. * [zip] Update create-zip.yml. * Test with WC 10.4. * Fix Fluent Forms after update. * Update changelog from readme.txt * Rework JS upon FluentForm Conversational update. * Fix the inability to send FluentForms Conversational Form. * Update changelog from readme.txt * Add anti-spam entry check for FluentForms. Refactoring to use non-global post data for entries. * Grammar. * Fix tests. * Fix double rendering of the hCaptcha widget on the Elementor Form. * Fix double rendering of the hCaptcha widget on the Elementor Form. * Fix menu layout on Playground. * Fix the racing condition which sometimes led to double rendering of the hCaptcha widget on any forms. * Fix the racing condition which sometimes led to double rendering of the hCaptcha widget on any forms. * Fix the racing condition which sometimes led to double rendering of the hCaptcha widget on any forms. * Fix the racing condition which sometimes led to double rendering of the hCaptcha widget on any forms. * Fix menu layout on Playground. * Fix jests in hcaptcha.test.js. * Fix jests in hcaptcha.test.js. * Fix jests in app.test.js. * Fix jests in hcaptcha-elementor-pro.test.js. * Remove debug statement. * Update changelog from readme.txt * [zip] Bump up version to 4.21.0-RC2. * Add anti-spam entry check for Forminator. * Restore 100% coverage for Forminator. * 4.21.0 part2. * qs's arrayLimit bypass in its bracket notation allows DoS via memory exhaustion #39 * qs's arrayLimit bypass in its bracket notation allows DoS via memory exhaustion #39 * Update src/php/Admin/Notifications.php Co-authored-by: e271828- <[email protected]> * Update src/php/Admin/NotificationsBase.php Co-authored-by: e271828- <[email protected]> * Update src/php/Admin/WhatsNew.php Co-authored-by: e271828- <[email protected]> * Update src/php/Admin/WhatsNew.php Co-authored-by: e271828- <[email protected]> * Update tests/php/integration/Admin/NotificationsTest.php Co-authored-by: e271828- <[email protected]> * Fix phpcs. * Code style. * Update readme.txt. * Fix tests. * Update readme.txt * Update readme.txt --------- Co-authored-by: hCaptcha GHA <[email protected]> Co-authored-by: e271828- <[email protected]>
1 parent 0c75705 commit 02af3b9

File tree

85 files changed

+4090
-1238
lines changed

Some content is hidden

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

85 files changed

+4090
-1238
lines changed

assets/css/admin-nf.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.hcaptcha-notice-label {
2+
font-weight: 600;
3+
padding: 8px 0;
4+
}
5+
6+
.hcaptcha-notice-description {
7+
padding: 15px 0;
8+
}

assets/css/integrations.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,15 @@
157157

158158
.hcaptcha-integrations table tr td fieldset {
159159
width: 100%;
160+
overflow: hidden;
161+
min-inline-size: unset;
160162
}
161163

162164
.hcaptcha-integrations table tr td fieldset label {
163165
width: 100%;
166+
white-space: nowrap;
167+
text-overflow: ellipsis;
168+
overflow: hidden;
164169
}
165170

166171
#hcaptcha-options label + .helper {
@@ -211,10 +216,12 @@
211216

212217
#hcaptcha-options label + .helper i.antispam-honeypot {
213218
background-image: url('../images/antispam-honeypot.svg');
219+
background-color: #fff;
214220
}
215221

216222
#hcaptcha-options label + .helper i.antispam-fst {
217223
background-image: url('../images/antispam-fst.svg');
224+
background-color: #fff;
218225
width: 20px;
219226
transform: translateY(1px);
220227
margin-inline-start: 2px;

assets/css/whats-new.css

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,23 @@
109109
}
110110

111111
.hcaptcha-whats-new-block {
112-
padding: 75px 13%;
112+
display: flex;
113+
padding: 25px 10%;
114+
gap: 25px;
115+
align-items: center;
116+
}
117+
118+
.hcaptcha-whats-new-block.left {
119+
flex-direction: row;
120+
}
121+
122+
.hcaptcha-whats-new-block.right {
123+
flex-direction: row-reverse;
124+
}
125+
126+
.hcaptcha-whats-new-block.center {
127+
flex-direction: column;
128+
text-align: center;
113129
}
114130

115131
.hcaptcha-whats-new-block:first-of-type {
@@ -120,8 +136,22 @@
120136
background: #f0f2f5;
121137
}
122138

123-
.hcaptcha-whats-new-block.center {
124-
text-align: center;
139+
.hcaptcha-whats-new-text {
140+
/*flex: 0 0 calc(70% - 20px); !* 20px — half of the gap *!*/
141+
flex: 7;
142+
}
143+
144+
.hcaptcha-whats-new-block.center .hcaptcha-whats-new-text {
145+
flex: 0 0 100%;
146+
}
147+
148+
.hcaptcha-whats-new-image {
149+
/*flex: 0 0 calc(70% - 20px); !* 20px — half of the gap *!*/
150+
flex: 3;
151+
}
152+
153+
.hcaptcha-whats-new-block.center .hcaptcha-whats-new-image {
154+
flex: 0 0 100%;
125155
}
126156

127157
.hcaptcha-whats-new-badge {
@@ -156,12 +186,18 @@
156186
margin: 15px 0;
157187
}
158188

159-
.hcaptcha-whats-new-button {
160-
margin-bottom: 50px;
189+
.hcaptcha-whats-new-message ul {
190+
margin-top: -10px;
191+
}
192+
193+
.hcaptcha-whats-new-message ul li {
194+
list-style: inside;
161195
}
162196

163197
.hcaptcha-whats-new-image img {
164198
max-width: 100%;
199+
height: auto;
200+
display: block;
165201
}
166202

167203
@media (max-width: 600px) {

assets/images/ai-abilities.png

846 KB
Loading

assets/js/hcaptcha-elementor-pro.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@ const hcaptchaElementorPro = function() {
2323
return window?.parent?.HCaptchaMainObject?.params ?? '';
2424
}
2525
);
26-
27-
elementorFrontend.hooks.addAction(
28-
'frontend/element_ready/widget',
29-
function( $scope ) {
30-
if ( $scope[ 0 ].classList.contains( 'elementor-widget-form' ) ) {
31-
// Elementor reinserts an element during editing, so we need to bind events again.
32-
hCaptchaBindEvents();
33-
}
34-
}
35-
);
3626
};
3727

3828
window.hCaptchaElementorPro = hcaptchaElementorPro;

assets/js/hcaptcha-fluentform.js

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ const hCaptchaFluentForm = window.hCaptchaFluentForm || ( function( window, $ )
2121
onHCaptchaLoaded() {
2222
const formSelector = '.ffc_conv_form';
2323

24+
// We assume there should be only one conversational form on the page.
25+
const form = document.querySelector( formSelector );
26+
const hasCaptcha = () => form.querySelector( 'h-captcha' ) !== null;
27+
28+
if ( hasCaptcha() ) {
29+
return;
30+
}
31+
2432
const hasOwnCaptcha = () => {
2533
return document.getElementById( 'hcaptcha-container' ) !== null;
2634
};
@@ -29,15 +37,13 @@ const hCaptchaFluentForm = window.hCaptchaFluentForm || ( function( window, $ )
2937
* Process conversational form.
3038
*/
3139
const processForm = () => {
32-
// We assume there should be only one conversational form on the page.
33-
const form = document.querySelector( formSelector );
3440
const submitBtnSelector = '.ff-btn';
3541

36-
const isSubmitVisible = ( qForm ) => {
37-
return qForm.querySelector( submitBtnSelector ) !== null;
38-
};
39-
4042
const addCaptcha = () => {
43+
if ( hasCaptcha() ) {
44+
return;
45+
}
46+
4147
const hCaptchaHiddenClass = 'h-captcha-hidden';
4248
const hCaptchaClass = 'h-captcha';
4349
const hiddenCaptcha = document.getElementsByClassName( hCaptchaHiddenClass )[ 0 ];
@@ -63,17 +69,17 @@ const hCaptchaFluentForm = window.hCaptchaFluentForm || ( function( window, $ )
6369
const mutationObserverCallback = ( mutationList ) => {
6470
for ( const mutation of mutationList ) {
6571
if (
66-
! (
67-
mutation.type === 'attributes' &&
68-
mutation.attributeName === 'class' &&
69-
mutation.oldValue && mutation.oldValue.includes( 'q-is-inactive' )
70-
)
72+
mutation.type === 'attributes' &&
73+
mutation.attributeName === 'class'
7174
) {
72-
continue;
73-
}
74-
75-
if ( isSubmitVisible( mutation.target ) ) {
76-
addCaptcha();
75+
const el = mutation.target;
76+
77+
if (
78+
el.classList.contains( 'vff' ) &&
79+
el.classList.contains( 'ffc_last_step' )
80+
) {
81+
addCaptcha();
82+
}
7783
}
7884
}
7985
};
@@ -82,18 +88,14 @@ const hCaptchaFluentForm = window.hCaptchaFluentForm || ( function( window, $ )
8288
return;
8389
}
8490

85-
const qFormSelector = '.q-form';
86-
const qForms = form.querySelectorAll( qFormSelector );
8791
const config = {
8892
attributes: true,
89-
attributeOldValue: true,
93+
attributeFilter: [ 'class' ],
94+
subtree: true,
9095
};
9196

92-
[ ...qForms ].map( ( qForm ) => {
93-
const observer = new MutationObserver( mutationObserverCallback );
94-
observer.observe( qForm, config );
95-
return qForm;
96-
} );
97+
const observer = new MutationObserver( mutationObserverCallback );
98+
observer.observe( form, config );
9799
};
98100

99101
function waitForElement( selector ) {

assets/js/hcaptcha-helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class helper {
8888
this.params = new URLSearchParams();
8989
}
9090

91-
return this.params.get( actionName );
91+
return this.params.get( actionName ) ?? '';
9292
}
9393

9494
/**

assets/js/playground.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,35 @@
11
/* global jQuery, HCaptchaPlaygroundObject */
22

3-
const hCaptchaPlayground = window.hCaptchaPlayground || ( function( window, $ ) {
3+
const hCaptchaPlayground = window.hCaptchaPlayground || ( function( window, document, $ ) {
44
const app = {
55
init() {
6+
app.fixMenu();
67
$( document ).on( 'ajaxSuccess', app.ajaxSuccessHandler );
78
},
89

10+
// Fix admin menu.
11+
fixMenu() {
12+
const host = window.location.hostname ?? '';
13+
14+
let inIframe = false;
15+
16+
try {
17+
inIframe = window.self !== window.top;
18+
} catch ( e ) {
19+
// If cross-origin blocks access to window.top, we are in an iframe.
20+
inIframe = true;
21+
}
22+
23+
// Apply only on playground.wordpress.net.
24+
if ( inIframe && host === 'playground.wordpress.net' ) {
25+
const adminBar = document.getElementById( 'wpadminbar' );
26+
27+
if ( adminBar ) {
28+
adminBar.style.marginTop = '4px';
29+
}
30+
}
31+
},
32+
933
// jQuery ajaxSuccess handler.
1034
ajaxSuccessHandler( event, xhr, settings ) {
1135
const params = new URLSearchParams( settings.data );
@@ -40,7 +64,7 @@ const hCaptchaPlayground = window.hCaptchaPlayground || ( function( window, $ )
4064
};
4165

4266
return app;
43-
}( window, jQuery ) );
67+
}( window, document, jQuery ) );
4468

4569
window.hCaptchaPlayground = hCaptchaPlayground;
4670

changelog.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
= 4.21.0 =
2+
* Added AI-ready security actions via the WordPress Abilities API, enabling automated threat inspection and response.
3+
* Added compatibility with the latest version of the Ninja Forms plugin.
4+
* Fixed FluentForms integrations after the latest FluentForms update.
5+
* Fixed the inability to send FluentForms Conversational Form.
6+
* Fixed the racing condition which sometimes led to double rendering of the hCaptcha widget on any forms.
7+
* Fixed double rendering of the hCaptcha widget on the Elementor Form.
8+
* Fixed an error activating a free plugin when its premium version is not available.
9+
* Fixed highlighting of the suggested plugin when it is already activated.
10+
* Fixed an attempt for installation of an already installed plugin.
11+
* Fixed installing plugins declared as WordPress dependencies.
12+
* Fixed Jetpack test form appearance on the Playground.
13+
114
= 4.20.0 =
215
* Added Divi 5 support.
316
* Added onboarding wizard.

hcaptcha.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Plugin Name: hCaptcha for WP
1111
* Plugin URI: https://www.hcaptcha.com/
1212
* Description: hCaptcha keeps out bots and spam while putting privacy first. It is a drop-in replacement for reCAPTCHA.
13-
* Version: 4.20.0
13+
* Version: 4.21.0
1414
* Requires at least: 5.3
1515
* Requires PHP: 7.2
1616
* Author: hCaptcha
@@ -21,7 +21,7 @@
2121
* Domain Path: /languages/
2222
*
2323
* WC requires at least: 3.0
24-
* WC tested up to: 10.3
24+
* WC tested up to: 10.4
2525
*/
2626

2727
// phpcs:ignore Generic.Commenting.DocComment.MissingShort
@@ -39,7 +39,7 @@
3939
/**
4040
* Plugin version.
4141
*/
42-
const HCAPTCHA_VERSION = '4.20.0';
42+
const HCAPTCHA_VERSION = '4.21.0';
4343

4444
/**
4545
* Path to the plugin dir.

0 commit comments

Comments
 (0)