Skip to content

Commit 2c6b533

Browse files
authored
Merge pull request #723 from equalizedigital/release/1.15.1
Release v1.15.1
2 parents c816e66 + 947e5d1 commit 2c6b533

6 files changed

Lines changed: 143 additions & 30 deletions

File tree

accessibility-checker.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Plugin Name: Accessibility Checker
1111
* Plugin URI: https://a11ychecker.com
1212
* Description: Audit and check your website for accessibility before you hit publish. In-post accessibility scanner and guidance.
13-
* Version: 1.15.0
13+
* Version: 1.15.1
1414
* Author: Equalize Digital
1515
* Author URI: https://equalizedigital.com
1616
* License: GPL-2.0+
@@ -35,7 +35,7 @@
3535

3636
// Current plugin version.
3737
if ( ! defined( 'EDAC_VERSION' ) ) {
38-
define( 'EDAC_VERSION', '1.15.0' );
38+
define( 'EDAC_VERSION', '1.15.1' );
3939
}
4040

4141
// Current database version.

admin/class-enqueue-admin.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public static function enqueue_styles() {
4747
*/
4848
public static function maybe_enqueue_admin_and_editor_app_scripts() {
4949

50-
5150
global $pagenow;
5251
$post_types = get_option( 'edac_post_types' );
5352
$current_post_type = get_post_type();
@@ -75,7 +74,6 @@ public static function maybe_enqueue_admin_and_editor_app_scripts() {
7574
$post_id = is_object( $post ) ? $post->ID : null;
7675
wp_enqueue_script( 'edac', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/admin.bundle.js', [ 'jquery' ], EDAC_VERSION, false );
7776

78-
7977
wp_localize_script(
8078
'edac',
8179
'edac_script_vars',
@@ -87,9 +85,7 @@ public static function maybe_enqueue_admin_and_editor_app_scripts() {
8785
]
8886
);
8987

90-
91-
if ( 'post.php' === $pagenow ) {
92-
88+
if ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) {
9389

9490
// Is this posttype setup to be checked?
9591
$post_types = get_option( 'edac_post_types' );
@@ -99,7 +95,7 @@ public static function maybe_enqueue_admin_and_editor_app_scripts() {
9995
$pro = is_plugin_active( 'accessibility-checker-pro/accessibility-checker-pro.php' ) && EDAC_KEY_VALID;
10096

10197
if ( EDAC_DEBUG || strpos( EDAC_VERSION, '-beta' ) !== false ) {
102-
$debug = true;
98+
$debug = true; // @codeCoverageIgnore
10399
} else {
104100
$debug = false;
105101
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "accessibility-checker",
3-
"version": "1.15.0",
3+
"version": "1.15.1",
44
"description": "Audit and check your website for accessibility before you hit publish. In-post accessibility scanner and guidance.",
55
"author": "Equalize Digital",
66
"license": "GPL-2.0+",

readme.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Contributors: equalizedigital, alh0319, stevejonesdev
33
Tags: accessibility, accessible, wcag, ada, WP accessibility
44
Requires at least: 6.2
5-
Tested up to: 6.6.0
6-
Stable tag: 1.15.0
5+
Tested up to: 6.6.1
6+
Stable tag: 1.15.1
77
License: GPLv2 or later
88
License URI: http://www.gnu.org/licenses/gpl-2.0.html
99

@@ -171,6 +171,10 @@ No, Accessibility Checker runs completely on your server and does not require yo
171171

172172
== Changelog ==
173173

174+
= 1.15.1 =
175+
* Fixed: Issue where a modal could result in JS error preventing display
176+
* Fixed: Situations where Gutenberg created new posts may not trigger the JS scan when publishing
177+
174178
= 1.15.0 =
175179
* Added: WP-CLI commands to get stats and delete stats
176180
* Enhancement: Image inputs with alt text shouldn't flag for missing_form_label

src/emailOptIn/modal.js

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,39 @@ export const initOptInModal = () => {
1515
window.onload = function() {
1616
tb_show( 'Accessibility Checker', '#TB_inline?width=600&inlineId=edac-opt-in-modal', null );
1717

18-
// a small delay is needed to ensure the modal is fully loaded before creating a focus trap.
19-
setTimeout(
20-
function() {
21-
const modal = document.getElementById( 'TB_window' );
22-
modal.querySelector( '.tb-close-icon' )
23-
.setAttribute( 'aria-hidden', 'true' );
24-
25-
const focusTrap = createFocusTrap( modal );
26-
focusTrap.activate();
27-
28-
jQuery( document ).one(
29-
'tb_unload',
30-
function() {
31-
onModalClose( focusTrap );
32-
}
33-
);
34-
},
35-
200
36-
);
18+
// create a loop that will wait to find the close button before trying to bind the focus trap
19+
let attempts = 0;
20+
const intervalId = setInterval( () => {
21+
if ( bindFocusTrap() || attempts >= 10 ) {
22+
clearInterval( intervalId );
23+
}
24+
attempts++;
25+
}, 250 );
3726
};
3827
};
3928

29+
const bindFocusTrap = () => {
30+
const modal = document.getElementById( 'TB_window' );
31+
const closeIcon = modal?.querySelector( '.tb-close-icon' );
32+
if ( ! modal || ! closeIcon ) {
33+
return false;
34+
}
35+
36+
closeIcon.setAttribute( 'aria-hidden', 'true' );
37+
38+
const focusTrap = createFocusTrap( modal );
39+
focusTrap.activate();
40+
41+
jQuery( document ).one(
42+
'tb_unload',
43+
function() {
44+
onModalClose( focusTrap );
45+
}
46+
);
47+
48+
return true;
49+
};
50+
4051
const onModalClose = ( focusTrap ) => {
4152
focusTrap.deactivate();
4253

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?php
2+
/**
3+
* Test cases for the Enqueue_Admin class.
4+
*
5+
* @package accessibility-checker
6+
*/
7+
8+
use EDAC\Admin\Enqueue_Admin;
9+
10+
/**
11+
* Tests for functionality of the Enqueue_Admin class.
12+
*/
13+
class EnqueueAdminTest extends WP_UnitTestCase {
14+
15+
/**
16+
* Holds the instance of the Enqueue_Admin class.
17+
*
18+
* @var Enqueue_Admin the instance of the Enqueue_Admin class.
19+
*/
20+
private $enqueue_admin;
21+
22+
/**
23+
* Setup the option, global wp_scripts and the Enqueue_Admin instance.
24+
*
25+
* @return void
26+
*/
27+
protected function setUp(): void {
28+
parent::setUp();
29+
30+
update_option( 'edac_post_types', [ 'post', 'page' ] );
31+
32+
global $wp_scripts;
33+
$wp_scripts = new \WP_Scripts();
34+
35+
$this->enqueue_admin = new Enqueue_Admin();
36+
}
37+
38+
/**
39+
* Clean up the option, global wp_scripts and the Enqueue_Admin instance.
40+
*
41+
* @return void
42+
*/
43+
protected function tearDown(): void {
44+
parent::tearDown();
45+
46+
delete_option( 'edac_post_types' );
47+
48+
global $wp_scripts;
49+
unset( $wp_scripts );
50+
51+
unset( $this->enqueue_admin );
52+
}
53+
54+
/**
55+
* Test that the base script is enqueued in the admin on non-editor pages.
56+
*
57+
* @return void
58+
*/
59+
public function testEnqueueBaseScriptInAdminNonEditorPage() {
60+
$this->enqueue_admin::maybe_enqueue_admin_and_editor_app_scripts();
61+
62+
$this->assertTrue( wp_script_is( 'edac', 'enqueued' ) );
63+
$this->assertFalse( wp_script_is( 'edac-editor-app', 'enqueued' ) );
64+
}
65+
66+
/**
67+
* Test that the base script and editor script is enqueued in the editor for an existing page.
68+
*
69+
* @return void
70+
*/
71+
public function testEnqueueBaseAndEditorScriptsInAdminEditorExisting() {
72+
73+
global $post;
74+
$post = $this->factory()->post->create_and_get();
75+
76+
global $pagenow;
77+
$pagenow = 'post.php';
78+
79+
$this->enqueue_admin::maybe_enqueue_admin_and_editor_app_scripts();
80+
81+
$this->assertTrue( wp_script_is( 'edac', 'enqueued' ) );
82+
$this->assertTrue( wp_script_is( 'edac-editor-app', 'enqueued' ) );
83+
}
84+
85+
/**
86+
* Test that the base script and editor script is enqueued in the editor for a new page.
87+
*
88+
* @return void
89+
*/
90+
public function testEnqueueBaseAndEditorScriptsInAdminEditorNew() {
91+
global $post;
92+
$post = $this->factory()->post->create_and_get();
93+
94+
global $pagenow;
95+
$pagenow = 'post-new.php';
96+
97+
$this->enqueue_admin::maybe_enqueue_admin_and_editor_app_scripts();
98+
99+
$this->assertTrue( wp_script_is( 'edac', 'enqueued' ) );
100+
$this->assertTrue( wp_script_is( 'edac-editor-app', 'enqueued' ) );
101+
}
102+
}

0 commit comments

Comments
 (0)