Test Failed
Push — release/1.8.12 ( b58a2f...d255b1 )
by Ravinder
375:09 queued 372:17
created

templates/shortcode-goal.php (11 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * This template is used to display the goal with [give_goal]
4
 */
5
6
$form        = new Give_Donate_Form( $form_id );
7
$goal_option = give_get_meta( $form->ID, '_give_goal_option', true );
8
9
//Sanity check - ensure form has pass all condition to show goal.
10
if (
11
	( isset( $args['show_goal'] ) &&  ! filter_var( $args['show_goal'], FILTER_VALIDATE_BOOLEAN ) )
0 ignored issues
show
Expected 1 space before "!"; 2 found
Loading history...
12
	|| empty( $form->ID )
13
	|| ( is_singular( 'give_forms' ) && ! give_is_setting_enabled( $goal_option ) )
14
	|| ! give_is_setting_enabled( $goal_option )
15
	|| 0 === $form->goal
16
) {
17
	return false;
18
}
19
20
$goal_format = give_get_meta( $form_id, '_give_goal_format', true );
21
$color       = give_get_meta( $form_id, '_give_goal_color', true );
22
$show_text   = isset( $args['show_text'] ) ? filter_var( $args['show_text'], FILTER_VALIDATE_BOOLEAN ) : true;
23
$show_bar    = isset( $args['show_bar'] ) ? filter_var( $args['show_bar'], FILTER_VALIDATE_BOOLEAN ) : true;
24
25
26
/**
27
 * Filter the form income
28
 *
29
 * @since 1.8.8
30
 */
31
$income = apply_filters( 'give_goal_amount_raised_output', $form->get_earnings(), $form_id, $form );
32
33
/**
34
 * Filter the form
35
 *
36
 * @since 1.8.8
37
 */
38
$goal = apply_filters( 'give_goal_amount_target_output', $form->goal, $form_id, $form );
39
40
41
/**
42
 * Filter the goal progress output
43
 *
44
 * @since 1.8.8
45
 */
46
$progress = apply_filters( 'give_goal_amount_funded_percentage_output', round( ( $income / $goal ) * 100, 2 ), $form_id, $form );
47
48
49
// Set progress to 100 percentage if income > goal.
50
if ( $income >= $goal ) {
51
	$progress = 100;
52
}
53
54
?>
55
<div class="give-goal-progress">
56
	<?php if ( ! empty( $show_text ) ) : ?>
57
		<div class="raised">
58
			<?php
59
			if ( $goal_format !== 'percentage' ) :
0 ignored issues
show
Found "!== '". Use Yoda Condition checks, you must
Loading history...
60
61
				// Get formatted amount.
62
				$income = give_human_format_large_amount( give_format_amount( $income, array( 'sanitize' => false ) ) );
63
				$goal   = give_human_format_large_amount( give_format_amount( $goal, array( 'sanitize' => false ) ) );
64
65
				echo sprintf(
0 ignored issues
show
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'sprintf'
Loading history...
66
				/* translators: 1: amount of income raised 2: goal target ammount */
0 ignored issues
show
This line of the multi-line function call does not seem to be indented correctly. Expected 20 spaces, but found 16.
Loading history...
67
					__( '%1$s of %2$s raised', 'give' ),
68
					'<span class="income">' . give_currency_filter( $income ) . '</span>',
0 ignored issues
show
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'give_currency_filter'
Loading history...
69
					'<span class="goal-text">' . give_currency_filter( $goal ) . '</span>'
0 ignored issues
show
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'give_currency_filter'
Loading history...
70
				);
71
72
73
			elseif ( $goal_format == 'percentage' ) :
0 ignored issues
show
Found "== '". Use Yoda Condition checks, you must
Loading history...
74
75
				echo sprintf(
0 ignored issues
show
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'sprintf'
Loading history...
76
				/* translators: %s: percentage of the amount raised compared to the goal target */
0 ignored issues
show
This line of the multi-line function call does not seem to be indented correctly. Expected 20 spaces, but found 16.
Loading history...
77
					__( '%s%% funded', 'give' ),
78
					'<span class="give-percentage">' . round( $progress ) . '</span>'
0 ignored issues
show
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'round'
Loading history...
79
				);
80
81
			endif;
82
			?>
83
		</div>
84
	<?php endif; ?>
85
86
87
	<?php if ( ! empty( $show_bar ) ) : ?>
88
		<div class="give-progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="<?php echo esc_attr( $progress ); ?>">
89
			<span style="width: <?php echo esc_attr( $progress ); ?>%;<?php if ( ! empty( $color ) ) {
90
				echo 'background-color:' . $color;
0 ignored issues
show
Expected next thing to be a escaping function, not '$color'
Loading history...
91
			} ?>"></span>
92
		</div><!-- /.give-progress-bar -->
93
	<?php endif; ?>
94
95
</div><!-- /.goal-progress -->