Loads the translation data for a given script module ID and text domain.
Description
Works like load_script_textdomain() but for script modules registered via wp_register_script_module().
Parameters
$idstringrequired- The script module identifier.
$domainstringoptional- Text domain. Default
'default'.Default:
'default' $pathstringoptional- The full file path to the directory containing translation files.
Default:
''
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 );
}
Changelog
| Version | Description |
|---|---|
| 7.0.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.