Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
eb2dbb6
added: landmark and landmark location to database
SteveJonesDev Jun 24, 2025
906f46b
updated: test
SteveJonesDev Jun 24, 2025
5baaf70
added: support for conditional landmark tags and roles in landmark de…
SteveJonesDev Jul 2, 2025
fb4d1e7
added: include landmark data in AJAX response and updated layout for …
SteveJonesDev Jul 2, 2025
2fd3252
added: enhance landmark handling by including landmark selector and i…
SteveJonesDev Jul 2, 2025
4c02072
updated: to prevent variable hoisting
SteveJonesDev Jul 3, 2025
f21e8f3
added: escape CSS class names to prevent injection issues
SteveJonesDev Jul 3, 2025
80c0643
added: adjust scrolling behavior to include a 75px offset when naviga…
SteveJonesDev Jul 3, 2025
2f2ada3
added: set max-width and box-sizing for selected highlight elements
SteveJonesDev Jul 3, 2025
065b064
updated: add nullable type hints for landmark and landmark_selector p…
SteveJonesDev Jul 3, 2025
de8ca07
updated: use null coalescing operator for landmark and landmark_selec…
SteveJonesDev Jul 3, 2025
0510deb
updated: capitalize landmark names in aria labels and links for impro…
SteveJonesDev Jul 3, 2025
fed9312
updated: adjust z-index value for highlight tooltip to prevent overla…
SteveJonesDev Jul 3, 2025
bbd55f1
Merge branch 'develop' into steve/try/landmark-location
pattonwebz Jul 3, 2025
8a9e296
Merge branch 'steve/try/landmark-location' of https://github.com/equa…
SteveJonesDev Jul 3, 2025
205a64c
updated: revert database version to 1.0.4 in accessibility checker pl…
SteveJonesDev Jul 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion accessibility-checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

// Current database version.
if ( ! defined( 'EDAC_DB_VERSION' ) ) {
define( 'EDAC_DB_VERSION', '1.0.3' );
define( 'EDAC_DB_VERSION', '1.0.4' );
}

// Plugin Folder Path.
Expand Down
31 changes: 30 additions & 1 deletion admin/class-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ function ( $a, $b ) {

foreach ( $rules as $rule ) {
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Using direct query for interacting with custom database, safe variable used for table name, caching not required for one time operation.
$results = $wpdb->get_results( $wpdb->prepare( 'SELECT id, postid, object, ruletype, ignre, ignre_user, ignre_date, ignre_comment, ignre_global FROM %i where postid = %d and rule = %s and siteid = %d', $table_name, $postid, $rule['slug'], $siteid ), ARRAY_A );
$results = $wpdb->get_results( $wpdb->prepare( 'SELECT id, postid, object, ruletype, ignre, ignre_user, ignre_date, ignre_comment, ignre_global, landmark, landmark_selector FROM %i where postid = %d and rule = %s and siteid = %d', $table_name, $postid, $rule['slug'], $siteid ), ARRAY_A );
$count_classes = ( 'error' === $rule['rule_type'] ) ? ' edac-details-rule-count-error' : ' edac-details-rule-count-warning';
$count_classes .= ( 0 !== $rule['count'] ) ? ' active' : '';

Expand Down Expand Up @@ -406,6 +406,8 @@ function ( $a, $b ) {
$html .= ob_get_clean();
}



$html .=
'<div class="edac-details-rule-records-labels">
<div class="edac-details-rule-records-labels-label" aria-hidden="true">
Expand All @@ -414,6 +416,9 @@ function ( $a, $b ) {
<div class="edac-details-rule-records-labels-label" aria-hidden="true">
Image
</div>
<div class="edac-details-rule-records-labels-label" aria-hidden="true">
Landmark
</div>
<div class="edac-details-rule-records-labels-label" aria-hidden="true">
Actions
</div>
Expand Down Expand Up @@ -461,6 +466,30 @@ function ( $a, $b ) {

$html .= '</div>';

$html .= '<div class="edac-details-rule-records-record-cell edac-details-rule-records-record-landmark">';

$landmark = isset( $row['landmark'] ) ? esc_html( $row['landmark'] ) : '';
$landmark_selector = isset( $row['landmark_selector'] ) ? $row['landmark_selector'] : '';

if ( $landmark && $landmark_selector ) {
$landmark_url = add_query_arg(
[
'edac_landmark' => base64_encode( $landmark_selector ),
'edac_nonce' => wp_create_nonce( 'edac_highlight' ),
],
get_the_permalink( $postid )
);

// translators: %s is the landmark type (e.g., "Header", "Navigation", "Main").
$landmark_aria_label = sprintf( __( 'View %s landmark on website, opens a new window', 'accessibility-checker' ), ucwords( $landmark ) );
// translators: %s is the landmark type (e.g., "Header", "Navigation", "Main").
$html .= '<a href="' . $landmark_url . '" class="edac-details-rule-records-record-landmark-link" target="_blank" aria-label="' . esc_attr( $landmark_aria_label ) . '">' . ucwords( $landmark ) . '</a>';
} elseif ( $landmark ) {
$html .= ucwords( $landmark );
}

$html .= '</div>';

$html .= '<div class="edac-details-rule-records-record-cell edac-details-rule-records-record-actions">';

if ( ! isset( $rule['viewable'] ) || $rule['viewable'] ) {
Expand Down
68 changes: 37 additions & 31 deletions admin/class-insert-rule-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ class Insert_Rule_Data {
*
* @since 1.10.0
*
* @param object $post The post object. Must have a valid ID.
* @param string $rule The rule.
* @param string $ruletype The rule type.
* @param string $rule_obj The object.
* @param object $post The post object. Must have a valid ID.
* @param string $rule The rule.
* @param string $ruletype The rule type.
* @param string $rule_obj The object.
* @param string|null $landmark The landmark type (main, header, footer, nav), optional.
* @param string|null $landmark_selector The landmark selector, optional.
Comment on lines +28 to +29

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding scalar type hints to the $landmark and $landmark_selector parameters for better type safety and code clarity. Use ?string since they are nullable.

 * @param string|null $landmark The landmark type (main, header, footer, nav), optional.
 * @param string|null $landmark_selector The landmark selector, optional.

*
* @return void|int|\WP_Error The ID of the inserted record, void if no
* record was inserted or a WP_Error if the insert failed.
*/
public function insert( object $post, string $rule, string $ruletype, string $rule_obj ) {
public function insert( object $post, string $rule, string $ruletype, string $rule_obj, ?string $landmark = null, ?string $landmark_selector = null ) {

if ( ! isset( $post->ID, $post->post_type )
|| empty( $rule )
Expand All @@ -44,19 +46,21 @@ public function insert( object $post, string $rule, string $ruletype, string $ru

// set up rule data array.
$rule_data = [
'postid' => $post->ID,
'siteid' => get_current_blog_id(),
'type' => $post->post_type,
'rule' => $rule,
'ruletype' => $ruletype,
'object' => esc_attr( $rule_obj ),
'recordcheck' => 1,
'user' => get_current_user_id(),
'ignre' => 0,
'ignre_user' => null,
'ignre_date' => null,
'ignre_comment' => null,
'ignre_global' => 0,
'postid' => $post->ID,
'siteid' => get_current_blog_id(),
'type' => $post->post_type,
'landmark' => $landmark,
'landmark_selector' => $landmark_selector,
'rule' => $rule,
'ruletype' => $ruletype,
'object' => esc_attr( $rule_obj ),
'recordcheck' => 1,
'user' => get_current_user_id(),
'ignre' => 0,
'ignre_user' => null,
'ignre_date' => null,
'ignre_comment' => null,
'ignre_global' => 0,
];

// return if revision.
Expand Down Expand Up @@ -125,19 +129,21 @@ public function insert( object $post, string $rule, string $ruletype, string $ru
// the data is still as valid as it was when it was first set.
// Sanitize the filtered data.
$rule_data_sanitized = [
'postid' => absint( $rule_data['postid'] ),
'siteid' => absint( $rule_data['siteid'] ),
'type' => sanitize_text_field( $rule_data['type'] ),
'rule' => sanitize_text_field( $rule_data['rule'] ),
'ruletype' => sanitize_text_field( $rule_data['ruletype'] ),
'object' => esc_attr( $rule_data['object'] ),
'recordcheck' => absint( $rule_data['recordcheck'] ),
'user' => absint( $rule_data['user'] ),
'ignre' => absint( $rule_data['ignre'] ),
'ignre_user' => isset( $rule_data['ignre_user'] ) ? absint( $rule_data['ignre_user'] ) : null,
'ignre_date' => isset( $rule_data['ignre_date'] ) ? sanitize_text_field( $rule_data['ignre_date'] ) : null,
'ignre_comment' => isset( $rule_data['ignre_comment'] ) ? sanitize_text_field( $rule_data['ignre_comment'] ) : null,
'ignre_global' => absint( $rule_data['ignre_global'] ),
'postid' => absint( $rule_data['postid'] ),
'siteid' => absint( $rule_data['siteid'] ),
'type' => sanitize_text_field( $rule_data['type'] ),
'landmark' => isset( $rule_data['landmark'] ) ? sanitize_text_field( $rule_data['landmark'] ) : null,
'landmark_selector' => isset( $rule_data['landmark_selector'] ) ? sanitize_text_field( $rule_data['landmark_selector'] ) : null,
'rule' => sanitize_text_field( $rule_data['rule'] ),
'ruletype' => sanitize_text_field( $rule_data['ruletype'] ),
'object' => esc_attr( $rule_data['object'] ),
'recordcheck' => absint( $rule_data['recordcheck'] ),
'user' => absint( $rule_data['user'] ),
'ignre' => absint( $rule_data['ignre'] ),
'ignre_user' => isset( $rule_data['ignre_user'] ) ? absint( $rule_data['ignre_user'] ) : null,
'ignre_date' => isset( $rule_data['ignre_date'] ) ? sanitize_text_field( $rule_data['ignre_date'] ) : null,
'ignre_comment' => isset( $rule_data['ignre_comment'] ) ? sanitize_text_field( $rule_data['ignre_comment'] ) : null,
'ignre_global' => absint( $rule_data['ignre_global'] ),
];

// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Using direct query for adding data to database.
Expand Down
2 changes: 2 additions & 0 deletions admin/class-update-database.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public function edac_update_database() {
postid bigint(20) NOT NULL,
siteid text NOT NULL,
type text NOT NULL,
landmark varchar(20) NULL,
landmark_selector text NULL,
rule text NOT NULL,
ruletype text NOT NULL,
object mediumtext NOT NULL,
Expand Down
5 changes: 4 additions & 1 deletion includes/classes/class-rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,10 @@ public function set_post_scan_results( $request ) {
*/
do_action( 'edac_before_rule', $post_id, $actual_rule_id, 'js' );

( new Insert_Rule_Data() )->insert( $post, $actual_rule_id, $impact, $html );
$landmark = $violation['landmark'] ?? null;
$landmark_selector = $violation['landmarkSelector'] ?? null;

( new Insert_Rule_Data() )->insert( $post, $actual_rule_id, $impact, $html, $landmark, $landmark_selector );

/**
* Fires after a rule is run against the content.
Expand Down
4 changes: 2 additions & 2 deletions src/admin/sass/accessibility-checker-admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@
color: variables.$color-white;
background-color: variables.$color-dark-gray;
display: grid;
grid-template-columns: auto 125px 125px;
grid-template-columns: auto 125px 125px 125px;

&-label {
padding: 3px;
Expand All @@ -631,7 +631,7 @@

&-record {
display: grid;
grid-template-columns: auto 125px 125px;
grid-template-columns: auto 125px 125px 125px;

&-cell {
padding: 10px;
Expand Down
Loading