WP_Translation_File_MO::detect_endian_and_validate_file()
Detects endian and validates file.
Метод класса: WP_Translation_File_MO{}
Хуков нет.
Возвращает
false|'V'|'N'
. V for little endian, N for big endian, or false on failure.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->detect_endian_and_validate_file( $header );
- $header(строка) (обязательный)
- File contents.
Список изменений
С версии 6.5.0 | Введена. |
Код WP_Translation_File_MO::detect_endian_and_validate_file() WP Translation File MO::detect endian and validate file WP 6.6.2
protected function detect_endian_and_validate_file( string $header ) { $big = unpack( 'N', $header ); if ( false === $big ) { return false; } $big = reset( $big ); if ( false === $big ) { return false; } $little = unpack( 'V', $header ); if ( false === $little ) { return false; } $little = reset( $little ); if ( false === $little ) { return false; } // Force cast to an integer as it can be a float on x86 systems. See https://core.trac.wordpress.org/ticket/60678. if ( (int) self::MAGIC_MARKER === $big ) { return 'N'; } // Force cast to an integer as it can be a float on x86 systems. See https://core.trac.wordpress.org/ticket/60678. if ( (int) self::MAGIC_MARKER === $little ) { return 'V'; } $this->error = 'Magic marker does not exist'; return false; }