wp_resource_hints
Filters domains and URLs for resource hints of the given relation type.
Использование
add_filter( 'wp_resource_hints', 'wp_kama_resource_hints_filter', 10, 2 ); /** * Function for `wp_resource_hints` filter-hook. * * @param array $urls Array of resources and their attributes, or URLs to print for resource hints. * @param string $relation_type The relation type the URLs are printed for. One of 'dns-prefetch', 'preconnect', 'prefetch', or 'prerender'. * * @return array */ function wp_kama_resource_hints_filter( $urls, $relation_type ){ // filter... return $urls; }
- $urls(массив)
Array of resources and their attributes, or URLs to print for resource hints.
-
...$0(массив|строка)
Array of resource attributes, or a URL string.-
href(строка)
URL to include in resource hints. Required. -
as(строка)
How the browser should treat the resource (script, style, image, document, etc). -
crossorigin(строка)
Indicates the CORS policy of the specified resource. -
pr(float)
Expected probability that the resource hint will be used. - type(строка)
Type of the resource (text/html, text/css, etc).
-
-
- $relation_type(строка)
- The relation type the URLs are printed for. One of 'dns-prefetch', 'preconnect', 'prefetch', or 'prerender'.
Список изменений
С версии 4.6.0 | Введена. |
С версии 4.7.0 | The $urls parameter accepts arrays of specific HTML attributes as its child elements. |
Где вызывается хук
wp_resource_hints
wp-includes/general-template.php 3504
$urls = apply_filters( 'wp_resource_hints', $urls, $relation_type );