site_status_tests
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
apply_filters( 'site_status_tests', array[] $tests )
Описание
Состояние сайта определяется набором проверок, основанных на лучших практиках как команды WordPress Hosting Team, так и веб-стандартов в целом.
У некоторых сайтов могут быть иные требования, например проверки автоматических обновлений могут выполняться хостингом и поэтому отключены в ядре.
Или, возможно, вы хотите добавить новую проверку, например включено/отключено/устарело ли кэширование.
Проверки можно добавлять как прямые, так и асинхронные. Любая проверка, для завершения которой может потребоваться время, должна выполняться асинхронно, чтобы избежать продолжительных загрузок в wp-admin.
Оригинал (английский)
The site health is determined by a set of tests based on best practices from both the WordPress Hosting Team and web standards in general.
Some sites may not have the same requirements, for example the automatic update checks may be handled by a host, and are therefore disabled in core.
Or maybe you want to introduce a new test, is caching enabled/disabled/stale for example.
Tests may be added either as direct, or asynchronous ones. Any test that may require some time to complete should run asynchronously, to avoid extended loading periods within wp-admin.
Фильтруемое значение
directarray[] An array of direct tests....$identifierarray$identifiershould be a unique identifier for the test. Plugins and themes are encouraged to prefix test identifiers with their slug to avoid collisions between tests.labelstringThe friendly label to identify the test.testcallableThe callback function that runs the test and returns its result.skip_cronboolWhether to skip this test when running as cron.
}asyncarray[] An array of asynchronous tests....$identifierarray$identifiershould be a unique identifier for the test. Plugins and themes are encouraged to prefix test identifiers with their slug to avoid collisions between tests.labelstringThe friendly label to identify the test.teststringAn admin-ajax.php action to be called to perform the test, or if$has_restis true, a URL to a REST API endpoint to perform the test.has_restboolWhether the$testproperty points to a REST API endpoint.skip_cronboolWhether to skip this test when running as cron.async_direct_testcallableA manner of directly calling the test marked as asynchronous, as the scheduled event can not authenticate, and endpoints may require authentication.
}
$tests = apply_filters( 'site_status_tests', $tests );View all references View on Trac View on GitHub
Related
ChangelogUsed by Description WP_Site_Health::get_tests() wp-admin/includes/class-wp-site-health.phpReturns a set of tests that belong to the site status page.
User Contributed NotesVersion Description 5.6.0 Added the async_direct_testarray key for asynchronous tests.
Added theskip_cronarray key for all tests.5.2.0 Introduced. -
Skip to note 4 content
Rami Yushuvaev
7 years ago
You must log in to vote on the helpfulness of this noteVote results for this note: 1You must log in to vote on the helpfulness of this note
Example usage to remove a test:
function remove_background_updates_test( $tests ) { unset( $tests['async']['background_updates'] ); return $tests; } add_filter( 'site_status_tests', 'remove_background_updates_test' );Also check out the Site Health Manager plugin that allows you to easily remove custom status test using this hook.
Log in to add feedback -
Skip to note 5 content
Koen Reus
3 years ago
You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note
Useful code examples for adding your own tests and section to the Info tab can be found in the Site Health Check in 5.2 announcement article.
Log in to add feedback -
Skip to note 6 content
Joel
6 years ago
You must log in to vote on the helpfulness of this noteVote results for this note: -2You must log in to vote on the helpfulness of this note
Here’s a quick one-liner to disable 3 Site Health tests that tend to be false alarms. You can drop it into a plugin or your theme’s
functions.php.- PHP version (which is outside of user control anyway)
- theme version (complains when it doesn’t find one of the WordPress twenty**** themes)
- background updates (complains when you have a .git directory in your site root, for example)
add_filter('site_status_tests', function (array $test_type) { unset($test_type['direct']['php_version'], $test_type['direct']['theme_version'], $test_type['async']['background_updates']); return $test_type; }, 10, 1);- The PHP Version may be out of direct control of the user, but they should still know if they need to contact a host about getting it updated. And having a public .git directory is a problem, and should be warned about. There are security implications. In summary, best to not just disable tests because they are failing :) Caleb Burks 6 years ago
You must log in before being able to contribute a note or feedback.
Параметры
$tests
array[]
обязательный
directarray[] An array of direct tests....$identifierarray$identifiershould be a unique identifier for the test. Plugins and themes are encouraged to prefix test identifiers with their slug to avoid collisions between tests.labelstringThe friendly label to identify the test.testcallableThe callback function that runs the test and returns its result.skip_cronboolWhether to skip this test when running as cron.
}asyncarray[] An array of asynchronous tests....$identifierarray$identifiershould be a unique identifier for the test. Plugins and themes are encouraged to prefix test identifiers with their slug to avoid collisions between tests.labelstringThe friendly label to identify the test.teststringAn admin-ajax.php action to be called to perform the test, or if$has_restis true, a URL to a REST API endpoint to perform the test.has_restboolWhether the$testproperty points to a REST API endpoint.skip_cronboolWhether to skip this test when running as cron.async_direct_testcallableA manner of directly calling the test marked as asynchronous, as the scheduled event can not authenticate, and endpoints may require authentication.
}
$tests = apply_filters( 'site_status_tests', $tests );View all references View on Trac View on GitHub
Related
ChangelogUsed by Description WP_Site_Health::get_tests() wp-admin/includes/class-wp-site-health.phpReturns a set of tests that belong to the site status page.
User Contributed NotesVersion Description 5.6.0 Added the async_direct_testarray key for asynchronous tests.
Added theskip_cronarray key for all tests.5.2.0 Introduced. -
Skip to note 4 content
Rami Yushuvaev
7 years ago
You must log in to vote on the helpfulness of this noteVote results for this note: 1You must log in to vote on the helpfulness of this note
Example usage to remove a test:
function remove_background_updates_test( $tests ) { unset( $tests['async']['background_updates'] ); return $tests; } add_filter( 'site_status_tests', 'remove_background_updates_test' );Also check out the Site Health Manager plugin that allows you to easily remove custom status test using this hook.
Log in to add feedback -
Skip to note 5 content
Koen Reus
3 years ago
You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note
Useful code examples for adding your own tests and section to the Info tab can be found in the Site Health Check in 5.2 announcement article.
Log in to add feedback -
Skip to note 6 content
Joel
6 years ago
You must log in to vote on the helpfulness of this noteVote results for this note: -2You must log in to vote on the helpfulness of this note
Here’s a quick one-liner to disable 3 Site Health tests that tend to be false alarms. You can drop it into a plugin or your theme’s
functions.php.- PHP version (which is outside of user control anyway)
- theme version (complains when it doesn’t find one of the WordPress twenty**** themes)
- background updates (complains when you have a .git directory in your site root, for example)
add_filter('site_status_tests', function (array $test_type) { unset($test_type['direct']['php_version'], $test_type['direct']['theme_version'], $test_type['async']['background_updates']); return $test_type; }, 10, 1);- The PHP Version may be out of direct control of the user, but they should still know if they need to contact a host about getting it updated. And having a public .git directory is a problem, and should be warned about. There are security implications. In summary, best to not just disable tests because they are failing :) Caleb Burks 6 years ago
You must log in before being able to contribute a note or feedback.
Исходный код
wp-admin/includes/class-wp-site-health.php:3047
$tests = apply_filters( 'site_status_tests', $tests );
История изменений
| Версия | Описание |
|---|---|
| 5.6.0 | Added the async_direct_test array key for asynchronous tests. Added the skip_cron array key for all tests. |
| 5.2.0 | Introduced. |

