/**
  * Get the data being exported
  *
  * @return array $data
  */
 public function get_data()
 {
     global $wpdb;
     $data = array();
     $campaign = $this->campaign;
     $campaign = atcf_get_campaign($campaign);
     $backers = $campaign->backers();
     if (empty($backers)) {
         return $data;
     }
     foreach ($backers as $log) {
         $payment_id = get_post_meta($log->ID, '_edd_log_payment_id', true);
         $payment = get_post($payment_id);
         $payment_meta = edd_get_payment_meta($payment_id);
         $user_info = edd_get_payment_meta_user_info($payment_id);
         $downloads = edd_get_payment_meta_cart_details($payment_id);
         $total = edd_get_payment_amount($payment_id);
         $user_id = isset($user_info['id']) && $user_info['id'] != -1 ? $user_info['id'] : $user_info['email'];
         $products = '';
         if ($downloads) {
             foreach ($downloads as $key => $download) {
                 // Download ID
                 $id = isset($payment_meta['cart_details']) ? $download['id'] : $download;
                 // If the download has variable prices, override the default price
                 $price_override = isset($payment_meta['cart_details']) ? $download['price'] : null;
                 $price = edd_get_download_final_price($id, $user_info, $price_override);
                 // Display the Downoad Name
                 $products .= get_the_title($id) . ' - ';
                 if (isset($downloads[$key]['item_number'])) {
                     $price_options = $downloads[$key]['item_number']['options'];
                     if (isset($price_options['price_id'])) {
                         $products .= edd_get_price_option_name($id, $price_options['price_id']) . ' - ';
                     }
                 }
                 $products .= html_entity_decode(edd_currency_filter($price));
                 if ($key != count($downloads) - 1) {
                     $products .= ' / ';
                 }
             }
         }
         if (is_numeric($user_id)) {
             $user = get_userdata($user_id);
         } else {
             $user = false;
         }
         $shipping = isset($payment_meta['shipping']) ? $payment_meta['shipping'] : null;
         $data[] = apply_filters('atcf_csv_cols_values', array('id' => $payment_id, 'email' => $payment_meta['email'], 'first' => $user_info['first_name'], 'last' => $user_info['last_name'], 'shipping' => isset($shipping) ? implode("\n", $shipping) : '', 'products' => $products, 'amount' => html_entity_decode(edd_currency_filter(edd_format_amount($total))), 'tax' => html_entity_decode(edd_payment_tax($payment_id, $payment_meta)), 'discount' => isset($user_info['discount']) && $user_info['discount'] != 'none' ? $user_info['discount'] : __('none', 'atcf'), 'gateway' => edd_get_gateway_admin_label(get_post_meta($payment_id, '_edd_payment_gateway', true)), 'key' => $payment_meta['key'], 'date' => date_i18n(get_option('date_format'), strtotime($payment->post_date)), 'user' => $user ? $user->display_name : __('guest', 'atcf'), 'status' => edd_get_payment_status($payment, true)), $payment_id);
     }
     $data = apply_filters('edd_export_get_data', $data);
     $data = apply_filters('edd_export_get_data_' . $this->export_type, $data);
     return $data;
 }
コード例 #2
0
/**
 * Do any items in the cart require shipping?
 *
 * @since Astoundify Crowdfunding 0.9
 *
 * @return void
 */
function atcf_shipping_cart_shipping()
{
    $cart_items = edd_get_cart_contents();
    $needs = false;
    if (!empty($cart_items)) {
        foreach ($cart_items as $key => $item) {
            $campaign = atcf_get_campaign($item['id']);
            if ($campaign->needs_shipping()) {
                $needs = true;
            }
        }
    }
    return apply_filters('atcf_shipping_cart_shipping', $needs);
}
コード例 #3
0
/**
 * Export metabox
 *
 * @since Astoundify Crowdfunding 0.1-alpha
 *
 * @return void
 */
function atcf_campaign_export_box()
{
    ?>
	<div class="metabox-holder">
		<div id="post-body">
			<div id="post-body-content">
				<div class="postbox">
					<h3><span><?php 
    _e('Export Campaign Data', 'atcf');
    ?>
</span></h3>
					<div class="inside">
						<p><?php 
    _e('Download a CSV of all pledges recorded.', 'atcf');
    ?>
</p>
						<p>
							<form method="post">
								<select name="edd_export_campaign_id">
									<option value="0"><?php 
    printf(__('Select %s', 'atcf'), edd_get_label_singular());
    ?>
</option>

									<?php 
    $campaigns = get_posts(array('post_type' => 'download', 'posts_per_page' => -1));
    foreach ($campaigns as $campaign) {
        $_campaign = atcf_get_campaign($campaign);
        if (apply_filters('atcf_export_filter_completed', !$_campaign->is_funded() && 'fixed' == $_campaign->type())) {
            continue;
        }
        echo '<option value="' . $campaign->ID . '">' . $campaign->post_title . '</option>';
    }
    ?>
								</select>
								<input type="hidden" name="edd-action" value="export_campaign"/>
								<input type="submit" value="<?php 
    _e('Generate CSV', 'atcf');
    ?>
" class="button-secondary"/>
							</form>
						</p>
					</div><!-- .inside -->
				</div><!-- .postbox -->
			</div><!-- .post-body-content -->
		</div><!-- .post-body -->
	</div><!-- .metabox-holder -->
	<?php 
}
/**
 * Figure out the Paypal account info to send the funds to.
 *
 * @since Astoundify Crowdfunding 1.8
 *
 * @return $receivers
 */
function atcf_edap_adaptive_receivers($receivers, $payment_id)
{
    global $edd_options;
    $campaign_id = null;
    $cart_items = edd_get_payment_meta_cart_details($payment_id);
    if (!$cart_items || empty($cart_items)) {
        return $receivers;
    }
    foreach ($cart_items as $item) {
        $campaign_id = $item['id'];
        break;
    }
    if (0 == get_post($campaign_id)->ID) {
        return $receivers;
    }
    $campaign = atcf_get_campaign($campaign_id);
    return atcf_gateway_paypal_adaptive_payments_receivers($campaign);
}
コード例 #5
0
        $featured = new WP_Query(array('posts_per_page' => 'grid' == fundify_theme_mod('hero_style') ? apply_filters('fundify_hero_campaign_grid', 24) : 1));
    }
    ?>
		<?php 
    if ('grid' == fundify_theme_mod('hero_style')) {
        ?>
			<?php 
        for ($i = 0; $i < 1; $i++) {
            shuffle($featured->posts);
            ?>
			<ul id="carousel">
				<?php 
            while ($featured->have_posts()) {
                $featured->the_post();
                //bumbum: get campaign to use method is_active and hide inactive
                $campaign = atcf_get_campaign($post);
                if ($campaign->is_active()) {
                    ?>
						<li><a href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    the_post_thumbnail();
                    ?>
<br><?php 
                    the_title();
                    ?>
</a></li>
				<?php 
                }
            }
コード例 #6
0
 /**
  * Download Column Items
  *
  * @since Astoundify Crowdfunding 0.1-alpha
  *
  * @param array $supports The post type supports
  * @return array $supports The modified post type supports
  */
 function dashboard_column_item($column, $post_id)
 {
     $campaign = atcf_get_campaign($post_id);
     switch ($column) {
         case 'funded':
             printf(_x('%s of %s', 'funded of goal', 'atcf'), $campaign->current_amount(true), $campaign->goal(true));
             break;
         case 'expires':
             echo $campaign->is_endless() ? '&mdash;' : $campaign->days_remaining();
             break;
         case 'type':
             echo ucfirst($campaign->type());
             break;
         case 'backers':
             echo $campaign->backers_count();
             break;
         default:
             break;
     }
 }
コード例 #7
0
 /**
  * Load scripts.
  *
  * @since Astoundify 1.6
  *
  * @param mixed $template
  * @return string $template The path of the file to include
  */
 public function frontend_scripts()
 {
     global $edd_options;
     $is_submission = is_page($edd_options['submit_page']) || did_action('atcf_found_edit');
     $is_campaign = is_singular('download') || did_action('atcf_found_single') || apply_filters('atcf_is_campaign_page', false);
     if (!($is_submission || $is_campaign)) {
         return;
     }
     if ($is_campaign) {
         wp_enqueue_script('formatCurrency', $this->plugin_url . 'assets/js/jquery.formatCurrency-1.4.0.pack.js', array('jquery'));
     }
     wp_enqueue_script('atcf-scripts', $this->plugin_url . 'assets/js/crowdfunding.js', array('jquery'));
     $settings = array('pages' => array('is_submission' => $is_submission, 'is_campaign' => $is_campaign));
     if ($is_submission) {
         $settings['submit'] = array(array('i18n' => array('oneReward' => __('At least one reward is required.', 'atcf'))));
     }
     if ($is_campaign) {
         global $post;
         $campaign = atcf_get_campaign($post);
         $settings['campaign'] = array('i18n' => array(), 'isDonations' => $campaign->is_donations_only(), 'currency' => array('thousands' => $edd_options['thousands_separator'], 'decimal' => $edd_options['decimal_separator'], 'symbol' => edd_currency_filter(''), 'round' => apply_filters('edd_format_amount_decimals', 2)));
     }
     wp_localize_script('atcf-scripts', 'atcfSettings', $settings);
 }
コード例 #8
0
/**
 * Contribute now list options
 * @return void
**/
function wpo_campaign_contribute_options_custom($prices, $type, $download_id)
{
    $campaign = atcf_get_campaign($download_id);
    $uid = wpo_makeid();
    ?>
	<div class="edd_price_options <?php 
    echo $campaign->is_active() ? 'active' : 'expired';
    ?>
" <?php 
    echo $campaign->is_donations_only() ? 'style="display: none"' : null;
    ?>
>
		<ul>
			<?php 
    foreach ($prices as $key => $price) {
        ?>
				<?php 
        $amount = $price['amount'];
        $limit = isset($price['limit']) ? $price['limit'] : '';
        $bought = isset($price['bought']) ? $price['bought'] : 0;
        $allgone = false;
        if ($bought == absint($limit) && '' != $limit) {
            $allgone = true;
        }
        if (edd_use_taxes() && edd_taxes_on_prices()) {
            $amount += edd_calculate_tax($amount);
        }
        ?>
				<li class="atcf-price-option pledge-level <?php 
        echo $allgone ? 'inactive' : null;
        ?>
"  data-pri="<?php 
        echo edd_sanitize_amount($amount);
        ?>
"  data-price="<?php 
        echo edd_sanitize_amount($amount);
        ?>
-<?php 
        echo esc_attr($key);
        ?>
">
					<div class="clear">
						<h3><label><!-- <label for="<?php 
        echo esc_attr('edd_price_option_' . $download_id . '_' . $key);
        ?>
"> -->
							<?php 
        if ($campaign->is_active()) {
            if (!$allgone) {
                printf('<input type="radio" name="edd_options[price_id][]" id="%1$s" class="%2$s edd_price_options_input" value="%3$s"/>', esc_attr('edd_price_option_' . $download_id . '_' . $key . '_' . $uid), esc_attr('edd_price_option_' . $download_id), esc_attr($key));
            }
        }
        ?>
  
							<?php 
        echo edd_currency_filter(edd_format_amount($amount));
        ?>
						</label></h3>
						
						<div class="backers hidden">
							<div class="backer-count">
								<i class="icon-user"></i> <?php 
        printf(_n('1 Backer', '%1$s Backers', $bought, 'atcf'), $bought);
        ?>
							</div>
							<?php 
        if ('' != $limit && !$allgone) {
            ?>
								<small class="limit"><?php 
            printf(__('Limit of %d &mdash; %d remaining', 'atcf'), $limit, $limit - $bought);
            ?>
</small>
							<?php 
        } elseif ($allgone) {
            ?>
								<small class="gone"><?php 
            _e('All gone!', 'atcf');
            ?>
</small>
							<?php 
        }
        ?>
						</div>

					</div>
					<?php 
        //echo wpautop( wp_kses_data( $price[ 'name' ] ) );
        ?>
				</li>

			<?php 
    }
    ?>
			<li class="price-custom">
				<div class="campaign-price-input">
					<div class="price-wrapper"><span class="title"><?php 
    _e('Amount: ', TEXTDOMAIN);
    ?>
</span><input type="text" name="atcf_custom_price" value="" /></div>
				</div>	
			</li>

		</ul>
	</div><!--end .edd_price_options-->
<?php 
}
コード例 #9
0
/**
 * Request Data
 *
 * @since Astoundify Crowdfunding 0.8
 *
 * @return void
 */
function atcf_shortcode_profile_request_data()
{
    global $edd_options, $post;
    if ('GET' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    if (empty($_GET['action']) || 'atcf-request-data' !== $_GET['action']) {
        return;
    }
    if (!wp_verify_nonce($_GET['_wpnonce'], 'atcf-request-data')) {
        return;
    }
    $user = wp_get_current_user();
    $errors = new WP_Error();
    $crowdfunding = crowdfunding();
    $campaign = absint($_GET['campaign']);
    $campaign = atcf_get_campaign($campaign);
    if ($user->ID != $campaign->data->post_author) {
        $errors->add('non-owner', __('You are not the author of this campaign, and cannot request the data.', 'atcf'));
    }
    if (!empty($errors->errors)) {
        wp_die($errors);
    }
    if (0 != $campaign->ID) {
        require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/class-export.php';
        require $crowdfunding->includes_dir . 'class-export-campaigns.php';
        $campaign_export = new ATCF_Campaign_Export($campaign->ID);
        $campaign_export->export();
    }
    $url = isset($edd_options['profile_page']) ? get_permalink($edd_options['profile_page']) : get_permalink();
    $redirect = apply_filters('atcf_shortcode_profile_info_success_redirect', add_query_arg(array('exported' => $campaign->ID, 'success' => 'true'), $url));
    wp_safe_redirect($redirect);
    exit;
}
コード例 #10
0
/**
 * Base page/form. All fields are loaded through an action,
 * so the form can be extended for ever, fields can be removed, added, etc.
 *
 * @since Astoundify Crowdfunding 0.1-alpha
 *
 * @param $atts
 * @return $form
 */
function atcf_shortcode_submit($atts = array())
{
    global $edd_options;
    $atts = shortcode_atts(array('campaign_id' => false), $atts);
    $crowdfunding = crowdfunding();
    $campaign = $atts['campaign_id'] === false ? null : atcf_get_campaign($atts['campaign_id']);
    $is_draft = false;
    $is_editing = false;
    if (is_null($campaign)) {
        global $post;
        // If the current $post is a download, we know this is
        // either a draft, pending or published campaign
        if ('download' == $post->post_type) {
            $is_draft = 'draft' == $post->post_status;
            $is_editing = !$is_draft;
            $campaign = atcf_get_campaign($post);
        }
    }
    $args = array('campaign' => $campaign, 'previewing' => $is_draft, 'editing' => $is_editing);
    ob_start();
    /** Allow things to change the content of the shortcode. */
    if (apply_filters('atcf_shortcode_submit_hide', false, $args)) {
        do_action('atcf_shortcode_submit_hidden', $args);
        $form = ob_get_clean();
        return $form;
    }
    ?>
	<?php 
    do_action('atcf_shortcode_submit_before', $args, $args['campaign']);
    ?>

	<form action="" method="post" class="atcf-submit-campaign" enctype="multipart/form-data">

		<?php 
    foreach (atcf_shortcode_submit_fields() as $key => $field) {
        /** If we _aren't_ editing, and the field should only be shown on edit, skip... */
        if (!$is_editing && 'only' === $field['editable']) {
            continue;
        }
        /** If we _are_ editing, and the field is not editable, skip... */
        if ($is_editing && $field['editable'] === false) {
            continue;
        }
        $field = apply_filters('atcf_shortcode_submit_field', $key, $field, $args, $args['campaign']);
        $field = apply_filters('atcf_shortcode_submit_field_before_render_' . $key, $field);
        do_action('atcf_shortcode_submit_field_before_' . $key, $key, $field, $args, $args['campaign']);
        do_action('atcf_shortcode_submit_field_' . $field['type'], $key, $field, $args, $args['campaign']);
        do_action('atcf_shortcode_submit_field_after_' . $key, $key, $field, $args, $args['campaign']);
    }
    ?>

		<p class="atcf-submit-campaign-submit">
			<button type="submit" name="submit" value="submit" class="button">
				<?php 
    echo $is_editing ? sprintf(_x('Update %s', 'edit "campaign"', 'atcf'), edd_get_label_singular()) : sprintf(_x('Submit %s', 'submit "campaign"', 'atcf'), edd_get_label_singular());
    ?>
			</button>

			<?php 
    if (is_user_logged_in() && !$is_editing) {
        ?>
			<button type="submit" name="submit" value="preview" class="button button-secondary">
				<?php 
        _e('Save and Preview', 'atcf');
        ?>
			</button>
			<?php 
    }
    ?>

			<input type="hidden" name="action" value="atcf-campaign-submit" />
			<?php 
    wp_nonce_field('atcf-campaign-submit');
    ?>

			<?php 
    if ($is_editing || $is_draft) {
        ?>
				<input type="hidden" name="campaign_id" value="<?php 
        echo $campaign->ID;
        ?>
" />
			<?php 
    }
    ?>
		</p>
	</form>

	<?php 
    do_action('atcf_shortcode_submit_after', $args, $args['campaign']);
    ?>

<?php 
    $form = ob_get_clean();
    return $form;
}
コード例 #11
0
 /**
  * Get things moving.
  *
  * Defines some class variables and starts the processinging.
  *
  * @since Astoundify Crowdfunding 1.8
  *
  * @return void
  */
 function __construct($campaign_id, $process_failed = false)
 {
     global $edd_options;
     $this->to_process = isset($edd_options['atcf_to_process']) ? $edd_options['atcf_to_process'] : 20;
     $this->process_failed = $process_failed;
     $this->campaign_id = $campaign_id;
     $this->campaign = atcf_get_campaign($this->campaign_id);
     $this->payments = $this->campaign->__get('_payment_ids');
     $this->failed_payments = $this->campaign->__get('_campaign_failed_payments');
     if ($this->process_failed) {
         $this->payments = $this->failed_payments;
     }
     $this->gateways = edd_get_enabled_payment_gateways();
     $this->get_payments();
     $this->sort_payments();
     $this->process();
     $this->log_failed();
     $this->cleanup();
 }
コード例 #12
0
<?php

/**
 * The Template for displaying all single campaigns.
 *
 * @package Fundify
 * @since Fundify 1.0
 */
global $campaign, $wp_embed;
get_header();
?>

	<?php 
while (have_posts()) {
    the_post();
    $campaign = atcf_get_campaign($post->ID);
    ?>

		<?php 
    locate_template(array('campaign/title.php'), true);
    ?>
		
		<div id="content" class="post-details">
			<div class="container">
				
				<?php 
    do_action('atcf_campaign_before', $campaign);
    ?>
				
				<?php 
    locate_template(array('searchform-campaign.php'), true);