Skip to content

Commit

Permalink
V4.4.0 (#352)
Browse files Browse the repository at this point in the history
* Fix message layout on Integrations page.

* Fix message layout on Integrations page.

* Fix message layout on General page.

* Update readme.txt.

* Fix test.

* Fix message layout on General and Integrations pages.

* Fix processing of WooCommerce Register form.

* Bump up version.

* WPCS.

* Fix missing sitekey error.

* Fix missing sitekey error.

* Circumvent WP bug with naming of the first submenu.

* Move system notices to the message area.

* Do not store check config events.

* Amend Events.php tests.

* Update readme.txt.

* Update readme.txt.

* Add cursor pointer to datepicker labels.

* Add the action link on admin network plugins page.

* Add the action link on admin network plugins page.

* Add notification and fix links in menu pages mode.

* Update readme.txt.

* Fix Notifications.php tests.

* WPCS.

* Add support for Contact Form 7 embedded forms.

* Fix tests.

* Cover CF7 by tests 100%.

* WPCS.

* Add a live form in the Contact Form 7 admin editor.

* Fix CF7 live form on small screens.

* Update CF7 tests.

* WPCS.

* Update composer packages.

* Update composer packages.

* Update composer packages.

* Update js packages.

* Add prettier.

* Prevent a potential fatal in CoBlocks.

* Fix Firefox issue with not showing hCaptcha.

* Fix security issue with ws package.

* Block WC checkout.

* Remove frontend checkout.

* Remove frontend checkout.

* WPCS in Essential blocks.

* Add hCaptcha data to the WC Checkout REST.

* Add forced mode to the WC Checkout REST.

* Update readme.txt.

* WC compatibility 9.0.

* Cover WC Checkout by tests.

* Cover WC Checkout by tests.

* Update readme.txt.

* Check if a plugin or theme is installed before activation.

* Fix tests.

* Amend Integrations.php tests.

* Amend Integrations.php tests.

* Fix integrations.js tests.

* Fix error on activation/deactivation of a theme.

* Add activation of dependent plugins with a theme.

* Update Integrations.php tests.

* Update Integrations.php tests.

* Add dependencies.

* Fix error on activating Brizy plugin.

* Update Integrations.php tests.

* Update Integrations.php tests.

* Update Integrations.php tests.

* Update Integrations.php tests.

* Update package.json for a security reason.

* Update package.json for a security reason.

* Add support for GiveWP block forms created via Form Builder.

* Add proper error messaging to the block GiveWP form.

* Grammar.

* WP tested up to 6.6.

* Bump up the PHP version to 7.2.

* Raise the code to the PHP 7.2 level.

* Fix bug with not storing GiveWP as a source in the Events table.

* Make GiveWp block multistep form working.

* Fix create-zip.yml.

* Fix create-zip.yml.

* Fix no js module accepted by Divi.

* Code style.

* Code style.

* Fix issue with updated Brizy plugin.

* Code style.

* Do not include .gitattributes to the release zip.

* Change the plugin name.

* Move scoped libs from /lib to /vendors dir.

* Remove scoped packages before the release build to run scoper and delete scoped packages from /vendor.

* Bump up version.

* Update phpcs.xml.

* Update readme.txt.

* Do not remove scoped packages before deploy.

* Always remove scoped packages from vendor.

* Fix warnings and deprecation messages in admin when CF7 is active.
Add a live form in the Contact Form 7 admin form view.

* Fix fatal error with Gravity Forms.

* Fix CF7 tests.

* Bump up version.

* Update phpcs.xml.

* Update readme.txt.

* Bump up version.

* Fix tag generator hCaptcha.

* Fix CF7 live form with tag generator.

* Fix CF7 live form with tag generator.

* Fix CF7 live form with tag generator.

* Fix NF script issue.

* Fix Ninja Forms Ajax processing.

* Rename scoped namespace to HCaptcha\Vendors\...

* Improve dump in scoper.

* Remove scoped packages before final dump.

* Always do dump.

* Improve naming.

* Update readme.txt.

* Fix tests with --classmap=authoritative.

* Fix error with the Elementor Checkout Element.

* Fix nf jest.

* Fix nf jest.

* Fix nf jest.

* Add integration with WPS Hide Login plugin.

* Add compatibility with Contact Form 7 Stripe integration.

* Update CF& tests.

* Block hCaptcha in admin for CF7 Stripe.

* Upgrade unit tests to PHP 7.2.

* Upgrade integration tests to PHP 7.2.

* Update Mailpoet integration.

* Do not activate the plugin on cron requests.

* Do not activate the plugin on cron requests.

* Move RequestTest.php to unit tests.

* Fix Request tests.

* Cover Request.php 100%.

* Cover Request.php 100%.

* Fix ignorance of Pro params in the Elementor admin editor.

* Add Elementor screenshots.

* Add Elementor screenshots.

* Fix ESLint

* Do not show notifications for activated features.

* Add notification counters.

* Add CF7 admin notification.

* Fix NotificationsTest.php.

* Fixed inability to activate the Elementor Pro plugin when Elementor plugin is activated.

* Fix tests.

* Update Elementor admin screenshot.

* Add Elementor admin notification.

* Update readme.txt.

* Cover CF7 Admin 100%.

* Cover Elementor Login 100%.

* Cover Elementor Login 100%.

* Cover Jetpack 100%.

* Cover Elementor Login 100%.

* Cover Essential Addons Login 100%.

* Cover Essential Addons Login 100%.

* Cover Essential Addons Register 100%.

* Add link to the article.

* Fix replies to wpDiscuz comments.

* Fix replies in the WP Dashboard with wpDiscuz.

* Fix wpDiscuz tests.

* Fix sending several wpDiscuz comments without a page reload.

* Add compatibility with LoginPress plugin.

* Fix tests.

* Fix tests.

* Improved compatibility with Wordfence Login Security plugin.

* Improved compatibility with Wordfence Login Security plugin.

* Bump up version.
  • Loading branch information
kagg-design authored Aug 1, 2024
1 parent 79902b1 commit 25bdd39
Show file tree
Hide file tree
Showing 140 changed files with 2,606 additions and 1,087 deletions.
8 changes: 4 additions & 4 deletions .php-scoper/hcaptcha-wordpress-plugin-scoper.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
$finders[0]->name( [ 'keywords*.txt', 'operators*.txt' ] );

$config = [
'prefix' => 'HCaptcha\Vendor',
'prefix' => 'HCaptcha\Vendors',
'finders' => $finders,
'patchers' => [
static function ( string $file_path, string $prefix, string $content ): string {
Expand All @@ -31,9 +31,9 @@ static function ( string $file_path, string $prefix, string $content ): string {
if ( false !== strpos( $file_path, 'matthiasmullie/minify/src/CSS.php' ) ) {
return str_replace(
[
"'HCaptcha\\\\Vendor\\\\1\\\\2\\\\3'",
"'HCaptcha\\\\Vendor\\\\1\\\\2'",
"'HCaptcha\\\\Vendor\\\\1'",
"'HCaptcha\\\\Vendors\\\\1\\\\2\\\\3'",
"'HCaptcha\\\\Vendors\\\\1\\\\2'",
"'HCaptcha\\\\Vendors\\\\1'",
],
[
"'\\\\1\\\\2\\\\3'",
Expand Down
93 changes: 44 additions & 49 deletions .php-scoper/src/Scoper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use Composer\Installer\PackageEvent;
use Composer\Script\Event;
use Isolated\Symfony\Component\Finder\Finder;
use Seld\JsonLint\ParsingException;

/**
* Class Scoper.
Expand All @@ -43,13 +42,6 @@ class Scoper {
*/
private static $do_scope = false;

/**
* Do dump-autoload, as some packages were updated or removed.
*
* @var bool
*/
private static $do_dump = false;

/**
* Post-update composer command.
*
Expand All @@ -59,7 +51,7 @@ class Scoper {
* @noinspection PhpUnused
*/
public static function post_cmd( Event $event ): void {
$packages = $event->getComposer()->getPackage()->getExtra()['scope-packages'] ?? [];
$scope_packages = $event->getComposer()->getPackage()->getExtra()['scope-packages'] ?? [];

if ( self::$do_scope ) {
self::prepare_scope( $event );
Expand All @@ -75,7 +67,7 @@ static function ( $package ) {
)
);

$removed_packages = array_diff( $packages, $locked_packages );
$removed_packages = array_diff( $scope_packages, $locked_packages );
$vendor_prefixed = self::get_vendor_prefixed_dir();

foreach ( $removed_packages as $removed_package ) {
Expand All @@ -86,9 +78,8 @@ static function ( $package ) {
// Always delete scoped packages from vendor.
self::cleanup_scope( $event );

if ( self::$do_dump ) {
self::dump( $event );
}
// Always do dump.
self::dump( $event );
}

/**
Expand All @@ -100,8 +91,8 @@ static function ( $package ) {
* @noinspection PhpUnused
*/
public static function post_package_install( PackageEvent $package_event ): void {
$packages = $package_event->getComposer()->getPackage()->getExtra()['scope-packages'] ?? [];
$operation = $package_event->getOperation();
$scope_packages = $package_event->getComposer()->getPackage()->getExtra()['scope-packages'] ?? [];
$operation = $package_event->getOperation();

/**
* Current operation.
Expand All @@ -110,7 +101,7 @@ public static function post_package_install( PackageEvent $package_event ): void
*/
$package = $operation->getPackage()->getName();

if ( ! in_array( $package, $packages, true ) ) {
if ( ! in_array( $package, $scope_packages, true ) ) {
return;
}

Expand All @@ -127,8 +118,8 @@ public static function post_package_install( PackageEvent $package_event ): void
* @noinspection PhpUnused
*/
public static function post_package_update( PackageEvent $event ): void {
$packages = $event->getComposer()->getPackage()->getExtra()['scope-packages'] ?? [];
$operation = $event->getOperation();
$scope_packages = $event->getComposer()->getPackage()->getExtra()['scope-packages'] ?? [];
$operation = $event->getOperation();

/**
* Current operation.
Expand All @@ -137,7 +128,7 @@ public static function post_package_update( PackageEvent $event ): void {
*/
$package = $operation->getInitialPackage()->getName();

if ( ! in_array( $package, $packages, true ) ) {
if ( ! in_array( $package, $scope_packages, true ) ) {
return;
}

Expand All @@ -153,8 +144,8 @@ public static function post_package_update( PackageEvent $event ): void {
* @noinspection PhpUnused
*/
public static function post_package_uninstall( PackageEvent $event ): void {
$packages = $event->getComposer()->getPackage()->getExtra()['scope-packages'] ?? [];
$operation = $event->getOperation();
$scope_packages = $event->getComposer()->getPackage()->getExtra()['scope-packages'] ?? [];
$operation = $event->getOperation();

/**
* Current operation.
Expand All @@ -163,13 +154,11 @@ public static function post_package_uninstall( PackageEvent $event ): void {
*/
$package = $operation->getPackage()->getName();

if ( ! in_array( $package, $packages, true ) ) {
if ( ! in_array( $package, $scope_packages, true ) ) {
return;
}

self::delete_package( self::get_vendor_prefixed_dir(), $package );

self::$do_dump = true;
}

/**
Expand All @@ -179,12 +168,11 @@ public static function post_package_uninstall( PackageEvent $event ): void {
* @param Event $event Composer event.
*
* @return void
* @noinspection MkdirRaceConditionInspection
*/
private static function prepare_scope( Event $event ): void {
$packages = $event->getComposer()->getPackage()->getExtra()['scope-packages'] ?? [];
$scope_packages = $event->getComposer()->getPackage()->getExtra()['scope-packages'] ?? [];

if ( ! $packages ) {
if ( ! $scope_packages ) {
return;
}

Expand Down Expand Up @@ -256,8 +244,6 @@ static function ( $scope_package ) {

// phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.system_calls_shell_exec, WordPress.Security.EscapeOutput.OutputNotEscaped
echo shell_exec( $scoper_cmd );

self::$do_dump = true;
}

/**
Expand All @@ -277,8 +263,8 @@ private static function cleanup_scope( Event $event ): void {
$vendor = self::get_vendor_dir();

// Loop through the list of packages and delete relevant dirs in vendor.
foreach ( $scope_packages as $package ) {
self::delete_package( $vendor, $package );
foreach ( $scope_packages as $scope_package ) {
self::delete_package( $vendor, $scope_package );
}
}

Expand All @@ -290,6 +276,8 @@ private static function cleanup_scope( Event $event ): void {
* @return void
*/
private static function dump( BaseEvent $event ): void {
global $argv;

/**
* Current event.
*
Expand All @@ -302,9 +290,20 @@ private static function dump( BaseEvent $event ): void {
$package = $composer->getPackage();
$config = $composer->getConfig();

$optimize = $config->get( 'optimize-autoloader' );
$authoritative = $config->get( 'classmap-authoritative' );
$apcu = $config->get( 'apcu-autoloader' );
$scope_packages = $package->getExtra()['scope-packages'] ?? [];
$local_packages = $local_repo->getPackages();

foreach ( $local_packages as $local_package ) {
$package_name = $local_package->getName();

if ( in_array( $package_name, $scope_packages, true ) ) {
$local_repo->removePackage( $local_package );
}
}

$optimize = in_array( '--optimize-autoloader', $argv, true );
$authoritative = in_array( '--classmap-authoritative', $argv, true );
$apcu = in_array( '--apcu-autoloader', $argv, true );

if ( $authoritative ) {
$event->getIO()->write( '<info>Generating optimized autoload files (authoritative)</info>' );
Expand All @@ -320,22 +319,18 @@ private static function dump( BaseEvent $event ): void {
$generator->setRunScripts( false );
$generator->setApcu( $apcu );

try {
$class_map = $generator->dump(
$config,
$local_repo,
$package,
$installation_manager,
'composer',
$optimize,
null,
$composer->getLocker()
);
$class_map = $generator->dump(
$config,
$local_repo,
$package,
$installation_manager,
'composer',
$optimize,
null,
$composer->getLocker()
);

$number_of_classes = count( $class_map );
} catch ( ParsingException $e ) {
$number_of_classes = 0;
}
$number_of_classes = $class_map->count();

if ( $authoritative ) {
$event->getIO()
Expand Down
2 changes: 1 addition & 1 deletion .tests/js/__mocks__/backboneMarionette.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Mock Backbone
// noinspection JSUnresolvedReference

const Backbone = {
Expand Down Expand Up @@ -40,4 +39,5 @@ const Marionette = {
};

global.Backbone = Backbone;
global.nfRadio = Backbone.Radio;
global.Marionette = Marionette;
6 changes: 3 additions & 3 deletions .tests/js/__mocks__/backboneRadio.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// noinspection JSUnresolvedVariable

/* global Backbone */

const submitChannel = {
listenTo: jest.fn(),
};
Expand All @@ -11,7 +9,7 @@ const fieldsChannel = {
request: jest.fn(),
};

Backbone.Radio = {
const nfRadio = {
channel: jest.fn( ( channelName ) => {
if ( channelName === 'submit' ) {
return submitChannel;
Expand All @@ -21,3 +19,5 @@ Backbone.Radio = {
}
} ),
};

global.nfRadio = nfRadio;
16 changes: 15 additions & 1 deletion .tests/js/assets-js-files/hcaptcha-elementor-pro.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,27 @@ require( '../../../assets/js/hcaptcha-elementor-pro' );

describe( 'Elementor Frontend hCaptcha', () => {
beforeEach( () => {
global.wp = {
hooks: {
addFilter: jest.fn(),
applyFilters: jest.fn( ( hook, content ) => content ),
},
};

elementorFrontendHooks.addAction.mockClear();
} );

test( 'addAction is called with correct arguments', () => {
test( 'filter and action are called with correct arguments', () => {
// Simulate jQuery.ready
window.hCaptchaElementorPro();

expect( wp.hooks.addFilter ).toHaveBeenCalledTimes( 1 );
expect( wp.hooks.addFilter ).toHaveBeenCalledWith(
'hcaptcha.params',
'hcaptcha',
expect.any( Function )
);

expect( elementorFrontendHooks.addAction ).toHaveBeenCalledTimes( 1 );
expect( elementorFrontendHooks.addAction ).toHaveBeenCalledWith(
'frontend/element_ready/widget',
Expand Down
12 changes: 6 additions & 6 deletions .tests/js/assets-js-files/ncaptcha-nf.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// noinspection JSUnresolvedFunction,JSUnresolvedVariable

/* global Backbone */
/* global nfRadio */

import $ from 'jquery';

Expand Down Expand Up @@ -28,13 +28,13 @@ describe( 'Ninja Forms hCaptcha', () => {
controller = window.hCaptchaFieldController;

// Reset the request mock function
Backbone.Radio.channel( 'fields' ).request.mockReset();
nfRadio.channel( 'fields' ).request.mockReset();
} );

test( 'initialize registers listeners', () => {
controller.initialize();
expect( Backbone.Radio.channel ).toHaveBeenCalledWith( 'submit' );
expect( Backbone.Radio.channel ).toHaveBeenCalledWith( 'fields' );
expect( nfRadio.channel ).toHaveBeenCalledWith( 'submit' );
expect( nfRadio.channel ).toHaveBeenCalledWith( 'fields' );

expect( controller.listenTo ).toHaveBeenCalledWith(
expect.any( Object ),
Expand All @@ -57,7 +57,7 @@ describe( 'Ninja Forms hCaptcha', () => {

controller.updateHcaptcha( model );

expect( Backbone.Radio.channel( 'fields' ).request ).not.toHaveBeenCalled();
expect( nfRadio.channel( 'fields' ).request ).not.toHaveBeenCalled();
} );

test( 'updateHcaptcha removes error if value is set', () => {
Expand All @@ -68,7 +68,7 @@ describe( 'Ninja Forms hCaptcha', () => {

controller.updateHcaptcha( model );

expect( Backbone.Radio.channel( 'fields' ).request ).toHaveBeenCalledWith(
expect( nfRadio.channel( 'fields' ).request ).toHaveBeenCalledWith(
'remove:error',
expect.anything(),
'required-error'
Expand Down
Loading

0 comments on commit 25bdd39

Please sign in to comment.