Filter hook 'pre_load_script_translations'

in WP Core File wp-includes/l10n.php at line 1297

View Source

pre_load_script_translations

Filter Hook
Description
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.

Hook Information

File Location wp-includes/l10n.php View on GitHub
Hook Type Filter
Line Number 1297

Hook Parameters

Type Name Description
string|false|null $translations JSON-encoded translation data. Default null.
string|false $file Path to the translation file to load. False if there isn't one.
string $handle Name of the script to register a translation domain to.
string $domain The text domain.

Usage Examples

Basic Usage
<?php
// Hook into pre_load_script_translations
add_filter('pre_load_script_translations', 'my_custom_filter', 10, 4);

function my_custom_filter($translations, $file, $handle, $domain) {
    // Your custom filtering logic here
    return $translations;
}

Source Code Context

wp-includes/l10n.php:1297 - How this hook is used in WordPress core
<?php
1292  	 * @param string|false|null $translations JSON-encoded translation data. Default null.
1293  	 * @param string|false      $file         Path to the translation file to load. False if there isn't one.
1294  	 * @param string            $handle       Name of the script to register a translation domain to.
1295  	 * @param string            $domain       The text domain.
1296  	 */
1297  	$translations = apply_filters( 'pre_load_script_translations', null, $file, $handle, $domain );
1298  
1299  	if ( null !== $translations ) {
1300  		return $translations;
1301  	}
1302  

PHP Documentation

<?php
/**
	 * 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.
	 *
	 * @since 5.0.2
	 *
	 * @param string|false|null $translations JSON-encoded translation data. Default null.
	 * @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.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 4
  • File: wp-includes/l10n.php
Related Hooks

Related hooks will be displayed here in future updates.