diff -r 48c4eec2b7e6 -r 8c2e4d02f4ef wp/wp-includes/class-wp-dependencies.php --- a/wp/wp-includes/class-wp-dependencies.php Fri Sep 05 18:40:08 2025 +0200 +++ b/wp/wp-includes/class-wp-dependencies.php Fri Sep 05 18:52:52 2025 +0200 @@ -490,4 +490,42 @@ return true; } + + /** + * Get etag header for cache validation. + * + * @since 6.7.0 + * + * @global string $wp_version The WordPress version string. + * + * @param string[] $load Array of script or style handles to load. + * @return string Etag header. + */ + public function get_etag( $load ) { + /* + * Note: wp_get_wp_version() is not used here, as this file can be included + * via wp-admin/load-scripts.php or wp-admin/load-styles.php, in which case + * wp-includes/functions.php is not loaded. + */ + global $wp_version; + + $etag = "WP:{$wp_version};"; + + foreach ( $load as $handle ) { + if ( ! array_key_exists( $handle, $this->registered ) ) { + continue; + } + + $ver = $this->registered[ $handle ]->ver ?? $wp_version; + $etag .= "{$handle}:{$ver};"; + } + + /* + * This is not intended to be cryptographically secure, just a fast way to get + * a fixed length string based on the script versions. As this file does not + * load the full WordPress environment, it is not possible to use the salted + * wp_hash() function. + */ + return 'W/"' . md5( $etag ) . '"'; + } }