wp_resource_hints
Filter HookDescription
Filters domains and URLs for resource hints of the given relation type. as its child elements. Array of resource attributes, or a URL string. (`script`, `style`, `image`, `document`, etc). } }Hook Information
File Location |
wp-includes/general-template.php
View on GitHub
|
Hook Type | Filter |
Line Number | 3649 |
Hook Parameters
Type | Name | Description |
---|---|---|
array
|
$urls
|
{ Array of resources and their attributes, or URLs to print for resource hints. |
string
|
$relation_type
|
The relation type the URLs are printed for. One of 'dns-prefetch', 'preconnect', 'prefetch', or 'prerender'. |
Usage Examples
Basic Usage
<?php
// Hook into wp_resource_hints
add_filter('wp_resource_hints', 'my_custom_filter', 10, 2);
function my_custom_filter($urls, $relation_type) {
// Your custom filtering logic here
return $urls;
}
Source Code Context
wp-includes/general-template.php:3649
- How this hook is used in WordPress core
<?php
3644 * }
3645 * }
3646 * @param string $relation_type The relation type the URLs are printed for. One of
3647 * 'dns-prefetch', 'preconnect', 'prefetch', or 'prerender'.
3648 */
3649 $urls = apply_filters( 'wp_resource_hints', $urls, $relation_type );
3650
3651 foreach ( $urls as $key => $url ) {
3652 $atts = array();
3653
3654 if ( is_array( $url ) ) {
PHP Documentation
<?php
/**
* Filters domains and URLs for resource hints of the given relation type.
*
* @since 4.6.0
* @since 4.7.0 The `$urls` parameter accepts arrays of specific HTML attributes
* as its child elements.
*
* @param array $urls {
* 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).
* }
* }
* @param string $relation_type The relation type the URLs are printed for. One of
* 'dns-prefetch', 'preconnect', 'prefetch', or 'prerender'.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/general-template.php
Related Hooks
Related hooks will be displayed here in future updates.