Skip to content

Commit c3fe478

Browse files
V3.7.0 (#308)
* Remove rate plugin CTA from options.php. * Update composer.json. * Update packages. * Add enterprise settings. * Fix colored border of hCaptcha challenge arrow. * Bump up version. * Fix Enterpise section on mobile. * Add other Enterprise params. * Apply suggestions from code review * Apply suggestions from code review * Add urlencode for api.js params. * WPCS. * Add dot to helper text. --------- Co-authored-by: e271828- <e271828-@users.noreply.github.com>
1 parent 37b1c18 commit c3fe478

File tree

12 files changed

+778
-819
lines changed

12 files changed

+778
-819
lines changed

.tests/php/integration/AAAMainTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,10 @@ static function ( $name ) {
520520
.h-captcha iframe {
521521
position: relative;
522522
}
523+
524+
div[style*="z-index: 2147483647"] div[style*="border-width: 11px"][style*="position: absolute"][style*="pointer-events: none"] {
525+
border-style: none;
526+
}
523527
CSS;
524528

525529
$expected = "<style>\n$expected\n</style>\n";

.tests/php/unit/HCaptchaTestCase.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,49 @@ protected function get_test_general_form_fields(): array {
574574
)
575575
),
576576
],
577+
'api_host' => [
578+
'label' => 'API Host',
579+
'type' => 'text',
580+
'section' => 'enterprise',
581+
'default' => 'js.hcaptcha.com',
582+
'helper' => 'See Enterprise docs.',
583+
],
584+
'asset_host' => [
585+
'label' => 'Asset Host',
586+
'type' => 'text',
587+
'section' => 'enterprise',
588+
'helper' => 'See Enterprise docs.',
589+
],
590+
'endpoint' => [
591+
'label' => 'Endpoint',
592+
'type' => 'text',
593+
'section' => 'enterprise',
594+
'helper' => 'See Enterprise docs.',
595+
],
596+
'host' => [
597+
'label' => 'Host',
598+
'type' => 'text',
599+
'section' => 'enterprise',
600+
'helper' => 'See Enterprise docs.',
601+
],
602+
'image_host' => [
603+
'label' => 'Image Host',
604+
'type' => 'text',
605+
'section' => 'enterprise',
606+
'helper' => 'See Enterprise docs.',
607+
],
608+
'report_api' => [
609+
'label' => 'Report API',
610+
'type' => 'text',
611+
'section' => 'enterprise',
612+
'helper' => 'See Enterprise docs.',
613+
],
614+
'sentry' => [
615+
'label' => 'Sentry',
616+
'type' => 'text',
617+
'section' => 'enterprise',
618+
'helper' => 'See Enterprise docs.',
619+
],
577620
'off_when_logged_in' => [
578621
'label' => 'Other Settings',
579622
'type' => 'checkbox',

assets/css/general.css

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,30 @@
124124
width: 100%;
125125
}
126126

127+
/* Section Enterprise */
128+
.hcaptcha-section-enterprise + table {
129+
max-width: 760px;
130+
}
131+
132+
.hcaptcha-section-enterprise + table tbody {
133+
display: grid;
134+
grid-template-columns: repeat(2, 1fr);
135+
gap: 10px 20px;
136+
padding: 15px 20px;
137+
}
138+
139+
.hcaptcha-section-enterprise + table tbody th {
140+
width: auto;
141+
}
142+
143+
.hcaptcha-section-enterprise + table tbody tr th {
144+
padding: 0 0 10px 0;
145+
}
146+
147+
.hcaptcha-section-enterprise + table tbody tr td input {
148+
width: 100%;
149+
}
150+
127151
/* Section Other */
128152
.hcaptcha-section-other + table {
129153
max-width: 760px;

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
"codeception/module-db": "^1.2.0",
4141
"codeception/module-webdriver": "^1.4.1",
4242
"lucatume/function-mocker": "dev-master",
43-
"lucatume/wp-browser": "^3.2.1",
44-
"squizlabs/php_codesniffer": "^3.7.2",
43+
"lucatume/wp-browser": "^3.2.3",
44+
"squizlabs/php_codesniffer": "^3.8.1",
4545
"phpcompatibility/php-compatibility": "^9.3.5",
4646
"phpcompatibility/phpcompatibility-wp": "^2.1.4",
4747
"wp-coding-standards/wpcs": "^3.0.1"

hcaptcha.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Plugin Name: hCaptcha for WordPress
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: 3.6.0
13+
* Version: 3.7.0
1414
* Requires at least: 5.0
1515
* Requires PHP: 7.0
1616
* Author: hCaptcha
@@ -39,7 +39,7 @@
3939
/**
4040
* Plugin version.
4141
*/
42-
const HCAPTCHA_VERSION = '3.6.0';
42+
const HCAPTCHA_VERSION = '3.7.0';
4343

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

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,30 @@
4141
}
4242
},
4343
"engines": {
44-
"node": ">=21.2.0",
45-
"npm": ">=10.2.4"
44+
"node": ">=21.5.0",
45+
"npm": ">=10.3.0"
4646
},
4747
"packageManager": "yarn@4.0.2",
4848
"dependencies": {
49-
"@wordpress/hooks": "^3.47.0"
49+
"@wordpress/hooks": "^3.48.0"
5050
},
5151
"devDependencies": {
52-
"@babel/core": "^7.23.5",
53-
"@babel/preset-env": "^7.23.5",
54-
"@inrupt/jest-jsdom-polyfills": "^2.5.0",
55-
"@wordpress/eslint-plugin": "^17.4.0",
52+
"@babel/core": "^7.23.7",
53+
"@babel/preset-env": "^7.23.8",
54+
"@inrupt/jest-jsdom-polyfills": "^3.0.2",
55+
"@wordpress/eslint-plugin": "^17.5.0",
5656
"babel-loader": "^9.1.3",
5757
"coveralls": "^3.1.1",
58-
"css-loader": "^6.8.1",
58+
"css-loader": "^6.9.0",
5959
"css-minimizer-webpack-plugin": "^5.0.1",
60-
"eslint": "8.55.0",
60+
"eslint": "8.56.0",
6161
"glob": "^10.3.10",
6262
"jest": "^29.7.0",
6363
"jest-environment-jsdom": "^29.7.0",
6464
"jest-fetch-mock": "^3.0.3",
6565
"jquery": "^3.7.0",
66-
"mini-css-extract-plugin": "^2.7.6",
67-
"terser-webpack-plugin": "^5.3.9",
66+
"mini-css-extract-plugin": "^2.7.7",
67+
"terser-webpack-plugin": "^5.3.10",
6868
"webpack": "^5.89.0",
6969
"webpack-cli": "^5.1.4",
7070
"webpack-remove-empty-scripts": "^1.0.4"

readme.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: captcha, hcaptcha, recaptcha, spam, abuse
44
Requires at least: 5.0
55
Tested up to: 6.4
66
Requires PHP: 7.0.0
7-
Stable tag: 3.6.0
7+
Stable tag: 3.7.0
88
License: GPLv2 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -540,6 +540,12 @@ Instructions for popular native integrations are below:
540540

541541
== Changelog ==
542542

543+
= 3.7.0 =
544+
* Tested with WooCommerce 8.5.
545+
* Added optional Enterprise settings.
546+
* Fixed improper display of the "rate plugin" message on options.php.
547+
* Fixed colored border of hCaptcha challenge arrow.
548+
543549
= 3.6.0 =
544550
* Tested with WooCommerce 8.4.
545551
* Added compatibility with BuddyPress 12.0.

src/php/Main.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ class Main {
4646
*/
4747
const OBJECT = 'HCaptchaMainObject';
4848

49+
/**
50+
* Default API host.
51+
*/
52+
const API_HOST = 'js.hcaptcha.com';
53+
4954
/**
5055
* Form shown somewhere, use this flag to run the script.
5156
*
@@ -358,6 +363,10 @@ public function print_inline_styles() {
358363
.h-captcha iframe {
359364
position: relative;
360365
}
366+
367+
div[style*="z-index: 2147483647"] div[style*="border-width: 11px"][style*="position: absolute"][style*="pointer-events: none"] {
368+
border-style: none;
369+
}
361370
CSS;
362371

363372
HCaptcha::css_display( $css );
@@ -407,7 +416,26 @@ public function get_api_src(): string {
407416
$params['custom'] = 'true';
408417
}
409418

410-
return add_query_arg( $params, 'https://js.hcaptcha.com/1/api.js' );
419+
$api_host = trim( $this->settings()->get( 'api_host' ) ) ?: self::API_HOST;
420+
421+
$enterprise_params = [
422+
'asset_host',
423+
'endpoint',
424+
'host',
425+
'image_host',
426+
'report_api',
427+
'sentry',
428+
];
429+
430+
foreach ( $enterprise_params as $enterprise_param ) {
431+
$value = trim( $this->settings()->get( $enterprise_param ) );
432+
433+
if ( $value ) {
434+
$params[ $enterprise_param ] = rawurlencode( $value );
435+
}
436+
}
437+
438+
return add_query_arg( $params, "https://$api_host/1/api.js" );
411439
}
412440

413441
/**

src/php/Settings/Abstracts/SettingsBase.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,9 +1271,13 @@ public function load_plugin_textdomain() {
12711271
/**
12721272
* Is current admin screen the plugin options screen.
12731273
*
1274+
* @param string|array $ids Additional screen id or ids to check.
1275+
*
12741276
* @return bool
12751277
*/
1276-
protected function is_options_screen(): bool {
1278+
protected function is_options_screen( $ids = 'options' ): bool {
1279+
$ids = (array) $ids;
1280+
12771281
if ( ! function_exists( 'get_current_screen' ) ) {
12781282
return false;
12791283
}
@@ -1290,7 +1294,7 @@ protected function is_options_screen(): bool {
12901294
$screen_id = str_replace( 'settings_page', 'toplevel_page', $screen_id );
12911295
}
12921296

1293-
return 'options' === $current_screen->id || $screen_id === $current_screen->id;
1297+
return $screen_id === $current_screen->id || in_array( $current_screen->id, $ids, true );
12941298
}
12951299

12961300
/**

src/php/Settings/General.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use HCaptcha\Admin\Notifications;
1111
use HCaptcha\Helpers\HCaptcha;
12+
use HCaptcha\Main;
1213
use KAGG\Settings\Abstracts\SettingsBase;
1314

1415
/**
@@ -48,6 +49,11 @@ class General extends PluginSettingsBase {
4849
*/
4950
const SECTION_CUSTOM = 'custom';
5051

52+
/**
53+
* Enterprise section id.
54+
*/
55+
const SECTION_ENTERPRISE = 'enterprise';
56+
5157
/**
5258
* Other section id.
5359
*/
@@ -369,6 +375,49 @@ public function init_form_fields() {
369375
)
370376
),
371377
],
378+
'api_host' => [
379+
'label' => __( 'API Host', 'hcaptcha-for-forms-and-more' ),
380+
'type' => 'text',
381+
'section' => self::SECTION_ENTERPRISE,
382+
'default' => Main::API_HOST,
383+
'helper' => __( 'See Enterprise docs.' ),
384+
],
385+
'asset_host' => [
386+
'label' => __( 'Asset Host', 'hcaptcha-for-forms-and-more' ),
387+
'type' => 'text',
388+
'section' => self::SECTION_ENTERPRISE,
389+
'helper' => __( 'See Enterprise docs.', 'hcaptcha-for-forms-and-more' ),
390+
],
391+
'endpoint' => [
392+
'label' => __( 'Endpoint', 'hcaptcha-for-forms-and-more' ),
393+
'type' => 'text',
394+
'section' => self::SECTION_ENTERPRISE,
395+
'helper' => __( 'See Enterprise docs.', 'hcaptcha-for-forms-and-more' ),
396+
],
397+
'host' => [
398+
'label' => __( 'Host', 'hcaptcha-for-forms-and-more' ),
399+
'type' => 'text',
400+
'section' => self::SECTION_ENTERPRISE,
401+
'helper' => __( 'See Enterprise docs.', 'hcaptcha-for-forms-and-more' ),
402+
],
403+
'image_host' => [
404+
'label' => __( 'Image Host', 'hcaptcha-for-forms-and-more' ),
405+
'type' => 'text',
406+
'section' => self::SECTION_ENTERPRISE,
407+
'helper' => __( 'See Enterprise docs.', 'hcaptcha-for-forms-and-more' ),
408+
],
409+
'report_api' => [
410+
'label' => __( 'Report API', 'hcaptcha-for-forms-and-more' ),
411+
'type' => 'text',
412+
'section' => self::SECTION_ENTERPRISE,
413+
'helper' => __( 'See Enterprise docs.', 'hcaptcha-for-forms-and-more' ),
414+
],
415+
'sentry' => [
416+
'label' => __( 'Sentry', 'hcaptcha-for-forms-and-more' ),
417+
'type' => 'text',
418+
'section' => self::SECTION_ENTERPRISE,
419+
'helper' => __( 'See Enterprise docs.', 'hcaptcha-for-forms-and-more' ),
420+
],
372421
'off_when_logged_in' => [
373422
'label' => __( 'Other Settings', 'hcaptcha-for-forms-and-more' ),
374423
'type' => 'checkbox',
@@ -474,6 +523,9 @@ public function section_callback( array $arguments ) {
474523
case self::SECTION_CUSTOM:
475524
$this->print_section_header( $arguments['id'], __( 'Custom', 'hcaptcha-for-forms-and-more' ) );
476525
break;
526+
case self::SECTION_ENTERPRISE:
527+
$this->print_section_header( $arguments['id'], __( 'Enterprise', 'hcaptcha-for-forms-and-more' ) );
528+
break;
477529
case self::SECTION_OTHER:
478530
$this->print_section_header( $arguments['id'], __( 'Other', 'hcaptcha-for-forms-and-more' ) );
479531
break;

0 commit comments

Comments
 (0)