コード例 #1
1
function ck_edd_user_download_button($purchase_form, $args)
{
    global $edd_options;
    if (!is_user_logged_in()) {
        return $purchase_form;
    }
    $download_id = (string) $args['download_id'];
    $current_user_id = get_current_user_id();
    // If the user has purchased this item, itterate through their purchases to get the specific
    // purchase data and pull out the key and email associated with it. This is necessary for the
    // generation of the download link
    if (edd_has_user_purchased($current_user_id, $download_id, $variable_price_id = null)) {
        $user_purchases = edd_get_users_purchases($current_user_id, -1, false, 'complete');
        foreach ($user_purchases as $purchase) {
            $cart_items = edd_get_payment_meta_cart_details($purchase->ID);
            $item_ids = wp_list_pluck($cart_items, 'id');
            if (in_array($download_id, $item_ids)) {
                $email = edd_get_payment_user_email($purchase->ID);
                $payment_key = edd_get_payment_key($purchase->ID);
            }
        }
        $download_ids = array();
        if (edd_is_bundled_product($download_id)) {
            $download_ids = edd_get_bundled_products($download_id);
        } else {
            $download_ids[] = $download_id;
        }
        // Setup the style and colors associated with the settings
        $style = isset($edd_options['button_style']) ? $edd_options['button_style'] : 'button';
        $color = isset($edd_options['checkout_color']) ? $edd_options['checkout_color'] : 'blue';
        $new_purchase_form = '';
        foreach ($download_ids as $item) {
            // Attempt to get the file data associated with this download
            $download_data = edd_get_download_files($item, null);
            if ($download_data) {
                foreach ($download_data as $filekey => $file) {
                    // Generate the file URL and then make a link to it
                    $file_url = edd_get_download_file_url($payment_key, $email, $filekey, $item, null);
                    $new_purchase_form .= '<a href="' . $file_url . '" class="' . $style . ' ' . $color . ' edd-submit"><span class="edd-add-to-cart-label">Download ' . $file['name'] . '</span></a>&nbsp;';
                }
            }
            // As long as we ended up with links to show, use them.
            if (!empty($new_purchase_form)) {
                $purchase_form = '<h4>' . __('You already own this product. Download it now:', 'edd') . '</h4>' . $new_purchase_form;
            }
        }
    }
    return $purchase_form;
}
コード例 #2
1
<?php

$purchases = edd_get_users_purchases();
if ($purchases) {
    do_action('edd_before_download_history');
    ?>
	<table id="edd_user_history">
		<thead>
			<tr class="edd_download_history_row">
				<?php 
    do_action('edd_download_history_header_start');
    ?>
				<th class="edd_download_download_name"><?php 
    _e('Download Name', 'edd');
    ?>
</th>
				<?php 
    if (!edd_no_redownload()) {
        ?>
					<th class="edd_download_download_files"><?php 
        _e('Files', 'edd');
        ?>
</th>
				<?php 
    }
    ?>
				<?php 
    do_action('edd_download_history_header_end');
    ?>
			</tr>
		</thead>
コード例 #3
0
/**
 * Displays a list of restricted pages the currently logged-in user has access to
 *
 * @since       1.5.0
 * @param       array $atts The attributes to pass to the shortcode
 * @param       string $content The content of the shortcode
 * @return      string $content The data to return for the shortcode
 */
function edd_cr_pages_shortcode($atts, $content = null)
{
    $atts = shortcode_atts(array('class' => ''), $atts);
    if (is_user_logged_in()) {
        $pages = array();
        $purchases = edd_get_users_purchases(get_current_user_id(), -1);
        if ($purchases) {
            foreach ($purchases as $purchase) {
                $restricted = edd_cr_get_restricted_pages($purchase->ID);
                if (empty($restricted)) {
                    continue;
                }
                $page_ids = wp_list_pluck($restricted, 'ID');
                $pages = array_unique(array_merge($page_ids, $pages));
            }
            if (!empty($pages)) {
                $content = '<ul class="edd_cr_pages">';
                foreach ($pages as $page_id) {
                    $content .= '<li><a href="' . esc_url(get_permalink($page_id)) . '">' . get_the_title($page_id) . '</a></li>';
                }
                $content .= '</ul>';
            } else {
                $content = '<div class="edd_cr_no_pages">' . __('You have not purchased access to any content.', 'edd-cr') . '</div>';
            }
        } else {
            $content = '<div class="edd_cr_no_pages">' . __('You have not purchased access to any content.', 'edd-cr') . '</div>';
        }
    } else {
        $content = '<div class="edd_cr_not_logged_in">' . __('You must be logged in to access your purchased content.', 'edd-cr') . '</div>';
    }
    return $content;
}
コード例 #4
0
/**
 * Check if the current user has a valid license for the $download_id passed-in.
 *
 * @param  array ( 'download' => Download/Item ID (post_id), 'price_id' => Price ID )
 * @return bool true/false
 */
function edd_sl_current_user_has_valid_license_for($download_ids)
{
    // Get the current user ID
    $current_user_id = get_current_user_id();
    // Set default for license validity to false
    $license_valid_for_download = false;
    // Get the current user's purchases
    $user_purchases = edd_get_users_purchases($current_user_id);
    if ($user_purchases) {
        foreach ($user_purchases as $user_purchase) {
            setup_postdata($user_purchase);
            // Get all the licenses for all the user's purchases
            $sl = edd_software_licensing();
            $licenses = $sl->get_licenses_of_purchase($user_purchase->ID);
            if (is_array($licenses)) {
                foreach ($licenses as $license_post) {
                    $license_key = get_post_meta($license_post->ID, '_edd_sl_key', true);
                    foreach ($download_ids as $download_id) {
                        if ($sl->is_download_id_valid_for_license($download_id['download'], $license_key)) {
                            $license_status = $sl->get_license_status($license_post->ID);
                            if ($license_status != 'expired' && $license_post->post_status == 'publish') {
                                $license_valid_for_download = true;
                                break;
                            }
                        }
                    }
                }
            }
            wp_reset_postdata();
        }
    }
    return $license_valid_for_download;
}
コード例 #5
0
/**	
 * Has User Purchased	
 *	
 * Checks to see if a user has purchased a download.	
 *	
 * @access      public	
 * @since       1.0	
 * @param       int $user_id - the ID of the user to check	
 * @param       array $downloads - Array of IDs to check if purchased. If an int is passed, it will be converted to an array	
 * @param       int $variable_price_id - the variable price ID to check for	
 * @return      boolean - true if has purchased and license is active, false otherwise	
 */
function dwqa_siteinfo_has_user_purchased($user_id, $downloads, $variable_price_id = null, $verify_purchase = false)
{
    $users_purchases = edd_get_users_purchases($user_id);
    $return = false;
    if (!is_array($downloads) && $downloads !== NULL) {
        $downloads = array($downloads);
    }
    $now = strtotime(date('Y-m-d H:i:s'));
    if ($users_purchases) {
        foreach ($users_purchases as $purchase) {
            $purchased_files = edd_get_payment_meta_downloads($purchase->ID);
            $licenses = edd_software_licensing()->get_licenses_of_purchase($purchase->ID);
            $licenses_products = array();
            if (is_array($licenses)) {
                foreach ($licenses as $license) {
                    $download_id = get_post_meta($license->ID, '_edd_sl_download_id', true);
                    $status = get_post_meta($license->ID, '_edd_sl_status', true);
                    $expire = get_post_meta($license->ID, '_edd_sl_expiration', true);
                    $licenses_products[$download_id] = array();
                    $licenses_products[$download_id]['status'] = $status;
                    $licenses_products[$download_id]['expire'] = $expire;
                }
            } else {
                return false;
            }
            if (is_array($purchased_files)) {
                foreach ($purchased_files as $download) {
                    if ($downloads === NULL || in_array($download['id'], $downloads)) {
                        //check to see if the license is active
                        //echo $licenses_products[$download['id']]['expire'] . ">" . $now . "==========";
                        if (isset($licenses_products[$download['id']]['expire']) && $now > $licenses_products[$download['id']]['expire']) {
                            // || $licenses_products[$download['id']]['status'] == 'inactive'
                            if ($verify_purchase) {
                                return "purchased_expired";
                            } else {
                                return false;
                            }
                        }
                        $variable_prices = edd_has_variable_prices($download['id']);
                        if ($variable_prices && !is_null($variable_price_id) && $variable_price_id !== false) {
                            if (isset($download['options']['price_id']) && $variable_price_id == $download['options']['price_id']) {
                                return true;
                            } else {
                                return false;
                            }
                        } else {
                            return true;
                        }
                    }
                }
            }
        }
    }
    return false;
}
コード例 #6
0
/**
 * EDD Forum Sidebar
 *
 * @since		1.0.0
 * @return		void
 */
function edd_bbp_sidebar()
{
    global $post;
    $user_id = get_the_author_meta('ID');
    $user_data = get_userdata($user_id);
    ?>
	<div class="box">

		<?php 
    do_action('edd_bbp_sidebar');
    ?>

		<h3><?php 
    echo get_the_author_meta('first_name') . '  ' . get_the_author_meta('last_name');
    ?>
</h3>
		<p class="bbp-user-forum-role"><?php 
    printf('Forum Role: %s', bbp_get_user_display_role($user_id));
    ?>
</p>
		<p class="bbp-user-topic-count"><?php 
    printf('Topics Started: %s', bbp_get_user_topic_count_raw($user_id));
    ?>
</p>
		<p class="bbp-user-reply-count"><?php 
    printf('Replies Created: %s', bbp_get_user_reply_count_raw($user_id));
    ?>
</p>

		<div class="rcp_support_status">
			<h4>Priority Support Access</h4>
			<?php 
    if (function_exists('rcp_is_active')) {
        if (rcp_is_active($user_id)) {
            ?>
				<p>Has <strong>Priority Support</strong> access.</p>
			<?php 
        } elseif (rcp_is_expired($user_id)) {
            ?>
				<p><strong>Priority Support</strong> access has <span style="color:red;">expired</span>.</p>
			<?php 
        } else {
            ?>
				<p>Has no priority support accesss</p>
			<?php 
        }
    }
    ?>
		</div><!-- /.rcp_support_status -->

		<div class="edd_users_purchases">
			<h4>User's Purchases:</h4>
			<?php 
    $purchases = edd_get_users_purchases($user_data->user_email, 100, false, 'any');
    if ($purchases) {
        echo '<ul>';
        foreach ($purchases as $purchase) {
            echo '<li>';
            echo '<strong><a href="' . admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=' . $purchase->ID) . '">#' . $purchase->ID . ' - ' . edd_get_payment_status($purchase, true) . '</a></strong><br/>';
            $downloads = edd_get_payment_meta_downloads($purchase->ID);
            foreach ($downloads as $download) {
                echo get_the_title($download['id']) . ' - ' . date('F j, Y', strtotime($purchase->post_date)) . '<br/>';
            }
            if (function_exists('edd_software_licensing')) {
                $licenses = edd_software_licensing()->get_licenses_of_purchase($purchase->ID);
                if ($licenses) {
                    echo '<strong>Licenses:</strong><br/>';
                    foreach ($licenses as $license) {
                        $key = edd_software_licensing()->get_license_key($license->ID);
                        echo '<a href="' . admin_url('edit.php?post_type=download&page=edd-licenses&s=' . $key) . '">' . $key . '</a>';
                        echo ' - ' . edd_software_licensing()->get_license_status($license->ID);
                        echo '<br/>';
                    }
                }
                echo '<hr/>';
            }
            echo '</li>';
        }
        echo '</ul>';
    } else {
        echo '<p>This user has never purchased anything.</p>';
    }
    ?>
		</div>
	</div>
	<?php 
}
コード例 #7
0
function edd_userpro_embed_profile_fields($hook_args)
{
    if (!current_user_can('edit_user', $hook_args['user_id'])) {
        return;
    }
    echo '<div class="userpro-section userpro-column userpro-collapsible-1 userpro-collapsed-1">' . __('Purchase History', 'edd-userpro-embed') . '</div>';
    echo '<div class="userpro-field userpro-field-edd-purchase-history userpro-field-view" data-key="edd-purchase-history">';
    $purchases = edd_get_users_purchases($hook_args['user_id'], 99999, true, 'any');
    if ($purchases) {
        do_action('edd_before_purchase_history');
        ?>
		<table id="edd_user_history">
			<thead>
				<tr class="edd_purchase_row">
					<?php 
        do_action('edd_purchase_history_header_before');
        ?>
					<th class="edd_purchase_id"><?php 
        _e('ID', 'easy-digital-downloads');
        ?>
</th>
					<th class="edd_purchase_date"><?php 
        _e('Date', 'easy-digital-downloads');
        ?>
</th>
					<th class="edd_purchase_amount"><?php 
        _e('Amount', 'easy-digital-downloads');
        ?>
</th>
					<th class="edd_purchase_details"><?php 
        _e('Details', 'easy-digital-downloads');
        ?>
</th>
					<?php 
        do_action('edd_purchase_history_header_after');
        ?>
				</tr>
			</thead>
			<?php 
        foreach ($purchases as $post) {
            setup_postdata($post);
            ?>
				<?php 
            $purchase_data = edd_get_payment_meta($post->ID);
            ?>
				<tr class="edd_purchase_row">
					<?php 
            do_action('edd_purchase_history_row_start', $post->ID, $purchase_data);
            ?>
					<td class="edd_purchase_id">#<?php 
            echo edd_get_payment_number($post->ID);
            ?>
</td>
					<td class="edd_purchase_date"><?php 
            echo date_i18n(get_option('date_format'), strtotime(get_post_field('post_date', $post->ID)));
            ?>
</td>
					<td class="edd_purchase_amount">
						<span class="edd_purchase_amount"><?php 
            echo edd_currency_filter(edd_format_amount(edd_get_payment_amount($post->ID)));
            ?>
</span>
					</td>
					<td class="edd_purchase_details">
						<?php 
            if ($post->post_status != 'publish') {
                ?>
						<span class="edd_purchase_status <?php 
                echo $post->post_status;
                ?>
"><?php 
                echo edd_get_payment_status($post, true);
                ?>
</span>
						<a href="<?php 
                echo esc_url(add_query_arg('payment_key', edd_get_payment_key($post->ID), edd_get_success_page_uri()));
                ?>
">&raquo;</a>
						<?php 
            } else {
                ?>
						<a href="<?php 
                echo esc_url(add_query_arg('payment_key', edd_get_payment_key($post->ID), edd_get_success_page_uri()));
                ?>
"><?php 
                _e('View Details', 'edd-userpro-embed');
                ?>
</a>
						<?php 
            }
            ?>
					</td>
					<?php 
            do_action('edd_purchase_history_row_end', $post->ID, $purchase_data);
            ?>
				</tr>
			<?php 
        }
        ?>
		</table>
		<?php 
        do_action('edd_after_purchase_history');
        ?>
		<?php 
        wp_reset_postdata();
        ?>
	<?php 
    } else {
        ?>
		<p class="edd-no-purchases"><?php 
        _e('You have not made any purchases', 'edd-userpro-embed');
        ?>
</p>
	<?php 
    }
    echo '</div>';
}
コード例 #8
0
ファイル: tpl-account.php プロジェクト: wpmonty/99-demos
            ?>
                                                <div role="tabpanel" class="tab-pane" id="downloads"><?php 
            echo do_shortcode('[download_history]');
            ?>
</div>
                                                <div role="tabpanel" class="tab-pane" id="profile"><?php 
            echo do_shortcode('[edd_profile_editor]');
            ?>
</div>
                                                <div role="tabpanel" class="tab-pane" id="subscriptions">

                                                    <?php 
            /**
             * This template is used to display the purchase history of the current user.
             */
            $subscriptions = edd_get_users_purchases(get_current_user_id(), 20, true, 'any');
            if ($subscriptions) {
                do_action('edd_before_purchase_history');
                ?>
                                                    		<table id="edd_user_history" class="table table-striped table-hover table-responsive">
                                                    			<thead>
                                                    				<tr class="edd_purchase_row">
                                                    					<?php 
                do_action('edd_purchase_history_header_before');
                ?>
                                                    					<th class="edd_purchase_id"><?php 
                _e('ID', 'edd');
                ?>
</th>
                                                    					<th class="edd_purchase_date"><?php 
                _e('Date', 'edd');
コード例 #9
0
/**
 * Get user purchase count for download
 *
 * @since       1.0.1
 * @param       int $user_id the ID of the user to check
 * @param       int $download_id the download ID to check
 * @param       int $variable_price_id the variable price ID to check
 * @return      int $count the number of times the product has been purchased
 */
function edd_pl_get_user_purchase_count($user_id, $download_id, $variable_price_id = null)
{
    if (!is_user_logged_in()) {
        return 0;
    }
    $users_purchases = edd_get_users_purchases($user_id, 999);
    $count = 0;
    $download_id = array($download_id);
    if ($users_purchases) {
        foreach ($users_purchases as $purchase) {
            $purchased_files = edd_get_payment_meta_downloads($purchase->ID);
            if (is_array($purchased_files)) {
                foreach ($purchased_files as $download) {
                    if (isset($download['id']) && in_array($download['id'], $download_id)) {
                        $count++;
                    }
                }
            }
        }
    }
    return $count;
}
コード例 #10
0
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     global $user_ID, $edd_options;
     if (is_user_logged_in()) {
         $purchases = edd_get_users_purchases($user_ID);
         if ($purchases) {
             echo $before_widget;
             if ($title) {
                 echo $before_title . $title . $after_title;
             }
             foreach ($purchases as $purchase) {
                 $purchase_data = edd_get_payment_meta($purchase->ID);
                 $downloads = edd_get_payment_meta_downloads($purchase->ID);
                 if ($downloads) {
                     foreach ($downloads as $download) {
                         $id = isset($purchase_data['cart_details']) ? $download['id'] : $download;
                         $price_id = isset($download['options']['price_id']) ? $download['options']['price_id'] : null;
                         $download_files = edd_get_download_files($id, $price_id);
                         echo '<div class="edd-purchased-widget-purchase edd-purchased-widget-purchase-' . $purchase->ID . '" id="edd-purchased-widget-purchase-' . $id . '">';
                         echo '<div class="edd-purchased-widget-purchase-name">' . get_the_title($id) . '</div>';
                         echo '<ul class="edd-purchased-widget-file-list">';
                         if (!edd_no_redownload()) {
                             if ($download_files) {
                                 foreach ($download_files as $filekey => $file) {
                                     $download_url = edd_get_download_file_url($purchase_data['key'], $purchase_data['email'], $filekey, $id, $price_id);
                                     echo '<li class="edd-purchased-widget-file"><a href="' . $download_url . '" class="edd-purchased-widget-file-link">' . $file['name'] . '</a></li>';
                                 }
                             } else {
                                 echo '<li class="edd-purchased-widget-no-file">' . __('No downloadable files found.', 'edd');
                             }
                         }
                         echo '</ul>';
                         echo '</div>';
                     }
                 }
             }
         }
         echo $after_widget;
     }
 }
コード例 #11
0
     */
    $user_id = get_current_user_id();
    $args = array('post_type' => 'download', 'post_status' => 'publish', 'order' => 'ASC', 'author' => $user_id);
    $products = get_posts($args);
    $downloaded_user_id_array = array();
    if (!empty($products)) {
        foreach ($products as $key => $product) {
            $puchase_ids = get_payment_ids($product->ID);
            foreach ($puchase_ids as $puchase_ids_key => $puchase_id) {
                $downloaded_user_id = get_post_meta($puchase_id, '_edd_payment_user_id');
                $downloaded_user_id_array[] = $downloaded_user_id[0];
            }
        }
        $downloaded_user_id_array = array_unique($downloaded_user_id_array);
        for ($i = 0; $i <= count($downloaded_user_id_array); $i++) {
            $customer_purchases = edd_get_users_purchases($downloaded_user_id_array[$i], 20, true, 'any');
            $author_obj = get_user_by('id', $downloaded_user_id_array[$i]);
            $customer_name = $author_obj->data->display_name;
            if ($customer_name == '') {
                $customer_name = $author_obj->data->user_nicename;
            }
            if ($customer_purchases) {
                do_action('edd_before_download_history');
                ?>

                <table id="edd_user_history" class="edd-table">
                    <?php 
                //if ($i == 0) {
                ?>
                    <thead>
                        <tr class="edd_download_history_row">
コード例 #12
0
/**
 * Has Purchases
 *
 * Checks to see if a user has purchased at least one item.
 *
 * @access      public
 * @since       1.0
 * @param       $user_id int - the ID of the user to check
 * @return      bool - true if has purchased, false other wise.
*/
function edd_has_purchases($user_id = null)
{
    if (is_null($user_id)) {
        global $user_ID;
        $user_id = $user_ID;
    }
    if (edd_get_users_purchases($user_id, 1)) {
        return true;
        // user has at least one purchase
    }
    return false;
    // user has never purchased anything
}
コード例 #13
0
ファイル: functions.php プロジェクト: SelaInc/eassignment
/**
 * Get a customer's purchases
 * @param  [type] $user_id           [description]
 * @param  [type] $download_id       [description]
 * @param  [type] $variable_price_id [description]
 * @since  1.0
 * @return [type]                    [description]
 */
function edd_wl_get_purchases($user_id, $download_id, $variable_price_id = null)
{
    $users_purchases = edd_get_users_purchases($user_id);
    $return = false;
    if ($users_purchases) {
        foreach ($users_purchases as $purchase) {
            $purchased_files = edd_get_payment_meta_downloads($purchase->ID);
            if (is_array($purchased_files)) {
                foreach ($purchased_files as $download) {
                    $variable_prices = edd_has_variable_prices($download['id']);
                    if ($variable_prices && !is_null($variable_price_id) && $variable_price_id !== false) {
                        if (isset($download['options']['price_id']) && $variable_price_id == $download['options']['price_id']) {
                            $return = true;
                            break 2;
                        } else {
                            $return = false;
                        }
                    } elseif ($download_id == $download['id']) {
                        $return = true;
                    }
                }
            }
        }
    }
    return $return;
}
コード例 #14
0
/**
 * Forum Sidebar
 *
 * @since        1.0.0
 * @return        void
 */
function wi_bbp_sidebar()
{
    global $post;
    $user_id = get_the_author_meta('ID');
    $user_data = get_userdata($user_id);
    ?>
	<div class="box">

		<?php 
    do_action('wi_bbp_sidebar');
    ?>

		<h3><?php 
    echo get_the_author_meta('first_name') . '  ' . get_the_author_meta('last_name');
    ?>
</h3>

		<p class="bbp-user-forum-role"><?php 
    printf('Forum Role: %s', bbp_get_user_display_role($user_id));
    ?>
</p>

		<p class="bbp-user-topic-count"><?php 
    printf('Topics Started: %s', bbp_get_user_topic_count_raw($user_id));
    ?>
</p>

		<p class="bbp-user-reply-count"><?php 
    printf('Replies Created: %s', bbp_get_user_reply_count_raw($user_id));
    ?>
</p>


		<div class="wi_users_purchases">
			<h3><?php 
    _e('User\'s Purchases:', 'wi_bbp');
    ?>
</h3>
			<?php 
    $purchases = edd_get_users_purchases($user_data->user_email, 100, false, 'any');
    if ($purchases) {
        echo '<ul>';
        foreach ($purchases as $purchase) {
            echo '<li>';
            echo '<strong><a href="' . admin_url('edit.php?post_type=download&page=give-payment-history&view=view-order-details&id=' . $purchase->ID) . '">#' . $purchase->ID . ' - ' . edd_get_payment_status($purchase, true) . '</a></strong><br/>';
            $downloads = edd_get_payment_meta_downloads($purchase->ID);
            foreach ($downloads as $download) {
                echo get_the_title($download['id']) . ' - ' . date('F j, Y', strtotime($purchase->post_date)) . '<br/>';
            }
            //Check license key
            if (function_exists('edd_software_licensing')) {
                $licenses = edd_software_licensing()->get_licenses_of_purchase($purchase->ID);
                if ($licenses) {
                    echo '<strong>Licenses:</strong><br/>';
                    foreach ($licenses as $license) {
                        $key = edd_software_licensing()->get_license_key($license->ID);
                        echo '<a href="' . admin_url('edit.php?post_type=download&page=give-licenses&s=' . $key) . '">' . $key . '</a>';
                        echo ' - ' . edd_software_licensing()->get_license_status($license->ID);
                        echo '<br/>';
                    }
                }
                echo '<hr/>';
            }
            echo '</li>';
        }
        echo '</ul>';
    } else {
        echo '<p>This user has never purchased anything.</p>';
    }
    ?>
		</div>
	</div>
	<?php 
}
コード例 #15
0
    /**
     * Front-end display of widget.
     *
     * @see WP_Widget::widget()
     *
     * @param array $args     Widget arguments.
     * @param array $instance Saved values from database.
     */
    public function widget($args, $instance)
    {
        //No EDD? Bail
        if (!class_exists('Easy_Digital_Downloads')) {
            return false;
        }
        //Not EDD admin? Bail
        if (!current_user_can('view_shop_sensitive_data')) {
            return false;
        }
        //Handle before_widget args
        echo $args['before_widget'];
        if (!empty($instance['title'])) {
            echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
        }
        $user_id = get_the_author_meta('ID');
        $user_data = get_userdata($user_id);
        ?>
		<div class="box">

			<?php 
        do_action('wi_bbp_sidebar');
        ?>

			<h3><?php 
        echo get_the_author_meta('first_name') . '  ' . get_the_author_meta('last_name');
        ?>
</h3>

			<p class="bbp-user-forum-role"><?php 
        printf('Forum Role: %s', bbp_get_user_display_role($user_id));
        ?>
</p>

			<p class="bbp-user-topic-count"><?php 
        printf('Topics Started: %s', bbp_get_user_topic_count_raw($user_id));
        ?>
</p>

			<p class="bbp-user-reply-count"><?php 
        printf('Replies Created: %s', bbp_get_user_reply_count_raw($user_id));
        ?>
</p>


			<div class="wi_users_purchases">
				<h3><?php 
        _e('User\'s Purchases:', 'wi_bbp');
        ?>
</h3>
				<?php 
        $purchases = edd_get_users_purchases($user_data->user_email, 100, false, 'any');
        if ($purchases) {
            echo '<ul>';
            foreach ($purchases as $purchase) {
                echo '<li>';
                echo '<strong><a href="' . admin_url('edit.php?post_type=download&page=give-payment-history&view=view-order-details&id=' . $purchase->ID) . '">#' . $purchase->ID . ' - ' . edd_get_payment_status($purchase, true) . '</a></strong><br/>';
                $downloads = edd_get_payment_meta_downloads($purchase->ID);
                foreach ($downloads as $download) {
                    echo get_the_title($download['id']) . ' - ' . date('F j, Y', strtotime($purchase->post_date)) . '<br/>';
                }
                //Check license key
                if (function_exists('edd_software_licensing')) {
                    $licenses = edd_software_licensing()->get_licenses_of_purchase($purchase->ID);
                    if ($licenses) {
                        echo '<strong>' . __('Licenses:', 'edd') . '</strong><br/>';
                        foreach ($licenses as $license) {
                            $key = edd_software_licensing()->get_license_key($license->ID);
                            $download_id = edd_software_licensing()->get_download_by_license($key);
                            $title = get_the_title($download_id);
                            //output license URL
                            echo $title . ' - <a href="' . admin_url('edit.php?post_type=download&page=give-licenses&s=' . $key) . '">' . $key . '</a>';
                            echo ' - ' . edd_software_licensing()->get_license_status($license->ID);
                            echo '<br/>';
                        }
                    }
                    echo '<hr/>';
                }
                echo '</li>';
            }
            echo '</ul>';
        } else {
            echo '<p>' . __('This user has never purchased anything.', 'wi_bbp') . '</p>';
        }
        ?>
			</div>
		</div>
		<?php 
        //After widget args
        echo $args['after_widget'];
        return false;
    }
コード例 #16
0
<?php

if (!empty($_GET['edd-verify-success'])) {
    ?>
<p class="edd-account-verified edd_success">
	<?php 
    _e('Your account has been successfully verified!', 'easy-digital-downloads');
    ?>
</p>
<?php 
}
/**
 * This template is used to display the purchase history of the current user.
 */
if (is_user_logged_in()) {
    $purchases = edd_get_users_purchases(get_current_user_id(), 20, true, 'any');
    if ($purchases) {
        do_action('edd_before_purchase_history');
        ?>
		<table id="edd_user_history">
			<thead>
				<tr class="edd_purchase_row">
					<?php 
        do_action('edd_purchase_history_header_before');
        ?>
					<th class="edd_purchase_id"><?php 
        _e('ID', 'easy-digital-downloads');
        ?>
</th>
					<th class="edd_purchase_date"><?php 
        _e('Date', 'easy-digital-downloads');
コード例 #17
0
/**
 * Has Purchases
 *
 * Checks to see if a user has purchased at least one item.
 *
 * @access      public
 * @since       1.0
 * @param       $user_id int - the ID of the user to check
 * @return      bool - true if has purchased, false other wise.
 */
function edd_has_purchases($user_id = null)
{
    if (empty($user_id)) {
        $user_id = get_current_user_id();
    }
    if (edd_get_users_purchases($user_id, 1)) {
        return true;
        // User has at least one purchase
    }
    return false;
    // User has never purchased anything
}
コード例 #18
0
ファイル: account.php プロジェクト: companyjuice/theme
/**
 * Account
 * @since 1.0
*/
function affwp_account()
{
    ?>

	<?php 
    $has_ultimate_license = in_array(3, affwp_get_users_price_ids());
    $has_professional_license = in_array(2, affwp_get_users_price_ids());
    $has_plus_license = in_array(1, affwp_get_users_price_ids());
    $has_personal_license = in_array(0, affwp_get_users_price_ids());
    /**
     * Logout message
     */
    if (isset($_GET['logout']) && $_GET['logout'] == 'success') {
        ?>
	<p class="alert notice">
		<?php 
        _e('You have been successfully logged out', 'affwp');
        ?>
	</p>
<?php 
    }
    ?>



	<?php 
    // user is not logged in
    if (!is_user_logged_in()) {
        ?>
		<p>
			<a href="<?php 
        echo site_url('account/affiliates');
        ?>
">Looking for our affiliate area?</a>
		</p>
		<p>
			<a href="<?php 
        echo site_url('account/register');
        ?>
">Need to register an account?</a>
		</p>

		<?php 
        echo edd_login_form(add_query_arg(array('login' => 'success', 'logout' => false), site_url($_SERVER['REQUEST_URI'])));
        ?>

	<?php 
        // user is logged in
    } else {
        ?>


	<h2>Professional Add-ons</h2>
	<?php 
        global $post;
        /**
         * Displays the most recent post
         */
        $args = array('posts_per_page' => -1, 'post_type' => 'download', 'tax_query' => array(array('taxonomy' => 'download_category', 'field' => 'slug', 'terms' => 'pro-add-ons')));
        $add_ons = new WP_Query($args);
        ?>
	<table id="edd-pro-add-ons">
		<thead>
			<tr>
				<th><?php 
        _e('Name', 'affwp');
        ?>
</th>
				<th><?php 
        _e('Version', 'affwp');
        ?>
</th>
				<th><?php 
        _e('AffiliateWP version required', 'affwp');
        ?>
</th>
				<th><?php 
        _e('Download', 'affwp');
        ?>
</th>
			</tr>
		</thead>

		<tbody>

	<?php 
        if (have_posts()) {
            ?>

			<?php 
            while ($add_ons->have_posts()) {
                $add_ons->the_post();
                ?>

			<?php 
                $version = get_post_meta(get_the_ID(), '_edd_sl_version', true);
                $requires = get_post_meta(get_the_ID(), '_affwp_addon_requires', true);
                ?>
			<tr>
				<td>
					<?php 
                if (affwp_addon_is_coming_soon(get_the_ID()) && current_user_can('manage_options')) {
                    ?>
						<a href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    the_title();
                    ?>
</a>
					<?php 
                } elseif (affwp_addon_is_coming_soon(get_the_ID())) {
                    ?>
						<?php 
                    the_title();
                    ?>
 - coming soon
					<?php 
                } else {
                    ?>
						<a href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    the_title();
                    ?>
</a>
					<?php 
                }
                ?>

				</td>
				<td><?php 
                echo esc_attr($version);
                ?>
</td>
				<td><?php 
                echo esc_attr($requires);
                ?>
</td>
				<td>
					<?php 
                if (edd_get_download_files(get_the_ID())) {
                    ?>

						<?php 
                    if (!($has_ultimate_license || $has_professional_license)) {
                        ?>

							<?php 
                        if (!affwp_addon_is_coming_soon(get_the_ID()) || current_user_can('manage_options')) {
                            ?>

								<?php 
                            if ($has_plus_license || $has_personal_license) {
                                // upgrade
                                ?>

									<a href="#upgrade" title="Upgrade License" class="popup-content" data-effect="mfp-move-from-bottom">Upgrade license to download</a>

								<?php 
                            } else {
                                // no license
                                ?>
									<a href="<?php 
                                echo site_url('pricing');
                                ?>
">Purchase ultimate or professional<br/> license to download</a>
								<?php 
                            }
                            ?>

							<?php 
                        }
                        ?>

						<?php 
                    } else {
                        ?>

							<?php 
                        if ($has_ultimate_license || $has_professional_license) {
                            ?>

								<?php 
                            if (!affwp_addon_is_coming_soon(get_the_ID()) || current_user_can('manage_options')) {
                                ?>

									<a href="<?php 
                                echo affwp_get_add_on_download_url(get_the_ID());
                                ?>
">Download add-on</a>

								<?php 
                            }
                            ?>

							<?php 
                        }
                        ?>
						<?php 
                    }
                    ?>

					<?php 
                }
                // edd_get_download_files
                ?>
				</td>
			</tr>

		<?php 
            }
            ?>

	<?php 
        }
        wp_reset_postdata();
        ?>
		</tbody>
	</table>


	<?php 
        affwp_upgrade_license_modal();
        ?>

	<div class="affwp-licenses">
		<?php 
        $licenses = affwp_get_users_licenses();
        $license_heading = count($licenses) > 1 ? 'Your Licenses' : 'Your license';
        ?>

		<h2><?php 
        echo $license_heading;
        ?>
</h2>

		<?php 
        // a customer can happily have more than 1 license of any type
        if ($licenses) {
            ?>

				<?php 
            foreach ($licenses as $id => $license) {
                if ($license['limit'] == 0) {
                    $license['limit'] = 'Unlimited';
                } else {
                    $license['limit'] = $license['limit'];
                }
                $license_limit_text = $license['limit'] > 1 || $license['limit'] == 'Unlimited' ? ' sites' : ' site';
                ?>
					<div class="affwp-license">

						<p><strong><?php 
                echo edd_get_price_option_name(affwp_get_affiliatewp_id(), $license['price_id']);
                ?>
</strong> (<?php 
                echo $license['limit'] . $license_limit_text;
                ?>
) - <?php 
                echo $license['license'];
                ?>
</p>

						<?php 
                if (affwp_has_license_expired($license['license'])) {
                    $renewal_link = edd_get_checkout_uri(array('edd_license_key' => $license['license'], 'download_id' => affwp_get_affiliatewp_id()));
                    ?>
							<p class="license-expired"><a href="<?php 
                    echo esc_url($renewal_link);
                    ?>
">Your license has expired. Renew your license now and save 40% &rarr;</a></p>
						<?php 
                }
                ?>

						<?php 
                if ($license['price_id'] != 3) {
                    // only provide upgrade if not ultimate
                    ?>

							<ul>
								<?php 
                    if ($license['price_id'] == 0) {
                        // personal
                        ?>
									<li><a title="Upgrade to Ultimate license" href="<?php 
                        echo affwp_get_license_upgrade_url('ultimate', $id);
                        ?>
">Upgrade to Ultimate license (unlimited sites)</a></li>
									<li><a title="Upgrade to Professional license" href="<?php 
                        echo affwp_get_license_upgrade_url('professional', $id);
                        ?>
">Upgrade to Professional license (unlimited sites)</a></li>
									<li><a title="Upgrade to Plus license" href="<?php 
                        echo affwp_get_license_upgrade_url('plus', $id);
                        ?>
">Upgrade to Plus license (3 sites)</a></li>
								<?php 
                    }
                    ?>

								<?php 
                    if ($license['price_id'] == 1) {
                        // plus
                        ?>
									<li><a title="Upgrade to Ultimate license" href="<?php 
                        echo affwp_get_license_upgrade_url('ultimate', $id);
                        ?>
">Upgrade to Ultimate license (unlimited sites)</a></li>
									<li><a title="Upgrade to Professional license" href="<?php 
                        echo affwp_get_license_upgrade_url('professional', $id);
                        ?>
">Upgrade to Professional license (unlimited sites)</a></li>
								<?php 
                    }
                    ?>

								<?php 
                    if ($license['price_id'] == 2) {
                        // professional
                        ?>
									<li><a title="Upgrade to Ultimate license" href="<?php 
                        echo affwp_get_license_upgrade_url('ultimate', $id);
                        ?>
">Upgrade to Ultimate license (unlimited sites)</a></li>
								<?php 
                    }
                    ?>
							</ul>

						<?php 
                }
                ?>

					</div>

				<?php 
            }
            ?>

			<?php 
        } else {
            ?>
				<p>You do not have a license yet. <a href="<?php 
            echo site_url('pricing');
            ?>
">View pricing &rarr;</a></p>
			<?php 
        }
        ?>
	</div>


	<?php 
        // get current user's purchases
        $purchases = edd_get_users_purchases('', -1);
        $purchase_ids = array();
        $discount_codes = array();
        if ($purchases) {
            $purchase_ids = wp_list_pluck($purchases, 'ID');
        }
        if ($purchase_ids) {
            foreach ($purchase_ids as $id) {
                $discount_code = get_post_meta($id, '_edd_purchase_rewards_discount', true);
                if ($discount_code && edd_is_discount_active($discount_code) && !(function_exists('edd_purchase_rewards') && edd_purchase_rewards()->discounts->discount_code_used($discount_code))) {
                    $discount_codes[] = edd_get_discount_code($discount_code);
                }
            }
        }
        ?>

	<?php 
        if ($discount_codes) {
            ?>
		<h2>Available Discount Codes</h2>
		<p>Click a discount below and it will be applied to checkout.</p>
	<ul class="edd-pr-discounts">
		<?php 
            foreach ($discount_codes as $code) {
                ?>
			<li>
				<a href="<?php 
                echo add_query_arg('discount', $code, site_url('/account/'));
                ?>
">
				<?php 
                echo $code;
                ?>
				</a>
			</li>
		<?php 
            }
            ?>
	</ul>
	<?php 
        }
        ?>

	<?php 
        // purchase history
        echo '<h2>' . __('Purchase History', 'affwp') . '</h2>';
        echo edd_purchase_history();
        // download history
        echo '<h2>' . __('Download History', 'affwp') . '</h2>';
        echo edd_download_history();
        // profile editor
        echo '<h2>' . __('Edit your profile', 'affwp') . '</h2>';
        echo do_shortcode('[edd_profile_editor]');
        ?>

	<?php 
    }
    ?>

<?php 
}