WP_Speculation_Rules::is_valid_modepublic staticWP 6.8.0

Checks whether the given speculation rules mode is valid.

Method of the class: WP_Speculation_Rules{}

No Hooks.

Returns

bool. True if valid, false otherwise.

Usage

$result = WP_Speculation_Rules::is_valid_mode( $mode ): bool;
$mode(mixed) (required)
Speculation rules mode.

Changelog

Since 6.8.0 Introduced.
Since 7.1.0 The $mode param now allows mixed and not just string.

WP_Speculation_Rules::is_valid_mode() code WP 7.1

public static function is_valid_mode( $mode ): bool {
	return is_string( $mode ) && isset( self::$mode_allowlist[ $mode ] );
}