Wyświetlanie kodu AS3/MXML w Wordpress MU

8 maj 2008 – 21:51

Potrzebne są:

Po instalacji wtyczki, pliki z zestawami kolorowania trzeba wrzucić do katalogu wp-content/plugins/syntaxhighlighter-plus/shlfiles

Wymagane zmiany:

syntaxhighlighter.php:
poniżej linii 70 - żeby włączyć obsługę nowych języków:

'as3'        => 'shBrushAS3.js',
'mxml'       => 'shBrushMxml.js',

w linii 173 - żeby włączyć zwijanie kodu:

$regex .= '(:?)(.*?)\3\](.*?)\[\/(\1|\4)\]/si';

w linii 330 - żeby włączyć zwijanie kodu:

$collapse = ($match[6]) ? ":" . strtolower( $match[6] ) : "";
$content = str_replace( $match[0], '<pre class="syntax-highlight:' . $language . $collapse ."\">" . htmlspecialchars( $match[7] ) . "</pre>", $content );

shCore.js (hack ze strony CodeSushi - żeby włączyć zwijanie kodu):

	ExpandSource: {
		label: '+ rozwiń źródło',
		check: function(highlighter) { return highlighter.collapse; },
		func: function(sender, highlighter)
		{
            var a = document.createElement("a");
            a.setAttribute('href', '#');
            a.onclick = function() {
                dp.sh.Toolbar.Command('CollapseSource',this);
                return false;
            }
            a.appendChild(document.createTextNode("- zwiń źródło"));  

            sender.parentNode.insertBefore(a, sender);
            sender.parentNode.removeChild(sender);  

            highlighter.div.className = highlighter.div.className.replace('collapsed', '');
		}
	},
    // dan's hack for expand collapse toggle.
    CollapseSource: {
        label: '- zwiń źródło',
        check: function(highlighter) { return false; },
        func: function(sender, highlighter)
        {
            var a = document.createElement("a");
            a.setAttribute('href', '#');
            a.onclick = function() {
                dp.sh.Toolbar.Command('ExpandSource',this);
                return false;
            }
            a.appendChild(document.createTextNode("+ rozwiń źródło"));
            sender.parentNode.insertBefore(a, sender);
            sender.parentNode.removeChild(sender);
            highlighter.div.className = highlighter.div.className + ' collapsed';
        }
    },

I ostatecznie wyłączyć filtrowanie treści w WP MU w pliku kses.php (wp-includes/kses.php):
w liniach 1073 i 1074:

//add_action('init', 'kses_init');
//add_action('set_current_user', 'kses_init');

Odpowiedz