WP_Script_Modules::get_src( string $id ): string

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Gets the versioned URL for a script module src.

Description

If $version is set to false, the version number is the currently installed WordPress version. If $version is set to null, no version is added.
Otherwise, the string passed in $version is used.

Parameters

$idstringrequired
The script module identifier.

Return

string The script module src with a version if relevant.

Source

private function get_src( string $id ): string {
	if ( ! isset( $this->registered[ $id ] ) ) {
		return '';
	}

	$script_module = $this->registered[ $id ];
	$src           = $script_module['src'];

	if ( false === $script_module['version'] ) {
		$src = add_query_arg( 'ver', get_bloginfo( 'version' ), $src );
	} elseif ( null !== $script_module['version'] ) {
		$src = add_query_arg( 'ver', $script_module['version'], $src );
	}

	/**
	 * Filters the script module source.
	 *
	 * @since 6.5.0
	 *
	 * @param string $src Module source url.
	 * @param string $id  Module identifier.
	 */
	$src = apply_filters( 'script_module_loader_src', $src, $id );

	return $src;
}

Hooks

apply_filters( ‘script_module_loader_src’, string $src, string $id )

Filters the script module source.

Changelog

VersionDescription
6.5.0Introduced.

User Contributed Notes

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