Completely disable editor

时间:2011-06-26 作者:Tom

如何从页面中完全禁用visual和html编辑器?我知道我可以在我的个人资料中禁用可视化编辑器,但我正在尝试锁定内容输入区域,以便我的客户端不会把事情搞砸。

2 个回复
最合适的回答,由SO网友:Wyck 整理而成

为什么不使用自定义帖子类型,并且不添加对编辑器的任何支持,这毕竟是它们的用途和最简单的方法。这篇文章的答案包括如何做到这一点,

Hide content box with Custom Post Type?
http://codex.wordpress.org/Function_Reference/register_post_type

要删除页面或帖子(以及自定义类型)的该功能,您可以尝试使用remove_post_type_support . 对于页面;

add_action(\'init\', \'my_remove_editor_from_post_type\');
function my_remove_editor_from_post_type() {
    remove_post_type_support( \'page\', \'editor\' );
}
参考号:http://codex.wordpress.org/Function_Reference/remove_post_type_support

一个黑客解决方案是使用CSSdisplay:none; 对于#editorcontainer 或子id或类之一。然后,您还可以仅为特定用户将该样式排队。

SO网友:MartinJJ

你认为这可能是你想要的,代码和更多信息来自wpsnipp:

add_filter( \'wp_default_editor\', create_function(\'\', \'return "tinymce";\') );
add_action( \'admin_head\', \'disable_html_editor_wps\' );
function disable_html_editor_wps() {
global $current_user;
get_currentuserinfo();
if ($current_user_can(\'manage_options\') {
    echo \'<style type="text/css">#editor-toolbar #edButtonHTML, #quicktags {display: none;}</style>\';
}
}
我将其从使用用户级别改为使用if ($current_user_can(\'manage_options\') { 因此,除了管理员之外,其他人都应该删除它,代码需要在主题函数中使用gi。php

结束

相关推荐

将富文本编辑器添加到小部件-特别是CKEditor

我正在尝试向小部件添加富文本编辑器,并使用CKEditor(http://ckeditor.com/download ) 使用简单的工具栏。在我尝试存钱之前,一切都很好。单击“保存”时,文本区域(和文本编辑器)消失,无法保存。删除texteditor允许textarea正常工作和保存。您可以在此处看到小部件代码:http://pastebin.com/C7VbxBSG当然,我添加了wp_register_script 和wp_enqueue_script我使用相同的代码将文本编辑器添加到页面和帖子的文本区