Skip to content

Instantly share code, notes, and snippets.

@kagg-design
Last active September 6, 2019 08:21
Show Gist options
  • Save kagg-design/0edcf726c4f8a59e77a491252bb8be01 to your computer and use it in GitHub Desktop.
Save kagg-design/0edcf726c4f8a59e77a491252bb8be01 to your computer and use it in GitHub Desktop.
Due to issue in SyntaxHighlighter Evolved plugin & symbol is output as & what makes code unreadable.
<?php
/**
* Filter to fix issue in SyntaxHighlighter Evolved plugin.
*
* @param string $code Code to format.
* @param array $atts Attributes.
* @param string $tag Tag.
*
* @return string
*/
function kagg_syntaxhighlighter_precode( $code, $atts, $tag ) {
if ( 'code' === $tag ) {
$code = wp_specialchars_decode( $code );
}
return $code;
}
add_filter( 'syntaxhighlighter_precode', 'kagg_syntaxhighlighter_precode', 10, 3 );
@arwidmark
Copy link

Nice little code snippet, but how do you make SyntaxHighlighter Evolved use it?

@kagg-design
Copy link
Author

Thank you @arwidmark. I just add this snippet to functions.php of the theme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment