On this page
number_format_i18n( float $number, int $decimals ): string
Converts float number to format based on the locale.
Parameters
$numberfloat Required-
The number to convert based on locale.
$decimalsint Optional-
Precision of the number of decimal places. Default 0.
Return
string Converted number in string format.
More Information
i18n is an abbreviation for internationalization.
Source
File: wp-includes/functions.php. View all references
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
* @since 4.9.0 The `$number` and `$decimals` parameters were added.
*
* @param string $formatted Converted number in string format.
* @param float $number The number to convert based on locale.
* @param int $decimals Precision of the number of decimal places.
*/
return apply_filters( 'number_format_i18n', $formatted, $number, $decimals );
}
Hooks
- apply_filters( 'number_format_i18n',
string $formatted ,float $number ,int $decimals ) -
Filters the number formatted based on the locale.
Related
Uses
| Uses | Description |
|---|---|
| absint() wp-includes/functions.php | Converts a value to non-negative integer. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| WP_Site_Health::get_test_page_cache() wp-admin/includes/class-wp-site-health.php | Tests if a full page cache is available. |
| rest_validate_object_value_from_schema() wp-includes/rest-api.php | Validates an object value based on a schema. |
| rest_validate_array_value_from_schema() wp-includes/rest-api.php | Validates an array value based on a schema. |
| rest_validate_string_value_from_schema() wp-includes/rest-api.php | Validates a string value based on a schema. |
| WP_MS_Sites_List_Table::get_views() wp-admin/includes/class-wp-ms-sites-list-table.php | Gets links to filter sites by status. |
| WP_Privacy_Requests_Table::get_views() wp-admin/includes/class-wp-privacy-requests-table.php | Get an associative array ( id => link ) with the list of views available on this table. |
| WP_Customize_Manager::handle_load_themes_request() wp-includes/class-wp-customize-manager.php | Loads themes into the theme browsing/installation UI. |
| WP_Widget_Media::display_media_state() wp-includes/widgets/class-wp-widget-media.php | Filters the default media display states for items in the Media list table. |
| WP_Customize_Manager::save_changeset_post() wp-includes/class-wp-customize-manager.php | Saves the post for the loaded changeset. |
| print_embed_comments_button() wp-includes/embed.php | Prints the necessary markup for the embed comments button. |
| WP_Customize_Nav_Menus::enqueue_scripts() wp-includes/class-wp-customize-nav-menus.php | Enqueues scripts and styles for Customizer pane. |
| WP_Customize_Nav_Menus::customize_register() wp-includes/class-wp-customize-nav-menus.php | Adds the customizer settings and controls. |
| WP_MS_Sites_List_Table::column_users() wp-admin/includes/class-wp-ms-sites-list-table.php | Handles the users column output. |
| get_comments_number_text() wp-includes/comment-template.php | Displays the language string for the number of comments the current post has. |
| WP_MS_Users_List_Table::get_views() wp-admin/includes/class-wp-ms-users-list-table.php | |
| WP_Screen::render_screen_layout() wp-admin/includes/class-wp-screen.php | Renders the option for number of columns on the page. |
| WP_Plugins_List_Table::get_views() wp-admin/includes/class-wp-plugins-list-table.php | |
| WP_User_Search::do_paging() wp-admin/includes/deprecated.php | Handles paging for the user search query. |
| WP_List_Table::ajax_response() wp-admin/includes/class-wp-list-table.php | Handles an incoming ajax request (called from admin-ajax.php) |
| WP_List_Table::comments_bubble() wp-admin/includes/class-wp-list-table.php | Displays a comment count bubble. |
| WP_List_Table::pagination() wp-admin/includes/class-wp-list-table.php | Displays the pagination. |
| WP_MS_Themes_List_Table::get_views() wp-admin/includes/class-wp-ms-themes-list-table.php | |
| install_plugin_information() wp-admin/includes/plugin-install.php | Displays plugin information in dialog box form. |
| wp_dashboard_quota() wp-admin/includes/dashboard.php | Displays file upload quota on dashboard. |
| wp_dashboard_right_now() wp-admin/includes/dashboard.php | Dashboard widget that displays some basic stats about the site. |
| wp_network_dashboard_right_now() wp-admin/includes/dashboard.php | |
| WP_Plugin_Install_List_Table::display_rows() wp-admin/includes/class-wp-plugin-install-list-table.php | |
| wp_star_rating() wp-admin/includes/template.php | Outputs a HTML element with a star rating for a given rating. |
| WP_Users_List_Table::single_row() wp-admin/includes/class-wp-users-list-table.php | Generate HTML for a single row on the users.php admin panel. |
| WP_Users_List_Table::get_views() wp-admin/includes/class-wp-users-list-table.php | Return an associative array listing all the views that can be used with this table. |
| media_upload_library_form() wp-admin/includes/media.php | Outputs the legacy media upload form for the media library. |
| media_handle_upload() wp-admin/includes/media.php | Saves a file submitted from a POST request and create an attachment post for it. |
| wp_ajax_query_themes() wp-admin/includes/ajax-actions.php | Ajax handler for getting themes from themes_api() . |
| _wp_ajax_delete_comment_response() wp-admin/includes/ajax-actions.php | Sends back current comment total and new page links if they need to be updated. |
| wp_ajax_replyto_comment() wp-admin/includes/ajax-actions.php | Ajax handler for replying to a comment. |
| post_submit_meta_box() wp-admin/includes/meta-boxes.php | Displays post submit form fields. |
| WP_Comments_List_Table::get_views() wp-admin/includes/class-wp-comments-list-table.php | |
| WP_Terms_List_Table::column_posts() wp-admin/includes/class-wp-terms-list-table.php | |
| WP_Terms_List_Table::column_links() wp-admin/includes/class-wp-terms-list-table.php | |
| WP_Posts_List_Table::get_views() wp-admin/includes/class-wp-posts-list-table.php | |
| list_plugin_updates() wp-admin/update-core.php | Display the upgrade plugins form. |
| list_theme_updates() wp-admin/update-core.php | Display the upgrade themes form. |
| Walker_CategoryDropdown::start_el() wp-includes/class-walker-category-dropdown.php | Starts the element output. |
| Walker_Category::start_el() wp-includes/class-walker-category.php | Starts the element output. |
| wp_generate_tag_cloud() wp-includes/category-template.php | Generates a tag cloud (heatmap) from provided data. |
| wp_notify_moderator() wp-includes/pluggable.php | Notifies the moderator of the site about a new comment that is awaiting approval. |
| paginate_links() wp-includes/general-template.php | Retrieves paginated links for archive post pages. |
| timer_stop() wp-includes/load.php | Retrieve or display the time from the page start to when function is called. |
| size_format() wp-includes/functions.php | Converts a number of bytes to the largest unit the bytes will fit into. |
| wp_admin_bar_comments_menu() wp-includes/admin-bar.php | Adds edit comments link with awaiting moderation count bubble. |
| wp_admin_bar_updates_menu() wp-includes/admin-bar.php | Provides an update link if theme/plugin/core updates are available. |
| wpmu_validate_blog_signup() wp-includes/ms-functions.php | Processes new site registrations. |
| comments_popup_link() wp-includes/comment-template.php | Displays the link to the comments for the current post ID. |
| WP_Customize_Widgets::enqueue_scripts() wp-includes/class-wp-customize-widgets.php | Enqueues scripts and styles for Customizer panel and export data to JavaScript. |
Changelog
| Version | Description |
|---|---|
| 2.3.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/number_format_i18n