Skip to content

Commit

Permalink
V3.1.0 (#264)
Browse files Browse the repository at this point in the history
* Fix example of verify in the readme.txt.

* Update CI.

* Fix error on CF7 validation.

* Bump up version.

* Fix checkboxes disabled status after activation of a plugin on the Integrations page.

* Fix README.md.

* Fix README.md.

* Update screenshot-5.png.

* Add Notification system.

* Fix tests.

* Add animated icon on wp.org.

* Add animated icon on wp.org.

* Add animated icon on wp.org.

* Add animated icon on wp.org.

* Improve notifications design.

* Add reset notification feature.

* Add reset notification feature.

* Add reset notification feature.

* Change notification wording.

* Show notification after reset via ajax.

* Fix positioning bug when inserting notifications div.

* Update readme.txt.

* Fix CI after CF7 requirement for PHP 7.4.

* Fix mode selection for sample hCaptcha.

* Scroll to the ajax message on General.

* Bump up version.

* Update src/php/Admin/Notifications.php

Co-authored-by: e271828- <[email protected]>

* Update src/php/Admin/Notifications.php

Co-authored-by: e271828- <[email protected]>

---------

Co-authored-by: e271828- <[email protected]>
  • Loading branch information
kagg-design and e271828- authored Aug 8, 2023
1 parent df4b220 commit 3bef4f8
Show file tree
Hide file tree
Showing 19 changed files with 860 additions and 36 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:

- name: Install plugins
working-directory: ${{ env.wp-directory }}
run: wp plugin install bbpress buddypress contact-form-7 ultimate-member wpforms-lite wpforo
run: wp plugin install bbpress buddypress ultimate-member wpforms-lite wpforo

- name: Install plugins requiring 7.1
if: ${{ matrix.php-version >= '7.1' }}
Expand All @@ -123,6 +123,11 @@ jobs:
working-directory: ${{ env.wp-directory }}
run: wp plugin install woocommerce

- name: Install plugins requiring 7.4
if: ${{ matrix.php-version >= '7.4' }}
working-directory: ${{ env.wp-directory }}
run: wp plugin install contact-form-7

- name: Run WP tests
working-directory: ${{ env.wp-plugin-directory }}
run: composer integration -- --env github-actions
Expand Down
4 changes: 4 additions & 0 deletions .tests/php/integration/CF7/CF7Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
/**
* Test CF7 class.
*
* CF7 requires PHP 7.4.
*
* @requires PHP >= 7.4
*
* @group cf7
*/
class CF7Test extends HCaptchaPluginWPTestCase {
Expand Down
3 changes: 2 additions & 1 deletion .tests/php/integration/HCaptchaPluginWPTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ public static function tearDownAfterClass(): void { // phpcs:ignore PHPCompatib
*/
public function setUp(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
$plugins_requiring_php = [
'7.2' => [ 'woocommerce/woocommerce.php' ],
'7.1' => [ 'ninja-forms/ninja-forms.php' ],
'7.3' => [ 'woocommerce/woocommerce.php' ],
'7.4' => [ 'contact-form-7/wp-contact-form-7.php' ],
];

foreach ( $plugins_requiring_php as $php_version => $plugins_requiring_php_version ) {
Expand Down
6 changes: 6 additions & 0 deletions .tests/php/unit/HCaptchaTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,12 @@ protected function get_test_general_form_fields() {
'text' => 'Check',
'section' => General::SECTION_KEYS,
],
'reset_notifications' => [
'label' => 'Reset Notifications',
'type' => 'button',
'text' => 'Reset',
'section' => General::SECTION_KEYS,
],
'theme' => [
'label' => 'Theme',
'type' => 'select',
Expand Down
28 changes: 23 additions & 5 deletions .tests/php/unit/Settings/GeneralTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

namespace HCaptcha\Tests\Unit\Settings;

use HCaptcha\Admin\Notifications;
use HCaptcha\Main;
use HCaptcha\Settings\Abstracts\SettingsBase;
use HCaptcha\Settings\General;
Expand Down Expand Up @@ -124,15 +125,22 @@ public function test_init_form_fields() {
* @dataProvider dp_test_setup_fields
*/
public function test_setup_fields( $mode ) {
$settings = Mockery::mock( Settings::class )->makePartial();
$settings->shouldReceive( 'get_mode' )->andReturn( $mode );

$main = Mockery::mock( Main::class )->makePartial();
$main->shouldReceive( 'settings' )->andReturn( $settings );

$subject = Mockery::mock( General::class )->makePartial();
$subject->shouldAllowMockingProtectedMethods();
$subject->shouldReceive( 'is_options_screen' )->andReturn( true );
$subject->shouldReceive( 'get' )->andReturn( $mode );
$this->set_protected_property( $subject, 'form_fields', $this->get_test_form_fields() );

WP_Mock::passthruFunction( 'register_setting' );
WP_Mock::passthruFunction( 'add_settings_field' );

WP_Mock::userFunction( 'hcaptcha' )->with()->once()->andReturn( $main );

$subject->setup_fields();

$form_fields = $this->get_protected_property( $subject, 'form_fields' );
Expand Down Expand Up @@ -187,6 +195,18 @@ public function test_setup_fields_not_on_options_screen() {
public function test_section_callback( $section_id, $expected ) {
$subject = Mockery::mock( General::class )->makePartial()->shouldAllowMockingProtectedMethods();

$notifications = Mockery::mock( Notifications::class )->makePartial();

if ( General::SECTION_KEYS === $section_id ) {
$notifications->shouldReceive( 'show' )->once();
$main = Mockery::mock( Main::class )->makePartial();
$main->shouldReceive( 'notifications' )->andReturn( $notifications );

WP_Mock::userFunction( 'hcaptcha' )->with()->once()->andReturn( $main );
} else {
WP_Mock::userFunction( 'hcaptcha' )->never();
}

WP_Mock::passthruFunction( 'wp_kses_post' );

ob_start();
Expand All @@ -206,8 +226,6 @@ public function dp_test_section_callback() {
' <h2>
General </h2>
<div id="hcaptcha-message"></div>
<p>
To use <a href="https://www.hcaptcha.com/?r=wp&utm_source=wordpress&utm_medium=wpplugin&utm_campaign=sk" target="_blank">hCaptcha</a>, please register <a href="https://www.hcaptcha.com/signup-interstitial/?r=wp&utm_source=wordpress&utm_medium=wpplugin&utm_campaign=sk" target="_blank">here</a> to get your site and secret keys. </p>
<h3 class="hcaptcha-section-keys">Keys</h3>
',
],
Expand Down Expand Up @@ -244,7 +262,7 @@ public function test_admin_enqueue_scripts() {
$site_key = 'some key';

$settings = Mockery::mock( Settings::class )->makePartial();
$settings->shouldReceive( 'get_site_key' )->andReturn( $site_key );
$settings->shouldReceive( 'get' )->with( 'site_key' )->andReturn( $site_key );

$main = Mockery::mock( Main::class )->makePartial();
$main->shouldReceive( 'settings' )->andReturn( $settings );
Expand Down Expand Up @@ -297,7 +315,7 @@ static function ( $name ) use ( $plugin_url, $plugin_version ) {
General::OBJECT,
[
'ajaxUrl' => $ajax_url,
'action' => General::CHECK_CONFIG_ACTION,
'checkConfigAction' => General::CHECK_CONFIG_ACTION,
'nonce' => $nonce,
'modeLive' => General::MODE_LIVE,
'modeTestPublisher' => General::MODE_TEST_PUBLISHER,
Expand Down
Binary file removed .wordpress-org/icon-128x128.png
Binary file not shown.
69 changes: 69 additions & 0 deletions .wordpress-org/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 42 additions & 1 deletion assets/css/general.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#hcaptcha-message,
#setting-error-settings_updated {
max-width: 760px;
box-sizing: border-box;
}

#hcaptcha-options table tbody {
background: #fff;
}
Expand All @@ -20,11 +26,38 @@

.hcaptcha-section-keys + table tbody {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-template-columns: repeat(4, 1fr);
grid-template-areas:
"site-key site-key secret-key secret-key"
"sample-hcaptcha sample-hcaptcha check-config reset-notifications";
gap: 10px 20px;
padding: 15px 20px;
}

.hcaptcha-section-keys + table tbody th {
width: auto;
}

.hcaptcha-section-keys + table tbody tr.hcaptcha-general-site-key {
grid-area: site-key;
}

.hcaptcha-section-keys + table tbody tr.hcaptcha-general-secret-key {
grid-area: secret-key;
}

.hcaptcha-section-keys + table tbody tr.hcaptcha-general-sample-hcaptcha {
grid-area: sample-hcaptcha;
}

.hcaptcha-section-keys + table tbody tr.hcaptcha-general-check-config {
grid-area: check-config;
}

.hcaptcha-section-keys + table tbody tr.hcaptcha-reset-notifications {
grid-area: reset-notifications;
}

.hcaptcha-section-keys + table tbody tr th {
padding: 0 0 10px 0;
}
Expand Down Expand Up @@ -163,6 +196,14 @@
width: auto;
}

.hcaptcha-section-keys + table tbody {
grid-template-areas: unset;
}

.hcaptcha-section-keys + table tbody tr {
grid-area: unset !important;
}

.hcaptcha-section-other + table tbody {
grid-template-areas: unset;
}
Expand Down
95 changes: 95 additions & 0 deletions assets/css/notifications.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#hcaptcha-notifications {
margin: 5px 0 15px;
background: #fff;
padding: 15px 20px;
max-width: 760px;
box-sizing: border-box;
}

#hcaptcha-notifications-header {
display: flex;
margin-bottom: 10px;
padding-bottom: 10px;
border-bottom: 1px solid #c3c4c7;
line-height: 1.3;
font-size: 14px;
font-weight: 600;
justify-content: flex-start;
align-items: center;
column-gap: 3px;
}

#hcaptcha-notifications-header::before {
content: '';
background-image: url('../images/notification-bell.svg');
background-size: cover;
position: relative;
width: 30px;
height: 30px;
}

#hcaptcha-notifications-footer {
display: flex;
justify-content: space-between;
margin-top: 10px;
padding-top: 10px;
border-top: 1px solid #c3c4c7;
}

#hcaptcha-notifications .hcaptcha-notification {
margin: 0;
}

.hcaptcha-notification .hcaptcha-notification-title {
margin: 7px 0;
padding: 2px;
line-height: 1.3;
font-weight: 600;
}

.hcaptcha-notification {
display: none;
}

#hcaptcha-notifications-header + .hcaptcha-notification {
display: block;
}

#hcaptcha-navigation {
display: flex;
justify-content: flex-end;
column-gap: 3px;
}

#hcaptcha-navigation a {
width: 30px;
height: 30px;
border: 1px solid #2271b1;
border-radius: 3px;
background: #f6f7f7;
font-size: 16px;
line-height: 25px;
text-align: center;
cursor: pointer;
box-sizing: border-box;
}

#hcaptcha-navigation a.disabled {
color: #a7aaad;
border-color: #dcdcde;
background: #f6f7f7;
cursor: default;
}

#hcaptcha-navigation a.prev::after,
#hcaptcha-navigation a.next::after {
font-size: 12px;
}

#hcaptcha-navigation a.prev::after {
content: '<'
}

#hcaptcha-navigation a.next::after {
content: '>';
}
Loading

0 comments on commit 3bef4f8

Please sign in to comment.