: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @param array $results Query results.
private function maybe_format_amounts( $results ) {
// If the input is empty, leave early.
if ( empty( $results ) ) {
foreach ( $results as $key => $value ) {
// If the given stat card doesn't have a button class, leave early.
// If the given stat card doesn't have a button class of "is-amount," leave early.
if ( ! isset( $this->stat_cards[ $key ]['button_classes'] ) || ! in_array( 'is-amount', $this->stat_cards[ $key ]['button_classes'], true ) ) {
// Split the input by space to look for the count.
$input_arr = (array) explode( ' ', $value );
// If the given stat card doesn't have a count, leave early.
if ( empty( $this->stat_cards[ $key ]['has_count'] ) || ! isset( $input_arr[1] ) ) {
// Format the given amount and split the input by space.
$results[ $key ] = wpforms_format_amount( $value, true );
// The fields are stored as a `decimal` in the DB, and appears here as the string.
// But all strings values, passed to wpforms_format_amount() are sanitized.
// There is no need to sanitize it, as it is already a regular numeric string.
$amount = wpforms_format_amount( (float) ( $input_arr[0] ?? $value ), true );
// Format the amount with the concatenation of count in parentheses.
// Example: 2185.52000000 (79).
$results[ $key ] = sprintf(
esc_html( $input_arr[1] ) // 1: Would be count of the records.