wpseek.com
WordPress开发者和主题制作者的搜索引擎



load_script_textdomain › WordPress Function

Since5.0.0
已弃用n/a
› load_script_textdomain ( $handle, $domain = 'default', $path = '' )
参数: (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'
  • (string) $path Optional. The full file path to the directory containing translation files.
    Required: No
    默认: (empty)
查看:
  • WP_Scripts::set_translations()
返回:
  • (string|false) The translated strings in JSON encoding on success,
    false if the script textdomain could not be loaded.
定义在:
文档:
Change Log:
  • 5.0.2
  • 5.1.0

Loads the script translated strings.



源码

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