Posted By

mb2o on 12/13/10


Tagged

wordpress


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

mb2o
qubestream


Disable Automatic Formatting Using a Shortcode


 / Published in: PHP
 

URL: http://css-tricks.com/snippets/wordpress/disable-automatic-formatting-using-a-shortcode/

  1. function my_formatter($content) {       
  2. $new_content = '';       
  3. $pattern_full = '{(\[raw\].*?\[/raw\])}is';       
  4. $pattern_contents = '{\[raw\](.*?)\[/raw\]}is';       
  5. $pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);       
  6. foreach ($pieces as $piece) {               
  7. if (preg_match($pattern_contents, $piece, $matches)) {                       
  8. $new_content .= $matches[1];               
  9. } else {                       
  10. $new_content .= wptexturize(wpautop($piece));               
  11. }       
  12. }       
  13. return $new_content;
  14. }
  15. remove_filter('the_content', 'wpautop');
  16. remove_filter('the_content', 'wptexturize');
  17.  
  18. add_filter('the_content', 'my_formatter', 99);

Report this snippet  

You need to login to post a comment.