在新版本的Wordpress 3.0发布之前,我使用下面的jQuery代码向管理面板的编辑器工具栏中添加我自己的快捷代码的自定义按钮,效果很好。然而,随着版本3的发布,它已经停止工作,如果我在管理面板中查看源代码,我可以看到下面的代码正在正确加载,它只是不再工作,有人知道发生了什么变化,或者如何修复以使用新版本吗?
// Add CUSTOM buttons to html editor in admin!
add_action(\'admin_footer\',\'custom_editor_buttons\');
function custom_editor_buttons() {
?>
<script type="text/javascript" charset="utf-8">
<!-- Define our Editor buttons -->
edButtons[edButtons.length] = new edButton(
"hed_0",
"Citation",
"[ref]",
"[/ref]",
""
);
edButtons[edButtons.length] = new edButton(
"hed_1",
"highlight",
"[highlight]",
"[/highlight]",
""
);
jQuery(document).ready(function (b) {
<!-- Empty editor button tray -->
<!-- then re-build it with our custom buttons -->
jQuery("#ed_toolbar").empty();
function hedShowButtons(button, i) {
if ( button.id == \'ed_img\' ) {
jQuery("#ed_toolbar").append(\'<input type="button" id="\' + button.id + \'" accesskey="\' + button.access + \'" class="ed_button" onclick="edInsertImage(edCanvas);" value="\' + button.display + \'" />\');
}else if (button.id == \'ed_link\') {
jQuery("#ed_toolbar").append(\'<input type="button" id="\' + button.id + \'" accesskey="\' + button.access + \'" class="ed_button" onclick="edInsertLink(edCanvas, \' + i + \');" value="\' + button.display + \'" />\');
}else {
jQuery("#ed_toolbar").append(\'<input type="button" id="\' + button.id + \'" accesskey="\' + button.access + \'" class="ed_button" onclick="edInsertTag(edCanvas, \' + i + \');" value="\' + button.display + \'" />\');
}
}
for ( var i = 0; i < edButtons.length; i++ ) {
hedShowButtons(edButtons[i], i);
}
jQuery("#ed_toolbar").append(\'<input type="button" id="ed_tabs" class="ed_button" title="Enable and disable tabbing" value="disable tabs" />\');
jQuery("#ed_toolbar").append(\'<input type="button" onclick="fullscreen.on();" id="ed_fullscreen" class="ed_button" title="Enable and disable fullscreen mode" value="fullscreen" />\');
jQuery("#ed_toolbar").append(\'<input type="button" id="ed_spell" class="ed_button" onclick="edSpell(edCanvas);" title="\' + quicktagsL10n.dictionaryLookup + \'" value="\' + quicktagsL10n.lookup + \'" />\');
jQuery("#ed_toolbar").append(\'<input type="button" id="ed_close" class="ed_button" onclick="edCloseAllTags();" title="\' + quicktagsL10n.closeAllOpenTags + \'" value="\' + quicktagsL10n.closeTags + \'" />\');
});
</script>
<?php
}