为wordpress添加coolcode插件的quicktag

转载时请标明文章原始出处和作者信息, 作者: lostsnow.
http://www.lsproc.com/blog/add_coolcode_quicktag_for_wordpress/

修改 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);
	}
}

-- EOF --

博客世界最受欢迎的30个插件

转载时请标明文章原始出处和作者信息, 作者: lostsnow.
http://www.lsproc.com/blog/top_30_wordpress_plugins_in_blogosphere/

From:
http://fairyfish.com/2007/04/02/top-30-wordpress-plugins-in-blogosphere/

翻译于:
http://www.staska.net/2007/03/27/top-30-wordpress-plugins-in-blogosphere/

作者根据Lorelle的Lists of favorite WordPress plugins上的48列表和280个插件,选出最受欢迎的30个插件。

Continue reading

-- EOF --