bbp_register_view

Register a bbPress view.

Description

(array) bbp_register_view( (string) $view, (string) $title, (string) $query_args = '', (constant) $feed = true, (string) $capability = '' ); 

Returns (array)

The just registered (but processed) view

Parameters (5)

0. $view (string)
The view.
1. $title (string)
The title.
2. $query_args — Optional. (string) => ''
The query args.

Options

  • arguments. (bbp_has_topics()}) => null
array(
    'arguments.' => null
);        

3. $feed — Optional. (constant) => true
Have a feed for the view? Defaults to true. NOT IMPLEMENTED
4. $capability — Optional. (string) => ''
Capability that the current user must have

Usage

  1. if ( !function_exists( 'bbp_register_view' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/core/functions.php'; 
  3.  
  4. // The view. 
  5. $view = ''; 
  6.  
  7. // The title. 
  8. $title = ''; 
  9.  
  10. // The query args. 
  11. $query_args = array( 
  12. 'arguments.' => null 
  13. ); 
  14.  
  15. // Have a feed for the view? Defaults to true. NOT IMPLEMENTED 
  16. $feed = true; 
  17.  
  18. // Capability that the current user must have 
  19. $capability = ''; 
  20.  
  21. // NOTICE! Understand what this does before running. 
  22. $result = bbp_register_view($view, $title, $query_args, $feed, $capability); 
  23.  

Defined (1)

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

/includes/core/functions.php  
  1. function bbp_register_view( $view, $title, $query_args = '', $feed = true, $capability = '' ) { 
  2.  
  3. // Bail if user does not have capability 
  4. if ( ! empty( $capability ) && ! current_user_can( $capability ) ) 
  5. return false; 
  6.  
  7. $bbp =bbpress); 
  8. $view = sanitize_title( $view ); 
  9. $title = esc_html( $title ); 
  10.  
  11. if ( empty( $view ) || empty( $title ) ) 
  12. return false; 
  13.  
  14. $query_args = bbp_parse_args( $query_args, '', 'register_view' ); 
  15.  
  16. // Set show_stickies to false if it wasn't supplied 
  17. if ( !isset( $query_args['show_stickies'] ) ) 
  18. $query_args['show_stickies'] = false; 
  19.  
  20. $bbp->views[$view] = array( 
  21. 'title' => $title,  
  22. 'query' => $query_args,  
  23. 'feed' => $feed 
  24. ); 
  25.  
  26. return $bbp->views[$view];