| 1 |
<?php |
| 2 |
/** |
| 3 |
* Display a list of donors, either for a specific campaign or sitewide. |
| 4 |
* |
| 5 |
* Override this template by copying it to yourtheme/charitable/donor-loop.php |
| 6 |
* |
| 7 |
* @package Charitable/Templates/Donor |
| 8 |
* @author Studio 164a |
| 9 |
* @since 1.5.0 |
| 10 |
* @version 1.5.0 |
| 11 |
*/ |
| 12 |
|
| 13 |
// Exit if accessed directly. |
| 14 |
if ( ! defined( 'ABSPATH' ) ) { exit; } |
| 15 |
|
| 16 |
/* Donors have to be included in the view args. */ |
| 17 |
if ( ! array_key_exists( 'donors', $view_args ) ) { |
| 18 |
return; |
| 19 |
} |
| 20 |
|
| 21 |
$donors = $view_args['donors']; |
| 22 |
$args = $view_args; |
| 23 |
$campaign_id = $view_args['campaign']; |
| 24 |
|
| 25 |
if ( ! charitable_is_campaign_page() && 'current' === $campaign_id ) { |
| 26 |
return; |
| 27 |
} |
| 28 |
|
| 29 |
if ( 'all' == $campaign_id ) { |
| 30 |
$args['campaign'] = false; |
| 31 |
} elseif ( 'current' == $campaign_id ) { |
| 32 |
$args['campaign'] = get_the_ID(); |
| 33 |
} |
| 34 |
|
| 35 |
$orientation = array_key_exists( 'orientation', $view_args ) ? $view_args['orientation'] : 'vertical'; |
| 36 |
$style = ''; |
| 37 |
|
| 38 |
if ( 'horizontal' == $orientation ) { |
| 39 |
$width = array_key_exists( 'width', $view_args ) ? $view_args['width'] : get_option( 'thumbnail_size_w', 100 ); |
| 40 |
if ( 100 != $width ) { |
| 41 |
$style = '<style>.donors-list.donors-list-horizontal .donor{ width:' . $width . 'px; }</style>'; |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
if ( $donors->count() ) : |
| 46 |
echo $style; |
| 47 |
?> |
| 48 |
<ol class="donors-list donors-list-<?php echo $orientation; ?>"> |
| 49 |
<?php |
| 50 |
foreach ( $donors as $donor ) : |
| 51 |
|
| 52 |
$args['donor'] = $donor; |
| 53 |
|
| 54 |
charitable_template( 'donor-loop/donor.php', $args ); |
| 55 |
|
| 56 |
endforeach; |
| 57 |
?> |
| 58 |
</ol> |
| 59 |
<?php else : ?> |
| 60 |
<p><?php _e( 'No donors yet. Be the first!', 'charitable' ); ?></p> |
| 61 |
<?php |
| 62 |
endif; |
| 63 |
|