| 1 |
<?php |
| 2 |
/** |
| 3 |
* Display a widget with a link to donate to a campaign. |
| 4 |
* |
| 5 |
* Override this template by copying it to yourtheme/charitable/widgets/donate.php |
| 6 |
* |
| 7 |
* @package Charitable/Templates/Widgets |
| 8 |
* @author WP Charitable LLC |
| 9 |
* @since 1.0.0 |
| 10 |
* @version 1.5.0 |
| 11 |
* @version 1.8.8.6 |
| 12 |
*/ |
| 13 |
|
| 14 |
// Exit if accessed directly. |
| 15 |
if ( ! defined( 'ABSPATH' ) ) { |
| 16 |
exit; |
| 17 |
} |
| 18 |
|
| 19 |
if ( ! charitable_is_campaign_page() && 'current' == $view_args['campaign_id'] ) : // phpcs:ignore |
| 20 |
return; |
| 21 |
endif; |
| 22 |
|
| 23 |
$charitable_widget_title = apply_filters( 'widget_title', $view_args['title'] ); |
| 24 |
$charitable_campaign_id = 'current' == $view_args['campaign_id'] ? get_the_ID() : $view_args['campaign_id']; // phpcs:ignore |
| 25 |
$charitable_campaign = charitable_get_campaign( $charitable_campaign_id ); |
| 26 |
|
| 27 |
if ( ! $charitable_campaign || ! $charitable_campaign->can_receive_donations() ) : |
| 28 |
return; |
| 29 |
endif; |
| 30 |
|
| 31 |
$charitable_suggested_donations = $charitable_campaign->get_suggested_donations(); |
| 32 |
|
| 33 |
if ( empty( $charitable_suggested_donations ) && ! $charitable_campaign->get( 'allow_custom_donations' ) ) : |
| 34 |
return; |
| 35 |
endif; |
| 36 |
|
| 37 |
echo $view_args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 38 |
|
| 39 |
if ( ! empty( $charitable_widget_title ) ) : |
| 40 |
echo $view_args['before_title'] . esc_html( $charitable_widget_title ) . $view_args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 41 |
endif; |
| 42 |
|
| 43 |
$charitable_form = new Charitable_Donation_Amount_Form( $charitable_campaign ); |
| 44 |
$charitable_form->render(); |
| 45 |
|
| 46 |
echo $view_args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 47 |
|