Kết nối với chúng tôi

Fix lỗi number format i18n, number_format_thousands trên WordPress

Fix lỗi number format i18n, number_format_thousands trên WordPress

Hướng dẫn sửa lỗi number format i18n, number_format_thousands_sep trên WordPress

Thời gian gần đây, nhiều website nền tảng WordPress bất ngờ xuất hiện lỗi khó chịu khi cập nhật phiên bản wordpress mới. Cụ thể, từ khi cập nhật lên phiên bản wordpress 4.6 trở lên, các số đếm > 1000 đều có dạng <số nhỏ hơn 100>number_format_thousands<số nhỏ hơn 1000>.

Cách sửa lỗi wp-statistics plugin thống kê bị lỗi number format thousands sep do bị lỗi number format i18n trong file wp-includes/functions.php để sửa lỗi number format thousands này thì cần sửa lại định dạng trong file functions.php trong thư mục wp-includes . Cách sửa đơn giản bạn chuyển wordpress của bạn tiếng việt thành tiếng anh là được. Sửa lỗi plugin wp-statistics thống kê cho wordpress hoặc khi vào mục new plugin, Thêm plugin sẽ thấy các con số hàng nghìn bị lỗi

Fix lỗi wordpress hiển thị number_format_thousands_sep đối với các số lơn hơn 1000

Và mình cũng không ngoại lệ, cảm thấy khó chịu và không chuyên nghiệp tẹo nào. A cay trên nương với kiểu hiển thị ngớ ngẩn này. Mình lọ mọ 1 thời gian và xin chia sẻ với các bạn cách fix đơn giản bên dưới:

Phiên bản tiếng Việt cách sửa như sau:

trong thư mục wp-includes mở file functions.php tìm thousands_sep trong đoạn sau

function number_format_i18n( $number, $decimals = 0 ) {
global $wp_locale;

if ( isset( $wp_locale ) ) {
$formatted = number_format( $number, absint( $decimals ), $wp_locale->number_format[‘decimal_point’], $wp_locale->number_format[‘thousands_sep’] );
} else {
$formatted = number_format( $number, absint( $decimals ) );
}

/**
* Filters the number formatted based on the locale.
*
* @since 2.8.0
*
* @param string $formatted Converted number in string format.
*/
return apply_filters( ‘number_format_i18n’, $formatted );
}

Thay từ thousands_sep thành decimals

Sau khi thay

function number_format_i18n( $number, $decimals = 0 ) {
global $wp_locale;

if ( isset( $wp_locale ) ) {
$formatted = number_format( $number, absint( $decimals ), $wp_locale->number_format[‘decimal_point’], $wp_locale->number_format[‘decimals’] );
} else {
$formatted = number_format( $number, absint( $decimals ) );
}

/**
* Filters the number formatted based on the locale.
*
* @since 2.8.0
*
* @param string $formatted Converted number in string format.
*/
return apply_filters( ‘number_format_i18n’, $formatted );
}

Như vậy bệnh error number_format_thousands sau khi sửa trong phiên bản mới chạy tiếng việt ok

Như vậy những ai đang sử dụng plugin thống kê wp statistics thì sửa để hiện chuẩn các thông số nhé.

Phiên bản tiếng Anh cách sửa như sau:

  1. Bạn tìm đến và mở file: “wp-includes/class-wp-locate.php
  2. Tiến hành thay các đoạn sau:

$this->number_format[‘thousands_sep’] = ( ‘number_format_thousands_sep’ === $thousands_sep ) ? ‘,’ : $thousands_sep;

Thành

$this->number_format[‘decimal_point’] = ‘.’;

$this->number_format[‘decimal_point’] = ( ‘number_format_decimal_point’ === $decimal_point ) ? ‘.’ : $decimal_point;

Thành

$this->number_format[‘thousands_sep’] = ‘,’;

Chúc các bạn may mắn!

Nguồn: Hiepads.net – Nguyentienthu.net

4.8/5 - (5 bình chọn)

Các bình luận

Cùng chuyên mục Thủ thuật Wordpress

Lên trên