Skip to content

Backport v1.30.1 - #1206

Merged
pattonwebz merged 17 commits into
developfrom
william/no-ticket/enhance-endpoint-checks
Aug 25, 2025
Merged

Backport v1.30.1#1206
pattonwebz merged 17 commits into
developfrom
william/no-ticket/enhance-endpoint-checks

Conversation

@pattonwebz

@pattonwebz pattonwebz commented Aug 22, 2025

Copy link
Copy Markdown
Member

Checklist

  • PR is linked to the main issue in the repo
  • Tests are added that cover changes

Summary by CodeRabbit

  • Bug Fixes

    • Frontend: Rescan and Clear buttons now appear only for users who can edit the post.
    • Admin: “Update Counts” button is shown only to users with publish permissions.
    • REST API: Stricter permission checks and required, sanitized post IDs on relevant endpoints.
    • Improved capability checks for saving and clearing issues.
  • Tests

    • Added REST API permission tests, including scenarios for managing one’s own posts.
  • Documentation

    • Updated changelog for 1.30.1.
  • Chores

    • Version bump to 1.30.1.

pattonwebz and others added 17 commits July 22, 2025 21:14
…ighter

This is used alongside the other logged in check to determine if we show a button to rescan or clear issues to a given user
This test verifies that a limited user can save scan results and clear issues for their own post.

[PRO-165]
Enhance the API by ensuring that the 'id' argument is required and properly sanitized.
Ensure consistent code style by aligning closing braces for validation callbacks in the REST API.
Added assertions to check for 'success', 'id', and 'flushed' keys in the API response data for various test cases.
Updated the plugin version in multiple files to reflect the new release and added improvements to the changelog.

[PRO-165]
Copilot AI review requested due to automatic review settings August 22, 2025 10:45
@coderabbitai

coderabbitai Bot commented Aug 22, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Version bump to 1.30.1 across plugin, package.json, and readme. Tightened permission checks in REST API with a new helper for per-post edit verification. Frontend enqueues and app now pass/use userCanEdit to gate Clear/Rescan buttons. Admin “Update Counts” button is capability-gated. New PHPUnit tests validate REST permissions.

Changes

Cohort / File(s) Summary
Version bump
accessibility-checker.php, package.json, readme.txt
Incremented version to 1.30.1; updated stable tag and changelog; no functional code changes beyond constant/string updates.
Admin UI gating
admin/class-welcome-page.php
“Update Counts” button rendered only for users with publish_posts.
Frontend enqueue data
includes/classes/class-enqueue-frontend.php
Localized data now includes userCanEdit using current_user_can( 'edit_post', $post_id ) for active post types.
REST API permissions refactor
includes/classes/class-rest-api.php
Added REST_Api::user_can_edit_passed_post_id( $request ); required/sanitized id for relevant POST routes; switched several routes to edit_posts/publish_posts; centralized per-post edit checks.
Frontend highlighter gating
src/frontendHighlighterApp/index.js
UI buttons (Clear/Rescan) render only when userCanEdit is true; container class logic updated accordingly.
Tests
tests/phpunit/includes/classes/RestApiEndpointsTest.php
New PHPUnit tests cover REST permissions for posting scan results, clearing issues, and limited users managing own posts.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Browser as Frontend Highlighter
  participant WP as WP Localize/Enqueue
  Note over WP: Compute userCanEdit = current_user_can('edit_post', post_id)
  WP->>Browser: edacFrontendHighlighterApp { loggedIn, userCanFix, userCanEdit }
  Browser->>Browser: userCanEdit = app.userCanEdit && app.loggedIn
  alt userCanEdit
    Browser->>User: Show "Clear Issues" & "Rescan This Page"
  else not userCanEdit
    Browser->>User: Hide action buttons
  end
Loading
sequenceDiagram
  autonumber
  actor Client
  participant REST as REST API
  participant Caps as WP Cap Check
  Client->>REST: POST /post-scan-results { id }
  REST->>REST: user_can_edit_passed_post_id(request)
  alt id missing/invalid
    REST-->>Client: 400/ WP_Error
  else id present
    REST->>Caps: current_user_can('edit_post', id)
    alt can edit
      REST-->>Client: 200 { success }
    else cannot edit
      REST-->>Client: 403
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

codex

Suggested reviewers

  • SteveJonesDev

Poem

A minor tick from zero to one, the dial turns neat,
Buttons hide from fools who can’t yet edit the beat.
REST stands guard, “Who goes there?” with might,
Only post editors pass through the light.
Tests salute—green flags in a row,
1.30.1 rolls on—tight ship, let’s go! 🚀

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch william/no-ticket/enhance-endpoint-checks

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copilot AI left a comment

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.

Pull Request Overview

This is a backport of version 1.30.1 that improves permission handling for the frontend highlighter and REST API endpoints. The key focus is ensuring that users can only perform actions on posts they have edit permissions for, replacing generic capability checks with more specific post-level permission validation.

  • Enhanced REST API permission callbacks to check edit capabilities for specific posts
  • Updated frontend highlighter to show rescan/clear buttons only when users can edit the post
  • Added comprehensive test coverage for the new permission model

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
accessibility-checker.php Version number update to 1.30.1
package.json Package version bump to match plugin version
readme.txt Changelog entry and stable tag update
includes/classes/class-rest-api.php Enhanced permission callbacks with post-specific capability checks
includes/classes/class-enqueue-frontend.php Added userCanEdit flag for frontend scripts
src/frontendHighlighterApp/index.js Updated UI logic to use userCanEdit instead of generic logged-in check
admin/class-welcome-page.php Added permission check for update counts button
tests/phpunit/includes/classes/RestApiEndpointsTest.php New comprehensive test suite for REST API permission handling

* REST handler to clear issues results for a given post ID.
*
* @param WP_REST_Request $request The request passed from the REST call.
* @param \WP_REST_Request $request The request passed from the REST call.

Copilot AI Aug 22, 2025

Copy link

Choose a reason for hiding this comment

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

The docblock parameter type should use the fully qualified class name \WP_REST_Request to match the pattern used elsewhere in the function (line 217 uses \WP_REST_Request).

Copilot uses AI. Check for mistakes.

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Summary of Changes

Hello @pattonwebz, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request backports version 1.30.1 of the Accessibility Checker plugin, primarily focusing on enhancing user permission checks for various features. It refines when certain actions, like updating scan counts or clearing issues, are available to users, ensuring that capabilities are robustly enforced across both the administrative interface and frontend functionalities, including REST API endpoints. This update improves security and user experience by preventing unauthorized actions and dynamically adjusting the UI based on user permissions.

Highlights

  • Version Update: The plugin version has been incremented to 1.30.1 across all relevant files, including the main plugin file, package.json, and readme.txt.
  • Enhanced Permission Checks: Implemented more granular capability checks for actions such as updating scan counts in the admin dashboard and displaying "Clear Issues" and "Rescan" buttons in the frontend highlighter, ensuring these actions are only available to users with appropriate permissions.
  • Robust REST API Security: Strengthened permission callbacks for several REST API endpoints related to accessibility scans, ensuring that actions like saving and clearing post scan results, and retrieving scan statistics, are properly restricted based on user capabilities. This includes the introduction of a new helper function for consistent post-specific edit permissions.
  • New PHPUnit Tests: Dedicated PHPUnit tests have been introduced to validate the correctness and security of the updated REST API endpoint permissions, covering various user roles and post ownership scenarios.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request is a backport for version 1.30.1, primarily focused on enhancing security by tightening permissions on several REST API endpoints and ensuring these permissions are reflected on the frontend. The introduction of unit tests for the REST API endpoints is a significant improvement that will help maintain code quality and stability. The changes are well-implemented and consistent across the codebase. I've included a couple of minor suggestions to improve code clarity and remove redundancy.

Comment on lines +221 to +227
public function user_can_edit_passed_post_id( $request ) {
if ( ! isset( $request['id'] ) ) {
return new \WP_Error( 'rest_post_invalid_id', __( 'A required parameter is missing.', 'accessibility-checker' ), [ 'status' => 400 ] );
}
$post_id = (int) $request['id'];
return current_user_can( 'edit_post', $post_id ); // able to edit the post.
}

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

The if ( ! isset( $request['id'] ) ) check is redundant. The REST API routes using this permission callback (/post-scan-results and /clear-issues) define the id parameter as required. WordPress's REST API automatically handles missing required parameters and returns an error before this callback is executed. Removing this check will make the code cleaner and rely on the framework's validation.

public function user_can_edit_passed_post_id( $request ) {
	$post_id = (int) $request['id'];
	return current_user_can( 'edit_post', $post_id ); // able to edit the post.
}

// Admin can POST results for the post.
wp_set_current_user( self::$admin_id );
$request = new WP_REST_Request( 'POST', '/accessibility-checker/v1/post-scan-results/' . self::$post_id );
$request->set_param( 'id', self::$post_id );

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

This set_param() call is redundant. The id parameter is already part of the URL provided to the WP_REST_Request constructor on the previous line. The WordPress REST Server will parse the ID from the route pattern (/post-scan-results/(?P<id>\d+)). Removing this line will make the test code cleaner. This applies to similar set_param('id', ...) calls in this test file (lines 131, 148, 165, 189, 208).

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🧹 Nitpick comments (6)
admin/class-welcome-page.php (1)

43-47: Good gate on “Update Counts”; also lock it down server-side.

Hiding the button unless the user can publish is the right move. Double-check that the AJAX/REST handler for clearing cached stats enforces the same capability so a direct call can’t bypass the UI.

If you want to make the capability adjustable without more code changes, you can filter it inline:

-							<?php if ( current_user_can( 'publish_posts' ) ) : ?>
+							<?php if ( current_user_can( apply_filters( 'edac_filter_welcome_update_counts_cap', 'publish_posts' ) ) ) : ?>

Follow-up:

  • Verify the corresponding endpoint/action checks current_user_can('publish_posts') (or the filtered cap).
  • If this button triggers admin-ajax, consider passing a nonce via a data attribute and validating it server-side.
readme.txt (1)

214-217: Changelog reads clearly; consider naming the exact caps for clarity.

Optional polish: mention the specific capabilities (edit_post for per-post actions, publish_posts for Update Counts) so site owners instantly know who sees what.

includes/classes/class-enqueue-frontend.php (1)

96-113: New userCanEdit flag is the right call; tighten a couple of edges.

  • Exposing userCanEdit keeps the frontend honest about who sees “Clear/Rescan.” Good.
  • When visibility is forced via the filter for non-editors, editorLink may be false. Guard it to avoid odd UI states.
  • Minor: cast postID to int before localizing.

Apply this small tweak:

 			wp_localize_script(
 				'edac-frontend-highlighter-app',
 				'edacFrontendHighlighterApp',
 				[
-					'postID'           => $post_id,
+					'postID'           => absint( $post_id ),
 					'nonce'            => wp_create_nonce( 'ajax-nonce' ),
 					'restNonce'        => wp_create_nonce( 'wp_rest' ),
 					'userCanFix'       => current_user_can( apply_filters( 'edac_filter_settings_capability', 'manage_options' ) ),
-					'userCanEdit'      => current_user_can( 'edit_post', $post_id ),
+					'userCanEdit'      => current_user_can( 'edit_post', $post_id ),
 					'edacUrl'          => esc_url_raw( get_site_url() ),
 					'ajaxurl'          => admin_url( 'admin-ajax.php' ),
 					'loggedIn'         => is_user_logged_in(),
 					'appCssUrl'        => EDAC_PLUGIN_URL . 'build/css/frontendHighlighterApp.css?ver=' . EDAC_VERSION,
-					'editorLink'       => get_edit_post_link( $post_id ),
+					'editorLink'       => current_user_can( 'edit_post', $post_id ) ? get_edit_post_link( $post_id ) : '',
 					'scannerBundleUrl' => plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/pageScanner.bundle.js',
 				]
 			);

Confirm the REST endpoints backing “Rescan” and “Clear” enforce per-post edit checks (permission_callback) so UI and server stay in lockstep.

src/frontendHighlighterApp/index.js (1)

397-405: Gate Clear/Rescan on edit permission: solid hardening. Minor polish to ensure strict boolean.

Nice job hiding destructive actions unless the user can actually edit. I pity the bug that tries to click what ain’t there.

You can simplify and make the check explicitly boolean (avoids accidental truthy surprises) like so:

-const userCanEdit = edacFrontendHighlighterApp && edacFrontendHighlighterApp?.userCanEdit && edacFrontendHighlighterApp?.loggedIn;
+const userCanEdit = Boolean(edacFrontendHighlighterApp?.userCanEdit && edacFrontendHighlighterApp?.loggedIn);
includes/classes/class-rest-api.php (1)

210-227: Add typehint and early invalid-ID guard in helper.

Permission callbacks run before arg validation/sanitation. You already cast, which is good. Typehinting the request parameter helps IDEs and static analyzers; also return a 400 when id casts to 0.

- public function user_can_edit_passed_post_id( $request ) {
+ public function user_can_edit_passed_post_id( \WP_REST_Request $request ) {
 	if ( ! isset( $request['id'] ) ) {
 		return new \WP_Error( 'rest_post_invalid_id', __( 'A required parameter is missing.', 'accessibility-checker' ), [ 'status' => 400 ] );
 	}
 	$post_id = (int) $request['id'];
+	if ( $post_id <= 0 ) {
+		return new \WP_Error( 'rest_post_invalid_id', __( 'Invalid post ID.', 'accessibility-checker' ), [ 'status' => 400 ] );
+	}
 	return current_user_can( 'edit_post', $post_id ); // able to edit the post.
 }
tests/phpunit/includes/classes/RestApiEndpointsTest.php (1)

177-217: Ownership path verified. Consider adding coverage for tightened stats endpoints.

Great that authors can manage their own drafts. To round it out, add small tests for the capability changes on stats endpoints to prevent regressions.

Here are ready-to-drop tests you can append to this class:

public function test_scans_stats_requires_edit_posts() {
	$this->assertNotNull( $this->server );
	// Anonymous should be forbidden.
	wp_set_current_user( 0 );
	$respAnon = $this->server->dispatch( new WP_REST_Request( 'GET', '/accessibility-checker/v1/scans-stats' ) );
	$this->assertSame( 401, $respAnon->get_status() );

	// Limited user (subscriber + edit_posts) allowed.
	wp_set_current_user( self::$limited_id );
	$respUser = $this->server->dispatch( new WP_REST_Request( 'GET', '/accessibility-checker/v1/scans-stats' ) );
	$this->assertSame( 200, $respUser->get_status() );
}

public function test_clear_cached_scans_stats_requires_publish_posts() {
	$this->assertNotNull( $this->server );

	// Limited user lacks publish_posts.
	wp_set_current_user( self::$limited_id );
	$respDenied = $this->server->dispatch( new WP_REST_Request( 'POST', '/accessibility-checker/v1/clear-cached-scans-stats' ) );
	$this->assertSame( 403, $respDenied->get_status() );

	// Admin allowed.
	wp_set_current_user( self::$admin_id );
	$respOk = $this->server->dispatch( new WP_REST_Request( 'POST', '/accessibility-checker/v1/clear-cached-scans-stats' ) );
	$this->assertSame( 200, $respOk->get_status() );
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between dd032c4 and 3456ce5.

📒 Files selected for processing (8)
  • accessibility-checker.php (3 hunks)
  • admin/class-welcome-page.php (1 hunks)
  • includes/classes/class-enqueue-frontend.php (1 hunks)
  • includes/classes/class-rest-api.php (7 hunks)
  • package.json (1 hunks)
  • readme.txt (2 hunks)
  • src/frontendHighlighterApp/index.js (2 hunks)
  • tests/phpunit/includes/classes/RestApiEndpointsTest.php (1 hunks)
🧰 Additional context used
📓 Path-based instructions (12)
**/*.php

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.php: Follow WordPress coding standards (WPCS) in all PHP files
Use PSR-4 autoloading with EqualizeDigital\AccessibilityChecker namespace for new classes
Use WordPress hooks and filters appropriately
Use edac_ prefix for custom hooks and filters
Minimum PHP 7.4 compatibility
Use type hints where appropriate in PHP code
Follow WordPress security best practices (sanitization, validation, nonces)
Use WordPress database API (wpdb) for database operations
Prefix all functions and classes with edac_ when in global namespace
Use WordPress hooks (actions/filters) for extensibility
Use WordPress transients for caching
Sanitize all user inputs
Validate and escape all outputs
Use WordPress nonces for form submissions
Implement proper capability checks
Provide appropriate hooks for extensibility when adding new functionality
Use descriptive hook names with edac_ prefix
Document all custom hooks in docblocks
Document custom hooks and filters with clear descriptions and parameter types
Use PHPDoc for all public classes, methods, and properties
Escape all output, especially in admin screens and user-generated content
Use WordPress error handling functions (e.g., WP_Error) for PHP errors

Files:

  • includes/classes/class-enqueue-frontend.php
  • admin/class-welcome-page.php
  • tests/phpunit/includes/classes/RestApiEndpointsTest.php
  • accessibility-checker.php
  • includes/classes/class-rest-api.php
**/class-*.php

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/class-*.php: Legacy files are autoloaded using EDAC namespace
Legacy class names use WordPress style (Class_Name_Convention)
Legacy file names use class-class-name.php (WordPress style)
Legacy Classes: class-class-name.php
Deprecate legacy code with clear docblocks and migration notes

Files:

  • includes/classes/class-enqueue-frontend.php
  • admin/class-welcome-page.php
  • includes/classes/class-rest-api.php
**/*.{php,js}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{php,js}: Follow WordPress internationalization (i18n) practices and use accessibility-checker text domain
All user-facing text must be translatable
Add inline comments for complex accessibility logic or non-obvious code
Use semantic HTML structure
ARIA attributes used correctly
Keyboard navigation supported
Images have descriptive alt text
Heading hierarchy logical
Screen reader compatibility
Forms are accessible and labeled

Files:

  • includes/classes/class-enqueue-frontend.php
  • admin/class-welcome-page.php
  • src/frontendHighlighterApp/index.js
  • tests/phpunit/includes/classes/RestApiEndpointsTest.php
  • accessibility-checker.php
  • includes/classes/class-rest-api.php
includes/**/*.php

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

includes/**/*.php: Validate all AJAX requests and REST endpoints with nonces and capability checks
Avoid blocking queries in PHP, especially during scans

Files:

  • includes/classes/class-enqueue-frontend.php
  • includes/classes/class-rest-api.php
**/*.js

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.js: Strings in JavaScript also need translation support using wp.i18n functions
Gracefully handle JavaScript errors to avoid breaking accessibility features

Files:

  • src/frontendHighlighterApp/index.js
**/*.{css,js}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Support RTL languages where applicable

Files:

  • src/frontendHighlighterApp/index.js
src/**/*.js

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/**/*.js: Focus management implemented
Minimize DOM operations in JavaScript for frontend scanning

Files:

  • src/frontendHighlighterApp/index.js
**/[a-z]*.js

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

JavaScript Utilities: utilityName.js

Files:

  • src/frontendHighlighterApp/index.js
**/[A-Z]*.php

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/[A-Z]*.php: Class names use CamelCase (ClassNameConvention) for new classes
File names use ClassNameConvention.php for new classes (CamelCase)
Classes: ClassName.php

Files:

  • tests/phpunit/includes/classes/RestApiEndpointsTest.php
tests/phpunit/**/*.php

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

tests/phpunit/**/*.php: Write unit tests for new PHP functions and classes
Add integration tests for major features and accessibility rules

Files:

  • tests/phpunit/includes/classes/RestApiEndpointsTest.php
{changelog.txt,readme.txt}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Update changelog.txt and readme.txt for each release

Files:

  • readme.txt
accessibility-checker.php

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Implement proper activation/deactivation hooks

Files:

  • accessibility-checker.php
🧠 Learnings (3)
📚 Learning: 2025-08-04T16:46:23.515Z
Learnt from: CR
PR: equalizedigital/accessibility-checker#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-04T16:46:23.515Z
Learning: Applies to tests/phpunit/**/*.php : Add integration tests for major features and accessibility rules

Applied to files:

  • tests/phpunit/includes/classes/RestApiEndpointsTest.php
📚 Learning: 2025-07-18T01:29:35.548Z
Learnt from: SteveJonesDev
PR: equalizedigital/accessibility-checker#1088
File: includes/classes/Rules/Rule/EmptyParagraphTagRule.php:50-50
Timestamp: 2025-07-18T01:29:35.548Z
Learning: In the Accessibility Checker plugin, the 'wcag' field can use custom values like '0.1' to represent best practice rules and manual testing requirements that don't map directly to specific WCAG success criteria but are still important for accessibility compliance.

Applied to files:

  • accessibility-checker.php
📚 Learning: 2025-07-18T01:18:27.812Z
Learnt from: SteveJonesDev
PR: equalizedigital/accessibility-checker#1088
File: includes/classes/Rules/Rule/VideoPresentRule.php:41-42
Timestamp: 2025-07-18T01:18:27.812Z
Learning: In the Accessibility Checker plugin, the 'wcag' field can use custom values like '0.3' to represent best practice rules and manual testing requirements that don't map directly to specific WCAG success criteria but are still important for accessibility compliance.

Applied to files:

  • accessibility-checker.php
🧬 Code graph analysis (1)
tests/phpunit/includes/classes/RestApiEndpointsTest.php (1)
admin/class-update-database.php (2)
  • Update_Database (16-82)
  • edac_update_database (36-81)
🪛 LanguageTool
readme.txt

[grammar] ~6-~6: There might be a mistake here.
Context: ...6.6 Tested up to: 6.8 Stable tag: 1.30.1 License: GPLv2 or later License URI: htt...

(QB_NEW_EN)

🔇 Additional comments (11)
accessibility-checker.php (1)

13-13: Versions updated correctly; ship it.

Header Version and EDAC_VERSION constant both read 1.30.1. Nice and tight.

Run the version sync script I dropped on package.json to confirm everything matches across files.

Also applies to: 39-39

readme.txt (1)

6-6: Stable tag synced to 1.30.1—on point.

This matches the plugin header and constant updates. Keep those numbers marching together every release.

src/frontendHighlighterApp/index.js (1)

419-419: Class toggle for single-button state looks good.

The conditional class injection based on edit capability reads clean and pairs correctly with the new gating.

includes/classes/class-rest-api.php (4)

82-87: Route args hardened: required + absint.

Good tightening on path params. Required + sanitize at the route layer reduces downstream footguns.

Also applies to: 176-181


89-91: Centralized per-post permission check is the right move.

Delegating to a single helper keeps permission logic consistent across endpoints.

Also applies to: 183-185


232-232: Docblock cleanup is accurate.

Using fully-qualified WP_REST_Request in the docblock aligns with the rest of the file.


107-107: Stats endpoints: admin‐only consumers confirmed, safe to bump capabilities

I’ve verified that all calls to /scans-stats* and /clear-cached-scans-stats originate exclusively from the admin-bundled script (admin.bundle.js via edacScriptVars.edacApiUrl). No front-end or public-facing bundles reference these endpoints. Raising the permission to edit_posts/publish_posts therefore only affects users with access to the admin UI and will not break any public or third-party integrations.

Action items:

  • Add a note in CHANGELOG.md about the increased capability requirement.
  • Update documentation to reflect the new edit_posts/publish_posts prerequisites.
tests/phpunit/includes/classes/RestApiEndpointsTest.php (4)

72-94: Fixture setup is pragmatic and stable.

Enabling scannable post types and ensuring the plugin table exists avoids flaky tests. Good hustle.


101-135: Admin vs limited user on post-scan-results: on point.

Nice minimal payload and clear assertions on 200 vs 403. This covers the new permission helper well.


142-170: Clear-issues permissions test is crisp.

Good use of JSON body and headers; assertions map cleanly to the REST behavior.


47-53: Routes are properly registered in the plugin bootstrap
I’ve confirmed that the plugin’s main initialization instantiates REST_Api and immediately calls its init_hooks() method, ensuring all REST routes are hooked into rest_api_init before any dispatch occurs. The test’s calls to

do_action( 'init' );
do_action( 'rest_api_init' );
$this->server = rest_get_server();

therefore correctly register your routes in the test context. No further changes are needed.

Comment thread package.json
{
"name": "accessibility-checker",
"version": "1.30.0",
"version": "1.30.1",

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.

💡 Verification agent

🧩 Analysis chain

Version bump looks clean; keep the release numbers in lockstep.

1.30.1 here matches the PR intent. Make sure the plugin header, EDAC_VERSION, and readme stable tag all say 1.30.1 so no one gets tripped up by mismatched versions.

Run this to verify all the version surfaces are in sync (expected: 1.30.1):


🏁 Script executed:

#!/bin/bash
set -euo pipefail
expected="1.30.1"

echo "Checking versions…"
pkg=$(jq -r .version package.json)
php_header=$(rg -nP '^\s*\*\s*Version:\s*([0-9.]+)' -or '$1' accessibility-checker.php | head -n1)
php_const=$(rg -nP "define\(\s*'EDAC_VERSION'\s*,\s*'([^']+)'\s*\)" -or '$1' accessibility-checker.php | head -n1)
readme=$(rg -nP '^Stable tag:\s*([0-9.]+)' -or '$1' readme.txt | head -n1)

printf "package.json: %s\nplugin header: %s\nEDAC_VERSION: %s\nreadme stable tag: %s\n" \
  "$pkg" "$php_header" "$php_const" "$readme"

test "$pkg" = "$expected" && test "$php_header" = "$expected" && test "$php_const" = "$expected" && test "$readme" = "$expected" \
  && echo "OK: versions match $expected" || { echo "Mismatch detected"; exit 1; }

Length of output: 797


Update version-check script to strip line numbers
The actual version strings in package.json, the plugin header (accessibility-checker.php), the EDAC_VERSION constant, and the readme.txt stable tag are all set to 1.30.1, but the verification script is pulling in line-number prefixes (e.g. 13:1.30.1), causing a false “Mismatch detected.”

• Remove the -n flag from each rg invocation so it only emits the captured group. For example:

- php_header=$(rg -nP '^\s*\*\s*Version:\s*([0-9.]+)' -or '$1' accessibility-checker.php | head -n1)
+ php_header=$(rg -P  '^\s*\*\s*Version:\s*([0-9.]+)' -or '$1' accessibility-checker.php | head -n1)

- php_const=$(rg -nP "define\(\s*'EDAC_VERSION'\s*,\s*'([^']+)'\s*\)" -or '$1' accessibility-checker.php | head -n1)
+ php_const=$(rg -P  "define\(\s*'EDAC_VERSION'\s*,\s*'([^']+)'\s*\)" -or '$1' accessibility-checker.php | head -n1)

- readme=$(rg -nP '^Stable tag:\s*([0-9.]+)' -or '$1' readme.txt                  | head -n1)
+ readme=$(rg -P  '^Stable tag:\s*([0-9.]+)' -or '$1' readme.txt                  | head -n1)

• After this change, re-run the script to confirm you get:

OK: versions match 1.30.1

With that tweak, your version bump verification will be rock-solid, fool!

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"version": "1.30.1",
# In your version-check script, replace these lines:
- php_header=$(rg -nP '^\s*\*\s*Version:\s*([0-9.]+)' -or '$1' accessibility-checker.php | head -n1)
- php_const=$(rg -nP "define\(\s*'EDAC_VERSION'\s*,\s*'([^']+)'\s*\)" -or '$1' accessibility-checker.php | head -n1)
- readme=$(rg -nP '^Stable tag:\s*([0-9.]+)' -or '$1' readme.txt | head -n1)
# with these lines:
php_header=$(rg -P '^\s*\*\s*Version:\s*([0-9.]+)' -or '$1' accessibility-checker.php | head -n1)
php_const=$(rg -P "define\(\s*'EDAC_VERSION'\s*,\s*'([^']+)'\s*\)" -or '$1' accessibility-checker.php | head -n1)
readme=$(rg -P '^Stable tag:\s*([0-9.]+)' -or '$1' readme.txt | head -n1)
🤖 Prompt for AI Agents
In package.json around line 3, the version-check script is failing because
ripgrep (rg) is invoked with the -n flag which prefixes results with line
numbers (e.g. "13:1.30.1") causing false mismatches; edit the script(s) that
extract versions to remove the -n flag from each rg invocation so rg outputs
only the captured group (the version string), then re-run the verification to
confirm it reports "OK: versions match 1.30.1".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants