From 712ca22293f710d502b51ee10c955d03a0c7430d Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 31 May 2021 15:38:46 +0000 Subject: [PATCH] Docs: Improve documentation for the `wp_resource_hints` filter. Clarify that as of WordPress 4.7, the `$urls` parameter can accept arrays of specific HTML attributes as its child elements, in addition to URLs. Follow-up to [37920], [38826]. Props vanyukov, Rahmohn, desrosj, peterwilsoncc, SergeyBiryukov. Fixes #52842. git-svn-id: https://develop.svn.wordpress.org/trunk@51048 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/general-template.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index 0b59b935d3..a246660c56 100644 --- a/src/wp-includes/general-template.php +++ b/src/wp-includes/general-template.php @@ -3294,9 +3294,25 @@ function wp_resource_hints() { * Filters domains and URLs for resource hints of 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 URLs to print for resource hints. - * @param string $relation_type The relation type the URLs are printed for, e.g. 'preconnect' or 'prerender'. + * @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, + * e.g. 'preconnect' or 'prerender'. */ $urls = apply_filters( 'wp_resource_hints', $urls, $relation_type );