bb_get_topic_from_uri

The BuddyPress bb get topic from uri function.

Description

bb_get_topic_from_uri( $uri ); 

Parameters (1)

0. $uri
The uri.

Usage

  1. if ( !function_exists( 'bb_get_topic_from_uri' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-topics.php'; 
  3.  
  4. // The uri. 
  5. $uri = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bb_get_topic_from_uri($uri); 
  9.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-topics.php  
  1. function bb_get_topic_from_uri( $uri ) { 
  2. // Extract the topic id or slug of the uri 
  3. if ( 'topic' === bb_get_path(0, false, $uri) ) { 
  4. $topic_id_or_slug = bb_get_path(1, false, $uri); 
  5. } else { 
  6. if ($parsed_uri = parse_url($uri)) { 
  7. if (preg_match('@/topic\.php$@' , $parsed_uri['path'])) { 
  8. $args = wp_parse_args($parsed_uri['query']); 
  9. if (isset($args['id'])) { 
  10. $topic_id_or_slug = $args['id']; 
  11.  
  12. if ( !$topic_id_or_slug ) 
  13. return false; 
  14.  
  15. return get_topic( $topic_id_or_slug );