WP_Translation_File::create( string $file, string|null $filetype = null ): false|WP_Translation_File

In this article

Creates a new WP_Translation_File instance for a given file.

Parameters

$filestringrequired
File name.
$filetypestring|nulloptional
File type. Default inferred from file name.

Default:null

Return

false|WP_Translation_File

Source

public static function create( string $file, string $filetype = null ) {
	if ( ! is_readable( $file ) ) {
		return false;
	}

	if ( null === $filetype ) {
		$pos = strrpos( $file, '.' );
		if ( false !== $pos ) {
			$filetype = substr( $file, $pos + 1 );
		}
	}

	switch ( $filetype ) {
		case 'mo':
			return new WP_Translation_File_MO( $file );
		case 'php':
			return new WP_Translation_File_PHP( $file );
		default:
			return false;
	}
}

Changelog

VersionDescription
6.5.0Introduced.

User Contributed Notes

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