wp_editor() | WordPress集成TinyMCE编辑器

作者猫斯基 2015-02-22 370 人读过

最新文章

函数

wp_editor( $content, $editor_id, $settings = array() );

    参数

  • $content – textarea中的内容
  • $editor_id – 编辑器的HTML ID,只能包含小写字母
  • $settings – 设置选项,是一个数组,可以设置的参数包括:
    • wpautop – 是否开启wpautop,默认为true
    • media_buttons – 是否显示上传多媒体的按钮,默认true
    • textarea_name – textarea的name属性,默认与$editor_id相同
    • textarea_rows – textarea的rows属性,默认是get_option(‘default_post_edit_rows’, 10),这一项在后台设置
    • tabindex – tabindex数值,tabindex规定用户用键盘的tab键切换表单元素时的顺序。
    • editor_css – 给编辑器添加css样式,适用于visual和html模式,必须包含<style>标签
    • teeny – 是否开启精简模式,这种模式下只加载基本插件(不加载任何外部TinyMCE插件),加载的插件包括inlinepopups、fullscreen、wordpress、wplink和wpdialogs,默认为false
    • tinymce – 用数组形式直接向tinyMCE传递参数
    • quicktags – 加载Quicktags,即HTML模式下的那些按钮,可以用数组形式直接向Quicktags传递参数。
    • dfw – 是否用DFW替换默认的全屏编辑器(需要特殊的DOM元素和css支持),开启该模式时,加载的全屏插件是wpfullscreen,默认为false。

使用示例

启用精简模式

wp_editor( '', 'myeditor', array(
    'teeny' => true )
);

关闭上传按钮

wp_editor( '', 'myeditor', array(
    'media_buttons' => false )
);

更换皮肤为default,默认是wp_theme。另外可选的皮肤还有:defaulto2k7highcontrast

wp_editor( '', 'myeditor', array(
    'media_buttons' => false,
    'tinymce' => array( 'plugins' => '','skin' => 'default') )
);

控制每行显示哪些按钮,显示部分WordPress隐藏的按钮。

wp_editor( '', 'myeditor', array(
    'media_buttons' => false,
    'tinymce' => array( 'plugins' => '',
          'skin' => 'o2k7',
          'theme_advanced_buttons1' => 'undo,redo,|,bold,italic,underline,strikethrough|,justifyleft,justifycenter,justifyright,justifyfull,|,forecolor,backcolor',
          'theme_advanced_buttons2' => 'cut,copy,paste,|,bullist,numlist,blockquote,|,link,unlink,anchor,image,|,sub,sup,hr'
           )
    )
);

本文由 猫斯基 原创发布。

著作权均归用户本人所有。独家文章转载,请联系本站管理员。获得授权后,须注明本文地址! 本文地址:https://www.maosiji.com/2896.html

关注我们

站长

WordPress迷