/** * Is this level expiring within one pay period * * @since 1.8.6.3 * * @param object $level PMPro Level Object to test */ function pmpro_isLevelExpiringSoon(&$level) { if (!pmpro_isLevelExpiring($level) || empty($level->enddate)) { $r = false; } else { //days til expiration for the standard level $standard = pmpro_getLevel($level->id); if (!empty($standard->expiration_number)) { if ($standard->expiration_period == 'Day') { $days = $level->expiration_number; } elseif ($standard->expiration_period == 'Week') { $days = $level->expiration_number * 7; } elseif ($standard->expiration_period == 'Month') { $days = $level->expiration_number * 30; } elseif ($standard->expiration_period == 'Year') { $days = $level->expiration_number * 365; } } else { $days = 30; } //are we within the days til expiration? $now = current_time('timestamp'); if ($now + $days * 3600 * 24 < strtotime($level->enddate, $now)) { $r = true; } else { $r = false; } } //filter $r = apply_filters('pmpro_is_level_expiring_soon', $r, $level); return $r; }
" <?php if (pmpro_isLevelExpiring($level)) { echo "checked='checked'"; } ?> onclick="if(jQuery(this).is(':checked')) { jQuery(this).parent().parent().siblings('.expiration_info').show(); } else { jQuery(this).parent().parent().siblings('.expiration_info').hide();}" /> <label for="expiration_<?php echo $level->id; ?> "><?php _e('Check this to set when membership access expires.', 'pmpro'); ?> </label></td> </tr> <tr class="expiration_info" <?php if (!pmpro_isLevelExpiring($level)) { ?> style="display: none;"<?php } ?> > <th scope="row" valign="top"><label for="billing_amount"><?php _e('Expires In', 'pmpro'); ?> :</label></th> <td> <input id="expiration_number" name="expiration_number[]" type="text" size="10" value="<?php echo str_replace("\"", """, stripslashes($level->expiration_number)); ?> " /> <select id="expiration_period" name="expiration_period[]">
<tr class="trial_info recurring_info" <?php if (!pmpro_isLevelTrial($level)) echo "style='display:none;'";?>> <th scope="row" valign="top"><label for="trial_amount">Trial Billing Amount:</label></th> <td> <?php echo $pmpro_currency_symbol?><input name="trial_amount[]" type="text" size="20" value="<?php echo str_replace("\"", """, stripslashes($level->trial_amount))?>" /> <small>for the first</small> <input name="trial_limit[]" type="text" size="10" value="<?php echo str_replace("\"", """, stripslashes($level->trial_limit))?>" /> <small>subscription payments.</small> </td> </tr> <tr> <th scope="row" valign="top"><label>Membership Expiration:</label></th> <td><input id="expiration" name="expiration[]" type="checkbox" value="<?php echo $level->id?>" <?php if(pmpro_isLevelExpiring($level)) { echo "checked='checked'"; } ?> onclick="if(jQuery(this).is(':checked')) { jQuery(this).parent().parent().siblings('.expiration_info').show(); } else { jQuery(this).parent().parent().siblings('.expiration_info').hide();}" /> <small>Check this to set an expiration date for new sign ups.</small></td> </tr> <tr class="expiration_info" <?php if(!pmpro_isLevelExpiring($level)) {?>style="display: none;"<?php } ?>> <th scope="row" valign="top"><label for="billing_amount">Expire In:</label></th> <td> <input id="expiration_number" name="expiration_number[]" type="text" size="10" value="<?php echo str_replace("\"", """, stripslashes($level->expiration_number))?>" /> <select id="expiration_period" name="expiration_period[]"> <?php $cycles = array( 'Day(s)' => 'Day', 'Week(s)' => 'Week', 'Month(s)' => 'Month', 'Year(s)' => 'Year' ); foreach ( $cycles as $name => $value ) { echo "<option value='$value'"; if ( $level->expiration_period == $value ) echo " selected='selected'"; echo ">$name</option>"; } ?> </select> <br /><small>How long before the expiration expires. Not that any future payments will be canceled when the membership expires.</small> </td>