/**
  * Display a login form on the support page if the user is not logged in.
  *
  * @since 2.0.0
  *
  * @param string $content
  * @return mixed
  */
 public function filter_shortcode_login($content)
 {
     if (!is_page(donkey_get_setting('page_submit'))) {
         return $content;
     }
     if (is_user_logged_in()) {
         return $content;
     }
     return edd_login_form();
 }
/**
 * Output registration form
 */
function vp_edd_membership_form($atts, $content = null)
{
    extract(shortcode_atts(array(), $atts));
    // get the previous url from GET parameters
    $redirect = '';
    if (isset($_GET['redirect'])) {
        $redirect = urldecode($_GET['redirect']);
    }
    // begin output
    ?>
		<?php 
    do_action('vp_edd_fd_before_member');
    ?>

		<!-- login form -->
		<?php 
    echo edd_login_form($redirect);
    ?>
		<!-- /login form -->

		<!-- registration form -->
		<?php 
    if (!is_user_logged_in()) {
        ?>
			<form method="POST" action="">
				<?php 
        vp_edd_fd_get_register_fields();
        ?>
				<input type="submit" value="<?php 
        _e('Register', 'vp_edd_fd');
        ?>
" />
			</form>
		<?php 
    }
    ?>
		<!-- /registration form -->

		<?php 
    do_action('vp_edd_fd_after_member');
    ?>
	<?php 
    // end of output
}
/**
 * Login Shortcode
 *
 * Shows a login form allowing users to users to log in. This function simply
 * calls the edd_login_form function to display the login form.
 *
 * @since 1.0
 * @param array $atts Shortcode attributes
 * @param string $content
 * @uses edd_login_form()
 * @return string
 */
function edd_login_form_shortcode($atts, $content = null)
{
    extract(shortcode_atts(array('redirect' => ''), $atts));
    return edd_login_form($redirect);
}
/**
 * Support Dashboard Shortcode Callback
 *
 * Show:
 *  - open tickets
 *  - assigned tickets
 *  - unassigned tickets
 *  - tickets awaiting answer
 *
 * @since		1.0.0
 * @param		array $atts Shortcode attributes
 * @param		string $content The shortcode content
 * @global		int $user_ID The ID of the current user
 * @return
 */
function edd_bbp_dashboard_shortcode($atts, $content = null)
{
    global $user_ID;
    // Bail if not logged in
    if (!is_user_logged_in()) {
        return edd_login_form();
    }
    // Bail if current user isn't a moderator
    if (!current_user_can('moderate')) {
        return;
    }
    // Enqueue our styles
    wp_enqueue_script('bootstrap', EDD_BBP_URL . 'assets/js/bootstrap.min.js');
    wp_enqueue_style('bootstrap', EDD_BBP_URL . 'assets/css/bootstrap.min.css');
    // Show ticket overview for all mods
    $mods = edd_bbp_get_all_mods();
    ?>

	<?php 
    if ($mods) {
        ?>
		<div class="row" id="mods-grid">
		<?php 
        foreach ($mods as $mod) {
            ?>

			<?php 
            $ticket_count = edd_bbp_count_tickets_of_mod($mod->ID);
            ?>

			<div class="mod col-xs-6 col-sm-3">
				<div class="mod-name"><?php 
            echo $mod->display_name;
            ?>
</div>
				<div class="mod-gravatar"><?php 
            echo get_avatar($mod->ID, 45);
            ?>
</div>
				<div class="mod-ticket-count">
					<a href="<?php 
            echo add_query_arg('mod', $mod->ID);
            ?>
">Tickets: <strong><?php 
            echo $ticket_count;
            ?>
</strong></div></a>
			</div>

		<?php 
        }
        ?>
		</div>
	<?php 
    }
    if (!empty($_GET['mod'])) {
        // Get open, assigned tickets
        $args = array('post_type' => 'topic', 'meta_query' => array('relation' => 'AND', array('key' => '_bbps_topic_status', 'value' => '1'), array('key' => 'bbps_topic_assigned', 'value' => $_GET['mod'])), 'posts_per_page' => -1, 'post_parent__not_in' => array(318));
        $assigned_tickets = new WP_Query($args);
        $mod = get_userdata($_GET['mod']);
        ob_start();
        ?>
		<div class="bbp-tickets">
			<?php 
        if ($assigned_tickets->have_posts()) {
            ?>
				<h4>Tickets assigned to <?php 
            echo $mod->display_name;
            ?>
</h4>
					<table class="table table-striped" width="100%">
						<tr>
							<th width="35%">Topic Title</th>
							<th width="25%">Last Post By</th>
							<th width="25%">Last Updated</th>
							<th width="15%">Post Count</th>
						</tr>
						<?php 
            while ($assigned_tickets->have_posts()) {
                $assigned_tickets->the_post();
                ?>
							<?php 
                $parent = get_post_field('post_parent', get_the_ID());
                ?>
							<?php 
                $row_class = $parent == 499 ? 'danger' : '';
                ?>
							<?php 
                $last_reply_id = bbp_get_topic_last_reply_id(get_the_ID());
                ?>
							<?php 
                $last_reply_data = get_post($last_reply_id);
                ?>
							<tr class = "<?php 
                echo $row_class;
                ?>
">
								<td>
								<a href="<?php 
                the_permalink();
                ?>
"><?php 
                the_title();
                ?>
</a>
								</td>
								<td><?php 
                the_author_meta('display_name', $last_reply_data->post_author);
                ?>
</td>
								<td><?php 
                bbp_topic_freshness_link();
                ?>
</td>
								<td><?php 
                bbp_topic_post_count(get_the_ID());
                ?>
</td>
							</tr>
						<?php 
            }
            ?>
					<?php 
            wp_reset_postdata();
            ?>
					</table>
			<?php 
        } else {
            ?>
				<div>This mod has no assigned tickets.</div>
			<?php 
        }
        ?>
		</div>
		<?php 
        return ob_get_clean();
    }
    // Get tickets awaiting answer
    $args = array('post_type' => 'topic', 'meta_query' => array('relation' => 'AND', array('key' => '_bbps_topic_pending'), array('key' => '_bbps_topic_status', 'value' => '1'), array('key' => 'bbps_topic_assigned', 'value' => $user_ID)), 'order' => 'ASC', 'orderby' => 'meta_value', 'meta_key' => '_bbp_last_active_time', 'posts_per_page' => -1, 'post_parent__not_in' => array(318));
    $waiting_tickets = new WP_Query($args);
    // Get open, assigned tickets
    $args = array('post_type' => 'topic', 'meta_query' => array('relation' => 'AND', array('key' => '_bbps_topic_status', 'value' => '1'), array('key' => 'bbps_topic_assigned', 'value' => $user_ID)), 'order' => 'ASC', 'orderby' => 'meta_value', 'meta_key' => '_bbp_last_active_time', 'posts_per_page' => -1, 'post_parent__not_in' => array(318));
    $assigned_tickets = new WP_Query($args);
    // Get unassigned tickets
    $args = array('post_type' => 'topic', 'meta_query' => array('relation' => 'AND', array('key' => 'bbps_topic_assigned', 'compare' => 'NOT EXISTS', 'value' => '1'), array('key' => '_bbps_topic_status', 'value' => '1')), 'order' => 'ASC', 'orderby' => 'meta_value', 'meta_key' => '_bbp_last_active_time', 'posts_per_page' => -1, 'post_status' => 'publish', 'post_parent__not_in' => array(318));
    $unassigned_tickets = new WP_Query($args);
    // Get tickets with no replies
    $args = array('post_type' => 'topic', 'meta_query' => array('relation' => 'AND', array('key' => '_bbp_voice_count', 'value' => '1'), array('key' => '_bbps_topic_status', 'value' => '1')), 'posts_per_page' => -1, 'post_status' => 'publish');
    $no_reply_tickets = new WP_Query($args);
    // Get unresolved tickets
    $args = array('post_type' => 'topic', 'post_parent__not_in' => array(318), 'posts_per_page' => -1, 'post_status' => 'publish', 'order' => 'ASC', 'orderby' => 'meta_value', 'meta_key' => '_bbp_last_active_time', 'meta_query' => array(array('key' => '_bbps_topic_status', 'value' => '1')));
    $unresolved_tickets = new WP_Query($args);
    // Get unresolved tickets
    $args = array('post_type' => 'topic', 'post_parent' => 318, 'posts_per_page' => 30, 'post_status' => 'publish');
    $feature_requests = new WP_Query($args);
    $open_count = 0;
    $unassigned_count = 0;
    $unresolved_count = 0;
    ob_start();
    ?>
	<style>
	#support-tabs { padding-left: 0; }
	#support-tabs li { list-style: none; margin-left: 0; font-size: 95%;}
	#support-tabs li a { padding: 4px; }
	#mods-grid { margin-bottom: 20px; }
	</style>
	<ul class="nav nav-tabs" id="support-tabs">
		<li><a href="#your-waiting-tickets" data-toggle="tab">Awaiting Your Response (<?php 
    echo $waiting_tickets->post_count;
    ?>
)</a></li>
		<li><a href="#your-tickets" data-toggle="tab">Your Open Tickets (<?php 
    echo $assigned_tickets->post_count;
    ?>
)</a></li>
		<li><a href="#unassigned" data-toggle="tab">Unassigned Tickets (<?php 
    echo $unassigned_tickets->post_count;
    ?>
)</a></li>
		<li><a href="#no-replies" data-toggle="tab">No Replies (<?php 
    echo $no_reply_tickets->post_count;
    ?>
)</a></li>
		<li><a href="#unresolved" data-toggle="tab">Unresolved Tickets (<?php 
    echo $unresolved_tickets->post_count;
    ?>
)</a></li>
		<li><a href="#feature-requests" data-toggle="tab">Feature Requests</a></li>
	</ul>
	<div class="tab-content">
		<div class="tab-pane active" id="your-waiting-tickets">
			<ul class="bbp-tickets">
				<?php 
    if ($waiting_tickets->have_posts()) {
        ?>
					<form class="form-table" method="post">
						<table class="table table-striped" width="100%">
							<tr>
								<th></th>
								<th width="40%">Topic Title</th>
								<th width="25%">Last Updated</th>
								<th width="25%">Actions</th>
							</tr>
							<?php 
        while ($waiting_tickets->have_posts()) {
            $waiting_tickets->the_post();
            ?>
								<?php 
            $parent = get_post_field('post_parent', get_the_ID());
            ?>
								<?php 
            $row_class = $parent == 499 ? 'danger' : '';
            ?>
								<?php 
            $remove_url = add_query_arg(array('topic_id' => get_the_ID(), 'bbps_action' => 'remove_pending'));
            ?>
								<tr class = "<?php 
            echo $row_class;
            ?>
">
									<td>
										<input type="checkbox" name="tickets[]" value="<?php 
            echo esc_attr(get_the_ID());
            ?>
"/>
									</td>
									<td>
										<a href="<?php 
            the_permalink();
            ?>
"><?php 
            the_title();
            ?>
</a>
									</td>
									<td><?php 
            bbp_topic_freshness_link(get_the_ID());
            ?>
</td>
									<td><a href="<?php 
            echo $remove_url;
            ?>
">Remove Pending Status</a></td>
								</tr>
							<?php 
        }
        ?>
						</table>
						<input type="hidden" name="edd_action" value="remove_ticket_pending_status"/>
						<input type="submit" value="Remove Pending Status"/>
						<?php 
        wp_reset_postdata();
        ?>
					</form>
				<?php 
    } else {
        ?>
					<li>No tickets awaiting your reply. Excellent, now go grab some unresolved or unassigned tickets.</li>
				<?php 
    }
    ?>
			</ul>
		</div>
		<div class="tab-pane" id="your-tickets">
			<ul class="bbp-tickets">
				<?php 
    if ($assigned_tickets->have_posts()) {
        ?>
					<table class="table table-striped" width="100%">
						<tr>
							<th width="40%">Topic Title</th>
							<th width="30%">Last Post By</th>
							<th width="30%">Last Updated</th>
						</tr>
						<?php 
        while ($assigned_tickets->have_posts()) {
            $assigned_tickets->the_post();
            ?>
							<?php 
            $parent = get_post_field('post_parent', get_the_ID());
            ?>
							<?php 
            $row_class = $parent == 499 ? 'danger' : '';
            ?>
							<?php 
            $last_reply_id = bbp_get_topic_last_reply_id(get_the_ID());
            ?>
							<?php 
            $last_reply_data = get_post($last_reply_id);
            ?>
							<tr class = "<?php 
            echo $row_class;
            ?>
">
								<td>
								<a href="<?php 
            the_permalink();
            ?>
"><?php 
            the_title();
            ?>
</a>
								</td>
								<td><?php 
            the_author_meta('display_name', $last_reply_data->post_author);
            ?>
</td>
								<td><?php 
            bbp_topic_freshness_link(get_the_ID());
            ?>
</td>
							</tr>
						<?php 
        }
        ?>
					<?php 
        wp_reset_postdata();
        ?>
					</table>
				<?php 
    } else {
        ?>
					<li>No unresolved tickets, yay! Now go grab some unresolved or unassigned tickets.</li>
				<?php 
    }
    ?>
			</ul>
		</div>
		<div class="tab-pane" id="unassigned">
			<ul class="bbp-tickets">
				<?php 
    if ($unassigned_tickets->have_posts()) {
        ?>
					<table class="table table-striped" width="100%">
						<tr>
							<th width="40%">Topic Title</th>
							<th width="30%">Last Post By</th>
							<th width="30%">Last Updated</th>
						</tr>
						<?php 
        while ($unassigned_tickets->have_posts()) {
            $unassigned_tickets->the_post();
            ?>
							<?php 
            $parent = get_post_field('post_parent', get_the_ID());
            ?>
							<?php 
            $row_class = $parent == 499 ? 'danger' : '';
            ?>
							<?php 
            $last_reply_id = bbp_get_topic_last_reply_id(get_the_ID());
            ?>
							<?php 
            $last_reply_data = get_post($last_reply_id);
            ?>
							<tr class = "<?php 
            echo $row_class;
            ?>
">
								<td>
								<a href="<?php 
            the_permalink();
            ?>
"><?php 
            the_title();
            ?>
</a>
								</td>
								<td><?php 
            the_author_meta('display_name', $last_reply_data->post_author);
            ?>
</td>
								<td><?php 
            bbp_topic_freshness_link(get_the_ID());
            ?>
</td>
							</tr>
						<?php 
        }
        ?>
					<?php 
        wp_reset_postdata();
        ?>
					</table>
				<?php 
    } else {
        ?>
					<li>No unassigned tickets, yay!</li>
				<?php 
    }
    ?>
			</ul>
		</div>
		<div class="tab-pane" id="no-replies">
			<ul class="bbp-tickets">
				<?php 
    if ($no_reply_tickets->have_posts()) {
        ?>
					<table class="table table-striped" width="100%">
						<tr>
							<th width="40%">Topic Title</th>
							<th width="30%">Posted</th>
							<th width="30%">Assignee</th>
						</tr>
						<?php 
        while ($no_reply_tickets->have_posts()) {
            $no_reply_tickets->the_post();
            ?>
							<?php 
            $parent = get_post_field('post_parent', get_the_ID());
            ?>
							<?php 
            $row_class = $parent == 499 ? 'danger' : '';
            ?>

							<?php 
            $assignee_id = edd_bbp_get_topic_assignee_id(get_the_ID());
            ?>
							<?php 
            $assignee_name = edd_bbp_get_topic_assignee_name($assignee_id);
            ?>
							<tr class = "<?php 
            echo $row_class;
            ?>
">
								<td>
								<a href="<?php 
            the_permalink();
            ?>
"><?php 
            the_title();
            ?>
</a>
								</td>
								<td><?php 
            bbp_topic_freshness_link(get_the_ID());
            ?>
</td>
								<td><?php 
            echo !empty($assignee_name) ? $assignee_name : 'Unassigned';
            ?>
</td>
							</tr>
						<?php 
        }
        ?>
					<?php 
        wp_reset_postdata();
        ?>
					</table>
				<?php 
    } else {
        ?>
					<li>No tickets without replies, yay!</li>
				<?php 
    }
    ?>
			</ul>
		</div>
		<div class="tab-pane" id="unresolved">
			<ul class="bbp-tickets">
				<?php 
    if ($unresolved_tickets->have_posts()) {
        ?>
					<table class="table table-striped" width="100%">
						<tr>
							<th width="35%">Topic Title</th>
							<th width="25%">Last Updated</th>
							<th width="25%">Assignee</th>
							<th width="15%">Post Count</th>
						</tr>
						<?php 
        while ($unresolved_tickets->have_posts()) {
            $unresolved_tickets->the_post();
            ?>
							<?php 
            $parent = get_post_field('post_parent', get_the_ID());
            ?>
							<?php 
            $row_class = $parent == 499 ? 'danger' : '';
            ?>

							<?php 
            $assignee_id = edd_bbp_get_topic_assignee_id(get_the_ID());
            ?>
							<?php 
            $assignee_name = edd_bbp_get_topic_assignee_name($assignee_id);
            ?>
							<tr class = "<?php 
            echo $row_class;
            ?>
">
								<td>
								<a href="<?php 
            the_permalink();
            ?>
"><?php 
            the_title();
            ?>
</a>
								</td>
								<td><?php 
            bbp_topic_freshness_link(get_the_ID());
            ?>
</td>
								<td><?php 
            echo !empty($assignee_name) ? $assignee_name : 'Unassigned';
            ?>
</td>
								<td><?php 
            bbp_topic_post_count(get_the_ID());
            ?>
</td>
							</tr>
						<?php 
        }
        ?>
					<?php 
        wp_reset_postdata();
        ?>
					</table>
				<?php 
    } else {
        ?>
					<li>No unassigned tickets, yay!</li>
				<?php 
    }
    ?>
			</ul>
		</div>
		<div class="tab-pane" id="feature-requests">
			<ul class="bbp-tickets">
				<?php 
    if ($feature_requests->have_posts()) {
        ?>
					<?php 
        while ($feature_requests->have_posts()) {
            $feature_requests->the_post();
            ?>
						<li><a href="<?php 
            the_permalink();
            ?>
"><?php 
            the_title();
            ?>
</a></li>
					<?php 
        }
        ?>
					<?php 
        wp_reset_postdata();
        ?>
				<?php 
    }
    ?>
			</ul>
		</div>
	</div>

	<script>
	jQuery( function($) {
		$('#support-tabs a:first').tab('show');
	})
	</script>
	<?php 
    return ob_get_clean();
}
				<?php do_action( 'edd_profile_editor_address' ); ?>
			</p>
			<?php do_action( 'edd_profile_editor_after_address' ); ?>
			<span id="edd_profile_password_label"><legend><?php _e( 'Change your Password', 'edd' ); ?></legend></span>
			<p id="edd_profile_password_wrap">
				<label for="edd_user_pass"><?php _e( 'New Password', 'edd' ); ?></label>
				<input name="edd_new_user_pass1" id="edd_new_user_pass1" class="password edd-input" type="password"/>
				<br />
				<label for="edd_user_pass"><?php _e( 'Re-enter Password', 'edd' ); ?></label>
				<input name="edd_new_user_pass2" id="edd_new_user_pass2" class="password edd-input" type="password"/>
				<?php do_action( 'edd_profile_editor_password' ); ?>
			</p>
			<p class="edd_password_change_notice"><?php _e( 'Please note after changing your password, you must log back in.', 'edd' ); ?></p>
			<?php do_action( 'edd_profile_editor_after_password' ); ?>
			<p id="edd_profile_submit_wrap">
				<input type="hidden" name="edd_profile_editor_nonce" value="<?php echo wp_create_nonce( 'edd-profile-editor-nonce' ); ?>"/>
				<input type="hidden" name="edd_action" value="edit_user_profile" />
				<input type="hidden" name="edd_redirect" value="<?php echo esc_url( edd_get_current_page_url() ); ?>" />
				<input name="edd_profile_editor_submit" id="edd_profile_editor_submit" type="submit" class="edd_submit" value="<?php _e( 'Save Changes', 'edd' ); ?>"/>
			</p>
		</fieldset>
	</form><!-- #edd_profile_editor_form -->

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

	<?php
else:
	echo __( 'You need to login to edit your profile.', 'edd' );
	echo edd_login_form();
endif;
/**
 * Login Shortcode
 *
 * Shows a login form allowing users to users to log in. This function simply
 * calls the edd_login_form function to display the login form.
 *
 * @since 1.0
 * @param array $atts Shortcode attributes
 * @param string $content
 * @uses edd_login_form()
 * @return string
 */
function edd_login_form_shortcode($atts, $content = null)
{
    $redirect = '';
    extract(shortcode_atts(array('redirect' => $redirect), $atts, 'edd_login'));
    if (empty($redirect)) {
        $login_redirect_page = edd_get_option('login_redirect_page', '');
        if (!empty($login_redirect_page)) {
            $redirect = get_permalink($login_redirect_page);
        }
    }
    if (empty($redirect)) {
        $purchase_history = edd_get_option('purchase_history_page', 0);
        if (!empty($purchase_history)) {
            $redirect = get_permalink($purchase_history);
        }
    }
    if (empty($redirect)) {
        $redirect = home_url();
    }
    return edd_login_form($redirect);
}
Beispiel #7
0
/**
 * 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 
}