╃苍狼山庄╃╃苍狼山庄╃

Clang出品,
必属精品!

为WordPress编辑器添加WP-Syntax按钮

熟悉程序设计的网友,在 WordPress 插入代码是经常的事情。使用代码插件,可以让你的程序代码更容易阅读。WP-Syntax 就是这样一个代码插件,不过,WP-Syntax 插件使用起来却并不太方便。
使用这个插件,每次插入代码的时候,都需要手动输入一些预设置的格式,如果能够在编辑器框里增加一个按钮,自动输入这些重复的内容,就方便多了。

首先先安装WP-Syntax插件,然后找到WordPress安装文件夹里的\wp-includes\js\quicktags.js这个文件,这个文件里是编辑按钮的语句,例如:

edButtons[edButtons.length]=new edButton("ed_li","li","\t
  • ","
  • \n","l"); edButtons[edButtons.length]=new edButton("ed_code","code","","","c"); edButtons[edButtons.length]=new edButton("ed_more","more","","","t",-1);


    上面调用的按钮就是li的按钮、code的按钮和more的按钮,你会发现他们都是同样的格式,那么我们也可以复制一条插入到code代码的后面,就OK了,那么调用WP-Syntax的语句就是(请把“< /pre>”中间的空格去掉):

    edButtons[edButtons.length]=new edButton("ed_pre","pre","

    ","< /pre>","p");


    同理我们可以插入一个END按钮,文章写完后我们插入一个END标识:

    edButtons[edButtons.length]=new edButton("ed_end","end","

    ------------------------------End------------------------------

    ","","e",-1);


    如果你还安装了anyplayer这个插件,已可以再加入下面的代码:

    edButtons[edButtons.length]=new edButton("ed_video","video","[anyplayer:type=swf url= width=500 height=400]","","v",-1);


    颜色按钮:

    edButtons[edButtons.length]=new edButton("ed_color","color","","","h");


    添加好后进入wp后台,发布日志时插入代码,在HTML编辑模式下,点击你添加的按钮,就自动把要添加的代码插入了!

    本原创文章未经允许不得转载 | 当前页面:╃苍狼山庄╃ » 为WordPress编辑器添加WP-Syntax按钮

    评论

    文章评论已关闭!