WP_Site_Health_Auto_Updates::test_constants() WordPress Method

The WP_Site_Health_Auto_Updates::test_constants() method is used to check for the existence of the constants necessary for the auto-updates feature to work. This includes the WP_AUTO_UPDATE_CORE constant, as well as the AUTOMATIC_UPDATER_DISABLED and WP_AUTO_UPDATE_CORE constants. If any of these constants are not defined, the auto-updates feature will not be enabled.

WP_Site_Health_Auto_Updates::test_constants( string $constant, bool|string|array $value ) #

Test if auto-updates related constants are set correctly.


Parameters

$constant

(string)(Required)The name of the constant to check.

$value

(bool|string|array)(Required)The value that the constant should be, if set, or an array of acceptable values.


Top ↑

Return

(array) The test results.


Top ↑

Source

File: wp-admin/includes/class-wp-site-health-auto-updates.php

	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: %s: Name of the constant used. */
					__( 'The %s constant is defined and enabled.' ),
					"<code>$constant</code>"
				),
				'severity'    => 'fail',
			);
		}
	}


Top ↑

Changelog

Changelog
VersionDescription
5.5.1The $value parameter can accept an array.
5.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.