/** * Display a widget with a link to donate to a campaign. * * @author Studio 164a * @since 1.0.0 */ if (!defined('ABSPATH')) { exit; } // Exit if accessed directly if (!charitable_is_campaign_page() && 'current' == $view_args['campaign_id']) { return; } $widget_title = apply_filters('widget_title', $view_args['title']); $campaign_id = $view_args['campaign_id'] == 'current' ? get_the_ID() : $view_args['campaign_id']; $campaign = new Charitable_Campaign($campaign_id); if ($campaign->has_ended()) { return; } $suggested_donations = $campaign->get_suggested_donations(); $currency_helper = charitable()->get_currency_helper(); if (empty($suggested_donations) && !$campaign->get('allow_custom_donations')) { return; } echo $view_args['before_widget']; if (!empty($widget_title)) { echo $view_args['before_title'] . $widget_title . $view_args['after_title']; } $form = new Charitable_Donation_Amount_Form($campaign); $form->render(); echo $view_args['after_widget'];
/** * Add the donation form straight into the campaign page. * * @param Charitable_Campaign $campaign * @return void * @since 1.0.0 */ function charitable_template_campaign_donation_form_in_page(Charitable_Campaign $campaign) { if ($campaign->has_ended()) { return; } if ('same_page' == charitable_get_option('donation_form_display', 'separate_page')) { charitable_get_current_donation_form()->render(); } }
/** * If we are viewing a single campaign page, add a class to the body for the style of donation form. * * @param string[] $classes * @return string[] * @access public * @since 1.0.0 */ public function add_body_classes($classes) { if (charitable_is_campaign_page()) { $campaign = new Charitable_Campaign(get_the_ID()); if ($campaign->has_ended()) { $classes[] = 'campaign-ended'; } else { $classes[] = 'donation-form-display-' . charitable_get_option('donation_form_display', 'separate_page'); } } return $classes; }