-
Notifications
You must be signed in to change notification settings - Fork 19
Backport v1.30.1 #1206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backport v1.30.1 #1206
Changes from all commits
1cdb35c
03552e1
c26e743
651dc62
e6e6eec
a48215b
525151b
edf9b50
1f170c1
f4b27d6
2b10940
b139ffb
7a20d43
ab4599b
9889dd9
0bf343f
3456ce5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,13 +79,15 @@ function () use ( $ns, $version ) { | |
| 'callback' => [ $this, 'set_post_scan_results' ], | ||
| 'args' => [ | ||
| 'id' => [ | ||
| 'required' => true, | ||
| 'validate_callback' => function ( $param ) { | ||
| return is_numeric( $param ); | ||
| }, | ||
| 'sanitize_callback' => 'absint', | ||
| ], | ||
| ], | ||
| 'permission_callback' => function () { | ||
| return current_user_can( 'edit_posts' ); | ||
| 'permission_callback' => function ( $request ) { | ||
| return $this->user_can_edit_passed_post_id( $request ); | ||
| }, | ||
| ] | ||
| ); | ||
|
|
@@ -102,7 +104,7 @@ function () use ( $ns, $version ) { | |
| 'methods' => 'GET', | ||
| 'callback' => [ $this, 'get_scans_stats' ], | ||
| 'permission_callback' => function () { | ||
| return current_user_can( 'read' ); // able to access the admin dashboard. | ||
| return current_user_can( 'edit_posts' ); | ||
| }, | ||
| ] | ||
| ); | ||
|
|
@@ -119,7 +121,7 @@ function () use ( $ns, $version ) { | |
| 'methods' => 'POST', | ||
| 'callback' => [ $this, 'clear_cached_scans_stats' ], | ||
| 'permission_callback' => function () { | ||
| return current_user_can( 'read' ); // able to access the admin dashboard. | ||
| return current_user_can( 'publish_posts' ); | ||
| }, | ||
| ] | ||
| ); | ||
|
|
@@ -136,7 +138,7 @@ function () use ( $ns, $version ) { | |
| 'methods' => 'GET', | ||
| 'callback' => [ $this, 'get_scans_stats_by_post_type' ], | ||
| 'permission_callback' => function () { | ||
| return current_user_can( 'read' ); // able to access the admin dashboard. | ||
| return current_user_can( 'edit_posts' ); | ||
| }, | ||
| ] | ||
| ); | ||
|
|
@@ -153,7 +155,7 @@ function () use ( $ns, $version ) { | |
| 'methods' => 'GET', | ||
| 'callback' => [ $this, 'get_scans_stats_by_post_types' ], | ||
| 'permission_callback' => function () { | ||
| return current_user_can( 'read' ); // able to access the admin dashboard. | ||
| return current_user_can( 'edit_posts' ); | ||
| }, | ||
| ] | ||
| ); | ||
|
|
@@ -171,13 +173,15 @@ function () use ( $ns, $version ) { | |
| 'callback' => [ $this, 'clear_issues_for_post' ], | ||
| 'args' => [ | ||
| 'id' => [ | ||
| 'required' => true, | ||
| 'validate_callback' => function ( $param ) { | ||
| return is_numeric( $param ); | ||
| }, | ||
| 'sanitize_callback' => 'absint', | ||
| ], | ||
| ], | ||
| 'permission_callback' => function () { | ||
| return current_user_can( 'edit_posts' ); | ||
| 'permission_callback' => function ( $request ) { | ||
| return $this->user_can_edit_passed_post_id( $request ); | ||
| }, | ||
| ] | ||
| ); | ||
|
|
@@ -203,10 +207,29 @@ function () use ( $ns, $version ) { | |
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Check if the user can edit a post. | ||
| * | ||
| * This is a permission callback to replace several places where we check if the user can edit a post. | ||
| * | ||
| * @since 1.30.1 | ||
| * | ||
| * @param \WP_REST_Request $request The request object passed from the REST call. This should contain the 'id' of the post to check permissions for. | ||
| * | ||
| * @return bool|\WP_Error | ||
| */ | ||
| 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. | ||
| } | ||
|
|
||
| /** | ||
| * 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. | ||
|
||
| * | ||
| * @return \WP_REST_Response | ||
| */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,6 @@ | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| "name": "accessibility-checker", | ||||||||||||||||||||||||||
| "version": "1.30.0", | ||||||||||||||||||||||||||
| "version": "1.30.1", | ||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVersion 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 • Remove the - 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: With that tweak, your version bump verification will be rock-solid, fool! 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
| "description": "Audit and check your website for accessibility before you hit publish. In-post accessibility scanner and guidance.", | ||||||||||||||||||||||||||
| "author": "Equalize Digital", | ||||||||||||||||||||||||||
| "license": "GPL-2.0+", | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
if ( ! isset( $request['id'] ) )check is redundant. The REST API routes using this permission callback (/post-scan-resultsand/clear-issues) define theidparameter asrequired. 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.