From 7f9c9dc73122e8d676b25be1f599ec487489060b Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Fri, 18 Mar 2022 20:48:02 +0000 Subject: [PATCH] Formatting: Add support for formatting sizes as PB, EB, ZB, and YB. Props henry.wright, Presskopp Fixes #40875 Built from https://develop.svn.wordpress.org/trunk@52955 git-svn-id: http://core.svn.wordpress.org/trunk@52544 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/default-constants.php | 5 +++++ wp-includes/functions.php | 13 +++++++++++-- wp-includes/version.php | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/wp-includes/default-constants.php b/wp-includes/default-constants.php index 64baf0d20c..56754033a0 100644 --- a/wp-includes/default-constants.php +++ b/wp-includes/default-constants.php @@ -22,11 +22,16 @@ function wp_initial_constants() { * Constants for expressing human-readable data sizes in their respective number of bytes. * * @since 4.4.0 + * @since 6.0.0 `PB_IN_BYTES`, `EB_IN_BYTES`, `ZB_IN_BYTES`, and `YB_IN_BYTES` were added. */ define( 'KB_IN_BYTES', 1024 ); define( 'MB_IN_BYTES', 1024 * KB_IN_BYTES ); define( 'GB_IN_BYTES', 1024 * MB_IN_BYTES ); define( 'TB_IN_BYTES', 1024 * GB_IN_BYTES ); + define( 'PB_IN_BYTES', 1024 * TB_IN_BYTES ); + define( 'EB_IN_BYTES', 1024 * PB_IN_BYTES ); + define( 'ZB_IN_BYTES', 1024 * EB_IN_BYTES ); + define( 'YB_IN_BYTES', 1024 * ZB_IN_BYTES ); /**#@-*/ // Start of run timestamp. diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 1a9ecfe859..0e0f626e56 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -441,11 +441,11 @@ function number_format_i18n( $number, $decimals = 0 ) { } /** - * Convert number of bytes largest unit bytes will fit into. + * Converts a number of bytes to the largest unit the bytes will fit into. * * It is easier to read 1 KB than 1024 bytes and 1 MB than 1048576 bytes. Converts * number of bytes to human readable number by taking the number of that unit - * that the bytes will go into it. Supports TB value. + * that the bytes will go into it. Supports YB value. * * Please note that integers in PHP are limited to 32 bits, unless they are on * 64 bit architecture, then they have 64 bit size. If you need to place the @@ -455,6 +455,7 @@ function number_format_i18n( $number, $decimals = 0 ) { * Technically the correct unit names for powers of 1024 are KiB, MiB etc. * * @since 2.3.0 + * @since 6.0.0 Support for PB, EB, ZB, and YB was added. * * @param int|string $bytes Number of bytes. Note max integer size for integers. * @param int $decimals Optional. Precision of number of decimal places. Default 0. @@ -462,6 +463,14 @@ function number_format_i18n( $number, $decimals = 0 ) { */ function size_format( $bytes, $decimals = 0 ) { $quant = array( + /* translators: Unit symbol for yottabyte. */ + _x( 'YB', 'unit symbol' ) => YB_IN_BYTES, + /* translators: Unit symbol for zettabyte. */ + _x( 'ZB', 'unit symbol' ) => ZB_IN_BYTES, + /* translators: Unit symbol for exabyte. */ + _x( 'EB', 'unit symbol' ) => EB_IN_BYTES, + /* translators: Unit symbol for petabyte. */ + _x( 'PB', 'unit symbol' ) => PB_IN_BYTES, /* translators: Unit symbol for terabyte. */ _x( 'TB', 'unit symbol' ) => TB_IN_BYTES, /* translators: Unit symbol for gigabyte. */ diff --git a/wp-includes/version.php b/wp-includes/version.php index 97cbf6567c..0b7911c0c4 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.0-alpha-52954'; +$wp_version = '6.0-alpha-52955'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.