bb_autop

The BuddyPress bb autop function.

Description

bb_autop( $pee, (int) $br = 1 ); 

Parameters (2)

0. $pee
The pee.
1. $br — Optional. (int) => 1
The br.

Usage

  1. if ( !function_exists( 'bb_autop' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-formatting.php'; 
  3.  
  4. // The pee. 
  5. $pee = null; 
  6.  
  7. // The br. 
  8. $br = 1; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bb_autop($pee, $br); 
  12.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-formatting.php  
  1. function bb_autop($pee, $br = 1) { // Reduced to be faster 
  2. $pee = $pee . "\n"; // just to make things a little easier, pad the end 
  3. $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee); 
  4. // Space things out a little 
  5. $pee = preg_replace('!(<(?:ul|ol|li|blockquote|pre|p)[^>]*>)!', "\n$1", $pee);  
  6. $pee = preg_replace('!(</(?:ul|ol|li|blockquote|pre|p)>)!', "$1\n", $pee); 
  7. $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines  
  8. $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates 
  9. $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end  
  10. $pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace  
  11. $pee = preg_replace('!<p>\s*(</?(?:ul|ol|li|blockquote|p)[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag 
  12. $pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists 
  13. $pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee); 
  14. $pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee); 
  15. $pee = preg_replace('!<p>\s*(</?(?:ul|ol|li|blockquote|p)[^>]*>)!', "$1", $pee); 
  16. $pee = preg_replace('!(</?(?:ul|ol|li|blockquote|p)[^>]*>)\s*</p>!', "$1", $pee);  
  17. if ($br) $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks 
  18. $pee = preg_replace('!(</?(?:ul|ol|li|blockquote|p)[^>]*>)\s*<br />!', "$1", $pee); 
  19. $pee = preg_replace('!<br />(\s*</?(?:p|li|ul|ol)>)!', '$1', $pee); 
  20. if ( false !== strpos( $pee, '<pre' ) ) 
  21. $pee = preg_replace_callback('!(<pre.*?>)(.*?)</pre>!is', 'clean_pre', $pee ); 
  22. return $pee;