wp_convert_bytes_to_hr()
Устарела с версии 3.6.0. Больше не поддерживается и может быть удалена. Используйте size_format().
Converts an integer byte value to a shorthand byte value.
Хуков нет.
Возвращает
Строку. A shorthand byte value.
Использование
wp_convert_bytes_to_hr( $bytes );
- $bytes(int) (обязательный)
- An integer byte value.
Заметки
- Смотрите: size_format()
Список изменений
| С версии 2.3.0 | Введена. |
| Устарела с 3.6.0 | Use size_format() |
Код wp_convert_bytes_to_hr() wp convert bytes to hr WP 6.9.1
function wp_convert_bytes_to_hr( $bytes ) {
_deprecated_function( __FUNCTION__, '3.6.0', 'size_format()' );
$units = array( 0 => 'B', 1 => 'KB', 2 => 'MB', 3 => 'GB', 4 => 'TB' );
$log = log( $bytes, KB_IN_BYTES );
$power = ! is_nan( $log ) && ! is_infinite( $log ) ? (int) $log : 0;
$size = KB_IN_BYTES ** ( $log - $power );
if ( ! is_nan( $size ) && array_key_exists( $power, $units ) ) {
$unit = $units[ $power ];
} else {
$size = $bytes;
$unit = $units[0];
}
return $size . $unit;
}