/** * Add extra submitted fields to the Funds Recipient tab in the campaign admin page. * * @param array $data * @param Charitable_Campaign $campaign * @return array $data */ function ed_add_campaign_funding_data($data, Charitable_Campaign $campaign) { // Get the data that was submitted when the campaign was added. $submitted = $campaign->get('submission_data'); $campaign_form = new Charitable_Ambassadors_Campaign_Form(); // Go through all user fields and add their value to the list of fields to display. foreach ($campaign_form->get_user_fields() as $key => $field) { $data[$key] = array('label' => isset($field['label']) ? $field['label'] : $key, 'value' => isset($submitted[$key]) ? $submitted[$key] : '-'); } return $data; }
/** * Static method that is fired within 24 hours after a campaign is finished. * * @param int $campaign_id * @return boolean * @access public * @static * @since 1.1.0 */ public static function send_with_campaign_id($campaign_id) { if (!charitable_get_helper('emails')->is_enabled_email(self::get_email_id())) { return false; } $campaign = new Charitable_Campaign($campaign_id); $time_since_ended = $campaign->get_time_since_ended(); /* If the since since ended is 0 (campaign is still going) or more than 24 hours, return false */ if ($time_since_ended == 0 || $time_since_ended > 86400) { return false; } $email = new Charitable_Email_Campaign_End(array('campaign' => $campaign)); $email->send(); return true; }
/** * Returns the donation form content for a particular campaign, through AJAX. * * @return void * @since 1.2.3 */ function charitable_ajax_get_donation_form() { if (!isset($_POST['campaign_id'])) { wp_send_json_error(); } /* Load the template files. */ require_once charitable()->get_path('includes') . 'public/charitable-template-functions.php'; require_once charitable()->get_path('includes') . 'public/charitable-template-hooks.php'; $campaign = new Charitable_Campaign($_POST['campaign_id']); ob_start(); $campaign->get_donation_form()->render(); $output = ob_get_clean(); wp_send_json_success($output); die; }
/** * Display the campaign's goal amount. * * @return string * @access public * @since 1.1.0 */ public function get_campaign_goal() { if (!$this->has_valid_campaign()) { return ''; } return $this->campaign->get_monetary_goal(); }
/** * Delete all campaign donation records for a given donation. * * @param int $donation_id * @access public * @static * @since 1.2.0 * @return bool */ public static function delete_donation_records($donation_id) { $table = charitable_get_table('campaign_donations'); foreach ($table->get_campaigns_for_donation($donation_id) as $campaign_id) { Charitable_Campaign::flush_donations_cache($campaign_id); } return $table->delete_by('donation_id', $donation_id); }
/** * Output the campaign donation status on campaigns displayed within the loop. * * @param Charitable_Campaign $campaign * @param mixed[] $args * @return void * @since 1.0.0 */ function charitable_template_campaign_loop_donate_link($campaign, $args = array()) { if (isset($args['button']) && 'donate' != $args['button']) { return; } $campaign->donate_button_loop_template(); }
$thumbnail_size = apply_filters('charitable_campaign_widget_thumbnail_size', 'medium'); if (!$campaigns->have_posts()) { return; } echo $view_args['before_widget']; if (!empty($view_args['title'])) { echo $view_args['before_title'] . $view_args['title'] . $view_args['after_title']; } ?> <ol class="campaigns"> <?php while ($campaigns->have_posts()) { $campaigns->the_post(); $campaign = new Charitable_Campaign(get_the_ID()); ?> <li class="campaign"> <?php if ($show_thumbnail && has_post_thumbnail()) { the_post_thumbnail($thumbnail_size); } ?> <h6 class="campaign-title"><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h6>
/** * Display the campaign progress barometer. * * @uses charitable_template * * @param Charitable_Campaign $campaign * @return void * @since 1.0.0 */ function reach_template_campaign_progress_barometer(Charitable_Campaign $campaign) { if ($campaign->has_goal()) { charitable_template('campaign/progress-barometer.php', array('campaign' => $campaign)); } }
/** * 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'];
/** * Flush the donations cache for every campaign receiving a donation. * * @param int $donation_id * @return void * @since 1.0.0 */ function charitable_flush_campaigns_donation_cache($donation_id) { $campaign_donations = charitable_get_table('campaign_donations')->get_donation_records($donation_id); foreach ($campaign_donations as $campaign_donation) { Charitable_Campaign::flush_donations_cache($campaign_donation->campaign_id); } wp_cache_delete($donation_id, 'charitable_donation'); }
/** * 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; }
/** * Flush the donations cache for every campaign receiving a donation. * * @param int $donation_id * @return void * @access public * @static * @since 1.0.0 */ public static function flush_campaigns_donation_cache($donation_id) { $campaign_donations = charitable_get_table('campaign_donations')->get_donation_records($donation_id); foreach ($campaign_donations as $campaign_donation) { Charitable_Campaign::flush_donations_cache($campaign_donation->campaign_id); } }