wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_get_speculation_rules_default_configuration › WordPress Function

Seit7.1.0
Veraltetn/v
wp_get_speculation_rules_default_configuration ( Keine Parameter )
Zugriff:
  • private
Gibt zurück:
  • (array<string,string>) Associative array with 'mode' and 'eagerness' keys.
Definiert in:
Codex:

Returns the default speculation rules configuration that the value 'auto' resolves to.

WordPress Core defaults to a mode of 'prefetch' and an eagerness of 'conservative'. Hosting providers can override either default by way of the WP_SPECULATIVE_LOADING_DEFAULT_MODE and WP_SPECULATIVE_LOADING_DEFAULT_EAGERNESS constants or environment variables. This only changes what the 'auto' value resolves to, so a plugin which supplies an explicit mode or eagerness via the {@see 'wp_speculation_rules_configuration'} filter continues to take precedence. Note that an eagerness of 'immediate' is not permitted as a default, since WordPress does not allow it for the document-level rules that it generates.


Quellcode

function wp_get_speculation_rules_default_configuration(): array {
	$default_mode = 'prefetch';
	$mode         = wp_get_speculative_loading_override( 'WP_SPECULATIVE_LOADING_DEFAULT_MODE' );
	if ( WP_Speculation_Rules::is_valid_mode( $mode ) ) {
		$default_mode = $mode;
	}

	$default_eagerness = 'conservative';
	$eagerness         = wp_get_speculative_loading_override( 'WP_SPECULATIVE_LOADING_DEFAULT_EAGERNESS' );
	if (
		WP_Speculation_Rules::is_valid_eagerness( $eagerness ) &&
		// 'immediate' is a valid eagerness, but for safety WordPress does not allow it for document-level rules.
		'immediate' !== $eagerness
	) {
		$default_eagerness = $eagerness;
	}

	return array(
		'mode'      => $default_mode,
		'eagerness' => $default_eagerness,
	);
}