pmpro_url

The Paid Memberships Pro pmpro url function.

Description

pmpro_url( (constant) $page = NULL, (string) $querystring = '', (constant) $scheme = NULL ); 

Parameters (3)

0. $page — Optional. (constant) => NULL
The page.
1. $querystring — Optional. (string) => ''
The querystring.
2. $scheme — Optional. (constant) => NULL
The scheme.

Usage

  1. if ( !function_exists( 'pmpro_url' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/includes/functions.php'; 
  3.  
  4. // The page. 
  5. $page = NULL; 
  6.  
  7. // The querystring. 
  8. $querystring = ''; 
  9.  
  10. // The scheme. 
  11. $scheme = NULL; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = pmpro_url($page, $querystring, $scheme); 
  15.  

Defined (1)

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

/includes/functions.php  
  1. function pmpro_url($page = NULL, $querystring = "", $scheme = NULL) 
  2. global $besecure; 
  3. $besecure = apply_filters("besecure", $besecure); 
  4.  
  5. if(!$scheme && $besecure) 
  6. $scheme = "https"; 
  7. elseif(!$scheme) 
  8. $scheme = "http"; 
  9.  
  10. if(!$page) 
  11. $page = "levels"; 
  12.  
  13. global $pmpro_pages; 
  14.  
  15. //start with the permalink 
  16. $url = get_permalink($pmpro_pages[$page]); 
  17.  
  18. //WPML/etc support 
  19. if(function_exists("icl_object_id") && defined("ICL_LANGUAGE_CODE")) 
  20. $trans_id = icl_object_id($pmpro_pages[$page], "page", false, ICL_LANGUAGE_CODE); 
  21. if(!empty($trans_id)) 
  22. $url = get_permalink($trans_id); 
  23.  
  24. //figure out querystring 
  25. $querystring = str_replace("?", "", $querystring); 
  26. parse_str( $querystring, $query_args ); 
  27. $url = esc_url_raw( add_query_arg( $query_args, $url ) ); 
  28.  
  29. //figure out scheme 
  30. if(is_ssl()) 
  31. $url = str_replace("http:", "https:", $url); 
  32.  
  33. return $url;