Last active
August 29, 2015 14:20
-
-
Save bamadesigner/f665a367ddb2b5d8351c to your computer and use it in GitHub Desktop.
Allows me to remove extra space, and ultimately extra <p> and <br>, from shortcodes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// We have to remove the default shortcode filter | |
remove_filter( 'the_content', 'do_shortcode', 11 ); // AFTER wpautop() | |
// Strips extra space around and within shortcodes | |
add_filter( 'the_content', 'shortcode_cleanup', 11 ); | |
function shortcode_cleanup( $content ) { | |
// Clean it | |
$content = strtr( $content, array( "\n[" => '[', "]\n" => ']', '<p>[' => '[', ']</p>' => ']', ']<br>' => ']', ']<br />' => ']' ) ); | |
// Return the content | |
return do_shortcode( $content ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment