Last active
August 29, 2015 14:27
-
-
Save Wilto/7b0f901a77c1b860c76e to your computer and use it in GitHub Desktop.
you think this is a game
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
// https://www.youtube.com/watch?v=b9N3tIlEJNc | |
function normalize_headings( $content ) { | |
// Move all headings below H2 down one notch | |
$output = preg_replace( "/<(.*)h4(.*)>(.*)(<\/h2>)/", "<$1h5$2>$3</h5>", $content ); | |
$output = preg_replace( "/<(.*)h3(.*)>(.*)(<\/h2>)/", "<$1h4$2>$3</h4>", $output ); | |
// H1 and H2 both collapse to H3 | |
$output = preg_replace( "/<(.*)h1(.*)>(.*)(<\/h1>)/", "<$1h3$2>$3</h3>", $output ); | |
$output = preg_replace( "/<(.*)h2(.*)>(.*)(<\/h2>)/", "<$1h3$2>$3</h3>", $output ); | |
print apply_filters( 'normalize_headings', $output ); | |
} | |
add_filter('the_content', 'normalize_headings' ); |
kadamwhite
commented
Aug 11, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment