bbp_get_search_terms

Get the search terms.

Description

(bool|string) bbp_get_search_terms( (string) $passed_terms = '' ); 

Returns (bool|string)

Search terms on success, false on failure

Parameters (1)

0. $passed_terms — Optional. (string) => ''
Search terms

Usage

  1. if ( !function_exists( 'bbp_get_search_terms' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/search/template.php'; 
  3.  
  4. // Optional. Search terms 
  5. $passed_terms = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_get_search_terms($passed_terms); 
  9.  

Defined (1)

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

/includes/search/template.php  
  1. function bbp_get_search_terms( $passed_terms = '' ) { 
  2.  
  3. // Sanitize terms if they were passed in 
  4. if ( !empty( $passed_terms ) ) { 
  5. $search_terms = sanitize_title( $passed_terms ); 
  6.  
  7. // Use query variable if not 
  8. } else { 
  9. $search_terms = get_query_var( bbp_get_search_rewrite_id() ); 
  10.  
  11. // Trim whitespace and decode, or set explicitly to false if empty 
  12. $search_terms = !empty( $search_terms ) ? urldecode( trim( $search_terms ) ) : false; 
  13.  
  14. return apply_filters( 'bbp_get_search_terms', $search_terms, $passed_terms );