fix(admin): decouple AJAX calls and remove unnecessary return values - #1415
fix(admin): decouple AJAX calls and remove unnecessary return values#1415faisalahammad wants to merge 3 commits into
Conversation
Refactor the JavaScript AJAX chain so each step takes its own parameters instead of relying on raw response data from the previous step. Remove the now-unnecessary plugin and checks keys from the set_up_environment AJAX response, and drop the array return from configure_runner.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Pull request overview
This PR refactors the Plugin Check admin “Check it!” flow to decouple the chained AJAX calls by passing explicit parameters between steps (instead of passing raw response payloads), and simplifies the PHP AJAX response surface accordingly.
Changes:
- Refactored
plugin-check-admin.jsto pass explicitplugin,checks,types, and flags betweengetChecksToRun,setUpEnvironment,runChecks, andrunCheck. - Added shared JS helpers (
fetchAJAX,getSelectedValues) and updated exports to use the shared AJAX wrapper. - Simplified the PHP runtime setup endpoint by removing unnecessary returned
plugin/checksvalues and makingconfigure_runner()effectively void.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| includes/Admin/Admin_AJAX.php | Removes unused runner config return values and trims the runtime setup success payload to message only. |
| assets/js/plugin-check-admin.js | Introduces fetchAJAX/getSelectedValues helpers and refactors the admin AJAX flow to use explicit arguments (including export requests). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Update handleDataErrors to read the message from WP_Error array
responses and object responses alike, so export errors (which
return { message: ... }) no longer throw a TypeError.
Addresses PR feedback.
Refs WordPress#1415
Review fixes applied (commit b0d4609)Addressed the Copilot review finding:
Quality gates passed: |
|
@faisalahammad Small documentation note: since |
What?
Closes #131
Decouple the AJAX call chain in the JS admin so each step takes its own arguments instead of relying on raw response data from the previous step. Remove the now-unnecessary return values from the PHP endpoint.
Why?
The previous JS chain passed the full response
dataobject from one step to the next, forcing PHP endpoints to echo back values they did not own. For example,set_up_environmentreturnedpluginandchecksonly because the next step needed them. This made the flow harder to understand and maintain.How?
fetchAJAX(formData)wrapper to reduce repeated fetch boilerplate across 5 call sites.getSelectedValues(list)helper to read checked checkboxes from a NodeList.currentChecksvariable so check slugs are stored betweengetChecksToRunandrunChecks.getChecksToRun,setUpEnvironment,runChecks, andrunCheckto accept individual parameters instead of adataobject.pluginandchecksfrom theset_up_environmentresponse.configure_runner()now returnsvoid.exportResultsto use the sharedfetchAJAXwrapper.Testing Instructions
200andsuccess: true.plugin_check_set_up_environmentresponse - it should contain onlydata.message(nodata.pluginordata.checks).AI Usage Disclosure
If AI tools were used, please describe how they were used:
Used AI-assisted development tools for code suggestions and refactoring patterns.
Screenshots or screencast
No UI changes. The plugin behaves identically before and after.