Code Duplication    Length = 9-9 lines in 6 locations

includes/admin/give-metabox-functions.php 6 locations

@@ 1437-1445 (lines=9) @@
1434
 *
1435
 * @return string
1436
 */
1437
function _give_terms_option_field_value( $field_value, $field, $postid ) {
1438
	$term_option = give_get_meta( $postid, '_give_terms_option', true );
1439
1440
	if ( in_array( $term_option, array( 'none', 'yes' ) ) ) {
1441
		$field_value = ( 'yes' === $term_option ? 'enabled' : 'disabled' );
1442
	}
1443
1444
	return $field_value;
1445
}
1446
1447
add_filter( '_give_terms_option_field_value', '_give_terms_option_field_value', 10, 3 );
1448
@@ 1490-1498 (lines=9) @@
1487
 *
1488
 * @return string
1489
 */
1490
function _give_custom_amount_field_value( $field_value, $field, $postid ) {
1491
	$custom_amount = give_get_meta( $postid, '_give_custom_amount', true );
1492
1493
	if ( in_array( $custom_amount, array( 'yes', 'no' ) ) ) {
1494
		$field_value = ( 'yes' === $custom_amount ? 'enabled' : 'disabled' );
1495
	}
1496
1497
	return $field_value;
1498
}
1499
1500
add_filter( '_give_custom_amount_field_value', '_give_custom_amount_field_value', 10, 3 );
1501
@@ 1516-1524 (lines=9) @@
1513
 *
1514
 * @return string
1515
 */
1516
function _give_goal_option_field_value( $field_value, $field, $postid ) {
1517
	$goal_option = give_get_meta( $postid, '_give_goal_option', true );
1518
1519
	if ( in_array( $goal_option, array( 'yes', 'no' ) ) ) {
1520
		$field_value = ( 'yes' === $goal_option ? 'enabled' : 'disabled' );
1521
	}
1522
1523
	return $field_value;
1524
}
1525
1526
add_filter( '_give_goal_option_field_value', '_give_goal_option_field_value', 10, 3 );
1527
@@ 1542-1550 (lines=9) @@
1539
 *
1540
 * @return string
1541
 */
1542
function _give_close_form_when_goal_achieved_value( $field_value, $field, $postid ) {
1543
	$close_form = give_get_meta( $postid, '_give_close_form_when_goal_achieved', true );
1544
1545
	if ( in_array( $close_form, array( 'yes', 'no' ) ) ) {
1546
		$field_value = ( 'yes' === $close_form ? 'enabled' : 'disabled' );
1547
	}
1548
1549
	return $field_value;
1550
}
1551
1552
add_filter( '_give_close_form_when_goal_achieved_field_value', '_give_close_form_when_goal_achieved_value', 10, 3 );
1553
@@ 1568-1576 (lines=9) @@
1565
 *
1566
 * @return string
1567
 */
1568
function _give_logged_in_only_value( $field_value, $field, $postid ) {
1569
	$guest_donation = give_get_meta( $postid, '_give_logged_in_only', true );
1570
1571
	if ( in_array( $guest_donation, array( 'yes', 'no' ) ) ) {
1572
		$field_value = ( 'yes' === $guest_donation ? 'enabled' : 'disabled' );
1573
	}
1574
1575
	return $field_value;
1576
}
1577
1578
add_filter( '_give_logged_in_only_field_value', '_give_logged_in_only_value', 10, 3 );
1579
@@ 1594-1602 (lines=9) @@
1591
 *
1592
 * @return string
1593
 */
1594
function _give_customize_offline_donations_value( $field_value, $field, $postid ) {
1595
	$customize_offline_text = give_get_meta( $postid, '_give_customize_offline_donations', true );
1596
1597
	if ( in_array( $customize_offline_text, array( 'yes', 'no' ) ) ) {
1598
		$field_value = ( 'yes' === $customize_offline_text ? 'enabled' : 'disabled' );
1599
	}
1600
1601
	return $field_value;
1602
}
1603
1604
add_filter( '_give_customize_offline_donations_field_value', '_give_customize_offline_donations_value', 10, 3 );
1605