Created
February 1, 2018 13:11
-
-
Save palmiak/6056b4d5dbc66452e75a4218edc4d5c5 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
add_filter( 'the_content', 'strip_usless_shortcodes', 50 ); | |
function strip_usless_shortcodes( $content ) { | |
preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches ); | |
$pattern = get_shortcode_regex( $matches[1] ); | |
$content = preg_replace_callback( "/$pattern/", 'strip_usless_shortcodes_callback', $content ); | |
$content = str_replace( '<p></p>', '', $content ); | |
return $content; | |
} | |
function strip_usless_shortcodes_callback( $matches ) { | |
return $matches[5]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment