WP_Site_Health_Auto_Updates
Tests automatic update capabilities and configuration.
Since: 5.2.0
Source: wp-admin/includes/class-wp-site-health-auto-updates.php
Constructor
Requires wp-admin/includes/class-wp-upgrader.php.
Methods
run_tests()
Executes all auto-update tests and returns results.
public function run_tests(): array
Returns: Array of test result objects with description and severity properties.
Severities:
pass— Test passedinfo— Informationalwarning— Non-critical issuefail— Critical failure
test_constants()
Checks if auto-update constants are correctly configured.
public function test_constants(
string $constant,
bool|string|array $value
): array|null
Parameters:
$constant— Constant name (e.g.,WP_AUTO_UPDATE_CORE)$value— Expected value(s)
Checks: WP_AUTO_UPDATE_CORE should be true, 'beta', 'rc', 'development', 'branch-development', or 'minor'
test_wp_version_check_attached()
Verifies wp_version_check() filter is attached.
public function test_wp_version_check_attached(): array|null
Fails if: Plugin disabled updates via wp_version_check filter
test_filters_automatic_updater_disabled()
Checks automatic_updater_disabled filter.
public function test_filters_automatic_updater_disabled(): array|null
Fails if: apply_filters('automatic_updater_disabled', false) returns true
test_wp_automatic_updates_disabled()
Checks if WP_Automatic_Updater::is_disabled() returns true.
public function test_wp_automatic_updates_disabled(): array|false
test_if_failed_update()
Checks for previous auto-update failures.
public function test_if_failed_update(): array|false
Checks: auto_core_update_failed site option
Severity:
warningif non-critical failure (retry pending)warningif critical failure (updates disabled until manual update)
test_vcs_abspath()
Detects version control systems (.svn, .git, .hg, .bzr).
public function test_vcs_abspath(): array
Filter: automatic_updates_is_vcs_checkout — Allow updates despite VCS
test_check_wp_filesystem_method()
Checks if FTP credentials are required.
public function test_check_wp_filesystem_method(): array
Fails if: Site requires FTP credentials for updates
test_all_files_writable()
Verifies all core files are writable.
public function test_all_files_writable(): array|false
Process:
- Gets checksums from WordPress.org
- Checks each file’s writeability
- Reports up to 20 unwritable files
test_accepts_dev_updates()
For development versions, checks if dev updates allowed.
public function test_accepts_dev_updates(): array|false|null
Checks:
WP_AUTO_UPDATE_COREnot set to'minor'orfalseallow_dev_auto_core_updatesfilter
test_accepts_minor_updates()
Checks if security/maintenance updates allowed.
public function test_accepts_minor_updates(): array|null
Checks:
WP_AUTO_UPDATE_COREnotfalseallow_minor_auto_core_updatesfilter
Test Results Format
Each test returns:
array(
'description' => 'Human-readable explanation',
'severity' => 'pass|info|warning|fail',
)
Or null/false if test passes or doesn’t apply.
Integration with Site Health
Called by WP_Site_Health::get_test_background_updates():
$updater = new WP_Site_Health_Auto_Updates();
$tests = $updater->run_tests();
foreach ( $tests as $test ) {
if ( 'fail' === $test->severity ) {
// Mark as critical
} elseif ( 'warning' === $test->severity ) {
// Mark as recommended
}
}
Related Constants
| Constant | Values | Effect |
|---|---|---|
WP_AUTO_UPDATE_CORE |
true |
All auto-updates |
false |
No auto-updates | |
'minor' |
Security/maintenance only | |
'beta', 'rc', 'development' |
Pre-release updates | |
DISALLOW_FILE_MODS |
true |
Disables all file modifications |
AUTOMATIC_UPDATER_DISABLED |
true |
Disables automatic updater |
Related Filters
| Filter | Purpose |
|---|---|
automatic_updater_disabled |
Disable auto-updater |
allow_dev_auto_core_updates |
Allow dev version updates |
allow_minor_auto_core_updates |
Allow minor updates |
automatic_updates_is_vcs_checkout |
Allow updates in VCS dirs |