Skip to content

Commit

Permalink
Merge pull request #825 from equalizedigital/release/1.16.4
Browse files Browse the repository at this point in the history
Release/1.16.4
  • Loading branch information
pattonwebz authored Dec 5, 2024
2 parents 0c1949e + 8d1d438 commit f45d23f
Show file tree
Hide file tree
Showing 16 changed files with 2,991 additions and 1,868 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.16.3
* Version: 1.16.4
* 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.16.3' );
define( 'EDAC_VERSION', '1.16.4' );
}

// Current database version.
Expand Down
25 changes: 25 additions & 0 deletions admin/class-admin-notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace EDAC\Admin;

use EqualizeDigital\AccessibilityChecker\Fixes\FixesManager;

/**
* Class that handles admin notices
*/
Expand All @@ -27,6 +29,7 @@ public function init_hooks() {

add_action( 'in_admin_header', [ $this, 'edac_remove_admin_notices' ], 1000 );
add_action( 'init', [ $this, 'hook_notices' ] );
add_action( 'updated_option', [ $this, 'set_fixes_transient_on_save' ] );
}

/**
Expand Down Expand Up @@ -422,4 +425,26 @@ public function edac_password_protected_notice_ajax() {

wp_send_json_success( wp_json_encode( $results ) );
}

/**
* Save a transient to indicate that the fixes settings have been updated.
*
* @param string $option The option name that was saved.
*
* @return void
*/
public function set_fixes_transient_on_save( $option ) {
if ( ! class_exists( 'EqualizeDigital\AccessibilityChecker\Fixes\FixesManager' ) ) {
return;
}
$fixes_settings = FixesManager::get_instance()->get_fixes_settings();
$options_keys = [];
foreach ( $fixes_settings as $fix ) {
$options_keys = array_merge( $options_keys, array_keys( $fix['fields'] ) );
}
if ( in_array( $option, $options_keys, true ) ) {
// Set a custom transient as a flag.
set_transient( 'edac_fixes_settings_saved', true, 60 );
}
}
}
2 changes: 1 addition & 1 deletion admin/class-welcome-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static function render_summary() {
<?php esc_html_e( 'Update Counts', 'accessibility-checker' ); ?>
</button>

<a class="edac-ml-1 button" href="<?php echo esc_url( admin_url( 'admin.php?page=accessibility_checker_settings&tab=scan' ) ); ?>">
<a class="edac-ml-1 button" href="<?php echo esc_url( admin_url( 'admin.php?page=accessibility_checker_full_site_scan' ) ); ?>">
<?php esc_html_e( 'Start New Scan', 'accessibility-checker' ); ?>
</a>

Expand Down
2 changes: 1 addition & 1 deletion includes/classes/class-summary-generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private function count_warnings() {
global $wpdb;

$warnings_parameters = [ get_current_blog_id(), $this->post_id, 'warning', 0 ];
$warnings_where = 'WHERE siteid = siteid = %d and postid = %d and ruletype = %s and ignre = %d';
$warnings_where = 'WHERE siteid = %d and postid = %d and ruletype = %s and ignre = %d';
if ( EDAC_ANWW_ACTIVE ) {
array_push( $warnings_parameters, 'link_blank' );
$warnings_where .= ' and rule != %s';
Expand Down
41 changes: 26 additions & 15 deletions includes/rules/missing_table_header.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php // phpcs:ignore WordPress.Files.FileName.NotHyphenatedLowercase -- underscore is for valid function name.
/**
* Accessibility Checker pluign file.
* Accessibility Checker plugin file.
*
* @package Accessibility_Checker
*/
Expand All @@ -19,32 +19,43 @@ function edac_rule_missing_table_header( $content, $post ) { // phpcs:ignore --
$tables = $dom->find( 'table' );

if ( ! $tables ) {
return;
return $errors; // Return empty errors array if no tables are found.
}
foreach ( $tables as $table ) {

if ( ! edac_th_match_td( $table ) ) {
foreach ( $tables as $table ) {
// Check if the table has proper headers.
if ( ! edac_has_proper_headers( $table ) ) {
$errors[] = $table;
}
}

return $errors;
}

/**
* Check for TH TD matching
* Check if the table has proper headers
*
* @param obj $table Object to check.
* @return int
* @param object $table Object to check.
* @return bool
*/
function edac_th_match_td( $table ) {
$table_rows = $table->find( 'tr' );
$header_count = 0;
$max_rows = 0;
function edac_has_proper_headers( $table ) {
$table_rows = $table->find( 'tr' );
$has_headers = false;

foreach ( $table_rows as $table_row ) {
if ( 0 === $header_count ) {
$header_count = count( $table_row->find( 'th' ) );
// Check for row or column headers in the current row.
$headers = $table_row->find( 'th' );
foreach ( $headers as $header ) {
// Check if the header has a valid scope or contains text.
$scope = $header->getAttribute( 'scope' );
$text = trim( $header->plaintext );

if ( ! empty( $text ) && ( in_array( $scope, [ 'row', 'col', 'rowgroup', 'colgroup' ], true ) || empty( $scope ) ) ) {
$has_headers = true;
break 2; // Exit both loops as headers are valid.
}
}
$max_rows = max( $max_rows, count( $table_row->find( 'td' ) ) );
}
return $max_rows <= $header_count;

return $has_headers;
}
Loading

0 comments on commit f45d23f

Please sign in to comment.