Posted On June 27, 2020

WordPress Plugin Syntax Highlighter Fix

kimconnect 0 comments
blog.KimConnect.com >> Codes >> WordPress Plugin Syntax Highlighter Fix

Source: from a forum poster of this plugin’s Github page.

// Add this to functions.php
// Override the double encoded strings on (a) post save (b) code form Gutenberg blocks (c) shortcodes
function ntz_fix_syntax_highlighter($content)
{
	return preg_replace('/&([^;]+;)/', '&$1', $content);
}

add_filter('content_save_pre', 'ntz_fix_syntax_highlighter');
add_filter('syntaxhighlighter_htmlresult', 'ntz_fix_syntax_highlighter');
add_filter('syntaxhighlighter_precode', 'ntz_fix_syntax_highlighter');
// Add this function to force HTML entity encoding/decoding in PHP to include quotes against its default
function kagg_syntaxhighlighter_precode( $code, $atts, $tag ) {
	if ( 'code' === $tag ) {
		$code = wp_specialchars_decode( $code, ENT_QUOTES );
	}
	return $code;
}
add_filter( 'syntaxhighlighter_precode', 'kagg_syntaxhighlighter_precode', 10, 3 );

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: Checking Duplicating Identifiers Among ADFS Relying Party Trusts

function getDuplicatingIfd{ write-host "Checking each relying party trust for any duplicates of identifiers..." $trusts=Get-AdfsRelyingPartyTrust $allTrustNames=$trusts.Name…

PowerShell: Converting Time Stamp from Int64 to DateTime and Vice Versa

Here are some quick conversion methods between time values represented by Integer and DateTime data…

PowerShell: An Exercise in Calculating Checksums

$out = new-object byte[] 1073741824; #1GB(new-object Random).NextBytes($out);[IO.File]::WriteAllBytes($dummyFile, $out);Measure-command{$hash=jacksum -a crc8 -x $dummyFile}write-host $hash# New ServerPS…