Skip to content

Commit

Permalink
Merge pull request #680 from equalizedigital/release/1.14.0
Browse files Browse the repository at this point in the history
Release v1.14.0
  • Loading branch information
pattonwebz authored Jun 25, 2024
2 parents 20c4eff + d918497 commit 25f8c7a
Show file tree
Hide file tree
Showing 20 changed files with 487 additions and 223 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.13.1
* Version: 1.14.0
* 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.13.1' );
define( 'EDAC_VERSION', '1.14.0' );
}

// Current database version.
Expand Down
9 changes: 9 additions & 0 deletions admin/class-admin-notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ public function edac_remove_admin_notices() {
'accessibility-checker_page_accessibility_checker_settings',
];

/**
* Filter the screens where admin notices should be removed.
*
* @since 1.14.0
*
* @param array $screens The screens where admin notices should be removed.
*/
$screens = apply_filters( 'edac_filter_remove_admin_notices_screens', $screens );

if ( in_array( $current_screen->id, $screens, true ) ) {
remove_all_actions( 'admin_notices' );
remove_all_actions( 'all_admin_notices' );
Expand Down
126 changes: 74 additions & 52 deletions admin/class-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,54 +100,56 @@ public function summary() {
}
}

$html['content'] .= '<div class="edac-summary-total">';

$html['content'] .= '<div class="edac-summary-total-progress-circle ' . ( ( $summary['passed_tests'] > 50 ) ? ' over50' : '' ) . '">
<div class="edac-summary-total-progress-circle-label">
<div class="edac-panel-number">' . $summary['passed_tests'] . '%</div>
<div class="edac-panel-number-label">Passed Tests<sup>*</sup></div>
</div>
<div class="left-half-clipper">
<div class="first50-bar"></div>
<div class="value-bar" style="transform: rotate(' . $summary['passed_tests'] * 3.6 . 'deg);"></div>
</div>
</div>';

$html['content'] .= '<div class="edac-summary-total-mobile">
<div class="edac-panel-number">' . $summary['passed_tests'] . '%</div>
<div class="edac-panel-number-label">Passed Tests<sup>*</sup></div>
<div class="edac-summary-total-mobile-bar"><span style="width:' . ( $summary['passed_tests'] ) . '%;"></span></div>
</div>';

$html['content'] .= '</div>';

$html['content'] .= '
<div class="edac-summary-stats">
<div class="edac-summary-stat edac-summary-errors' . ( ( $summary['errors'] > 0 ) ? ' has-errors' : '' ) . '">
<div class="edac-panel-number">
' . $summary['errors'] . '
</div>
<div class="edac-panel-number-label">Error' . ( ( 1 !== $summary['errors'] ) ? 's' : '' ) . '</div>
</div>
<div class="edac-summary-stat edac-summary-contrast' . ( ( $summary['contrast_errors'] > 0 ) ? ' has-errors' : '' ) . '">
<div class="edac-panel-number">
' . $summary['contrast_errors'] . '
</div>
<div class="edac-panel-number-label">Contrast Error' . ( ( 1 !== $summary['contrast_errors'] ) ? 's' : '' ) . '</div>
</div>
<div class="edac-summary-stat edac-summary-warnings' . ( ( $summary['warnings'] > 0 ) ? ' has-warning' : '' ) . '">
<div class="edac-panel-number">
' . $summary['warnings'] . '
</div>
<div class="edac-panel-number-label">Warning' . ( ( 1 !== $summary['warnings'] ) ? 's' : '' ) . '</div>
</div>
<div class="edac-summary-stat edac-summary-ignored">
<div class="edac-panel-number">
' . $summary['ignored'] . '
</div>
<div class="edac-panel-number-label">Ignored Item' . ( ( 1 !== $summary['ignored'] ) ? 's' : '' ) . '</div>
</div>
</div>
$html['content'] .= '<ul class="edac-summary-grid">';

$html['content'] .= '<li class="edac-summary-total" aria-label="' . $summary['passed_tests'] . '% Passed Tests">';

$html['content'] .= '<div class="edac-summary-total-progress-circle ' . ( ( $summary['passed_tests'] > 50 ) ? ' over50' : '' ) . '">
<div class="edac-summary-total-progress-circle-label">
<div class="edac-panel-number">' . $summary['passed_tests'] . '%</div>
<div class="edac-panel-number-label">Passed Tests<sup><a href="#edac-summary-disclaimer" aria-label="About passed tests.">*</a></sup></div>
</div>
<div class="left-half-clipper">
<div class="first50-bar"></div>
<div class="value-bar" style="transform: rotate(' . $summary['passed_tests'] * 3.6 . 'deg);"></div>
</div>
</div>';

$html['content'] .= '<div class="edac-summary-total-mobile">
<div class="edac-panel-number">' . $summary['passed_tests'] . '%</div>
<div class="edac-panel-number-label">Passed Tests<sup><a href="#edac-summary-disclaimer" aria-label="About passed tests.">*</a></sup></div>
<div class="edac-summary-total-mobile-bar"><span style="width:' . ( $summary['passed_tests'] ) . '%;"></span></div>
</div>';

$html['content'] .= '</li>';

$html['content'] .= '
' . edac_generate_summary_stat(
'edac-summary-errors',
$summary['errors'],
/* translators: %s: Number of errors */
sprintf( _n( '%s Error', '%s Errors', $summary['errors'], 'accessibility-checker' ), $summary['errors'] )
) . '
' . edac_generate_summary_stat(
'edac-summary-contrast',
$summary['contrast_errors'],
/* translators: %s: Number of contrast errors */
sprintf( _n( '%s Contrast Error', '%s Contrast Errors', $summary['contrast_errors'], 'accessibility-checker' ), $summary['contrast_errors'] )
) . '
' . edac_generate_summary_stat(
'edac-summary-warnings',
$summary['warnings'],
/* translators: %s: Number of warnings */
sprintf( _n( '%s Warning', '%s Warnings', $summary['warnings'], 'accessibility-checker' ), $summary['warnings'] )
) . '
' . edac_generate_summary_stat(
'edac-summary-ignored',
$summary['ignored'],
/* translators: %s: Number of ignored items */
sprintf( _n( '%s Ignored Item', '%s Ignored Items', $summary['ignored'], 'accessibility-checker' ), $summary['ignored'] )
) . '
</ul>
<div class="edac-summary-readability">
<div class="edac-summary-readability-level">
<div><img src="' . EDAC_PLUGIN_URL . 'assets/images/readability icon navy.png" alt="" width="54"></div>
Expand All @@ -161,7 +163,7 @@ public function summary() {
<div class="edac-summary-readability-summary-text' . ( ( ( 'none' === $simplified_summary_prompt || $summary['simplified_summary'] || (int) $summary['content_grade'] <= 9 ) && ! $simplified_summary_grade_failed ) ? ' active' : '' ) . '">' . $simplified_summary_text . '</div>
</div>
</div>
<div class="edac-summary-disclaimer"><small>* True accessibility requires manual testing in addition to automated scans. <a href="https://a11ychecker.com/help4280">Learn how to manually test for accessibility</a>.</small></div>
<div id="edac-summary-disclaimer" class="edac-summary-disclaimer"><small>* True accessibility requires manual testing in addition to automated scans. <a href="https://a11ychecker.com/help4280">Learn how to manually test for accessibility</a>.</small></div>
';

if ( ! $html ) {
Expand Down Expand Up @@ -425,7 +427,9 @@ function ( $a, $b ) {
get_the_permalink( $postid )
);

$html .= '<a href="' . $url . '" class="edac-details-rule-records-record-actions-highlight-front" target="_blank" aria-label="' . __( 'View, opens a new window', 'accessibility-checker' ) . '" ><span class="dashicons dashicons-welcome-view-site"></span>View on page</a>';
// Translators: %d is the issue ID.
$aria_label = sprintf( __( 'View Issue ID %d on website, opens a new window', 'accessibility-checker' ), $id );
$html .= '<a href="' . $url . '" class="edac-details-rule-records-record-actions-highlight-front" target="_blank" aria-label="' . esc_attr( $aria_label ) . '" ><span class="dashicons dashicons-welcome-view-site"></span>' . __( 'View on page', 'accessibility-checker' ) . '</a>';
}

$html .= '</div>';
Expand Down Expand Up @@ -661,9 +665,27 @@ function ( $value ) {
$ignre_comment = ( 'enable' === $action && isset( $_REQUEST['comment'] ) ) ? sanitize_textarea_field( $_REQUEST['comment'] ) : null;
$ignore_global = ( 'enable' === $action && isset( $_REQUEST['ignore_global'] ) ) ? sanitize_textarea_field( $_REQUEST['ignore_global'] ) : 0;

foreach ( $ids as $id ) {
// If largeBatch is set and 'true', we need to perform an update using the 'object'
// instead of IDs. It is a much less efficient query than by IDs - but many IDs run
// into request size limits which caused this to not function at all.
if ( isset( $_REQUEST['largeBatch'] ) && 'true' === $_REQUEST['largeBatch'] ) {
// Get the 'object' from the first id.
$first_id = $ids[0];
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- We need to get the latest value, not a cached value.
$object = $wpdb->get_var( $wpdb->prepare( 'SELECT object FROM %i WHERE id = %d', $table_name, $first_id ) );

if ( ! $object ) {
$error = new \WP_Error( '-2', 'No ignore data to return' );
wp_send_json_error( $error );
}
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Safe variable used for table name, caching not required for one time operation.
$wpdb->query( $wpdb->prepare( 'UPDATE %i SET ignre = %d, ignre_user = %d, ignre_date = %s, ignre_comment = %s, ignre_global = %d WHERE siteid = %d and id = %d', $table_name, $ignre, $ignre_user, $ignre_date, $ignre_comment, $ignore_global, $siteid, $id ) );
$wpdb->query( $wpdb->prepare( 'UPDATE %i SET ignre = %d, ignre_user = %d, ignre_date = %s, ignre_comment = %s, ignre_global = %d WHERE siteid = %d and object = %s', $table_name, $ignre, $ignre_user, $ignre_date, $ignre_comment, $ignore_global, $siteid, $object ) );
} else {
// For small batches of IDs, we can just loop through.
foreach ( $ids as $id ) {
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Safe variable used for table name, caching not required for one time operation.
$wpdb->query( $wpdb->prepare( 'UPDATE %i SET ignre = %d, ignre_user = %d, ignre_date = %s, ignre_comment = %s, ignre_global = %d WHERE siteid = %d and object = %d', $table_name, $ignre, $ignre_user, $ignre_date, $ignre_comment, $ignore_global, $siteid, $id ) );
}
}

$data = [
Expand Down
17 changes: 17 additions & 0 deletions admin/class-frontend-highlight.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,23 @@ public function __construct() {
*/
public function init_hooks() {
add_action( 'wp_ajax_edac_frontend_highlight_ajax', [ $this, 'ajax' ] );

/**
* Filter the visibility of the frontend highlighter.
*
* 'edac_filter_frontend_highlighter_visibility' is a filter that can be used
* to allow users without edit permissions on the post to see the frontend
* highlighter. You can use the filter to perform additional permission checks
* on who can see it.
*
* @since 1.14.0
*
* @param bool $visibility The visibility of the frontend highlighter. Default is false, return true to show the frontend highlighter.
*/
if ( apply_filters( 'edac_filter_frontend_highlighter_visibility', false ) ) {
// A nopriv endpoint allows logged-out users to access the endpoint.
add_action( 'wp_ajax_nopriv_edac_frontend_highlight_ajax', [ $this, 'ajax' ] );
}
}

/**
Expand Down
22 changes: 19 additions & 3 deletions admin/class-scans-stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace EDAC\Admin;

use EqualizeDigital\AccessibilityCheckerPro\Admin\Scans;

/**
* Class that handles calculating scans stats
*/
Expand Down Expand Up @@ -176,7 +178,7 @@ function ( $item ) {

if ( $rule_query->count() ) {
++$data['rules_failed'];
}
}
}
$data['rules_passed'] = $this->rule_count - $data['rules_failed'];

Expand Down Expand Up @@ -231,7 +233,7 @@ function ( $item ) {
$data['posts_without_issues'] = 0;
$data['avg_issues_per_post'] = 0;

if ( $data['posts_scanned'] > 0
if ( $data['posts_scanned'] > 0
&& ! empty( Settings::get_scannable_post_types() )
&& ! empty( Settings::get_scannable_post_statuses() )
) {
Expand Down Expand Up @@ -270,7 +272,20 @@ function ( $item ) {
$data['fullscan_state'] = '';
$data['fullscan_completed_at'] = 0;

if ( class_exists( '\EDACP\Scans' ) ) {
// For back compat reasons the old class_exists is kept and moved to an else block.
// After a few releases the else should be removed.
if ( class_exists( '\EqualizeDigital\AccessibilityCheckerPro\Admin\Scans' ) ) {
$scans = new Scans();
$scan_state = $scans->scan_state();

$data['fullscan_state'] = $scan_state;
if ( Scans::SCAN_STATE_PHP_SCAN_RUNNING === $scan_state
|| Scans::SCAN_STATE_JS_SCAN_RUNNING === $scan_state
) {
$data['fullscan_running'] = true;
}
$data['fullscan_completed_at'] = $scans->scan_date( 'php' );
} elseif ( class_exists( '\EDACP\Scans' ) ) {
$scans = new \EDACP\Scans();
$scan_state = $scans->scan_state();

Expand All @@ -281,6 +296,7 @@ function ( $item ) {
$data['fullscan_running'] = true;
}
$data['fullscan_completed_at'] = $scans->scan_date( 'php' );

}

$data['cache_id'] = $transient_name;
Expand Down
9 changes: 7 additions & 2 deletions admin/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ public static function get_scannable_post_statuses() {
*/
public static function get_scannable_post_types() {

if ( ! class_exists( '\EDACP\Settings' ) ) {
// Check if the new settings class exists. This is added to allow for backwards compatibility
// with the old settings class. The old settings class check should be removed after a few releases.
$new_settings_class_exists = class_exists( 'EqualizeDigital\AccessibilityCheckerPro\Admin\Settings' );
if ( ! class_exists( '\EDACP\Settings' ) || ! $new_settings_class_exists ) {

$post_types = Helpers::get_option_as_array( 'edac_post_types' );

Expand All @@ -53,7 +56,9 @@ public static function get_scannable_post_types() {
return $post_types;
}

return \EDACP\Settings::get_scannable_post_types();
return $new_settings_class_exists
? \EqualizeDigital\AccessibilityCheckerPro\Admin\Settings::get_scannable_post_types()
: \EDACP\Settings::get_scannable_post_types();
}


Expand Down
22 changes: 22 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
Newer versions can be found in readme.txt.

= 1.10.2 =
* Updated: Tested up to WP 6.5.0

= 1.10.1 =
* Fixed: Prevent scheme-relative URLs from causing an error when scanning for animated gif of webp files
* Fixed: Potential edge case where an issue density calculation could cause a PHP warning and cause a failed scan
* Fixed: Ensure that missing form labels are reported in the scan results appropriately
* Fixed: Avoid error log when trashing posts in the block editor
* Created: Class to handle the editor meta box for scan results
* Deprecated: `edac_register_meta_boxes`, `edac_custom_meta_box_cb` functions

= 1.10.0 =
* Updated: Improved aria-hidden scanning rule
* Fixed: Prevent missing_transcript rule from flagging on certain links
* Fixed: Prevent duplicate scan and ensure cleanup runs when post is trashed from the block editor
* Fixed: Fix case where error may be thrown resulting in password protection message and logged error when creating new posts
* Updated: Use local styles for notyf in frontend highlighter
* Created: Class to insert scan result rules to the database
* Deprecated: `edac_insert_rule_data` function
* Created: Class to handle data purging and cleanup
* Deprecated: `edac_delete_post`, `edac_delete_post_meta`, `edac_delete_cpt_posts` functions

= 1.9.3 =
* Updated: capability checks for the welcome page, dashboard widget, and admin notices

Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
"type": "vcs",
"url": "https://github.com/equalizedigital/accessibility-checker-wp-env"
},
{
"type": "vcs",
"url": "https://github.com/equalizedigital/textstatistics"
}
{
"type": "vcs",
"url": "https://github.com/equalizedigital/textstatistics"
}
],
"require-dev": {
"automattic/vipwpcs": "^3",
Expand Down Expand Up @@ -75,4 +75,4 @@
"@php ./vendor/phpunit/phpunit/phpunit --testdox"
]
}
}
}
Loading

0 comments on commit 25f8c7a

Please sign in to comment.