bbp_make_urls_clickable

Make URLs clickable in content areas.

Description

(string) bbp_make_urls_clickable( (string) $text = '' ); 

Returns (string)

Parameters (1)

0. $text — Optional. (string) => ''
The text.

Usage

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

Defined (1)

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

/includes/common/formatting.php  
  1. function bbp_make_urls_clickable( $text = '' ) { 
  2. $url_clickable = '~ 
  3. ([\\s(<., ;:!?]) # 1: Leading whitespace, or punctuation 
  4. ( # 2: URL 
  5. [\\w]{1, 20}+:// # Scheme and hier-part prefix 
  6. (?=\S{1, 2000}\s) # Limit to URLs less than about 2000 characters long 
  7. [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]*+ # Non-punctuation URL character 
  8. (?: # Unroll the Loop: Only allow puctuation URL character if followed by a non-punctuation URL character 
  9. [\'., ;:!?)] # Punctuation URL character 
  10. [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]++ # Non-punctuation URL character 
  11. )* 
  12. (\)?) # 3: Trailing closing parenthesis (for parethesis balancing post processing) 
  13. ~xS'; 
  14.  
  15. // The regex is a non-anchored pattern and does not have a single fixed starting character. 
  16. // Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times. 
  17. return preg_replace_callback( $url_clickable, '_make_url_clickable_cb', $text );