Code Duplication    Length = 21-26 lines in 2 locations

includes/donors/class-give-donor-stats.php 1 location

@@ 86-111 (lines=26) @@
83
84
		$donated_amounts = $wpdb->get_results( $query, ARRAY_A );
85
86
		if ( ! empty( $donated_amounts ) ) {
87
			foreach ( $donated_amounts as $donation ) {
88
				// Do not include anonymous donation in calculation.
89
				if ( give_is_anonymous_donation( $donation['id'] ) ) {
90
					continue;
91
				}
92
93
				$currency_code = give_get_payment_currency_code( $donation['id'] );
94
95
				/**
96
				 * Filter the donation amount
97
				 * Note: this filter documented in payments/functions.php:give_donation_amount()
98
				 *
99
				 * @since 2.1
100
				 */
101
				$formatted_amount = apply_filters(
102
					'give_donation_amount',
103
					give_format_amount( $donation['total'], array( 'currency' => $currency_code ) ),
104
					$donation['total'],
105
					$donation['id'],
106
					array( 'type' => 'stats', 'currency' => false, 'amount' => false )
107
				);
108
109
				$donated_amount += (float) give_maybe_sanitize_amount( $formatted_amount, array( 'currency' => $currency_code  ) );
110
			}
111
		}
112
113
		return $donated_amount;
114
	}

includes/payments/class-payment-stats.php 1 location

@@ 156-176 (lines=21) @@
153
154
				$payments = $wpdb->get_results($query, ARRAY_A);
155
156
				if( ! empty( $payments ) ) {
157
					foreach ( $payments as $payment ) {
158
						$currency_code = give_get_payment_currency_code( $payment['id'] );
159
160
						/**
161
						 * Filter the donation amount
162
						 * Note: this filter documented in payments/functions.php:give_donation_amount()
163
						 *
164
						 * @since 2.1
165
						 */
166
						$formatted_amount = apply_filters(
167
							'give_donation_amount',
168
							give_format_amount(  $payment['total'], array( 'donation_id' =>  $payment['id'] ) ),
169
							$payment['total'],
170
							$payment['id'],
171
							array( 'type' => 'stats', 'currency'=> false, 'amount' => false )
172
						);
173
174
						$earnings += (float) give_maybe_sanitize_amount( $formatted_amount, array( 'currency' => $currency_code  ) );
175
					}
176
				}
177
178
			}
179