| 1 |
<?php |
| 2 |
/** |
| 3 |
* This template is used to display the progress of [give_totals] |
| 4 |
*/ |
| 5 |
|
| 6 |
// Bail out if total goal is empty. |
| 7 |
if ( empty( $total_goal ) ) { |
| 8 |
return false; |
| 9 |
} |
| 10 |
|
| 11 |
// Set Give total progress bar color. |
| 12 |
$color = apply_filters( 'give_totals_progress_color', '#2bc253' ); |
| 13 |
|
| 14 |
// Give total. |
| 15 |
$total = ! empty( $total ) ? $total : 0; |
| 16 |
|
| 17 |
/** |
| 18 |
* Filter the goal progress output |
| 19 |
* |
| 20 |
* @since 2.1 |
| 21 |
*/ |
| 22 |
$progress = round( ( $total / $total_goal ) * 100, 2 ); |
| 23 |
|
| 24 |
// Set progress to 100 percentage if total > total_goal |
| 25 |
$progress = $total >= $total_goal ? 100 : $progress; |
| 26 |
$progress = apply_filters( 'give_goal_totals_funded_percentage_output', $progress, $total, $total_goal ); |
| 27 |
|
| 28 |
?> |
| 29 |
<div class="give-goal-progress"> |
| 30 |
<div class="raised"> |
| 31 |
<?php |
| 32 |
echo sprintf( |
| 33 |
/* translators: %s: percentage of the amount raised compared to the goal target */ |
| 34 |
__( '<span class="give-percentage">%s%%</span> funded', 'give' ), |
| 35 |
round( $progress ) |
| 36 |
); |
| 37 |
?> |
| 38 |
</div> |
| 39 |
|
| 40 |
<div class="give-progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" |
| 41 |
aria-valuenow="<?php echo esc_attr( $progress ); ?>"> |
| 42 |
<span style="width: <?php echo esc_attr( $progress ); ?>%; |
| 43 |
<?php |
| 44 |
if ( ! empty( $color ) ) { |
| 45 |
echo 'background-color:' . $color; |
| 46 |
} |
| 47 |
?> |
| 48 |
"></span> |
| 49 |
</div><!-- /.give-progress-bar --> |
| 50 |
|
| 51 |
</div><!-- /.goal-progress --> |
| 52 |
|