pmpro_getLevelsExpiration

The Paid Memberships Pro pmpro getLevelsExpiration function.

Description

pmpro_getLevelsExpiration( &$levels ); 

Parameters (1)

0. $levels
The levels.

Usage

  1. if ( !function_exists( 'pmpro_getLevelsExpiration' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/includes/functions.php'; 
  3.  
  4. // The levels. 
  5. $levels = &$levels; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = pmpro_getLevelsExpiration($levels); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/functions.php  
  1. function pmpro_getLevelsExpiration(&$levels) 
  2. $expirystrings = array(); 
  3. $ongoinglevelnum = 0; 
  4. if(!empty($levels) && !is_array($levels)) { $levels = array($levels); } elseif(empty($levels)) { $levels = array(); } 
  5. foreach($levels as $curlevel) { 
  6. if($curlevel->expiration_number) { 
  7. $expirystrings[] = sprintf(__("%s membership expires after %d %s", 'paid-memberships-pro' ), $curlevel->name, $curlevel->expiration_number, pmpro_translate_billing_period($curlevel->expiration_period, $curlevel->expiration_number)); 
  8. } else { 
  9. $ongoinglevelnum++; 
  10.  
  11. $expiration_text = ""; 
  12. if(count($expirystrings)>0) { 
  13. $laststanza = array_pop($expirystrings); 
  14. $expiration_text = implode(', ', $expirystrings); 
  15. if(count($expirystrings)>0) { $expiration_text .= ", and "; } 
  16. $expiration_text .= $laststanza; 
  17. $expiration_text .= ". "; 
  18. if($ongoinglevelnum>0) { 
  19. $expiration_text .= "The remaining membership"; 
  20. if($ongoinglevelnum>1) { $expiration_text .= "s are"; } else { $expiration_text .= " is"; } 
  21. $expiration_text .= " ongoing."; 
  22.  
  23. /** 
  24. * Filter the levels expiration text. Note the s in levels. Similar to pmpro_levels_expiration_text 
  25. */ 
  26. $expiration_text = apply_filters("pmpro_levels_expiration_text", $expiration_text, $levels); 
  27. $expiration_text = apply_filters("pmpro_level_expiration_text", $expiration_text, $levels); // Backwards compatible 
  28. return $expiration_text;