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



load_script_module_textdomain › WordPress Function

Depuis7.0.0
Dépréciéen/a
› load_script_module_textdomain ( $id, $domain = 'default', $path = '' )
Paramètres: (3)
  • (string) $id The script module identifier.
    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)
Retourne:
  • (string|false) The JSON-encoded translated strings for the given script module and text domain.
    False if there are none.
Défini(e) dans:
Codex:

Loads the translation data for a given script module ID and text domain.

Works like load_script_textdomain but for script modules registered via wp_register_script_module.


Source

function load_script_module_textdomain( string $id, string $domain = 'default', string $path = '' ) {
	$module = wp_script_modules()->get_registered( $id );
	if ( null === $module ) {
		return false;
	}
	$src = $module['src'];

	// Ensure src is an absolute URL for path resolution.
	if ( ! preg_match( '|^(https?:)?//|', $src ) ) {
		$src = site_url( $src );
	}

	return _load_script_textdomain_from_src( $id, $src, $domain, $path, true );
}