get_translations_for_domain( string $domain ): Translations|NOOP_Translations

Returns the Translations instance for a text domain.

Description

If there isn’t one, returns empty Translations instance.

Parameters

$domainstringrequired
Text domain. Unique identifier for retrieving translated strings.

Return

Translations|NOOP_Translations A Translations instance.

Source

function get_translations_for_domain( $domain ) {
	global $l10n;
	if ( isset( $l10n[ $domain ] ) || ( _load_textdomain_just_in_time( $domain ) && isset( $l10n[ $domain ] ) ) ) {
		return $l10n[ $domain ];
	}

	static $noop_translations = null;
	if ( null === $noop_translations ) {
		$noop_translations = new NOOP_Translations();
	}

	$l10n[ $domain ] = &$noop_translations;

	return $noop_translations;
}

Changelog

VersionDescription
2.8.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.