WordPress.org

Make WordPress Core

Ticket #10555: 10555.diif

File 10555.diif, 917 bytes (added by westi, 4 years ago)

Alternative patch which preserves the functionality if the callee supplies a precision

Line 
1### Eclipse Workspace Patch 1.0
2#P wordpress-trunk
3Index: wp-includes/functions.php
4===================================================================
5--- wp-includes/functions.php   (revision 12385)
6+++ wp-includes/functions.php   (working copy)
7@@ -138,7 +138,16 @@
8 function number_format_i18n( $number, $decimals = null ) {
9        global $wp_locale;
10        // let the user override the precision only
11-       $decimals = ( is_null( $decimals ) ) ? $wp_locale->number_format['decimals'] : intval( $decimals );
12+       if ( is_null( $decimals ) ) {
13+               if ( !is_float($number) ) {
14+                       $decimals =  $wp_locale->number_format['decimals'];
15+               } else {
16+                       // If the number is not floating point don't show any significant figures.
17+                       $decimals = 0;
18+               }
19+       } else {
20+               $decimals = intval( $decimals );
21+       }
22 
23        $num = number_format( $number, $decimals, $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep'] );
24