/**
     * Use our own payment fields at checkout. (Remove the name attributes.)		
     * @since 1.8
     */
    static function pmpro_include_payment_information_fields($include)
    {
        //global vars
        global $pmpro_requirebilling, $pmpro_show_discount_code, $discount_code, $CardType, $AccountNumber, $ExpirationMonth, $ExpirationYear;
        //get accepted credit cards
        $pmpro_accepted_credit_cards = pmpro_getOption("accepted_credit_cards");
        $pmpro_accepted_credit_cards = explode(",", $pmpro_accepted_credit_cards);
        $pmpro_accepted_credit_cards_string = pmpro_implodeToEnglish($pmpro_accepted_credit_cards);
        //include ours
        ?>
			<table id="pmpro_payment_information_fields" class="pmpro_checkout top1em" width="100%" cellpadding="0" cellspacing="0" border="0" <?php 
        if (!$pmpro_requirebilling || apply_filters("pmpro_hide_payment_information_fields", false)) {
            ?>
style="display: none;"<?php 
        }
        ?>
>
			<thead>
				<tr>
					<th><span class="pmpro_thead-msg"><?php 
        printf(__('We Accept %s', 'pmpro'), $pmpro_accepted_credit_cards_string);
        ?>
</span><?php 
        _e('Payment Information', 'pmpro');
        ?>
</th>
				</tr>
			</thead>
			<tbody>
				<tr valign="top">
					<td>
						<?php 
        $sslseal = pmpro_getOption("sslseal");
        if ($sslseal) {
            ?>
								<div class="pmpro_sslseal"><?php 
            echo stripslashes($sslseal);
            ?>
</div>
							<?php 
        }
        ?>
						<?php 
        $pmpro_include_cardtype_field = apply_filters('pmpro_include_cardtype_field', false);
        if ($pmpro_include_cardtype_field) {
            ?>
							<div class="pmpro_payment-card-type">
								<label for="CardType"><?php 
            _e('Card Type', 'pmpro');
            ?>
</label>
								<select id="CardType" class=" <?php 
            echo pmpro_getClassForField("CardType");
            ?>
">
									<?php 
            foreach ($pmpro_accepted_credit_cards as $cc) {
                ?>
										<option value="<?php 
                echo $cc;
                ?>
" <?php 
                if ($CardType == $cc) {
                    ?>
selected="selected"<?php 
                }
                ?>
><?php 
                echo $cc;
                ?>
</option>
									<?php 
            }
            ?>
								</select>
							</div>
						<?php 
        } else {
            ?>
							<input type="hidden" id="CardType" name="CardType" value="<?php 
            echo esc_attr($CardType);
            ?>
" />
							<script>
								<!--
								jQuery(document).ready(function() {
										jQuery('#AccountNumber').validateCreditCard(function(result) {
											var cardtypenames = {
												"amex":"American Express",
												"diners_club_carte_blanche":"Diners Club Carte Blanche",
												"diners_club_international":"Diners Club International",
												"discover":"Discover",
												"jcb":"JCB",
												"laser":"Laser",
												"maestro":"Maestro",
												"mastercard":"Mastercard",
												"visa":"Visa",
												"visa_electron":"Visa Electron"
											}

											if(result.card_type)
												jQuery('#CardType').val(cardtypenames[result.card_type.name]);
											else
												jQuery('#CardType').val('Unknown Card Type');
										});
								});
								-->
							</script>
							<?php 
        }
        ?>

						<div class="pmpro_payment-account-number">
							<label for="AccountNumber"><?php 
        _e('Card Number', 'pmpro');
        ?>
</label>
							<input id="AccountNumber" class="input <?php 
        echo pmpro_getClassForField("AccountNumber");
        ?>
" type="text" size="25" value="<?php 
        echo esc_attr($AccountNumber);
        ?>
" autocomplete="off" />
						</div>

						<div class="pmpro_payment-expiration">
							<label for="ExpirationMonth"><?php 
        _e('Expiration Date', 'pmpro');
        ?>
</label>
							<select id="ExpirationMonth" class=" <?php 
        echo pmpro_getClassForField("ExpirationMonth");
        ?>
">
								<option value="01" <?php 
        if ($ExpirationMonth == "01") {
            ?>
selected="selected"<?php 
        }
        ?>
>01</option>
								<option value="02" <?php 
        if ($ExpirationMonth == "02") {
            ?>
selected="selected"<?php 
        }
        ?>
>02</option>
								<option value="03" <?php 
        if ($ExpirationMonth == "03") {
            ?>
selected="selected"<?php 
        }
        ?>
>03</option>
								<option value="04" <?php 
        if ($ExpirationMonth == "04") {
            ?>
selected="selected"<?php 
        }
        ?>
>04</option>
								<option value="05" <?php 
        if ($ExpirationMonth == "05") {
            ?>
selected="selected"<?php 
        }
        ?>
>05</option>
								<option value="06" <?php 
        if ($ExpirationMonth == "06") {
            ?>
selected="selected"<?php 
        }
        ?>
>06</option>
								<option value="07" <?php 
        if ($ExpirationMonth == "07") {
            ?>
selected="selected"<?php 
        }
        ?>
>07</option>
								<option value="08" <?php 
        if ($ExpirationMonth == "08") {
            ?>
selected="selected"<?php 
        }
        ?>
>08</option>
								<option value="09" <?php 
        if ($ExpirationMonth == "09") {
            ?>
selected="selected"<?php 
        }
        ?>
>09</option>
								<option value="10" <?php 
        if ($ExpirationMonth == "10") {
            ?>
selected="selected"<?php 
        }
        ?>
>10</option>
								<option value="11" <?php 
        if ($ExpirationMonth == "11") {
            ?>
selected="selected"<?php 
        }
        ?>
>11</option>
								<option value="12" <?php 
        if ($ExpirationMonth == "12") {
            ?>
selected="selected"<?php 
        }
        ?>
>12</option>
							</select>/<select id="ExpirationYear" class=" <?php 
        echo pmpro_getClassForField("ExpirationYear");
        ?>
">
								<?php 
        for ($i = date("Y"); $i < date("Y") + 10; $i++) {
            ?>
									<option value="<?php 
            echo $i;
            ?>
" <?php 
            if ($ExpirationYear == $i) {
                ?>
selected="selected"<?php 
            }
            ?>
><?php 
            echo $i;
            ?>
</option>
								<?php 
        }
        ?>
							</select>
						</div>

						<?php 
        $pmpro_show_cvv = apply_filters("pmpro_show_cvv", true);
        if ($pmpro_show_cvv) {
            ?>
						<div class="pmpro_payment-cvv">
							<label for="CVV"><?php 
            _ex('CVV', 'Credit card security code, CVV/CCV/CVV2', 'pmpro');
            ?>
</label>
							<input class="input" id="CVV" type="text" size="4" value="<?php 
            if (!empty($_REQUEST['CVV'])) {
                echo esc_attr($_REQUEST['CVV']);
            }
            ?>
" class=" <?php 
            echo pmpro_getClassForField("CVV");
            ?>
" />  <small>(<a href="javascript:void(0);" onclick="javascript:window.open('<?php 
            echo pmpro_https_filter(PMPRO_URL);
            ?>
/pages/popup-cvv.html','cvv','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=600, height=475');"><?php 
            _ex("what's this?", 'link to CVV help', 'pmpro');
            ?>
</a>)</small>
						</div>
						<?php 
        }
        ?>

						<?php 
        if ($pmpro_show_discount_code) {
            ?>
						<div class="pmpro_payment-discount-code">
							<label for="discount_code"><?php 
            _e('Discount Code', 'pmpro');
            ?>
</label>
							<input class="input <?php 
            echo pmpro_getClassForField("discount_code");
            ?>
" id="discount_code" name="discount_code" type="text" size="20" value="<?php 
            echo esc_attr($discount_code);
            ?>
" />
							<input type="button" id="discount_code_button" name="discount_code_button" value="<?php 
            _e('Apply', 'pmpro');
            ?>
" />
							<p id="discount_code_message" class="pmpro_message" style="display: none;"></p>
						</div>
						<?php 
        }
        ?>

					</td>
				</tr>
			</tbody>
			</table>
			<?php 
        //don't include the default
        return false;
    }
Beispiel #2
0
						<?php 
            }
            ?>
    
					</td>						
				</tr>											
			</tbody>
			</table>                   
			<?php 
        }
        ?>
			
			<?php 
        $pmpro_accepted_credit_cards = pmpro_getOption("accepted_credit_cards");
        $pmpro_accepted_credit_cards = explode(",", $pmpro_accepted_credit_cards);
        $pmpro_accepted_credit_cards_string = pmpro_implodeToEnglish($pmpro_accepted_credit_cards);
        ?>
			
			<table id="pmpro_payment_information_fields" class="pmpro_checkout top1em" width="100%" cellpadding="0" cellspacing="0" border="0">
			<thead>
				<tr>
					<th colspan="2"><span class="pmpro_thead-msg"><?php 
        printf(__('We accept %s', 'pmpro'), $pmpro_accepted_credit_cards_string);
        ?>
</span><?php 
        _e('Credit Card Information', 'pmpro');
        ?>
</th>
				</tr>
			</thead>
			<tbody>                    
?>
	<?php 
if (!$pmpro_confirm) {
    if ($old_level_ids) {
        if (!is_array($old_level_ids) && $old_level_ids == "all") {
            ?>
					<p><?php 
            _e('Are you sure you want to cancel your membership?', 'pmpro');
            ?>
</p>
					<?php 
        } else {
            $level_names = $wpdb->get_col("SELECT name FROM {$wpdb->pmpro_membership_levels} WHERE id IN('" . implode("','", $old_level_ids) . "')");
            ?>
					<p><?php 
            printf(_n('Are you sure you want to cancel your %s membership?', 'Are you sure you want to cancel your %s memberships?', count($level_names), 'pmpro'), pmpro_implodeToEnglish($level_names));
            ?>
</p>
					<?php 
        }
        ?>
			
			<div class="pmpro_actionlinks">
				<a class="pmpro_btn pmpro_yeslink yeslink" href="<?php 
        echo pmpro_url("cancel", "?levelstocancel=" . esc_attr($_REQUEST['levelstocancel']) . "&confirm=true");
        ?>
"><?php 
        _e('Yes, cancel this membership', 'pmpro');
        ?>
</a>
				<a class="pmpro_btn pmpro_cancel pmpro_nolink nolink" href="<?php 
function pmpro_membership_content_filter($content, $skipcheck = false)
{
    global $post, $current_user;
    if (!$skipcheck) {
        $hasaccess = pmpro_has_membership_access(NULL, NULL, true);
        if (is_array($hasaccess)) {
            //returned an array to give us the membership level values
            $post_membership_levels_ids = $hasaccess[1];
            $post_membership_levels_names = $hasaccess[2];
            $hasaccess = $hasaccess[0];
        }
    }
    if ($hasaccess) {
        //all good, return content
        return $content;
    } else {
        //if show excerpts is set, return just the excerpt
        if (pmpro_getOption("showexcerpts")) {
            //show excerpt
            global $post;
            if ($post->post_excerpt) {
                //defined exerpt
                $content = wpautop($post->post_excerpt);
            } elseif (strpos($content, "<span id=\"more-" . $post->ID . "\"></span>") !== false) {
                //more tag
                $pos = strpos($content, "<span id=\"more-" . $post->ID . "\"></span>");
                $content = wpautop(substr($content, 0, $pos));
            } elseif (strpos($content, 'class="more-link">') !== false) {
                //more link
                $content = preg_replace("/\\<a.*class\\=\"more\\-link\".*\\>.*\\<\\/a\\>/", "", $content);
            } else {
                //auto generated excerpt. pulled from wp_trim_excerpt
                $content = strip_shortcodes($content);
                $content = str_replace(']]>', ']]&gt;', $content);
                $content = strip_tags($content);
                $excerpt_length = apply_filters('excerpt_length', 55);
                $words = preg_split("/[\n\r\t ]+/", $content, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
                if (count($words) > $excerpt_length) {
                    array_pop($words);
                    $content = implode(' ', $words);
                    $content = $content . "... ";
                } else {
                    $content = implode(' ', $words) . "... ";
                }
                $content = wpautop($content);
            }
        } else {
            //else hide everything
            $content = "";
        }
        if (empty($post_membership_levels_ids)) {
            $post_membership_levels_ids = array();
        }
        if (empty($post_membership_levels_names)) {
            $post_membership_levels_names = array();
        }
        //hide levels which don't allow signups by default
        if (!apply_filters("pmpro_membership_content_filter_disallowed_levels", false, $post_membership_levels_ids, $post_membership_levels_names)) {
            foreach ($post_membership_levels_ids as $key => $id) {
                //does this level allow registrations?
                $level_obj = pmpro_getLevel($id);
                if (!$level_obj->allow_signups) {
                    unset($post_membership_levels_ids[$key]);
                    unset($post_membership_levels_names[$key]);
                }
            }
        }
        $pmpro_content_message_pre = '<div class="pmpro_content_message">';
        $pmpro_content_message_post = '</div>';
        $sr_search = array("!!levels!!", "!!referrer!!");
        $sr_replace = array(pmpro_implodeToEnglish($post_membership_levels_names), urlencode(site_url($_SERVER['REQUEST_URI'])));
        //get the correct message to show at the bottom
        if (is_feed()) {
            $newcontent = apply_filters("pmpro_rss_text_filter", stripslashes(pmpro_getOption("rsstext")));
            $content .= $pmpro_content_message_pre . str_replace($sr_search, $sr_replace, $newcontent) . $pmpro_content_message_post;
        } elseif ($current_user->ID) {
            //not a member
            $newcontent = apply_filters("pmpro_non_member_text_filter", stripslashes(pmpro_getOption("nonmembertext")));
            $content .= $pmpro_content_message_pre . str_replace($sr_search, $sr_replace, $newcontent) . $pmpro_content_message_post;
        } else {
            //not logged in!
            $newcontent = apply_filters("pmpro_not_logged_in_text_filter", stripslashes(pmpro_getOption("notloggedintext")));
            $content .= $pmpro_content_message_pre . str_replace($sr_search, $sr_replace, $newcontent) . $pmpro_content_message_post;
        }
    }
    return $content;
}
    /**
     * Use our own payment fields at checkout. (Remove the name attributes and set some data-encrypted-name attributes.)
     * @since 1.8
     */
    static function pmpro_include_payment_information_fields($include)
    {
        //global vars
        global $pmpro_requirebilling, $pmpro_show_discount_code, $discount_code, $CardType, $AccountNumber, $ExpirationMonth, $ExpirationYear;
        //get accepted credit cards
        $pmpro_accepted_credit_cards = pmpro_getOption("accepted_credit_cards");
        $pmpro_accepted_credit_cards = explode(",", $pmpro_accepted_credit_cards);
        $pmpro_accepted_credit_cards_string = pmpro_implodeToEnglish($pmpro_accepted_credit_cards);
        //include ours
        ?>
			<table id="pmpro_payment_information_fields" class="pmpro_checkout top1em" width="100%" cellpadding="0" cellspacing="0" border="0" <?php 
        if (!$pmpro_requirebilling || apply_filters("pmpro_hide_payment_information_fields", false)) {
            ?>
style="display: none;"<?php 
        }
        ?>
>
			<thead>
				<tr>
					<th>
						<span class="pmpro_thead-name"><?php 
        _e('Payment Information', 'pmpro');
        ?>
</span>
						<span class="pmpro_thead-msg"><?php 
        printf(__('We Accept %s', 'pmpro'), $pmpro_accepted_credit_cards_string);
        ?>
</span>
					</th>
				</tr>
			</thead>
			<tbody>                    
				<tr valign="top">		
					<td>	
						<?php 
        $sslseal = pmpro_getOption("sslseal");
        if ($sslseal) {
            ?>
								<div class="pmpro_sslseal"><?php 
            echo stripslashes($sslseal);
            ?>
</div>
							<?php 
        }
        ?>
						<?php 
        $pmpro_include_cardtype_field = apply_filters('pmpro_include_cardtype_field', true);
        if ($pmpro_include_cardtype_field) {
            ?>
							<div class="pmpro_payment-card-type">
								<label for="CardType"><?php 
            _e('Card Type', 'pmpro');
            ?>
</label>
								<select id="CardType" name="CardType" class=" <?php 
            echo pmpro_getClassForField("CardType");
            ?>
">
									<?php 
            foreach ($pmpro_accepted_credit_cards as $cc) {
                ?>
										<option value="<?php 
                echo $cc;
                ?>
" <?php 
                if ($CardType == $cc) {
                    ?>
selected="selected"<?php 
                }
                ?>
><?php 
                echo $cc;
                ?>
</option>
									<?php 
            }
            ?>
												
								</select> 
							</div>
						<?php 
        }
        ?>
					
						<div class="pmpro_payment-account-number">
							<label for="AccountNumber"><?php 
        _e('Card Number', 'pmpro');
        ?>
</label>
							<input id="AccountNumber" name="AccountNumber" class="input <?php 
        echo pmpro_getClassForField("AccountNumber");
        ?>
" type="text" size="25" value="<?php 
        echo esc_attr($AccountNumber);
        ?>
" data-encrypted-name="number" autocomplete="off" /> 
						</div>
					
						<div class="pmpro_payment-expiration">
							<label for="ExpirationMonth"><?php 
        _e('Expiration Date', 'pmpro');
        ?>
</label>
							<select id="ExpirationMonth" name="ExpirationMonth" class=" <?php 
        echo pmpro_getClassForField("ExpirationMonth");
        ?>
">
								<option value="01" <?php 
        if ($ExpirationMonth == "01") {
            ?>
selected="selected"<?php 
        }
        ?>
>01</option>
								<option value="02" <?php 
        if ($ExpirationMonth == "02") {
            ?>
selected="selected"<?php 
        }
        ?>
>02</option>
								<option value="03" <?php 
        if ($ExpirationMonth == "03") {
            ?>
selected="selected"<?php 
        }
        ?>
>03</option>
								<option value="04" <?php 
        if ($ExpirationMonth == "04") {
            ?>
selected="selected"<?php 
        }
        ?>
>04</option>
								<option value="05" <?php 
        if ($ExpirationMonth == "05") {
            ?>
selected="selected"<?php 
        }
        ?>
>05</option>
								<option value="06" <?php 
        if ($ExpirationMonth == "06") {
            ?>
selected="selected"<?php 
        }
        ?>
>06</option>
								<option value="07" <?php 
        if ($ExpirationMonth == "07") {
            ?>
selected="selected"<?php 
        }
        ?>
>07</option>
								<option value="08" <?php 
        if ($ExpirationMonth == "08") {
            ?>
selected="selected"<?php 
        }
        ?>
>08</option>
								<option value="09" <?php 
        if ($ExpirationMonth == "09") {
            ?>
selected="selected"<?php 
        }
        ?>
>09</option>
								<option value="10" <?php 
        if ($ExpirationMonth == "10") {
            ?>
selected="selected"<?php 
        }
        ?>
>10</option>
								<option value="11" <?php 
        if ($ExpirationMonth == "11") {
            ?>
selected="selected"<?php 
        }
        ?>
>11</option>
								<option value="12" <?php 
        if ($ExpirationMonth == "12") {
            ?>
selected="selected"<?php 
        }
        ?>
>12</option>
							</select>/<select id="ExpirationYear" name="ExpirationYear" class=" <?php 
        echo pmpro_getClassForField("ExpirationYear");
        ?>
">
								<?php 
        for ($i = date_i18n("Y"); $i < date_i18n("Y") + 10; $i++) {
            ?>
									<option value="<?php 
            echo $i;
            ?>
" <?php 
            if ($ExpirationYear == $i) {
                ?>
selected="selected"<?php 
            }
            ?>
><?php 
            echo $i;
            ?>
</option>
								<?php 
        }
        ?>
							</select> 					
						</div>
					
						<?php 
        $pmpro_show_cvv = apply_filters("pmpro_show_cvv", true);
        if ($pmpro_show_cvv) {
            ?>
						<div class="pmpro_payment-cvv">
							<label for="CVV"><?php 
            _e('CVV', 'pmpro');
            ?>
</label>
							<input class="input" id="CVV" name="cvv" type="text" size="4" value="<?php 
            if (!empty($_REQUEST['CVV'])) {
                echo esc_attr($_REQUEST['CVV']);
            }
            ?>
" class=" <?php 
            echo pmpro_getClassForField("CVV");
            ?>
" data-encrypted-name="cvv" />  <small>(<a href="javascript:void(0);" onclick="javascript:window.open('<?php 
            echo pmpro_https_filter(PMPRO_URL);
            ?>
/pages/popup-cvv.html','cvv','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=600, height=475');"><?php 
            _e("what's this?", 'pmpro');
            ?>
</a>)</small>
						</div>
						<?php 
        }
        ?>
						
						<?php 
        if ($pmpro_show_discount_code) {
            ?>
						<div class="pmpro_payment-discount-code">
							<label for="discount_code"><?php 
            _e('Discount Code', 'pmpro');
            ?>
</label>
							<input class="input <?php 
            echo pmpro_getClassForField("discount_code");
            ?>
" id="discount_code" name="discount_code" type="text" size="20" value="<?php 
            echo esc_attr($discount_code);
            ?>
" />
							<input type="button" id="discount_code_button" name="discount_code_button" value="<?php 
            _e('Apply', 'pmpro');
            ?>
" />
							<p id="discount_code_message" class="pmpro_message" style="display: none;"></p>
						</div>
						<?php 
        }
        ?>
						
					</td>			
				</tr>
			</tbody>
			</table>
			<?php 
        //don't include the default
        return false;
    }
    static function pmpro_include_payment_information_fields($include)
    {
        //global vars
        global $pmpro_requirebilling, $pmpro_show_discount_code, $discount_code, $CardType, $AccountNumber, $ExpirationMonth, $ExpirationYear;
        //get accepted credit cards
        $pmpro_accepted_credit_cards = pmpro_getOption("accepted_credit_cards");
        $pmpro_accepted_credit_cards = explode(",", $pmpro_accepted_credit_cards);
        $pmpro_accepted_credit_cards_string = pmpro_implodeToEnglish($pmpro_accepted_credit_cards);
        //include ours
        ?>
			<table id="pmpro_payment_information_fields" class="pmpro_checkout top1em" width="100%" cellpadding="0" cellspacing="0" border="0" 
			<?php 
        //if(!$pmpro_requirebilling || apply_filters("pmpro_hide_payment_information_fields", false) ) {
        ?>
			style="display: none;"
			<?php 
        //}
        ?>
>
			<thead>
				<tr>
					<th><span class="pmpro_thead-msg"><?php 
        printf(__('We Accept %s', 'pmpro'), $pmpro_accepted_credit_cards_string);
        ?>
</span><?php 
        _e('Payment Information', 'pmpro');
        ?>
</th>
				</tr>
			</thead>
			<tbody>
				<tr valign="top">
					<td>
						<?php 
        $sslseal = pmpro_getOption("sslseal");
        if ($sslseal) {
            ?>
								<div class="pmpro_sslseal"><?php 
            echo stripslashes($sslseal);
            ?>
</div>
							<?php 
        }
        ?>
						<?php 
        /*this section is for if any discount code exists*/
        //if($pmpro_show_discount_code) {
        ?>
						
						<!-- <div class="pmpro_payment-discount-code">
							<label for="discount_code"><?php 
        //_e('Discount Code', 'pmpro');
        ?>
</label>
							<input class="input <?php 
        //echo pmpro_getClassForField("discount_code");
        ?>
" id="discount_code" name="discount_code" type="text" size="20" value="<?php 
        //echo esc_attr($discount_code)
        ?>
" />
							<input type="button" id="discount_code_button" name="discount_code_button" value="<?php 
        //_e('Apply', 'pmpro');
        ?>
" />
							<p id="discount_code_message" class="pmpro_message" style="display: none;"></p>
						</div> -->
						<?php 
        //}
        ?>

					</td>
				</tr>
			</tbody>
			</table>
			<?php 
        //don't include the default
        return false;
    }
function pmproap_pmpro_text_filter($text)
{
    global $wpdb, $current_user, $post, $pmpro_currency_symbol;
    if (!empty($post)) {
        if (pmproap_isPostLocked($post->ID) && !pmproap_hasAccess($current_user->ID, $post->ID)) {
            //which level to use for checkout link?
            $text_level_id = pmproap_getLevelIDForCheckoutLink($post->ID, $current_user->ID);
            if (empty($text_level_id)) {
                $text = "<p>" . __("You must first purchase a membership level before purchasing this content. ", "pmproap") . "</p>";
                $text .= "<p><a href=\"" . pmpro_url("levels") . "\">" . __("Click here to choose a membership level.", "pmproap") . "</a></p>";
            } else {
                //what's the price
                $pmproap_price = get_post_meta($post->ID, "_pmproap_price", true);
                //check for all access levels
                $all_access_levels = apply_filters("pmproap_all_access_levels", array(), $current_user->ID, $post->ID);
                //update text
                if (!empty($all_access_levels)) {
                    $level_names = array();
                    foreach ($all_access_levels as $level_id) {
                        $level = pmpro_getLevel($level_id);
                        $level_names[] = $level->name;
                    }
                    $text = "<p>" . __("This content requires that you purchase additional access. The price is %s or free for our %s members.", pmpro_formatPrice($pmproap_price), pmpro_implodeToEnglish($level_names)) . "</p>";
                    $text .= "<p><a href=\"" . pmpro_url("checkout", "?level=" . $text_level_id . "&ap=" . $post->ID) . "\">" . sprintf(__("Purchase this Content (%s)", 'pmproap'), pmpro_formatPrice($pmproap_price)) . "</a> <a href=\"" . pmpro_url("levels") . "\">" . __("Choose a Membership Level", "pmproap") . "</a></p>";
                } else {
                    $text = "<p>" . sprintf(__("This content requires that you purchase additional access. The price is %s.", "pmproap"), pmpro_formatPrice($pmproap_price)) . "</p>";
                    $text .= "<p><a href=\"" . pmpro_url("checkout", "?level=" . $text_level_id . "&ap=" . $post->ID) . "\">" . __("Click here to checkout", "pmproap") . "</a></p>";
                }
            }
        }
    }
    return $text;
}
 function sendCancelAdminEmail($user = NULL, $old_level_id = NULL)
 {
     global $wpdb, $current_user;
     if (!$user) {
         $user = $current_user;
     }
     if (!$user) {
         return false;
     }
     //check settings
     $send = pmpro_getOption("email_admin_cancels");
     if (empty($send)) {
         return true;
     }
     //didn't send, but we also don't want to indicate failure because the settings say to not send
     $this->email = get_bloginfo("admin_email");
     $this->subject = sprintf(__("Membership for %s at %s has been CANCELLED", "pmpro"), $user->user_login, get_option("blogname"));
     $this->template = "cancel_admin";
     $this->data = array("user_login" => $user->user_login, "user_email" => $user->user_email, "display_name" => $user->display_name, "sitename" => get_option("blogname"), "siteemail" => pmpro_getOption("from_email"), "login_link" => wp_login_url());
     if (!empty($old_level_id)) {
         if (!is_array($old_level_id)) {
             $old_level_id = array($old_level_id);
         }
         $this->data['membership_id'] = $old_level_id[0];
         //pass just the first as the level id
         $this->data['membership_level_name'] = pmpro_implodeToEnglish($wpdb->get_col("SELECT name FROM {$wpdb->pmpro_membership_levels} WHERE id IN('" . implode("','", $old_level_id) . "')"));
         //start and end date
         $startdate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(startdate) as startdate FROM {$wpdb->pmpro_memberships_users} WHERE user_id = '" . $user->ID . "' AND membership_id = '" . $old_level_id[0] . "' AND status IN('inactive', 'cancelled', 'admin_cancelled') ORDER BY id DESC");
         if (!empty($startdate)) {
             $this->data['startdate'] = date_i18n(get_option('date_format'), $startdate);
         } else {
             $this->data['startdate'] = "";
         }
         $enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(enddate) as enddate FROM {$wpdb->pmpro_memberships_users} WHERE user_id = '" . $user->ID . "' AND membership_id = '" . $old_level_id[0] . "' AND status IN('inactive', 'cancelled', 'admin_cancelled') ORDER BY id DESC");
         if (!empty($enddate)) {
             $this->data['enddate'] = date_i18n(get_option('date_format'), $enddate);
         } else {
             $this->data['enddate'] = "";
         }
     } else {
         $this->data['membership_id'] = '';
         $this->data['membership_level_name'] = __('All Levels', 'pmpro');
         $this->data['startdate'] = '';
         $this->data['enddate'] = '';
     }
     return $this->sendEmail();
 }
function pmprodlm_dlm_no_access_after_message($download)
{
    global $current_user;
    if (function_exists('pmpro_hasMembershipLevel')) {
        if (!pmpro_has_membership_access($download->id)) {
            $hasaccess = pmpro_has_membership_access($download->id, NULL, true);
            if (is_array($hasaccess)) {
                //returned an array to give us the membership level values
                $post_membership_levels_ids = $hasaccess[1];
                $post_membership_levels_names = $hasaccess[2];
                $hasaccess = $hasaccess[0];
            }
            if (empty($post_membership_levels_ids)) {
                $post_membership_levels_ids = array();
            }
            if (empty($post_membership_levels_names)) {
                $post_membership_levels_names = array();
            }
            //hide levels which don't allow signups by default
            if (!apply_filters("pmpro_membership_content_filter_disallowed_levels", false, $post_membership_levels_ids, $post_membership_levels_names)) {
                foreach ($post_membership_levels_ids as $key => $id) {
                    //does this level allow registrations?
                    $level_obj = pmpro_getLevel($id);
                    if (!$level_obj->allow_signups) {
                        unset($post_membership_levels_ids[$key]);
                        unset($post_membership_levels_names[$key]);
                    }
                }
            }
            $pmpro_content_message_pre = '<div class="pmpro_content_message">';
            $pmpro_content_message_post = '</div>';
            $content = '';
            $sr_search = array("!!levels!!", "!!referrer!!");
            $sr_replace = array(pmpro_implodeToEnglish($post_membership_levels_names), urlencode(site_url($_SERVER['REQUEST_URI'])));
            //get the correct message to show at the bottom
            if ($current_user->ID) {
                //not a member
                $newcontent = apply_filters("pmpro_non_member_text_filter", stripslashes(pmpro_getOption("nonmembertext")));
                $content .= $pmpro_content_message_pre . str_replace($sr_search, $sr_replace, $newcontent) . $pmpro_content_message_post;
            } else {
                //not logged in!
                $newcontent = apply_filters("pmpro_not_logged_in_text_filter", stripslashes(pmpro_getOption("notloggedintext")));
                $content .= $pmpro_content_message_pre . str_replace($sr_search, $sr_replace, $newcontent) . $pmpro_content_message_post;
            }
        }
    }
    echo $content;
}