Filter hook 'translation_file_format'

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

View Source

translation_file_format

Filter Hook
Description
Filters the preferred file format for translation files. Can be used to disable the use of PHP files for translations.

Hook Information

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

Hook Parameters

Type Name Description
string $preferred_format Preferred file format. Possible values: 'php', 'mo'. Default: 'php'.
string $domain The text domain.

Usage Examples

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

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

Source Code Context

wp-includes/l10n.php:816 - How this hook is used in WordPress core
<?php
 811  	 * @since 6.5.0
 812  	 *
 813  	 * @param string $preferred_format Preferred file format. Possible values: 'php', 'mo'. Default: 'php'.
 814  	 * @param string $domain           The text domain.
 815  	 */
 816  	$preferred_format = apply_filters( 'translation_file_format', 'php', $domain );
 817  	if ( ! in_array( $preferred_format, array( 'php', 'mo' ), true ) ) {
 818  		$preferred_format = 'php';
 819  	}
 820  
 821  	$translation_files = array();

PHP Documentation

<?php
/**
	 * Filters the preferred file format for translation files.
	 *
	 * Can be used to disable the use of PHP files for translations.
	 *
	 * @since 6.5.0
	 *
	 * @param string $preferred_format Preferred file format. Possible values: 'php', 'mo'. Default: 'php'.
	 * @param string $domain           The text domain.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/l10n.php
Related Hooks

Related hooks will be displayed here in future updates.