WP_Site_Health_Auto_Updates
- Since
- 5.2.0
- Source
wp-admin/includes/class-wp-site-health-auto-updates.php:10
Class for testing automatic updates in the WordPress code.
Compatibility
- WordPress
- since 5.2.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Hooks and filters fired · 4
Every hook that fires from inside WP_Site_Health_Auto_Updates, in the order it appears in the class, grouped by the method that fires it.
WP_Site_Health_Auto_Updates::test_filters_automatic_updater_disabled()
- apply_filters( automatic_updater_disabled )filter line 125
WP_Site_Health_Auto_Updates::test_vcs_abspath()
- apply_filters( automatic_updates_is_vcs_checkout )filter line 254
Methods · 12
- __construct()WP_Site_Health_Auto_Updates constructor.
- run_tests()Runs tests to determine if auto-updates can run.
- test_constants()Tests if auto-updates related constants are set correctly.
- test_wp_version_check_attached()Checks if updates are intercepted by a filter.
- test_filters_automatic_updater_disabled()Checks if automatic updates are disabled by a filter.
- test_wp_automatic_updates_disabled()Checks if automatic updates are disabled.
- test_if_failed_update()Checks if automatic updates have tried to run, but failed, previously.
- test_vcs_abspath()Checks if WordPress is controlled by a VCS (Git, Subversion etc).
- test_check_wp_filesystem_method()Checks if we can access files without providing credentials.
- test_all_files_writable()Checks if core files are writable by the web user/group.
- test_accepts_dev_updates()Checks if the install is using a development branch and can use nightly packages.
- test_accepts_minor_updates()Checks if the site supports automatic minor updates.
Source code
#[AllowDynamicProperties]class WP_Site_Health_Auto_Updates { /** * WP_Site_Health_Auto_Updates constructor. * * @since 5.2.0 */ public function __construct() { require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; } /** * Runs tests to determine if auto-updates can run. * * @since 5.2.0 * * @return array The test results. */ public function run_tests() { $tests = array( $this->test_constants( 'WP_AUTO_UPDATE_CORE', array( true, 'beta', 'rc', 'development', 'branch-development', 'minor' ) ), $this->test_wp_version_check_attached(), $this->test_filters_automatic_updater_disabled(), $this->test_wp_automatic_updates_disabled(), $this->test_if_failed_update(), $this->test_vcs_abspath(), $this->test_check_wp_filesystem_method(), $this->test_all_files_writable(), $this->test_accepts_dev_updates(), $this->test_accepts_minor_updates(), ); $tests = array_filter( $tests ); $tests = array_map( static function ( $test ) { $test = (object) $test; if ( empty( $test->severity ) ) { $test->severity = 'warning'; } return $test; }, $tests ); return $tests; } /** * Tests if auto-updates related constants are set correctly. * * @since 5.2.0 * @since 5.5.1 The `$value` parameter can accept an array. * * @param string $constant The name of the constant to check. * @param bool|string|array $value The value that the constant should be, if set, * or an array of acceptable values. * @return array|null The test results if there are any constants set incorrectly, * or null if the test passed. */ public function test_constants( $constant, $value ) { $acceptable_values = (array) $value; if ( defined( $constant ) && ! in_array( constant( $constant ), $acceptable_values, true ) ) { return array( 'description' => sprintf( /* translators: 1: Name of the constant used. 2: Value of the constant used. */ __( 'The %1$s constant is defined as %2$s' ), "<code>$constant</code>", '<code>' . esc_html( var_export( constant( $constant ), true ) ) . '</code>' ), 'severity' => 'fail', ); } return null; }Changelog
Introduced in 5.2.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-admin/includes/class-wp-site-health-auto-updates.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.