On this page
WP_Site_Health_Auto_Updates::test_constants( string $constant, bool|string|array $value ): array
Tests if auto-updates related constants are set correctly.
Parameters
$constantstring Required-
The name of the constant to check.
$valuebool|string|array Required-
The value that the constant should be, if set, or an array of acceptable values.
Return
array The test results.
Source
File: wp-admin/includes/class-wp-site-health-auto-updates.php. View all references
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',
);
}
}
Related
Uses
| Uses | Description |
|---|---|
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
| esc_html() wp-includes/formatting.php | Escaping for HTML blocks. |
Used By
| Used By | Description |
|---|---|
| WP_Site_Health_Auto_Updates::run_tests() wp-admin/includes/class-wp-site-health-auto-updates.php | Runs tests to determine if auto-updates can run. |
Changelog
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/test_constants