# charitable/1.7.0.5/templates/donor-loop.php

Charitable – Donation &amp; Fundraising Platform (Donation Forms, Recurring Donations &amp; Fundraising Campaigns), version 1.7.0.5. 70 lines.

- Page: https://pluginprobe.com/plugins/charitable/1.7.0.5/code/templates/donor-loop.php
- Raw: https://pluginprobe.com/plugins/charitable/1.7.0.5/raw/templates/donor-loop.php
- Modified: 2022-09-21T15:01:56+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/charitable/1.7.0.5/code/templates/donor-loop.php#L10-L20`.

```php
<?php
/**
 * Display a list of donors, either for a specific campaign or sitewide.
 *
 * Override this template by copying it to yourtheme/charitable/donor-loop.php
 *
 * @package Charitable/Templates/Donor
 * @author  WP Charitable LLC
 * @since   1.5.0
 * @version 1.6.31
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/* Donors have to be included in the view args. */
if ( ! array_key_exists( 'donors', $view_args ) ) {
	return;
}

$donors            = $view_args['donors'];
$args              = $view_args;
$campaign_id       = $view_args['campaign'];
$hide_if_no_donors = array_key_exists( 'hide_if_no_donors', $view_args ) && $view_args['hide_if_no_donors'];

if ( ! charitable_is_campaign_page() && 'current' === $campaign_id ) {
	return;
}

if ( ! $donors->count() && $hide_if_no_donors ) {
	return;
}

if ( 'all' == $campaign_id ) {
	$args['campaign'] = false;
} elseif ( 'current' == $campaign_id ) {
	$args['campaign'] = get_the_ID();
}

$orientation = array_key_exists( 'orientation', $view_args ) ? $view_args['orientation'] : 'vertical';
$style       = '';

if ( 'horizontal' == $orientation ) {
	$width = array_key_exists( 'width', $view_args ) ? $view_args['width'] : get_option( 'thumbnail_size_w', 100 );
	if ( 100 != $width ) {
		$style = '<style>.donors-list.donors-list-horizontal .donor{ width:' . $width . 'px; }</style>';
	}
}

if ( $donors->count() ) :
	echo $style;
	?>
	<ol class="donors-list donors-list-<?php echo $orientation; ?>">
		<?php
		foreach ( $donors as $donor ) :

			$args['donor'] = $donor;

			charitable_template( 'donor-loop/donor.php', $args );

		endforeach;
		?>
	</ol>
<?php else : ?>
	<p><?php _e( 'No donors yet. Be the first!', 'charitable' ); ?></p>
	<?php
endif;

```
