bbp_get_view_id

Get the view id.

Description

(bool|string) bbp_get_view_id( (string) $view = '' ); 

Use view id if supplied, otherwise bbp_get_view_rewrite_id() query var.

Returns (bool|string)

ID on success, false on failure

Parameters (1)

0. $view — Optional. (string) => ''
View id.

Usage

  1. if ( !function_exists( 'bbp_get_view_id' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/common/template.php'; 
  3.  
  4. // Optional. View id. 
  5. $view = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_get_view_id($view); 
  9.  

Defined (1)

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

/includes/common/template.php  
  1. function bbp_get_view_id( $view = '' ) { 
  2. $bbp =bbpress); 
  3.  
  4. if ( !empty( $view ) ) { 
  5. $view = sanitize_title( $view ); 
  6. } elseif ( ! empty( $bbp->current_view_id ) ) { 
  7. $view = $bbp->current_view_id; 
  8. } else { 
  9. $view = get_query_var( bbp_get_view_rewrite_id() ); 
  10.  
  11. if ( array_key_exists( $view, $bbp->views ) ) { 
  12. return $view; 
  13.  
  14. return false;