wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes



load_script_textdomain › WordPress Function

Depuis5.0.0
Dépréciéen/a
› load_script_textdomain ( $handle, $domain = 'default', $path = '' )
Paramètres: (3)
  • (string) $handle Name of the script to register a translation domain to.
    Requis: Oui
  • (string) $domain Optional. Text domain. Default 'default'.
    Requis: Non
    Défaut: 'default'
  • (string) $path Optional. The full file path to the directory containing translation files.
    Requis: Non
    Défaut: (vide)
Voir:
  • WP_Scripts::set_translations()
Retourne:
  • (string|false) The translated strings in JSON encoding on success,
    false if the script textdomain could not be loaded.
Défini(e) dans:
Codex:
Changelog:
  • 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 );
}