bb_basename

Plugins/Themes utility.

Description

bb_basename( $file, $directories ); 

Parameters (2)

0. $file
The file.
1. $directories
The directories.

Usage

  1. if ( !function_exists( 'bb_basename' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-core.php'; 
  3.  
  4. // The file. 
  5. $file = null; 
  6.  
  7. // The directories. 
  8. $directories = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bb_basename($file, $directories); 
  12.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-core.php  
  1. function bb_basename( $file, $directories ) 
  2. if ( strpos( $file, '#' ) !== false ) { 
  3. return $file; // It's already a basename 
  4.  
  5. foreach ( $directories as $type => $directory ) { 
  6. if ( strpos( $file, $directory ) !== false ) { 
  7. break; // Keep the $file and $directory set and use them below, nifty huh? 
  8.  
  9. list( $file, $directory ) = str_replace( '\\', '/', array( $file, $directory ) ); 
  10. list( $file, $directory ) = preg_replace( '|/+|', '/', array( $file, $directory ) ); 
  11. $file = preg_replace( '|^.*' . preg_quote( $directory, '|' ) . '|', $type . '#', $file ); 
  12.  
  13. return $file;