Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions assets/js/hcaptcha-cf7.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ document.addEventListener( 'DOMContentLoaded', function() {
return form;
} );
} );

document.addEventListener( 'DOMContentLoaded', hCaptchaBindEvents );
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
= 4.21.1 =
* Fixed hCaptcha not loading on Contact Form 7.

= 4.21.0 =
* Added AI-ready security actions via the WordPress Abilities API, enabling automated threat inspection and response.
* Added compatibility with the latest version of the Ninja Forms plugin.
Expand Down
4 changes: 2 additions & 2 deletions hcaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Plugin Name: hCaptcha for WP
* Plugin URI: https://www.hcaptcha.com/
* Description: hCaptcha keeps out bots and spam while putting privacy first. It is a drop-in replacement for reCAPTCHA.
* Version: 4.21.0
* Version: 4.21.1
* Requires at least: 5.3
* Requires PHP: 7.2
* Author: hCaptcha
Expand Down Expand Up @@ -39,7 +39,7 @@
/**
* Plugin version.
*/
const HCAPTCHA_VERSION = '4.21.0';
const HCAPTCHA_VERSION = '4.21.1';

/**
* Path to the plugin dir.
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: captcha, hcaptcha, antispam, abuse, protect
Requires at least: 5.3
Tested up to: 6.9
Requires PHP: 7.2
Stable tag: 4.21.0
Stable tag: 4.21.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -852,6 +852,9 @@ Instructions for popular native integrations are below:

== Changelog ==

= 4.21.1 =
* Fixed hCaptcha not loading on Contact Form 7.

= 4.21.0 =
* Added AI-ready security actions via the WordPress Abilities API, enabling automated threat inspection and response.
* Added compatibility with the latest version of the Ninja Forms plugin.
Expand Down
6 changes: 3 additions & 3 deletions src/js/hcaptcha/hcaptcha.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,12 +590,12 @@ class HCaptcha {
this.getForms().map( ( formElement ) => {
const hcaptchaElement = formElement.querySelector( '.h-captcha' );

if ( el && ( el !== hcaptchaElement ) ) {
// Ignore forms not having hcaptcha.
if ( null === hcaptchaElement ) {
return formElement;
}

// Ignore forms not having hcaptcha.
if ( null === hcaptchaElement ) {
if ( ( el instanceof HTMLElement ) && ( el !== hcaptchaElement ) ) {
return formElement;
}

Expand Down
3 changes: 2 additions & 1 deletion src/php/CF7/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace HCaptcha\CF7;

use HCaptcha\Helpers\Pages;
use HCaptcha\Main;
use WPCF7_ContactForm;
use WPCF7_TagGenerator;
use WPCF7_TagGeneratorGenerator;
Expand Down Expand Up @@ -307,7 +308,7 @@ public function enqueue_admin_scripts_before_cf7(): void {
wp_enqueue_script(
self::HANDLE,
HCAPTCHA_URL . "/assets/js/hcaptcha-cf7$min.js",
[],
[ Main::HANDLE ],
HCAPTCHA_VERSION,
true
);
Expand Down
3 changes: 2 additions & 1 deletion src/php/CF7/CF7.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use HCaptcha\Helpers\API;
use HCaptcha\Helpers\HCaptcha;
use HCaptcha\Main;
use WPCF7_FormTag;
use WPCF7_Submission;
use WPCF7_Validation;
Expand Down Expand Up @@ -309,7 +310,7 @@ public function enqueue_scripts(): void {
wp_enqueue_script(
self::HANDLE,
HCAPTCHA_URL . "/assets/js/hcaptcha-cf7$min.js",
[],
[ Main::HANDLE ],
HCAPTCHA_VERSION,
true
);
Expand Down
1 change: 1 addition & 0 deletions tests/js/assets-js-files/hcaptcha-cf7.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe( 'hCaptcha Contact Form 7', () => {

require( '../../../assets/js/hcaptcha-cf7.js' );
document.dispatchEvent( new Event( 'DOMContentLoaded' ) );
hCaptchaBindEvents.mockClear();
} );

afterEach( () => {
Expand Down