pre_load_script_translations filter-hookWP 5.0.2

Pre-filters script translations for the given file, script handle and text domain.

Returning a non-null value allows to override the default logic, effectively short-circuiting the function.

Usage

add_filter( 'pre_load_script_translations', 'wp_kama_pre_load_script_translations_filter', 10, 4 );

/**
 * Function for `pre_load_script_translations` filter-hook.
 * 
 * @param string|false|null $translations JSON-encoded translation data.
 * @param string|false      $file         Path to the translation file to load. False if there isn't one.
 * @param string            $handle       Name of the script to register a translation domain to.
 * @param string            $domain       The text domain.
 *
 * @return string|false|null
 */
function wp_kama_pre_load_script_translations_filter( $translations, $file, $handle, $domain ){

	// filter...
	return $translations;
}
$translations(string|false|null)
JSON-encoded translation data.
Default: null
$file(string|false)
Path to the translation file to load. False if there isn't one.
$handle(string)
Name of the script to register a translation domain to.
$domain(string)
The text domain.

Changelog

Since 5.0.2 Introduced.

Where the hook is called

load_script_translations()
pre_load_script_translations
wp-includes/l10n.php 1155
$translations = apply_filters( 'pre_load_script_translations', null, $file, $handle, $domain );

Where the hook is used in WordPress

Usage not found.