wp_get_speculation_rules_default_configuration()
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 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.
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Returns
array<string, string>. Associative array with 'mode' and 'eagerness' keys.
Usage
wp_get_speculation_rules_default_configuration(): array;
Changelog
| Since 7.1.0 | Introduced. |
wp_get_speculation_rules_default_configuration() wp get speculation rules default configuration code WP 7.1
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,
);
}