bb_get_path
The BuddyPress bb get path function.
Description
Parameters (3)
- 0. $level — Optional. (int) =>
1
- The level.
- 1. $base — Optional. (constant) =>
false
- The base.
- 2. $request — Optional. (bool) =>
false
- The request.
Usage
if ( !function_exists( 'bb_get_path' ) ) { require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-core.php'; } // The level. $level = 1; // The base. $base = false; // The request. $request = false; // NOTICE! Understand what this does before running. $result = bb_get_path($level, $base, $request);
Defined (1)
The function is defined in the following location(s).
- /bp-forums/bbpress/bb-includes/functions.bb-core.php
- function bb_get_path( $level = 1, $base = false, $request = false ) {
- if ( !$request )
- $request = $_SERVER['REQUEST_URI'];
- if ( is_string($request) )
- $request = parse_url($request);
- if ( !is_array($request) || !isset($request['path']) )
- return '';
- $path = rtrim($request['path'], " \t\n\r\0\x0B/");
- if ( !$base )
- $base = rtrim(bb_get_option('path'), " \t\n\r\0\x0B/");
- $path = preg_replace('|' . preg_quote($base, '|') . '/?|', '', $path, 1);
- if ( !$path )
- return '';
- if ( strpos($path, '/') === false )
- return '';
- $url = explode('/', $path);
- if ( !isset($url[$level]) )
- return '';
- return urldecode($url[$level]);
- }