wpseek.com
A WordPress-centric search engine for devs and theme authors



load_script_module_textdomain › WordPress Function

Since7.0.0
Deprecatedn/a
load_script_module_textdomain ( $id, $domain = 'default', $path = '' )
Parameters: (3)
  • (string) $id The script module identifier.
    Required: Yes
  • (string) $domain Optional. Text domain. Default 'default'.
    Required: No
    Default: 'default'
  • (string) $path Optional. The full file path to the directory containing translation files.
    Required: No
    Default: (empty)
Returns:
  • (string|false) The JSON-encoded translated strings for the given script module and text domain.
    False if there are none.
Defined at:
Codex:

Loads the translation data for a given script module ID and text domain.

Works like load_script_textdomain but for script modules registered via wp_register_script_module.


Source

function load_script_module_textdomain( string $id, string $domain = 'default', string $path = '' ) {
	$module = wp_script_modules()->get_registered( $id );
	if ( null === $module ) {
		return false;
	}
	$src = $module['src'];

	// Ensure src is an absolute URL for path resolution.
	if ( ! preg_match( '|^(https?:)?//|', $src ) ) {
		$src = site_url( $src );
	}

	return _load_script_textdomain_from_src( $id, $src, $domain, $path, true );
}