WordPress.org

Make WordPress Core

Ticket #10555: number-format-int-only.diff

File number-format-int-only.diff, 5.1 KB (added by nbachiyski, 8 years ago)
  • wp-includes/locale.php

     
    178178                // Numbers formatting
    179179                // See http://php.net/number_format
    180180
    181                 /* translators: $decimals argument for http://php.net/number_format, default is 0 */
    182                 $trans = __('number_format_decimals');
    183                 $this->number_format['decimals'] = ('number_format_decimals' == $trans) ? 0 : $trans;
    184 
    185                 /* translators: $dec_point argument for http://php.net/number_format, default is . */
    186                 $trans = __('number_format_decimal_point');
    187                 $this->number_format['decimal_point'] = ('number_format_decimal_point' == $trans) ? '.' : $trans;
    188 
    189181                /* translators: $thousands_sep argument for http://php.net/number_format, default is , */
    190182                $trans = __('number_format_thousands_sep');
    191183                $this->number_format['thousands_sep'] = ('number_format_thousands_sep' == $trans) ? ',' : $trans;
  • wp-includes/functions.php

     
    126126}
    127127
    128128/**
    129  * Convert number to format based on the locale.
     129 * Convert integer number to format based on the locale.
    130130 *
    131131 * @since 2.3.0
    132132 *
    133  * @param mixed $number The number to convert based on locale.
    134  * @param int $decimals Precision of the number of decimal places.
     133 * @param int $number The number to convert based on locale.
     134 * @param int $decimals Precision of the number of decimal places. Deprectated.
    135135 * @return string Converted number in string format.
    136136 */
    137137function number_format_i18n( $number, $decimals = null ) {
    138138        global $wp_locale;
    139         // let the user override the precision only
    140         $decimals = ( is_null( $decimals ) ) ? $wp_locale->number_format['decimals'] : intval( $decimals );
    141 
    142         $num = number_format( $number, $decimals, $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep'] );
    143 
    144         // let the user translate digits from latin to localized language
    145         return apply_filters( 'number_format_i18n', $num );
     139        $number = (int)$number;
     140        if ( !is_null( $decimals ) ) _deprecated_argument( __FUNCTION__, '3.0' );
     141        $formatted = number_format( $number, 0, null, $wp_locale->number_format['thousands_sep'] );
     142        return apply_filters( 'number_format_i18n', $formatted );
    146143}
    147144
    148145/**
     
    163160 * @since 2.3.0
    164161 *
    165162 * @param int|string $bytes Number of bytes. Note max integer size for integers.
    166  * @param int $decimals Precision of number of decimal places.
     163 * @param int $decimals Precision of number of decimal places. Deprecated.
    167164 * @return bool|string False on failure. Number string on success.
    168165 */
    169 function size_format( $bytes, $decimals = null ) {
     166function size_format( $bytes ) {
    170167        $quant = array(
    171168                // ========================= Origin ====
    172169                'TB' => 1099511627776,  // pow( 1024, 4)
     
    175172                'kB' => 1024,           // pow( 1024, 1)
    176173                'B ' => 1,              // pow( 1024, 0)
    177174        );
    178 
     175        if ( !is_null( $decimals ) ) _deprecated_argument( __FUNCTION__, '3.0' );
    179176        foreach ( $quant as $unit => $mag )
    180177                if ( doubleval($bytes) >= $mag )
    181                         return number_format_i18n( $bytes / $mag, $decimals ) . ' ' . $unit;
     178                        return number_format_i18n( round( $bytes / $mag ) ) . ' ' . $unit;
    182179
    183180        return false;
    184181}
  • wp-admin/admin-header.php

     
    3535//<![CDATA[
    3636addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
    3737var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time() ?>'};
    38 var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = '<?php echo substr($pagenow, 0, -4); ?>', typenow = '<?php echo $typenow; ?>', adminpage = '<?php echo $admin_body_class; ?>',  thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>', decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>';
     38var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = '<?php echo substr($pagenow, 0, -4); ?>', typenow = '<?php echo $typenow; ?>', adminpage = '<?php echo $admin_body_class; ?>',  thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>';
    3939//]]>
    4040</script>
    4141<?php
  • wp-includes/load.php

     
    215215        $mtime = $mtime[1] + $mtime[0];
    216216        $timeend = $mtime;
    217217        $timetotal = $timeend-$timestart;
    218         $r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision );
     218        $r = number_format( $timetotal, $precision );
    219219        if ( $display )
    220220                echo $r;
    221221        return $r;