bbp_make_mentions_clickable_callback

Callback to convert mention matchs to HTML A tag.

Description

(string) bbp_make_mentions_clickable_callback( (array) $matches = array() ); 

Returns (string)

HTML A tag with link to user profile.

Parameters (1)

0. $matches — Optional. (array) => array()
Single Regex Match.

Usage

  1. if ( !function_exists( 'bbp_make_mentions_clickable_callback' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/common/formatting.php'; 
  3.  
  4. // Single Regex Match. 
  5. $matches = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_make_mentions_clickable_callback($matches); 
  9.  

Defined (1)

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

/includes/common/formatting.php  
  1. function bbp_make_mentions_clickable_callback( $matches = array() ) { 
  2.  
  3. // Get user; bail if not found 
  4. $user = get_user_by( 'slug', $matches[2] ); 
  5. if ( empty( $user ) || bbp_is_user_inactive( $user->ID ) ) { 
  6. return $matches[0]; 
  7.  
  8. // Create the link to the user's profile 
  9. $url = bbp_get_user_profile_url( $user->ID ); 
  10. $anchor = '<a href="%1$s" rel="nofollow">@%2$s</a>'; 
  11. $link = sprintf( $anchor, esc_url( $url ), esc_html( $user->user_nicename ) ); 
  12.  
  13. return $matches[1] . $link;