Making WordPress.org


Ignore:
Timestamp:
01/15/2016 06:07:53 PM (9 years ago)
Author:
iandunn
Message:

WordCamp Budgets Dashboard: Centralize currency conversion and formatting.

These will be used by upcoming modules in addition to the current one.

Note that escaping was removed from format_amount(), since that should be done as late as possible.

wp_kses() is performant in this situation. See https://www.tollmanz.com/wp-kses-performance/

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network/includes/payment-requests-list-table.php

    r2273 r2298  
    173173        $amount = get_post_meta( $request->ID, '_camppayments_payment_amount', true );
    174174
    175         $amount = preg_replace( '#[^\d.-]+#', '', $amount );
    176         $amount = floatval( $amount );
    177 
    178         if ( strpos( $currency, 'null' ) === false && $amount ) {
    179             $output = sprintf( '%s %s', esc_html( number_format( $amount, 2 ) ), esc_html( $currency ) );
    180 
    181             if ( $currency != 'USD' ) {
    182                 $usd_amount = Payment_Requests_Dashboard::convert_currency( $currency, 'usd', $amount );
    183                 if ( $usd_amount )
    184                     $output .= sprintf( '<br />~&nbsp;%s&nbsp;USD', esc_html( number_format( $usd_amount, 2 ) ) );
    185             }
    186 
    187             return $output;
    188         } elseif ( $amount ) {
    189             return esc_html( $amount );
    190         }
     175        return wp_kses(
     176            \WordCamp\Budgets_Dashboard\format_amount( $amount, $currency ),
     177            array( 'br' => array() )
     178        );
    191179    }
    192180
Note: See TracChangeset for help on using the changeset viewer.