You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update the run_checks() method in the Admin_AJAX class to handle running checks and returning a response.
The run_checks method will first verify the request using the nonce passed and If invalid will return an error response.
Then the AJAX_Runner instance is gathered by calling the Plugin_Request_Utility::get_runner().
If the Plugin_Request_Utility::get_runner() returns null a new instance of the AJAX_Runner class should be created.
As part of creating the AJAX_Runner instance, the set_check_slugs() and set_plugin_slug () methods should be called passing in the appropriate values taken from the request.
Then the AJAX_Runnersrun() method is called and the Check_Results instance returned is stored in a variable.
If the run() method throws an exception, the error message is captured and returned in an error response to the client. The admin-plugin-check.js file will handle the error and display it on the admin page for debugging. Any further check requests will not be sent.
The results are then passed to the protected format_results() method in the Admin_AJAX class. This method will handle formatting all results into an array of messages, with each message being an object with the following properties.
message - The error or warning message.
type - Either error or warning.
standard - The standard or check name.
file - The filename and path
line_column - The line and column numbers the error/warning occurred.
A response is returned containing the following information
success - true or false as to whether the check run was successful.
results - The array of messages returned by format_results(). Can be an empty array.
check - The slug of the check that was run.
error - false if there were no critical errors when running checks, false if the check run was successful.
Update the plugin-check-admin.js to send requests to the admin-ajax.php endpoint to run checks.
The checks_to_run returned by the plugin_check_get_checks_to_run action will be used to send requests for each individual check.
The first check is removed from the array and sent in the request.
The next check in the checks_to_run array is removed and used in the next request. This process will repeat until the checks_to_run is empty and the last check is run.
When all checks have been run and the checks_to_run array is empty the runtime environment cleanup is executed by making a request to the admin-ajax.php endpoint with the plugin_check_cleanup_environment action (implemented in AJAX Runtime Environment Setup/Cleanup #86)
On a error response:
A user-friendly error message is displayed in the admin page with the error that occurred.
The runtime environment cleanup function will be run by making a request to the admin-ajax.php endpoint with the plugin_check_cleanup_environment action (implemented in AJAX Runtime Environment Setup/Cleanup #86)
Description
Handle running checks one by one and return output.
This issue is dependent on the following:
Acceptance Criteria
run_checks()method in theAdmin_AJAXclass to handle running checks and returning a response.run_checksmethod will first verify the request using the nonce passed and If invalid will return an error response.AJAX_Runnerinstance is gathered by calling thePlugin_Request_Utility::get_runner().Plugin_Request_Utility::get_runner()returnsnulla new instance of theAJAX_Runnerclass should be created.AJAX_Runnerinstance, theset_check_slugs()andset_plugin_slug ()methods should be called passing in the appropriate values taken from the request.AJAX_Runnersrun()method is called and theCheck_Resultsinstance returned is stored in a variable.run()method throws an exception, the error message is captured and returned in an error response to the client. Theadmin-plugin-check.jsfile will handle the error and display it on the admin page for debugging. Any further check requests will not be sent.format_results()method in theAdmin_AJAXclass. This method will handle formatting all results into an array of messages, with each message being an object with the following properties.message- The error or warning message.type- Eithererrororwarning.standard- The standard or check name.file- The filename and pathline_column- The line and column numbers the error/warning occurred.success-trueorfalseas to whether the check run was successful.results- The array of messages returned byformat_results(). Can be an empty array.check- The slug of the check that was run.error-falseif there were no critical errors when running checks,falseif the check run was successful.plugin-check-admin.jsto send requests to theadmin-ajax.phpendpoint to run checks.checks_to_runreturned by theplugin_check_get_checks_to_runaction will be used to send requests for each individual check.checks_to_runarray is removed and used in the next request. This process will repeat until thechecks_to_runis empty and the last check is run.checks_to_runarray is empty the runtime environment cleanup is executed by making a request to theadmin-ajax.phpendpoint with theplugin_check_cleanup_environmentaction (implemented in AJAX Runtime Environment Setup/Cleanup #86)admin-ajax.phpendpoint with theplugin_check_cleanup_environmentaction (implemented in AJAX Runtime Environment Setup/Cleanup #86)