wppaste
WordPress

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|string

    Array of resource attributes, or a URL string.
    • $hrefstring

      URL to include in resource hints. Required.
    • $asstring

      How the browser should treat the resource (script, style, image, document, etc).
    • $crossoriginstring

      Indicates the CORS policy of the specified resource.
    • $prfloat

      Expected probability that the resource hint will be used.
    • $typestring

      Type 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:3879wp_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.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 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 docblock
4.6.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 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.