bb_get_path

The BuddyPress bb get path function.

Description

bb_get_path( (int) $level = 1, (constant) $base = false, (bool) $request = false ); 

Parameters (3)

0. $level — Optional. (int) => 1
The level.
1. $base — Optional. (constant) => false
The base.
2. $request — Optional. (bool) => false
The request.

Usage

  1. if ( !function_exists( 'bb_get_path' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-core.php'; 
  3.  
  4. // The level. 
  5. $level = 1; 
  6.  
  7. // The base. 
  8. $base = false; 
  9.  
  10. // The request. 
  11. $request = false; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = bb_get_path($level, $base, $request); 
  15.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-core.php  
  1. function bb_get_path( $level = 1, $base = false, $request = false ) { 
  2. if ( !$request ) 
  3. $request = $_SERVER['REQUEST_URI']; 
  4. if ( is_string($request) ) 
  5. $request = parse_url($request); 
  6. if ( !is_array($request) || !isset($request['path']) ) 
  7. return ''; 
  8.  
  9. $path = rtrim($request['path'], " \t\n\r\0\x0B/"); 
  10. if ( !$base ) 
  11. $base = rtrim(bb_get_option('path'), " \t\n\r\0\x0B/"); 
  12. $path = preg_replace('|' . preg_quote($base, '|') . '/?|', '', $path, 1); 
  13. if ( !$path ) 
  14. return ''; 
  15. if ( strpos($path, '/') === false ) 
  16. return ''; 
  17.  
  18. $url = explode('/', $path); 
  19. if ( !isset($url[$level]) ) 
  20. return ''; 
  21.  
  22. return urldecode($url[$level]);