WP_Site_Health_Auto_Updates::test_constants()publicWP 5.2.0

Tests if auto-updates related constants are set correctly.

Метод класса: WP_Site_Health_Auto_Updates{}

Хуков нет.

Возвращает

Массив. The test results.

Использование

$WP_Site_Health_Auto_Updates = new WP_Site_Health_Auto_Updates();
$WP_Site_Health_Auto_Updates->test_constants( $constant, $value );
$constant(строка) (обязательный)
The name of the constant to check.
$value(true|false|строка|массив) (обязательный)
The value that the constant should be, if set, or an array of acceptable values.

Список изменений

С версии 5.2.0 Введена.
С версии 5.5.1 The $value parameter can accept an array.

Код WP_Site_Health_Auto_Updates::test_constants() WP 6.5.2

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',
		);
	}
}