给wordpress换了CK编辑器,但是还得弄个插入TAB的按钮

时间: 2015-08-24 / 分类: wordpress / 浏览次数: 2,597 views / 0个评论 发表评论

CKEditor 4.4.5 (revision 25cdcad)这个是编辑器版本,是安装了CKEditor for WordPress最新版本自动下载的

看来看去还是用插件比较方便弄按钮~

打开插件\wp-content\plugins\ckeditor-for-wordpress\ckeditor.config.js

增加插件,把它取名code

// code plugin
config.extraPlugins += (config.extraPlugins ? ‘,code’ : ‘code’ );
CKEDITOR.plugins.addExternal(‘code’, ckeditorSettings.pluginPath + ‘plugins/code/’);

 

然后进入插件目录创建个code文件夹

\wp-content\plugins\ckeditor-for-wordpress\plugins\code

 

添加插件JS文件

plugin.js

还有找来一个小图标,随便上网搜索一个就可以了

tab.png

 

然后编辑plugin.js

( function() {
    CKEDITOR.plugins.add( ‘code’,
    {
        init: function( editor )
        {
            var me = this;

            editor.ui.addButton( ‘code’,
            {
                label: ‘code’,
                command: ‘code’,
                icon: this.path + ‘tab.png’,
                toolbar: ‘wordpress,100’
            } );
        // Register the commands.
        editor.addCommand( ‘code’,
        {
            exec : function()
            {
                var tagtext = ”;
                var tab=’wptab’;
var end="end_wptabset";
                tagtext = tagtext + ""+"[" + tab + " name=’产品介绍’]" + "产品介绍内容 [/" + tab + "]" + "";
tagtext = tagtext + "[" + tab + " name=’产品参数’]" + "产品参数内容 [/" + tab + "]" + "";
tagtext = tagtext + "[" + tab + " name=’驱动程序’]" + "驱动程序内容 [/" + tab + "]" + "";
tagtext = tagtext + "[" + end + "]"+ "";
                    editor.insertText(tagtext);
            }
        });
        }
    } );

} )();

 

就可以了~

发表评论

您的昵称 *

您的邮箱 *

您的网站