bp_core_get_site_path

Get the path of the current site.

Description

(string) bp_core_get_site_path(); 

Returns (string)

URL to the current site.


Usage

  1. if ( !function_exists( 'bp_core_get_site_path' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_core_get_site_path(); 
  7.  

Defined (1)

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

/bp-core/bp-core-functions.php  
  1. function bp_core_get_site_path() { 
  2. global $current_site; 
  3.  
  4. if ( is_multisite() ) { 
  5. $site_path = $current_site->path; 
  6. } else { 
  7. $site_path = (array) explode( '/', home_url() ); 
  8.  
  9. if ( count( $site_path ) < 2 ) { 
  10. $site_path = '/'; 
  11. } else { 
  12. // Unset the first three segments (http(s)://example.com part). 
  13. unset( $site_path[0] ); 
  14. unset( $site_path[1] ); 
  15. unset( $site_path[2] ); 
  16.  
  17. if ( !count( $site_path ) ) { 
  18. $site_path = '/'; 
  19. } else { 
  20. $site_path = '/' . implode( '/', $site_path ) . '/'; 
  21.  
  22. /** 
  23. * Filters the path of the current site. 
  24. * @since 1.2.0 
  25. * @param string $site_path URL to the current site. 
  26. */ 
  27. return apply_filters( 'bp_core_get_site_path', $site_path );