wp_print_speculation_rules()
Prints the speculation rules.
For browsers that do not support speculation rules yet, the script[type="speculationrules"] tag will be ignored.
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
null. Nothing (null).
Usage
wp_print_speculation_rules(): void;
Changelog
| Since 6.8.0 | Introduced. |
wp_print_speculation_rules() wp print speculation rules code WP 7.0
function wp_print_speculation_rules(): void {
$speculation_rules = wp_get_speculation_rules();
if ( null === $speculation_rules ) {
return;
}
wp_print_inline_script_tag(
(string) wp_json_encode(
$speculation_rules,
JSON_HEX_TAG | JSON_UNESCAPED_SLASHES
),
array( 'type' => 'speculationrules' )
);
}