load_script_textdomain()
Loads the script translated strings.
Хуков нет.
Возвращает
Строку|false. The translated strings in JSON encoding on success, false if the script textdomain could not be loaded.
Использование
load_script_textdomain( $handle, $domain, $path );
- $handle(строка) (обязательный)
- Name of the script to register a translation domain to.
- $domain(строка)
- Text domain.
По умолчанию:'default' - $path(строка)
- The full file path to the directory containing translation files.
По умолчанию:''
Заметки
- Смотрите: WP_Scripts::set_translations()
Список изменений
| С версии 5.0.0 | Введена. |
| С версии 5.0.2 | Uses load_script_translations() to load translation data. |
| С версии 5.1.0 | The $domain parameter was made optional. |
Код load_script_textdomain() load script textdomain 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 );
}