apply_filters( 'wp_resource_hints', array $urls, string $relation_type )
- Since
- 4.6.0, 4.7.0
Filters domains and URLs for resource hints of the given relation type.
Compatibility
- WordPress
- since 4.7.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Parameters
$urlsarray- { Array of resources and their attributes, or URLs to print for resource hints.
@type array|string ...$0 { Array of resource attributes, or a URL string.
@type string $href URL to include in resource hints. Required.
@type string $as How the browser should treat the resource (script,style,image,document, etc).
@type string $crossorigin Indicates the CORS policy of the specified resource.
@type float $pr Expected probability that the resource hint will be used.
@type string $type Type of the resource (text/html,text/css, etc).
} }...$0array|stringArray of resource attributes, or a URL string.$hrefstringURL to include in resource hints. Required.$asstringHow the browser should treat the resource (script,style,image,document, etc).$crossoriginstringIndicates the CORS policy of the specified resource.$prfloatExpected probability that the resource hint will be used.$typestringType of the resource (text/html,text/css, etc).
$relation_typestring- The relation type the URLs are printed for. One of 'dns-prefetch', 'preconnect', 'prefetch', or 'prerender'.
Where this hook fires · 1
wp-includes/general-template.php:3663wp_resource_hints()
Source code
* @type string $type Type of the resource (`text/html`, `text/css`, etc). * } * } * @param string $relation_type The relation type the URLs are printed for. One of * 'dns-prefetch', 'preconnect', 'prefetch', or 'prerender'. */ $urls = apply_filters( 'wp_resource_hints', $urls, $relation_type ); foreach ( $urls as $key => $url ) { $atts = array(); if ( is_array( $url ) ) { if ( isset( $url['href'] ) ) {Changelog
Introduced in 4.6.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
4.7.0
The
$urls parameter accepts arrays of specific HTML attributes as its child elements.from the docblock4.6.0
Introduced.from the docblock
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
- Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.