WP_Translation_File::create()public staticWP 6.5.0

Creates a new WP_Translation_File instance for a given file.

Method of the class: WP_Translation_File{}

No Hooks.

Return

false|WP_Translation_File.

Usage

$result = WP_Translation_File::create( $file, ?string $filetype );
$file(string) (required)
File name.
?string $filetype **
-
Default: null

Changelog

Since 6.5.0 Introduced.

WP_Translation_File::create() code WP 6.7.1

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;
	}
}