Creates a new WP_Translation_File instance for a given file.
Parameters
$file
stringrequired- File name.
$filetype
string|nulloptional- File type. Default inferred from file name.
Default:
null
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
Version | Description |
---|---|
6.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.