load_script_textdomain( string $handle, string $domain = 'default', string $path = '' ): string|false

Loads the script translated strings.

Description

See also

Parameters

$handlestringrequired
Name of the script to register a translation domain to.
$domainstringoptional
Text domain. Default 'default'.

Default:'default'

$pathstringoptional
The full file path to the directory containing translation files.

Default:''

Return

string|false The translated strings in JSON encoding on success, false if the script textdomain could not be loaded.

Source

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 );
}

Changelog

VersionDescription
5.1.0The $domain parameter was made optional.
5.0.2Uses load_script_translations() to load translation data.
5.0.0Introduced.

User Contributed Notes

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