Advertisement
imranmodel32

Remove auto p & br tags form shortcode

Nov 28th, 2014
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1.  
  2. // matter remove auto P tag
  3.  
  4. function matter_remove_wpautop( $content, $autop = false ) {
  5.  
  6.     if ( $autop ) { // Possible to use !preg_match('('.WPBMap::getTagsRegexp().')', $content)
  7.         $content = wpautop( preg_replace( '/<\/?p\>/', "\n", $content ) . "\n" );
  8.     }
  9.     return do_shortcode( shortcode_unautop( $content) );
  10. }
  11.  
  12. // remove br tags form bootstrap shortcode
  13.  
  14. function matter_the_content_filter($content) {
  15.     $block = join("|",array("row", "column"));
  16.     $rep = preg_replace("/(<p>)?\[($block)(\s[^\]]+)?\](<\/p>|<br \/>)?/","[$2$3]",$content);
  17.     $rep = preg_replace("/(<p>)?\[\/($block)](<\/p>|<br \/>)?/","[/$2]",$rep);
  18. return $rep;
  19. }
  20. add_filter("the_content", "matter_the_content_filter");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement