/**
* Show Give Goals
* @since 1.0
*
* @param int $form_id
*
* @return bool
*/
function give_show_goal_progress($form_id)
{
$goal_option = get_post_meta($form_id, '_give_goal_option', true);
$form = new Give_Donate_Form($form_id);
$goal = $form->goal;
$income = $form->get_earnings();
$color = get_post_meta($form_id, '_give_goal_color', true);
if (empty($form->ID) || $goal_option !== 'yes' || $goal == 0) {
return false;
}
$progress = round($income / $goal * 100, 2);
if ($income > $goal) {
$progress = 100;
}
$output = '<div class="goal-progress">';
$output .= '<div class="raised">';
$output .= sprintf(_x('%s of %s raised', 'give', 'This text displays the amount of income raised compared to the goal.'), '<span class="income">' . give_currency_filter(give_format_amount($income)) . '</span>', '<span class="goal-text">' . give_currency_filter(give_format_amount($goal))) . '</span>';
$output .= '</div>';
$output .= '<div class="progress-bar">';
$output .= '<span style="width: ' . esc_attr($progress) . '%;';
if (!empty($color)) {
$output .= 'background-color:' . $color;
}
$output .= '"></span>';
$output .= '</div></div><!-- /.goal-progress -->';
echo apply_filters('give_goal_output', $output);
}