load_script_textdomain()
Loads the script translated strings.
No Hooks.
Returns
String|false. The translated strings in JSON encoding on success, false if the script textdomain could not be loaded.
Usage
load_script_textdomain( $handle, $domain, $path );
- $handle(string) (required)
- Name of the script to register a translation domain to.
- $domain(string)
- Text domain.
Default:'default' - $path(string)
- The full file path to the directory containing translation files.
Default:''
Notes
Changelog
| Since 5.0.0 | Introduced. |
| Since 5.0.2 | Uses load_script_translations() to load translation data. |
| Since 5.1.0 | The $domain parameter was made optional. |
load_script_textdomain() load script textdomain code WP 7.0
function load_script_textdomain( $handle, $domain = 'default', $path = '' ) {
$wp_scripts = wp_scripts();
if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
return false;
}
$src = $wp_scripts->registered[ $handle ]->src;
if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $wp_scripts->content_url && str_starts_with( $src, $wp_scripts->content_url ) ) ) {
$src = $wp_scripts->base_url . $src;
}
return _load_script_textdomain_from_src( $handle, $src, $domain, $path, false );
}