我有这个代码!
(function() {
tinymce.create("tinymce.plugins.afflpad", {
init : function(ed, url) {
ed.addCommand("afflpad_click", function(e) {
ed.insertContent('<b>' + ed.selection.getContent() + '</b>');
});
ed.addButton("afflpad_button", {
title : "Affiliate Link",
cmd : "afflpad_click",
icon : "wp_code",
});
},
getInfo : function() {
return {
longname : "Affiliate links",
author : "NAME",
authorurl : "HOMEPAGE",
infourl : "HOMEPAGE",
version : tinymce.majorVersion + "." + tinymce.minorVersion
};
}
});
tinymce.PluginManager.add("afflpad", tinymce.plugins.afflpad);
})();
1.第一次点击按钮打开
<b>
,第二次点击必须关闭</b>
标记2.如何添加活动课程?
3.如何检测按钮对象?
4.(不同功能)第二次点击按钮删除所选的
<b>
标签
php coodes:
function afflpad_mce_buttonhooks() {
if(current_user_can("edit_posts") && current_user_can("edit_pages") && get_user_option("rich_editing") == "true") {
add_filter("mce_external_plugins", "afflpad_register_tinymce_javascript");
add_filter("mce_buttons", "afflpad_register_mce_buttons");
}
}
add_action("init", "afflpad_mce_buttonhooks");
function afflpad_register_tinymce_javascript($plugin_array) {
$plugin_array["afflpad"] = (get_bloginfo('template_directory').'/js/editor-script.js');
return $plugin_array;
}
function afflpad_register_mce_buttons($buttons) {
array_push($buttons, "|", "afflpad_button");
return $buttons;
}
add_filter('mce_css', 'tuts_mcekit_editor_style');
function tuts_mcekit_editor_style($url) {
if ( !empty($url) )
$url .= ',';
$url .= (get_bloginfo('template_directory').'/editor-styles.css');
return $url;
}