Пример #1
0
/**
 * The template for displaying campaign content within loops.
 *
 * Override this template by copying it to yourtheme/charitable/campaign-loop/campaign.php
 *
 * @author  Studio 164a
 * @package Charitable/Templates/Campaign
 * @since   1.0.0
 * @version 1.0.0
 */
if (!defined('ABSPATH')) {
    exit;
}
// Exit if accessed directly
$campaign = charitable_get_current_campaign();
?>
<li id="campaign-<?php 
echo get_the_ID();
?>
" <?php 
post_class();
?>
>
<?php 
/**
 * @hook charitable_campaign_content_loop_before
 */
do_action('charitable_campaign_content_loop_before', $campaign, $view_args);
?>
	<a href="<?php 
 /**
  * Adds the modal donation window to a campaign page.
  *
  * @param   Charitable_Campaign $campaign
  * @return  void
  * @since   1.0.0
  */
 function charitable_template_campaign_modal_donation_window()
 {
     if (Charitable::CAMPAIGN_POST_TYPE != get_post_type()) {
         return;
     }
     $campaign = charitable_get_current_campaign();
     if ($campaign->has_ended()) {
         return;
     }
     if ('modal' == charitable_get_option('donation_form_display', 'separate_page')) {
         charitable_template('campaign/donate-modal-window.php', array('campaign' => $campaign));
     }
 }
 /**
  * Load the donation template if we're looking at the donate page.
  *
  * @param   string $template
  * @return  string
  * @access  protected
  * @since   1.0.0
  */
 protected function get_donate_template($template)
 {
     /* If a donation ID is included, make sure it belongs to the current user. */
     $donation_id = get_query_var('donation_id', false);
     if ($donation_id) {
         $donation = charitable_get_donation($donation_id);
         if (!$donation || !$donation->is_from_current_user()) {
             wp_safe_redirect(charitable_get_permalink('campaign_donation_page'));
             exit;
         }
     }
     /* If the campaign has exired, redirect the user to the campaign page. */
     $campaign = charitable_get_current_campaign();
     if (!$campaign || $campaign->has_ended()) {
         wp_safe_redirect(get_permalink($campaign->ID));
         exit;
     }
     do_action('charitable_is_donate_page');
     $new_template = apply_filters('charitable_donate_page_template', array('campaign-donation-page.php', 'page.php', 'index.php'));
     return charitable_get_template_path($new_template, $template);
 }
/**
 * Returns the current donation form.
 *
 * @return 	Charitable_Donation_Form_Interface|false
 * @since 	1.0.0
 */
function charitable_get_current_donation_form()
{
    $campaign = charitable_get_current_campaign();
    return false === $campaign ? false : $campaign->get_donation_form();
}
 /**
  * Create class object. A private constructor, so this is used in a singleton context. 
  * 
  * @return  void
  * @access  private
  * @since   1.0.0
  */
 private function __construct()
 {
     $this->campaign = charitable_get_current_campaign();
 }
 /**
  * Adds custom post classes when viewing campaign. 
  *
  * @return  string[] 
  * @access  public
  * @since   1.0.0
  */
 public function campaign_post_class($classes)
 {
     $campaign = charitable_get_current_campaign();
     if (!$campaign) {
         return $classes;
     }
     $classes[] = $campaign->has_goal() ? 'campaign-has-goal' : 'campaign-has-no-goal';
     $classes[] = $campaign->is_endless() ? 'campaign-is-endless' : 'campaign-has-end-date';
     return $classes;
 }