Skip to content

Instantly share code, notes, and snippets.

@Benunc
Created July 1, 2020 14:11
Show Gist options
  • Save Benunc/926699be362e4b4e058bde5579b82524 to your computer and use it in GitHub Desktop.
Save Benunc/926699be362e4b4e058bde5579b82524 to your computer and use it in GitHub Desktop.
VERY experimental shortcode for outputting the donor counts for a form. Outputs " A HUGE thanks to our ____ donors this year
<?php
function my_donor_count_shortcode( $atts ) {
// Defaults
$atts = shortcode_atts( array(
'form_id' => false,
), $atts, 'donor_count' );
$number = give_get_form_donor_count( $atts['form_id'] );
if ( $number > 0 ) :
ob_start();
?>
<div class="donor-count-wrap">
A HUGE thanks to our <span class="donor-count-donor-number"><?php echo $number; ?> donors </span>this year!
</div>
<?php
else :
//If you don't have donation forms that fit this query
?>
<div class="donor-count-no-donors-wrap">No donors yet for this form.</div>
<?php endif;
$output = ob_get_contents();
ob_end_clean();
return $output;
wp_reset_query();
}
add_shortcode( 'donor_count', 'my_donor_count_shortcode' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment