SyntaxHighlighter用のTemplate編集

SyntaxHighlighterが、新Themeでうまく表示されていなかったので、早速ソースをいじくってみることにする。
どうもjsファイルへのリンクタグが設定されていなかったようなので、以下のファイルの</body>タグ前に追加する事にする。
(CSSファイルの修正じゃなくって、HTMLテンプレートの編集で対応でした)

■修正ファイル

archive.php
index.php
page.php
search.php
single.php

■追加コード

<!-- SyntaxHighlighter Start -->
    <script type="text/javascript" src="<?php echo get_option('home'); ?>/wp-content/plugins/syntax-highlighter/js/shCore.js"></script>
    <script type="text/javascript" src="<?php echo get_option('home'); ?>/wp-content/plugins/syntax-highlighter/js/shBrushRuby.js"></script>
    <script type="text/javascript" src="<?php echo get_option('home'); ?>/wp-content/plugins/syntax-highlighter/js/shBrushCss.js"></script>
    <script type="text/javascript" src="<?php echo get_option('home'); ?>/wp-content/plugins/syntax-highlighter/js/shBrushJScript.js"></script>
    <script type="text/javascript" src="<?php echo get_option('home'); ?>/wp-content/plugins/syntax-highlighter/js/shBrushPhp.js"></script>
    <script type="text/javascript" src="<?php echo get_option('home'); ?>/wp-content/plugins/syntax-highlighter/js/shBrushSql.js"></script>
    <script type="text/javascript" src="<?php echo get_option('home'); ?>/wp-content/plugins/syntax-highlighter/js/shBrushXml.js"></script>
    <script type="text/javascript">//<![CDATA[
with(SyntaxHighlighter.config.strings){expandSource="+ ソースを表示";viewSource="プレインテキスト";copyToClipboard="クリップボードにコピー";copyToClipboardConfirmation="クリップボードにコピーされました";print="印刷";help="?";noBrush="Can't find brush for: ";brushNotHtmlScript="Brush wasn't made for html-script option: ";}SyntaxHighlighter.clipboardSwf="<?php echo get_option('home'); ?>/wp-content/plugins/syntax-highlighter/js/clipboard.swf";
SyntaxHighlighter.all();
//]]></script>
<!-- SyntaxHighlighter End -->

■参考ページ

syntaxHighlighter-plusのプラグイン

■その他

js内の日本語が文字化けしていたので、関係ファイルを全てUTF-8Nに変更してアップロードしなおしました。

なんかもっとスマートな方法があるような気もするけど、とりあえず気にしない。


Tags:

Leave a Reply

Get Adobe Flash playerPlugin by wpburn.com wordpress themes