Skip to content

Commit 590a53c

Browse files
V4.7.0 (#369)
* Fix Migrations test. * Bump up version to RC1. * Add akismet key to CF7. * Add compatibility with WordPress Recovery Mode. * Fix racing condition when loading hCaptcha API. * Update readme.txt. * Add custom element callback to app.js. * Add custom element callback to app.js. * Add custom element callback to app.js. * Remove custom element support in EA admin. * Update readme.txt. * Fix launching notifications script on every admin page. * Fix a problem with sending a Ninja form with solved hCaptcha. * Bump up version to RC2. * Update texts on Integrations page. * Fix missing hCaptcha in Formidable forms. * Fix non-blocking of reCaptcha scripts with Kadence Forms. * Fix showing hCaptcha in Elementor admin in some cases. * Fix inability to sort by Source column on Forms and Event admin pages. * Fix add_type_module. * Fix PCP errors. * Deprecate hcaptcha_get_verify_output. * Add the ability to use shortcode in the Mailchimp for WP form. * Fix tests after deprecation. * Adding hCaptcha to Jetpack admin. * Rewrite Jetpacj tests, cover 100%. * Bump up tested WP and WC versions. * Fix inability to deactivate Divi theme right after activation. * Fix tests with WP 6.7. * Fix inability to deactivate Divi theme right after activation. * Fix inability to deactivate Divi theme right after activation. * Activate plugins silently. * Deactivate plugins silently. * Fix activating network wide when active on site. * Fix Integrations tests. * Cover Integrations 100%. * CS. * Fix inability to deactivate Avada theme right after activation. * Add Integrations tests to 100%. * Fix CF7 admin scripts upon CF7 update. * Added compatibility with Contact Form 7 v6.0. * Fix CF7 tests. * Fix CF7 live form position in admin. * Add compatibility with Elementor Element Caching. * Amend Elementor tests. * Fixed open_basedir restriction warning in Query Monitor. * Adjust helpers positioning on General page. * Cover Mailchimp 100%. * Cover Formidable Forms 100%. * Cover Kadence Advanced Form 100%. * Cover Kadence AdvancedBlockParser 100%. * Cover Kadence Base 100%. * Cover Otter 100%. * phpcs. * Raise UM coverage to 100%. * Raise Fluent Forms coverage to 100%. * Show error message for shortcoded hCaptcha in Jetpack. * Add ability to use shortcode in the Jetpack Classic form. * Add ability to use shortcode parameters in the Jetpack Classic form. * Fix Jetpack tests. * Cover Helpers 100%. * Cover DownloadManager 100%. * Bump up version. * Apply suggestions from code review * Apply suggestions from code review --------- Co-authored-by: e271828- <e271828-@users.noreply.github.com>
1 parent 10d3762 commit 590a53c

File tree

82 files changed

+3658
-940
lines changed

Some content is hidden

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

82 files changed

+3658
-940
lines changed

.tests/js/hcaptcha/app.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jest.mock( '../../../src/js/hcaptcha/hcaptcha.js', () => {
99
getWidgetId: jest.fn(),
1010
reset: jest.fn(),
1111
bindEvents: jest.fn(),
12+
addSyncedEventListener: jest.fn(),
1213
submit: jest.fn(),
1314
};
1415
return jest.fn( () => mockHCaptcha );
@@ -46,6 +47,6 @@ describe( 'app.js', () => {
4647

4748
test( 'hCaptchaOnLoad should call bindEvents', () => {
4849
window.hCaptchaOnLoad();
49-
expect( hCaptcha.bindEvents ).toHaveBeenCalled();
50+
expect( hCaptcha.addSyncedEventListener ).toHaveBeenCalled();
5051
} );
5152
} );

.tests/php/integration/AAAMainTest.php

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use HCaptcha\Divi\EmailOptin;
2424
use HCaptcha\DownloadManager\DownloadManager;
2525
use HCaptcha\FluentForm\Form;
26-
use HCaptcha\Jetpack\JetpackForm;
2726
use HCaptcha\Main;
2827
use HCaptcha\ElementorPro\HCaptchaHandler;
2928
use HCaptcha\Migrations\Migrations;
@@ -45,6 +44,7 @@
4544
use tad\FunctionMocker\FunctionMocker;
4645
use HCaptcha\Admin\PluginStats;
4746
use HCaptcha\Admin\Events\Events;
47+
use WP_Textdomain_Registry;
4848

4949
/**
5050
* Test Main class.
@@ -889,7 +889,7 @@ function load() {
889889
window.removeEventListener( 'touchstart', load );
890890
document.body.removeEventListener( 'mouseenter', load );
891891
document.body.removeEventListener( 'click', load );
892-
window.removeEventListener( 'load', delayedLoad );
892+
window.removeEventListener( 'scroll', scrollHandler );
893893
894894
const t = document.getElementsByTagName( 'script' )[0];
895895
const s = document.createElement('script');
@@ -907,24 +907,24 @@ function scrollHandler() {
907907
return;
908908
}
909909
910-
window.removeEventListener( 'scroll', scrollHandler );
911910
load();
912911
}
913912
914-
function delayedLoad() {
915-
window.addEventListener( 'scroll', scrollHandler );
913+
document.addEventListener( 'hCaptchaBeforeAPI', function() {
916914
// noinspection JSAnnotator
917915
const delay = -100;
918916
919917
if ( delay >= 0 ) {
920918
setTimeout( load, delay );
919+
920+
return;
921921
}
922-
}
923922
924-
window.addEventListener( 'touchstart', load );
925-
document.body.addEventListener( 'mouseenter', load );
926-
document.body.addEventListener( 'click', load );
927-
window.addEventListener( 'load', delayedLoad );
923+
window.addEventListener( 'touchstart', load );
924+
document.body.addEventListener( 'mouseenter', load );
925+
document.body.addEventListener( 'click', load );
926+
window.addEventListener( 'scroll', scrollHandler );
927+
} );
928928
} )();
929929
JS;
930930

@@ -1505,7 +1505,7 @@ public function dp_test_load_modules(): array {
15051505
'Jetpack' => [
15061506
[ 'jetpack_status', 'contact' ],
15071507
'jetpack/jetpack.php',
1508-
JetpackForm::class,
1508+
\HCaptcha\Jetpack\Form::class,
15091509
],
15101510
'Kadence Form' => [
15111511
[ 'kadence_status', 'form' ],
@@ -1759,14 +1759,22 @@ static function ( $override, $domain, $mofile ) use ( &$override_filter_params )
17591759
3
17601760
);
17611761

1762+
$saved_wp_textdomain_registry = $GLOBALS['wp_textdomain_registry'] ?? null;
1763+
$GLOBALS['wp_textdomain_registry'] = new WP_Textdomain_Registry();
1764+
1765+
self::assertFalse( $GLOBALS['wp_textdomain_registry']->get( 'hcaptcha-for-forms-and-more', 'ko_KR' ) );
1766+
1767+
$GLOBALS['wp_textdomain_registry'] = new WP_Textdomain_Registry();
1768+
17621769
$subject->load_textdomain();
17631770

1771+
self::assertNotEmpty( $GLOBALS['wp_textdomain_registry']->get( 'hcaptcha-for-forms-and-more', 'ko_KR' ) );
1772+
1773+
$GLOBALS['wp_textdomain_registry'] = $saved_wp_textdomain_registry;
1774+
17641775
self::assertFalse( $override_filter_params[0][0] );
17651776
self::assertSame( $default_domain, $override_filter_params[0][1] );
17661777
self::assertSame( $default_mofile, $override_filter_params[0][2] );
1767-
self::assertFalse( $override_filter_params[1][0] );
1768-
self::assertSame( $domain, $override_filter_params[1][1] );
1769-
self::assertSame( basename( $mofile ), basename( $override_filter_params[1][2] ) );
17701778
}
17711779

17721780
/**

.tests/php/integration/CF7/AdminTest.php

Lines changed: 34 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
use HCaptcha\CF7\Admin;
1717
use HCaptcha\Tests\Integration\HCaptchaPluginWPTestCase;
18-
use Mockery;
1918
use WPCF7_TagGenerator;
2019

2120
/**
@@ -416,55 +415,39 @@ public function test_tag_generator_hcaptcha(): void {
416415
'title' => 'hCaptcha',
417416
'content' => 'tag-generator-panel-cf7-hcaptcha',
418417
];
419-
$expected = ' <div class="control-box">
418+
$expected = ' <header class="description-box">
419+
<h3>hCaptcha field form-tag generator</h3>
420+
<p>Generate a form-tag for a hCaptcha field.</p>
421+
</header>
422+
423+
<div class="control-box">
420424
<fieldset>
421-
<legend>Generate a form-tag for a hCaptcha field.</legend>
422-
423-
<table class="form-table">
424-
<tbody>
425-
426-
<tr>
427-
<th scope="row">
428-
<label for="tag-generator-panel-cf7-hcaptcha-id">
429-
Id attribute </label>
430-
</th>
431-
<td>
432-
<input
433-
type="text" name="id" class="idvalue oneline option"
434-
id="tag-generator-panel-cf7-hcaptcha-id"/>
435-
</td>
436-
</tr>
437-
438-
<tr>
439-
<th scope="row">
440-
<label for="tag-generator-panel-cf7-hcaptcha-class">
441-
Class attribute </label>
442-
</th>
443-
<td>
444-
<input
445-
type="text" name="class" class="classvalue oneline option"
446-
id="tag-generator-panel-cf7-hcaptcha-class"/>
447-
</td>
448-
</tr>
449-
450-
</tbody>
451-
</table>
452-
</fieldset>
425+
<legend id="tag-generator-panel-cf7-hcaptcha-type-legend">Field type</legend>
426+
427+
<select data-tag-part="basetype" aria-labelledby="tag-generator-panel-cf7-hcaptcha-type-legend"><option value="cf7-hcaptcha">hCaptcha field</option></select>
428+
429+
<br />
430+
<label>
431+
<input type="checkbox" data-tag-part="type-suffix" value="*" />
432+
This is a required field. </label>
433+
</fieldset>
434+
<fieldset>
435+
<legend id="tag-generator-panel-cf7-hcaptcha-name-legend">Field name</legend>
436+
<input type="text" data-tag-part="name" pattern="[A-Za-z][A-Za-z0-9_\-]*" aria-labelledby="tag-generator-panel-cf7-hcaptcha-name-legend" />
437+
438+
</fieldset>
439+
<fieldset>
440+
<legend id="tag-generator-panel-cf7-hcaptcha-class-legend">Class attribute</legend>
441+
<input type="text" data-tag-part="option" data-tag-option="class:" pattern="[A-Za-z0-9_\-\s]*" aria-labelledby="tag-generator-panel-cf7-hcaptcha-class-legend" />
442+
</fieldset>
453443
</div>
454444
455-
<div class="insert-box">
456-
<label>
457-
<input
458-
type="text" name="cf7-hcaptcha" class="tag code" readonly="readonly"
459-
onfocus="this.select()"/>
460-
</label>
461-
462-
<div class="submitbox">
463-
<input
464-
type="button" class="button button-primary insert-tag"
465-
value="Insert Tag"/>
466-
</div>
467-
</div>
445+
<footer class="insert-box">
446+
<div class="flex-container">
447+
<input type="text" class="code" readonly="readonly" onfocus="this.select();" data-tag-part="tag" aria-label="The form-tag to be inserted into the form template" /> <button type="button" class="button button-primary" data-taggen="insert-tag">Insert Tag</button>
448+
</div>
449+
<p class="mail-tag-tip">To use the user input in the email, insert the corresponding mail-tag <strong data-tag-part="mail-tag"></strong> into the email template.</p>
450+
</footer>
468451
';
469452

470453
$subject = new Admin();
@@ -478,7 +461,6 @@ public function test_tag_generator_hcaptcha(): void {
478461
* Test enqueue_admin_scripts_before_cf7() and enqueue_admin_scripts_after_cf7().
479462
*
480463
* @noinspection PhpConditionAlreadyCheckedInspection
481-
* @noinspection PhpUndefinedConstantInspection
482464
*/
483465
public function test_enqueue_admin_scripts(): void {
484466
global $wp_scripts;
@@ -503,16 +485,16 @@ public function test_enqueue_admin_scripts(): void {
503485

504486
wpcf7_admin_enqueue_scripts( 'wpcf7' );
505487

506-
$data = $wp_scripts->registered['wpcf7-admin']->extra['data'];
507-
preg_match( '/var wpcf7 = ({.+});/', $data, $m );
488+
$data = $wp_scripts->registered['wpcf7-admin']->extra['before'][1];
489+
preg_match( '/var wpcf7 = ({.+});/s', $data, $m );
508490
$wpcf7 = json_decode( $m[1], true );
509491

510492
self::assertArrayNotHasKey( 'api', $wpcf7 );
511493

512494
$subject->enqueue_admin_scripts_after_cf7();
513495

514-
$data = $wp_scripts->registered['wpcf7-admin']->extra['data'];
515-
preg_match( '/var wpcf7 = ({.+});/', $data, $m );
496+
$data = $wp_scripts->registered['wpcf7-admin']->extra['before'][1];
497+
preg_match( '/var wpcf7 = ({.+});/s', $data, $m );
516498
$wpcf7 = json_decode( $m[1], true );
517499

518500
self::assertArrayHasKey( 'api', $wpcf7 );

.tests/php/integration/DelayedScript/DelayedScriptTest.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function load() {
6161
window.removeEventListener( 'touchstart', load );
6262
document.body.removeEventListener( 'mouseenter', load );
6363
document.body.removeEventListener( 'click', load );
64-
window.removeEventListener( 'load', delayedLoad );
64+
window.removeEventListener( 'scroll', scrollHandler );
6565
6666
const some = 1;
6767
}
@@ -73,24 +73,24 @@ function scrollHandler() {
7373
return;
7474
}
7575
76-
window.removeEventListener( 'scroll', scrollHandler );
7776
load();
7877
}
7978
80-
function delayedLoad() {
81-
window.addEventListener( 'scroll', scrollHandler );
79+
document.addEventListener( 'hCaptchaBeforeAPI', function() {
8280
// noinspection JSAnnotator
8381
const delay = 3000;
8482
8583
if ( delay >= 0 ) {
8684
setTimeout( load, delay );
85+
86+
return;
8787
}
88-
}
8988
90-
window.addEventListener( 'touchstart', load );
91-
document.body.addEventListener( 'mouseenter', load );
92-
document.body.addEventListener( 'click', load );
93-
window.addEventListener( 'load', delayedLoad );
89+
window.addEventListener( 'touchstart', load );
90+
document.body.addEventListener( 'mouseenter', load );
91+
document.body.addEventListener( 'click', load );
92+
window.addEventListener( 'scroll', scrollHandler );
93+
} );
9494
} )();
9595
JS;
9696

@@ -142,7 +142,7 @@ function load() {
142142
window.removeEventListener( 'touchstart', load );
143143
document.body.removeEventListener( 'mouseenter', load );
144144
document.body.removeEventListener( 'click', load );
145-
window.removeEventListener( 'load', delayedLoad );
145+
window.removeEventListener( 'scroll', scrollHandler );
146146
147147
const t = document.getElementsByTagName( 'script' )[0];
148148
const s = document.createElement('script');
@@ -160,24 +160,24 @@ function scrollHandler() {
160160
return;
161161
}
162162
163-
window.removeEventListener( 'scroll', scrollHandler );
164163
load();
165164
}
166165
167-
function delayedLoad() {
168-
window.addEventListener( 'scroll', scrollHandler );
166+
document.addEventListener( 'hCaptchaBeforeAPI', function() {
169167
// noinspection JSAnnotator
170168
const delay = 3000;
171169
172170
if ( delay >= 0 ) {
173171
setTimeout( load, delay );
172+
173+
return;
174174
}
175-
}
176175
177-
window.addEventListener( 'touchstart', load );
178-
document.body.addEventListener( 'mouseenter', load );
179-
document.body.addEventListener( 'click', load );
180-
window.addEventListener( 'load', delayedLoad );
176+
window.addEventListener( 'touchstart', load );
177+
document.body.addEventListener( 'mouseenter', load );
178+
document.body.addEventListener( 'click', load );
179+
window.addEventListener( 'scroll', scrollHandler );
180+
} );
181181
} )();
182182
JS;
183183

0 commit comments

Comments
 (0)