Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2013
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. /** Disable WP autop using shortcode for selected text, courtesy of Matt Valvano, http://ideasandpixels.com/disable-wordpress-auto-formatting-short-code */
  4.  
  5. function my_formatter($content) {
  6. $new_content = '';
  7. $pattern_full = '{(\[raw\].*?\[/raw\])}is';
  8. $pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
  9. $pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);
  10.  
  11. foreach ($pieces as $piece) {
  12. if (preg_match($pattern_contents, $piece, $matches)) {
  13. $new_content .= $matches[1];
  14. } else {
  15. $new_content .= wptexturize(wpautop($piece));
  16. }
  17. }
  18. return $new_content;
  19. }
  20.  
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement