Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Plugin Name: PDB Comma Decimal Separator Display
- * Description: alters the display of decimal numbers to use comma as the decimal separator, and point as the thousands separator
- */
- add_filter('pdb-before_display_form_element', 'xnau_show_comma_decimals', 10, 2 );
- function xnau_show_comma_decimals( $display, $field )
- {
- // we are only modifying these form element types
- if ( $field->form_element === 'decimal' || $field->form_element === 'currency' ) {
- // count the number of decimal digits in the number
- $decimals = strlen( strstr( $field->value, '.' ) ) -1;
- // this function formats the number using comma for the decimal separator and dot for the thousands separator
- $display = number_format( $field->value, $decimals, ',', '.' );
- }
- return $display;
- }
Add Comment
Please, Sign In to add comment