Script loader: enable fetchpriority attribute in the wp_preload_resources filter.

Add `fetchpriority` to the attributes accepted by the `wp_preload_resources` filter. Developers can now use this filter to set fetchpriority for resources being preloaded.

Props nihar007, luboslives, tabrisrp.
Fixes #58510.


Built from https://develop.svn.wordpress.org/trunk@57789


git-svn-id: http://core.svn.wordpress.org/trunk@57290 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Adam Silverstein 2024-03-07 07:08:09 +00:00
parent 175bea53b7
commit 3c6a55d3f9
2 changed files with 12 additions and 10 deletions

View File

@ -3579,6 +3579,7 @@ function wp_preload_resources() {
* Filters domains and URLs for resource preloads.
*
* @since 6.1.0
* @since 6.6.0 Added the `$fetchpriority` attribute.
*
* @param array $preload_resources {
* Array of resources and their attributes, or URLs to print for resource preloads.
@ -3594,6 +3595,7 @@ function wp_preload_resources() {
* @type string $media Accepts media types or media queries. Allows responsive preloading.
* @type string $imagesizes Responsive source size to the source Set.
* @type string $imagesrcset Responsive image sources to the source set.
* @type string $fetchpriority Fetchpriority value for the resource.
* }
* }
*/
@ -3641,7 +3643,7 @@ function wp_preload_resources() {
}
// Ignore non-supported attributes.
$non_supported_attributes = array( 'as', 'crossorigin', 'href', 'imagesrcset', 'imagesizes', 'type', 'media' );
$non_supported_attributes = array( 'as', 'crossorigin', 'href', 'imagesrcset', 'imagesizes', 'type', 'media', 'fetchpriority' );
if ( ! in_array( $resource_key, $non_supported_attributes, true ) && ! is_numeric( $resource_key ) ) {
continue;
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.6-alpha-57788';
$wp_version = '6.6-alpha-57789';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.