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



load_script_textdomain › WordPress Function

Since5.0.0
Deprecatedn/a
load_script_textdomain ( $handle, $domain = 'default', $path = '' )
Parameters: (3)
  • (string) $handle Name of the script to register a translation domain to.
    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)
See:
  • WP_Scripts::set_translations()
Returns:
  • (string|false) The translated strings in JSON encoding on success,
    false if the script textdomain could not be loaded.
Defined at:
Codex:
Change Log:
  • 5.0.2
  • 5.1.0

Loads the script translated strings.



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