Code Duplication    Length = 11-23 lines in 2 locations

includes/payments/functions.php 2 locations

@@ 1356-1378 (lines=23) @@
1353
 *
1354
 * @return int $purchase Donation ID.
1355
 */
1356
function give_get_donation_id_by_key( $key ) {
1357
	global $wpdb;
1358
1359
	$purchase = $wpdb->get_var(
1360
		$wpdb->prepare(
1361
			"
1362
				SELECT post_id
1363
				FROM $wpdb->postmeta
1364
				WHERE meta_key = '_give_payment_purchase_key'
1365
				AND meta_value = %s
1366
				ORDER BY post_id DESC
1367
				LIMIT 1
1368
				",
1369
			$key
1370
		)
1371
	);
1372
1373
	if ( $purchase != null ) {
1374
		return $purchase;
1375
	}
1376
1377
	return 0;
1378
}
1379
1380
1381
/**
@@ 1391-1401 (lines=11) @@
1388
 *
1389
 * @return int $purchase Donation ID.
1390
 */
1391
function give_get_purchase_id_by_transaction_id( $key ) {
1392
	global $wpdb;
1393
1394
	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) );
1395
1396
	if ( $purchase != null ) {
1397
		return $purchase;
1398
	}
1399
1400
	return 0;
1401
}
1402
1403
/**
1404
 * Retrieve all notes attached to a donation