From 15aff334bc5eefa0ed3d71d5171c7059aba0cd58 Mon Sep 17 00:00:00 2001 From: matt Date: Thu, 21 Sep 2023 16:27:27 -0500 Subject: [PATCH 1/4] Fixes #216 --- includes/enqueue-scripts.php | 37 ++++++++++++++++++------------------ src/app/index.js | 19 ++++++++++++++++++ 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/includes/enqueue-scripts.php b/includes/enqueue-scripts.php index 6045667a..3ae06ba0 100644 --- a/includes/enqueue-scripts.php +++ b/includes/enqueue-scripts.php @@ -38,10 +38,10 @@ function edac_admin_enqueue_scripts() { 'edac', 'edac_script_vars', array( - 'postID' => $post_id, - 'nonce' => wp_create_nonce( 'ajax-nonce' ), + 'postID' => $post_id, + 'nonce' => wp_create_nonce( 'ajax-nonce' ), 'edacApiUrl' => esc_url_raw( rest_url() . 'accessibility-checker/v1' ), - 'restNonce' => wp_create_nonce( 'wp_rest' ) + 'restNonce' => wp_create_nonce( 'wp_rest' ), ) ); @@ -61,7 +61,6 @@ function edac_admin_enqueue_scripts() { } } - } @@ -80,12 +79,12 @@ function edac_enqueue_scripts( $mode = '' ) { return; } - $pro = edac_check_plugin_active( 'accessibility-checker-pro/accessibility-checker-pro.php' ) && EDAC_KEY_VALID === true; + $pro = edac_check_plugin_active( 'accessibility-checker-pro/accessibility-checker-pro.php' ) && EDAC_KEY_VALID === true; $has_pending_scans = false; $headers = array( 'Content-Type' => 'application/json', - 'X-WP-Nonce' => wp_create_nonce( 'wp_rest' ), + 'X-WP-Nonce' => wp_create_nonce( 'wp_rest' ), ); if ( '' === $mode ) { @@ -100,7 +99,7 @@ function edac_enqueue_scripts( $mode = '' ) { if ( ( 'full-scan' === $mode && $pro ) || ( 'ui' === $mode || 'editor-scan' === $mode - && + && $post_id && current_user_can( 'edit_post', $post_id ) ) ) { @@ -143,26 +142,26 @@ function edac_enqueue_scripts( $mode = '' ) { 'edac-app', 'edac_script_vars', array( - 'postID' => $post_id, - 'nonce' => wp_create_nonce( 'ajax-nonce' ), - 'edacUrl' => esc_url_raw( get_site_url() ), - 'edacApiUrl' => esc_url_raw( rest_url() . 'accessibility-checker/v1' ), + 'postID' => $post_id, + 'nonce' => wp_create_nonce( 'ajax-nonce' ), + 'edacUrl' => esc_url_raw( get_site_url() ), + 'edacApiUrl' => esc_url_raw( rest_url() . 'accessibility-checker/v1' ), 'edacHeaders' => $headers, - 'edacpApiUrl' => $pro ? esc_url_raw( rest_url() . 'accessibility-checker-pro/v1' ) : '', - 'ajaxurl' => admin_url( 'admin-ajax.php' ), - 'loggedIn' => is_user_logged_in(), - 'active' => $active, - 'mode' => $mode, - 'scanUrl' => get_preview_post_link( + 'edacpApiUrl' => $pro ? esc_url_raw( rest_url() . 'accessibility-checker-pro/v1' ) : '', + 'ajaxurl' => admin_url( 'admin-ajax.php' ), + 'loggedIn' => is_user_logged_in(), + 'active' => $active, + 'mode' => $mode, + 'scanUrl' => get_preview_post_link( $post_id, array( - 'edac-action' => 'js-scan', + 'edac-action' => 'js-scan', 'edac-preview-nonce' => wp_create_nonce( 'edac-preview_nonce' ), ) ), + 'appCssUrl' => plugin_dir_url( __DIR__ ) . 'build/css/app.css?ver=' . EDAC_VERSION, ) ); } - } diff --git a/src/app/index.js b/src/app/index.js index 24e20460..a013ef9d 100644 --- a/src/app/index.js +++ b/src/app/index.js @@ -699,6 +699,25 @@ class AccessibilityCheckerHighlight { * This function disables all styles on the page. */ disableStyles() { + + /* + If the site compiles css into a combined file, our method for disabling styles will cause out app's css to break. + This checks if the app's css is loading into #edac-app-css as expected. + If not, then we assume the css has been combined, so we manually add it to the document. + */ + if( ! document.querySelector('#edac-app-css') ){ + debug('css is combined, so adding app.css to page.'); + + var link = document.createElement('link'); + link.rel = 'stylesheet'; + link.id = 'edac-app-css'; + link.type = 'text/css'; + link.href = edac_script_vars.appCssUrl, + link.media = 'all'; + document.head.appendChild(link); + } + + this.originalCss = Array.from(document.head.querySelectorAll('style[type="text/css"], style, link[rel="stylesheet"]')); var elementsWithStyle = document.querySelectorAll('*[style]:not([class^="edac"])'); From 91f4b06078d035bc6de13aa8faec7b72c353279e Mon Sep 17 00:00:00 2001 From: matt Date: Fri, 22 Sep 2023 09:50:12 -0500 Subject: [PATCH 2/4] Fixes #321 --- includes/classes/class-scans-stats.php | 35 +++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/includes/classes/class-scans-stats.php b/includes/classes/class-scans-stats.php index f8d53a9d..61777890 100644 --- a/includes/classes/class-scans-stats.php +++ b/includes/classes/class-scans-stats.php @@ -122,7 +122,10 @@ public function summary() { $transient_name = $this->cache_name_prefix . '_summary'; $cache = get_transient( $transient_name ); - + + // TODO: + $cache = false; + if ( $this->cache_time && $cache ) { @@ -166,11 +169,35 @@ public function summary() { $data['is_truncated'] = $issues_query->has_truncated_results(); $data['posts_scanned'] = (int) $issues_query->distinct_posts_count(); - $data['rules_failed'] = (int) $issues_query->distinct_count(); - $data['rules_passed'] = (int) ( $tests_count - $data['rules_failed'] ); + $data['rules_failed'] = 0; + + + + // Get a count of rules that are not in the issues table. + $rule_slugs = array_map( + function ( $item ) { + return $item['slug']; + }, + edac_register_rules() + ); + + foreach ( $rule_slugs as $rule_slug ) { + $rule_query = new \EDAC\Issues_Query( + array( + 'rule_slugs' => array( $rule_slug ), + ), + 1, + Issues_Query::FLAG_INCLUDE_ALL_POST_TYPES + ); + + if ( $rule_query->count() ) { + ++$data['rules_failed']; + } + } + $data['rules_passed'] = $this->rule_count - $data['rules_failed']; if ( $data['posts_scanned'] > 0 && $tests_count > 0 ) { - $data['passed_percentage'] = round( ( $data['rules_passed'] / $tests_count ) * 100, 2 ); + $data['passed_percentage'] = round( ( $data['rules_passed'] / $this->rule_count ) * 100, 2 ); } else { $data['passed_percentage'] = 0; } From 35ede81844871ebb13a5a7e4e7f91fb87f9936b1 Mon Sep 17 00:00:00 2001 From: matt Date: Fri, 22 Sep 2023 09:52:51 -0500 Subject: [PATCH 3/4] Update - re-enabled cache that was disabled for testing --- includes/classes/class-scans-stats.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/includes/classes/class-scans-stats.php b/includes/classes/class-scans-stats.php index 61777890..c010a380 100644 --- a/includes/classes/class-scans-stats.php +++ b/includes/classes/class-scans-stats.php @@ -123,9 +123,6 @@ public function summary() { $cache = get_transient( $transient_name ); - // TODO: - $cache = false; - if ( $this->cache_time && $cache ) { From e9ab84d6fe34f4ca2b6197ee0341e3a5e8f4cec2 Mon Sep 17 00:00:00 2001 From: Steve Jones Date: Thu, 28 Sep 2023 13:15:10 -0400 Subject: [PATCH 4/4] updated - version and readme --- README.txt | 10 +++++++++- accessibility-checker.php | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.txt b/README.txt index b3775d63..0d3b2401 100644 --- a/README.txt +++ b/README.txt @@ -3,7 +3,7 @@ Contributors: equalizedigital, alh0319, stevejonesdev Tags: accessibility, accessible, wcag, ada, WP accessibility, section 508, aoda, a11y, audit, readability, content analysis Requires at least: 5.0.0 Tested up to: 6.3.1 -Stable tag: 1.6.0 +Stable tag: 1.6.1 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -171,6 +171,14 @@ No, Accessibility Checker runs completely on your server and does not require yo == Changelog == += 1.6.1 = +Updated: passed percentage calculation +Updated: frontend highlighting disable styles to be compatible with optimization plugins +Fixed: average issue density percentage not accounting for site ID and ignores +Updated: body density to receive HTML rather than the dom object +Updated: empty link check logic +Added: minor coding standards improvements + = 1.6.0 = Added: dashboard reports widget Added: frontend highlighting page scan trigger diff --git a/accessibility-checker.php b/accessibility-checker.php index 1f9346cd..bc11cf90 100644 --- a/accessibility-checker.php +++ b/accessibility-checker.php @@ -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.6.0 + * Version: 1.6.1 * Author: Equalize Digital * Author URI: https://equalizedigital.com * License: GPL-2.0+ @@ -38,7 +38,7 @@ // Current plugin version. if ( ! defined( 'EDAC_VERSION' ) ) { - define( 'EDAC_VERSION', '1.6.0' ); + define( 'EDAC_VERSION', '1.6.1' ); } // Current database version.