WP_Dependencies::get_etag( string[] $load ): string

In this article

Get etag header for cache validation.

Parameters

$loadstring[]required
Array of script or style handles to load.

Return

string Etag header.

Source

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 ) . '"';
}

Changelog

VersionDescription
6.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.