Example #1
0
            ?>
</h2>
			    		

					<?php 
        }
        ?>
	

			       	<?php 
        the_excerpt();
        ?>
		       	</div>
		       	
		       <?php 
        if (affwp_addon_is_coming_soon(get_the_ID())) {
            ?>
		    		<span class="coming-soon">Coming Soon</span>
		    	<?php 
        } else {
            ?>
	

		       	<a title="<?php 
            the_title_attribute();
            ?>
" href="<?php 
            the_permalink();
            ?>
" class="link">
 		    		Learn More  &rarr;
Example #2
0
/**		
 * Metabox callback
 * @since 1.0
*/
function affwp_addon_meta_box($post_id)
{
    ?>
	
	<p>
		<label for="affwp-addon-coming-soon">
			<input type="checkbox" name="affwp_addon_coming_soon" id="affwp-addon-coming-soon" value="1" <?php 
    checked(true, affwp_addon_is_coming_soon(get_the_ID()));
    ?>
 />
			<?php 
    _e('Add-on is coming soon', 'affwp');
    ?>
		</label>
	</p>

	<p><strong><?php 
    _e('AffiliateWP Version Required', 'affwp');
    ?>
</strong></p>
	<p>
		<label for="affwp_addon_requires" class="screen-reader-text">
			<?php 
    _e('Requires', 'affwp');
    ?>
		</label>
		<input class="widefat" type="text" name="affwp_addon_requires" id="affwp_addon_requires" value="<?php 
    echo esc_attr(get_post_meta(get_the_ID(), '_affwp_addon_requires', true));
    ?>
" size="30" />
	</p>

	<p><strong><?php 
    _e('EDD Version Required', 'affwp');
    ?>
</strong></p>
	<p>
		<label for="affwp-addon-requires-edd" class="screen-reader-text">
			<?php 
    _e('Requires', 'affwp');
    ?>
		</label>
		<input class="widefat" type="text" name="affwp_addon_edd_version_required" id="affwp-addon-requires-edd" value="<?php 
    echo esc_attr(get_post_meta(get_the_ID(), '_affwp_addon_edd_version_required', true));
    ?>
" size="30" />
	</p>

	<p><strong><?php 
    _e('External Download URL', 'affwp');
    ?>
</strong></p>
	<p>
		<label for="affwp-addon-download-url" class="screen-reader-text">
			<?php 
    _e('External Download URL', 'affwp');
    ?>
		</label>	
		<input class="widefat" type="text" name="affwp_addon_download_url" id="affwp-addon-download-url" value="<?php 
    echo esc_attr(get_post_meta(get_the_ID(), '_affwp_addon_download_url', true));
    ?>
" size="30" />
	</p>

	<p><strong><?php 
    _e('External Documentation URL', 'affwp');
    ?>
</strong></p>
	<p>
		<label for="affwp-addon-doc-url" class="screen-reader-text">
			<?php 
    _e('External Download URL', 'affwp');
    ?>
		</label>	
		<input class="widefat" type="text" name="affwp_addon_doc_url" id="affwp-addon-doc-url" value="<?php 
    echo esc_attr(get_post_meta(get_the_ID(), '_affwp_addon_doc_url', true));
    ?>
" size="30" />
	</p>

	<p><strong><?php 
    _e('Developer', 'affwp');
    ?>
</strong></p>
	<p>
		<label for="affwp-addon-download-developer" class="screen-reader-text">
			<?php 
    _e('Developer', 'affwp');
    ?>
		</label>	
		<input class="widefat" type="text" name="affwp_addon_developer" id="affwp-addon-developer" value="<?php 
    echo esc_attr(get_post_meta(get_the_ID(), '_affwp_addon_developer', true));
    ?>
" size="30" />
	</p>

	<p><strong><?php 
    _e('Developer URL', 'affwp');
    ?>
</strong></p>
	<p>
		<label for="affwp-addon-download-developer-url" class="screen-reader-text">
			<?php 
    _e('Developer URL', 'affwp');
    ?>
		</label>	
		<input class="widefat" type="text" name="affwp_addon_developer_url" id="affwp-addon-developer-url" value="<?php 
    echo esc_attr(get_post_meta(get_the_ID(), '_affwp_addon_developer_url', true));
    ?>
" size="30" />
	</p>

	<?php 
    wp_nonce_field('affwp_addon_metaboxes', 'affwp_addon_metaboxes');
    ?>

<?php 
}
Example #3
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 
}
Example #4
0
/**
 * Redirect if addon is accessed while coming soon
 * Admins can see addon just fine
 * @since 1.1.9
 */
function affwp_redirect_coming_soon()
{
    global $post;
    if (!is_singular('download') || current_user_can('manage_options')) {
        return;
    }
    $do_redirect = affwp_addon_is_coming_soon(get_the_ID());
    if ($do_redirect) {
        $redirect_url = site_url('addons');
        if (isset($_REQUEST['HTTP_REFERER'])) {
            $referer = esc_url($_REQUEST['HTTP_REFERER ']);
            if (strpos($referer, $redirect_url) !== false) {
                $redirect_url = $referer;
            }
        }
        wp_redirect($redirect_url, 301);
        exit;
    }
}
Example #5
0
/**
 * Addon popups
 */
function affwp_add_on_popups()
{
    ?>


	<?php 
    $args = array('post_type' => 'download', 'posts_per_page' => -1, 'tax_query' => array(array('taxonomy' => 'download_category', 'field' => 'slug', 'terms' => 'pro-add-ons')));
    $wp_query = new WP_Query($args);
    ?>

	<div id="modal-pro-add-ons" class="modal addons popup entry-content mfp-with-anim mfp-hide">
		<h1>Pro Add-ons</h1>
		<p>Pro add-ons are only available to <strong>Professional</strong> or <strong>Ultimate</strong> license-holders.</p>
		<?php 
    if ($wp_query->have_posts()) {
        ?>

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

		        <article>
					<?php 
            if (!affwp_addon_is_coming_soon(get_the_ID())) {
                // don't show coming soon add-ons
                ?>

			    		<h2><?php 
                the_title();
                ?>
</h2>

				    	<div class="columns columns-2">
				    		<div class="wrapper">
					    		<div class="item excerpt">
					    			<?php 
                the_excerpt();
                ?>
					    		</div>

					    		<div class="item image">
					    		<?php 
                affwp_post_thumbnail('thumbnail', false);
                ?>
					    		</div>
					    	</div>
				    	</div>

					<?php 
            }
            ?>

			</article>

		    <?php 
        }
        wp_reset_query();
        ?>



		<?php 
    }
    ?>

	</div>


	<div id="modal-third-party-add-ons" class="modal addons popup entry-content mfp-with-anim mfp-hide">


		<?php 
    $args = array('post_type' => 'download', 'posts_per_page' => -1, 'tax_query' => array(array('taxonomy' => 'download_category', 'field' => 'slug', 'terms' => '3rd-party')));
    $third_party = new WP_Query($args);
    ?>


		<h1>Third Party Add-ons</h1>

		<?php 
    if ($third_party->have_posts()) {
        ?>

		    <?php 
        while ($third_party->have_posts()) {
            $third_party->the_post();
            $coming_soon = affwp_addon_is_coming_soon(get_the_ID()) ? 'coming-soon' : '';
            ?>

		        <article <?php 
            post_class(array($coming_soon));
            ?>
>

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

			    		<h2><?php 
                the_title();
                ?>
</h2>

				    	<div class="columns columns-2">
				    		<div class="wrapper">
					    		<div class="item excerpt">
					    			<?php 
                the_excerpt();
                ?>
					    		</div>

					    		<div class="item image">
					    		<?php 
                affwp_post_thumbnail('thumbnail', false);
                ?>
					    		</div>
					    	</div>
				    	</div>

				    <?php 
            } elseif (affwp_addon_is_coming_soon(get_the_ID())) {
                ?>

				    	<h2><?php 
                the_title();
                ?>
</h2>

			    	 	<?php 
                the_excerpt();
                ?>

			    		<div class="post-thumbnail">
			    			<?php 
                if (current_user_can('manage_options')) {
                    ?>
			    				<?php 
                    affwp_post_thumbnail('thumbnail', false);
                    ?>
			    			<?php 
                } else {
                    ?>
			    				<img alt="<?php 
                    the_title();
                    ?>
 - Coming Soon" src="<?php 
                    echo get_stylesheet_directory_uri() . '/images/add-ons-coming-soon.png';
                    ?>
">
			    			<?php 
                }
                ?>

			    		</div>

					<?php 
            }
            ?>

			</article>

		    <?php 
        }
        wp_reset_query();
        ?>

		<?php 
    }
    ?>

	</div>






	<?php 
    $args = array('post_type' => 'download', 'posts_per_page' => -1, 'tax_query' => array(array('taxonomy' => 'download_category', 'field' => 'slug', 'terms' => 'official-free')));
    $official_free = new WP_Query($args);
    ?>

	<div id="modal-offical-free-add-ons" class="modal addons popup entry-content mfp-with-anim mfp-hide">

		<h1>Official Free Add-ons</h1>

		<?php 
    if ($official_free->have_posts()) {
        ?>

		    <?php 
        while ($official_free->have_posts()) {
            $official_free->the_post();
            $coming_soon = affwp_addon_is_coming_soon(get_the_ID()) ? 'coming-soon' : '';
            ?>

		        <article <?php 
            post_class(array($coming_soon));
            ?>
>

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

			    		<h2><?php 
                the_title();
                ?>
</h2>

				    	<div class="columns columns-2">
				    		<div class="wrapper">
					    		<div class="item excerpt">
					    			<?php 
                the_excerpt();
                ?>
					    		</div>

					    		<div class="item image">
					    		<?php 
                affwp_post_thumbnail('thumbnail', false);
                ?>
					    		</div>
					    	</div>
				    	</div>

				    <?php 
            } elseif (affwp_addon_is_coming_soon(get_the_ID())) {
                ?>

				    	<h2><?php 
                the_title();
                ?>
</h2>

			    	 	<?php 
                the_excerpt();
                ?>

			    		<div class="post-thumbnail">
			    			<?php 
                if (current_user_can('manage_options')) {
                    ?>
			    				<?php 
                    affwp_post_thumbnail('thumbnail', false);
                    ?>
			    			<?php 
                } else {
                    ?>
			    				<img alt="<?php 
                    the_title();
                    ?>
 - Coming Soon" src="<?php 
                    echo get_stylesheet_directory_uri() . '/images/add-ons-coming-soon.png';
                    ?>
">
			    			<?php 
                }
                ?>

			    		</div>

					<?php 
            }
            ?>

			</article>

		    <?php 
        }
        wp_reset_query();
        ?>

		<?php 
    }
    ?>


	</div>

	<?php 
}