hilite

The BP Groupblog hilite function.

Description

hilite( $text ); 

Parameters (1)

0. $text
The text.

Usage

  1. if ( !function_exists( 'hilite' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bp-groupblog/themes/p2/functions.php'; 
  3.  
  4. // The text. 
  5. $text = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = hilite($text); 
  9.  

Defined (1)

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

/themes/p2/functions.php  
  1. function hilite( $text ) { 
  2. $query_terms = array_filter( array_map( 'trim', get_search_query_terms() ) ); 
  3. foreach ( $query_terms as $term ) { 
  4. $term = preg_quote( $term, '/' ); 
  5. if ( !preg_match( '/<.+>/', $text ) ) { 
  6. $text = preg_replace( '/(\b'.$term.'\b)/i', '<span class="hilite">$1</span>', $text ); 
  7. } else { 
  8. $text = preg_replace( '/(?<=>)([^<]+)?(\b'.$term.'\b)/i', '$1<span class="hilite">$2</span>', $text ); 
  9. return $text;