getFormFeaturedImage($form_id))
&& $atts['show_featured_image']
&& $atts['columns'] !== '1'
) {
/*
* Filters the image size used in card layouts.
*
* @param string The image size.
* @param array Form grid attributes.
*/
$image_size = apply_filters('give_form_grid_image_size', $atts['image_size'], $atts);
$image_attr = '';
if ('auto' !== $atts['image_height']) {
$image_attr = [
'style' => 'height: ' . $atts['image_height'],
];
}
$image = wp_get_attachment_image(attachment_url_to_postid($imageSrc), $image_size, false, $image_attr);
echo "
";
} elseif (
give_is_setting_enabled($give_settings['form_featured_img'])
&& ($imageSrc = $formTemplate->getFormFeaturedImage($form_id))
&& $atts['show_featured_image']
&& $atts['columns'] === '1') {
echo "
";
}
?>
ID, '_give_goal_option', true);
// Sanity check - ensure form has pass all condition to show goal.
$hide_goal = (isset($atts['show_goal']) && !filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN))
|| empty($form->ID)
|| (is_singular('give_forms') && !give_is_setting_enabled($goal_option))
|| !give_is_setting_enabled($goal_option) || 0 === $form->goal;
// Maybe display the goal progress bar.
if (!$hide_goal) :
do_action('give_form_grid_goal_progress_stats_before', $form_id);
$goal_progress_stats = give_goal_progress_stats($form);
$goal_format = $goal_progress_stats['format'];
$color = $atts['progress_bar_color'];
$show_goal = isset($atts['show_goal']) ? filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN) : true;
/**
* @since 3.16.0 Revert changes implemented on the 3.14.0 version
* @since 3.14.0 Replace "$form->get_earnings()" with (new DonationQuery())->form($form->ID)->sumIntendedAmount()
*/
$shortcode_stats = apply_filters(
'give_goal_shortcode_stats',
[
'income' => $form->get_earnings(),
'goal' => $goal_progress_stats['raw_goal'],
],
$form_id,
$goal_progress_stats,
$args
);
$income = $shortcode_stats['income'];
$goal = $shortcode_stats['goal'];
switch ($goal_format) {
case 'donation':
$progress = $goal ? round(($form->get_sales() / $goal) * 100, 2) : 0;
$progress_bar_value = $form->get_sales() >= $goal ? 100 : $progress;
break;
case 'donors':
$progress = $goal ? round((give_get_form_donor_count($form->ID) / $goal) * 100, 2) : 0;
$progress_bar_value = give_get_form_donor_count($form->ID) >= $goal ? 100 : $progress;
break;
case 'percentage':
$progress = $goal ? round(($income / $goal) * 100, 2) : 0;
$progress_bar_value = $income >= $goal ? 100 : $progress;
break;
default:
$progress = $goal ? round(($income / $goal) * 100, 2) : 0;
$progress_bar_value = $income >= $goal ? 100 : $progress;
break;
}
?>
';
?>