Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#47864 closed enhancement (fixed)

Provide filters for Site Health Check results

Reported by: clorith's profile Clorith Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: normal Version: 5.2
Component: Site Health Keywords: has-patch needs-docs commit
Focuses: Cc:

Description

Currently, there's a filter to modify which PHP extensions are checked for, and even which tests to run, but nothing for the actual results.

There are scenarios where someone might want to extend the results, either by providing a more involved description for a given scenario, or maybe even to provide additional actions.

An example might be a hosting provider, PHP extensions are missing, so they add in an action link to the PHP extension manager of their control panel.
Perhaps they wanted to be more direct, they wanted the PHP version check, which recommends the user update, they add in an ajax button that'll switch the PHP version for them on the spot.

Basically, there are many possibilities here, and it would be nice if we offered them up on a nice silver platter.

There is one limitation I'm thinking of though; asynchronous tests.

While direct tests run on the spot, and thus have traditional filters available to them, the asynchronous ones run after the fact via JavaScript. Since we don't have a wrapper for the tests, they rely on whatever added the test creating their own admin-ajax action to capture them.

Are JavaScript filters the way to go for these, or does that create an odd separation between the two?

---

As for the proposed filter it self, using something like apply_filters( 'site_status_test_result', call_user_func( $test['test'] ), $test_key ) is what I'm looking at, where $test_key is the array key given in the WP_Site_Health::get_tests() list of tests, and can then be used as a reference.

Attachments (2)

47864.patch (2.9 KB) - added by Clorith 5 years ago.
47864.2.patch (2.8 KB) - added by Clorith 5 years ago.

Download all attachments as: .zip

Change History (7)

@Clorith
5 years ago

#1 @Clorith
5 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 5.3

47864.patch adds the filter site_status_test_result both to PHP, and with the same name and output for JavaScript on the asynchronous tests.

I'm not familiar with JS inline docs, and I'm not even sure if they are needed when the filter, and data, are the same, so they are not included here for now.

@Clorith
5 years ago

#2 @Clorith
5 years ago

  • Keywords needs-docs added

47864.2.patch is essentially the same as the original patch, but uses the existing format for pointing to identical filter declarations in other files.

Tagging with needs-docs for now, as I'm not sure if this is the right approach for cross-language filters, as our JS inline docs standard don't currently include filter and action pointers.

#3 @Clorith
5 years ago

  • Keywords commit added

Moving this forward, I'd like to see this land, the inline-docs for the JavaScript filter can be added on as we go along if the current approach in 47864.2.patch is lacking.

#4 @SergeyBiryukov
5 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 46269:

Site Health: Introduce site_status_test_result filter for the output of a finished Site Health test.

Props Clorith.
Fixes #47864.

This ticket was mentioned in Slack in #core by david.baumwald. View the logs.


4 years ago

Note: See TracTickets for help on using tickets.