Skip to content

Commit

Permalink
Merge pull request #723 from equalizedigital/release/1.15.1
Browse files Browse the repository at this point in the history
Release v1.15.1
  • Loading branch information
pattonwebz authored Jul 31, 2024
2 parents c816e66 + 947e5d1 commit 2c6b533
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 30 deletions.
4 changes: 2 additions & 2 deletions accessibility-checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Plugin Name: Accessibility Checker
* Plugin URI: https://a11ychecker.com
* Description: Audit and check your website for accessibility before you hit publish. In-post accessibility scanner and guidance.
* Version: 1.15.0
* Version: 1.15.1
* Author: Equalize Digital
* Author URI: https://equalizedigital.com
* License: GPL-2.0+
Expand All @@ -35,7 +35,7 @@

// Current plugin version.
if ( ! defined( 'EDAC_VERSION' ) ) {
define( 'EDAC_VERSION', '1.15.0' );
define( 'EDAC_VERSION', '1.15.1' );
}

// Current database version.
Expand Down
8 changes: 2 additions & 6 deletions admin/class-enqueue-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public static function enqueue_styles() {
*/
public static function maybe_enqueue_admin_and_editor_app_scripts() {


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


wp_localize_script(
'edac',
'edac_script_vars',
Expand All @@ -87,9 +85,7 @@ public static function maybe_enqueue_admin_and_editor_app_scripts() {
]
);


if ( 'post.php' === $pagenow ) {

if ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) {

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

if ( EDAC_DEBUG || strpos( EDAC_VERSION, '-beta' ) !== false ) {
$debug = true;
$debug = true; // @codeCoverageIgnore
} else {
$debug = false;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "accessibility-checker",
"version": "1.15.0",
"version": "1.15.1",
"description": "Audit and check your website for accessibility before you hit publish. In-post accessibility scanner and guidance.",
"author": "Equalize Digital",
"license": "GPL-2.0+",
Expand Down
8 changes: 6 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Contributors: equalizedigital, alh0319, stevejonesdev
Tags: accessibility, accessible, wcag, ada, WP accessibility
Requires at least: 6.2
Tested up to: 6.6.0
Stable tag: 1.15.0
Tested up to: 6.6.1
Stable tag: 1.15.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

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

== Changelog ==

= 1.15.1 =
* Fixed: Issue where a modal could result in JS error preventing display
* Fixed: Situations where Gutenberg created new posts may not trigger the JS scan when publishing

= 1.15.0 =
* Added: WP-CLI commands to get stats and delete stats
* Enhancement: Image inputs with alt text shouldn't flag for missing_form_label
Expand Down
49 changes: 30 additions & 19 deletions src/emailOptIn/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,39 @@ export const initOptInModal = () => {
window.onload = function() {
tb_show( 'Accessibility Checker', '#TB_inline?width=600&inlineId=edac-opt-in-modal', null );

// a small delay is needed to ensure the modal is fully loaded before creating a focus trap.
setTimeout(
function() {
const modal = document.getElementById( 'TB_window' );
modal.querySelector( '.tb-close-icon' )
.setAttribute( 'aria-hidden', 'true' );

const focusTrap = createFocusTrap( modal );
focusTrap.activate();

jQuery( document ).one(
'tb_unload',
function() {
onModalClose( focusTrap );
}
);
},
200
);
// create a loop that will wait to find the close button before trying to bind the focus trap
let attempts = 0;
const intervalId = setInterval( () => {
if ( bindFocusTrap() || attempts >= 10 ) {
clearInterval( intervalId );
}
attempts++;
}, 250 );
};
};

const bindFocusTrap = () => {
const modal = document.getElementById( 'TB_window' );
const closeIcon = modal?.querySelector( '.tb-close-icon' );
if ( ! modal || ! closeIcon ) {
return false;
}

closeIcon.setAttribute( 'aria-hidden', 'true' );

const focusTrap = createFocusTrap( modal );
focusTrap.activate();

jQuery( document ).one(
'tb_unload',
function() {
onModalClose( focusTrap );
}
);

return true;
};

const onModalClose = ( focusTrap ) => {
focusTrap.deactivate();

Expand Down
102 changes: 102 additions & 0 deletions tests/phpunit/Admin/EnqueueAdminTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?php
/**
* Test cases for the Enqueue_Admin class.
*
* @package accessibility-checker
*/

use EDAC\Admin\Enqueue_Admin;

/**
* Tests for functionality of the Enqueue_Admin class.
*/
class EnqueueAdminTest extends WP_UnitTestCase {

/**
* Holds the instance of the Enqueue_Admin class.
*
* @var Enqueue_Admin the instance of the Enqueue_Admin class.
*/
private $enqueue_admin;

/**
* Setup the option, global wp_scripts and the Enqueue_Admin instance.
*
* @return void
*/
protected function setUp(): void {
parent::setUp();

update_option( 'edac_post_types', [ 'post', 'page' ] );

global $wp_scripts;
$wp_scripts = new \WP_Scripts();

$this->enqueue_admin = new Enqueue_Admin();
}

/**
* Clean up the option, global wp_scripts and the Enqueue_Admin instance.
*
* @return void
*/
protected function tearDown(): void {
parent::tearDown();

delete_option( 'edac_post_types' );

global $wp_scripts;
unset( $wp_scripts );

unset( $this->enqueue_admin );
}

/**
* Test that the base script is enqueued in the admin on non-editor pages.
*
* @return void
*/
public function testEnqueueBaseScriptInAdminNonEditorPage() {
$this->enqueue_admin::maybe_enqueue_admin_and_editor_app_scripts();

$this->assertTrue( wp_script_is( 'edac', 'enqueued' ) );
$this->assertFalse( wp_script_is( 'edac-editor-app', 'enqueued' ) );
}

/**
* Test that the base script and editor script is enqueued in the editor for an existing page.
*
* @return void
*/
public function testEnqueueBaseAndEditorScriptsInAdminEditorExisting() {

global $post;
$post = $this->factory()->post->create_and_get();

global $pagenow;
$pagenow = 'post.php';

$this->enqueue_admin::maybe_enqueue_admin_and_editor_app_scripts();

$this->assertTrue( wp_script_is( 'edac', 'enqueued' ) );
$this->assertTrue( wp_script_is( 'edac-editor-app', 'enqueued' ) );
}

/**
* Test that the base script and editor script is enqueued in the editor for a new page.
*
* @return void
*/
public function testEnqueueBaseAndEditorScriptsInAdminEditorNew() {
global $post;
$post = $this->factory()->post->create_and_get();

global $pagenow;
$pagenow = 'post-new.php';

$this->enqueue_admin::maybe_enqueue_admin_and_editor_app_scripts();

$this->assertTrue( wp_script_is( 'edac', 'enqueued' ) );
$this->assertTrue( wp_script_is( 'edac-editor-app', 'enqueued' ) );
}
}

0 comments on commit 2c6b533

Please sign in to comment.