为wordpress添加coolcode插件的quicktag
修改 wp-includes/js/quicktags.js 文件
1. 找到
- edButtons[edButtons.length] =
- new edButton('ed_code'
- ,'code'
- ,'<code>'
- ,'</code>'
- ,'c'
- );
在后面添加
- edButtons[edButtons.length] =
- new edButton('ed_coolcode'
- ,'coolcode'
- ,''
- ,'</coolcode>'
- ,'x'
- );
2. 找到
- else if (button.id == 'ed_link') {
- document.write('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertLink(edCanvas, ' + i + ');" value="' + button.display + '" />');
- }
在后面添加
- else if (button.id == 'ed_coolcode') {
- document.write('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertCoolcode(edCanvas, ' + i + ');" value="' + button.display + '" />');
- }
3. 在文件末尾添加
- function edInsertCoolcode(myField, i, defaultLang, defaultLine) {
- if (!defaultLang) {
- defaultLang = 'php';
- }
- if (!defaultLine) {
- defaultLine = 'off';
- }
- if (!edCheckOpenTags(i)) {
- var codeLang = prompt('输入需要加亮的程序语言', defaultLang);
- var codeLine = prompt('是否显示行号(on, off)', defaultLine);
- edButtons[i].tagStart = '<' + 'coolcode';
- if (codeLang) {
- edButtons[i].tagStart = edButtons[i].tagStart + ' lang="'
- + codeLang + '"'
- }
- if (codeLine) {
- edButtons[i].tagStart = edButtons[i].tagStart + ' linenum="'
- + codeLine + '"';
- }
- edButtons[i].tagStart = edButtons[i].tagStart + '>';
- edInsertTag(myField, i);
- }
- else {
- edInsertTag(myField, i);
- }
- }
相关日志
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments
还没有评论。
发表评论