自定义管理页面上的 wordpress Ckeditor
Ckeditor for wordpress on custom admin page
我安装了适用于 Wordpress 的插件 CKEditor,并希望在我创建的自定义管理页面上显示 CKEditor。我使用 wordpress 函数 wp_editor() 来显示它。
wp_editor("initial content", "uniqueid");
问题是它显示了一个完全白色的编辑器而不是 CKEditor(所以:一个带有 HTML 和上面的 Visual 的大白色矩形)。它在我的页面上生成以下 html(我省略了 "HTML" 和 "Add Media" 按钮):
<div id="wp-uniqueid-wrap" class="wp-editor-wrap tmce-active"><link rel="stylesheet" id="editor-buttons-css" href="/wp-includes/css/editor.min.css?ver=4.1.1" type="text/css" media="all">
<div id="wp-uniqueid-editor-tools" class="wp-editor-tools">
<a id="uniqueid-tmce" class="hide-if-no-js wp-switch-editor switch-tmce" onclick="switchEditors.switchto(this);">Visual</a>
</div>
<div id="wp-uniqueid-editor-container" class="wp-editor-container">
<textarea class="wp-editor-area theEditor" rows="10" cols="40" name="uniqueid" id="uniqueid"><p>initial content</p></textarea>
</div>
</div>
只有当我单击 "Visual" 选项卡时,我才能获得 CKEditor。只有这样它才看起来和我的常规管理页面(帖子和页面)中的完全一样。
所以,我的问题是我应该添加什么到我的自定义管理页面或我的自定义功能以使 CKEditor 出现在自定义管理页面上,就像它出现在 "edit post" 和 "edit page" 上一样页面,用户无需单击“可视化”选项卡即可显示编辑器及其内容?
或者,反过来说,为了让 CKEditor 正常显示,将哪些代码添加到常规 "edit post" 和 "edit page" 页面?
编辑:
我设法让它部分工作。还有一些事情困扰着我。
我在 wp_editor() 调用后添加了以下内容:
<script>
window.onload = function(){
CKEDITOR.replace( "uniqueid" );
};
</script>
现在看到小编了。
我遇到了同样的问题 wp_editor() 没有在 Wordpress 的自定义字段上显示多个 TinyMCE 编辑器,因为它们都有相同的 class - 所以我添加了两个 'wp_create_nonce($name)' 和 'wp_create_nonce($this->id)'
<?php wp_editor($value, 'editor-'. wp_create_nonce($name) . wp_create_nonce($this->id) .'', $settings = array('textarea_name' => $name)); ?>
随机数是根据当前时间、$action参数和当前用户ID生成的。
我安装了适用于 Wordpress 的插件 CKEditor,并希望在我创建的自定义管理页面上显示 CKEditor。我使用 wordpress 函数 wp_editor() 来显示它。
wp_editor("initial content", "uniqueid");
问题是它显示了一个完全白色的编辑器而不是 CKEditor(所以:一个带有 HTML 和上面的 Visual 的大白色矩形)。它在我的页面上生成以下 html(我省略了 "HTML" 和 "Add Media" 按钮):
<div id="wp-uniqueid-wrap" class="wp-editor-wrap tmce-active"><link rel="stylesheet" id="editor-buttons-css" href="/wp-includes/css/editor.min.css?ver=4.1.1" type="text/css" media="all">
<div id="wp-uniqueid-editor-tools" class="wp-editor-tools">
<a id="uniqueid-tmce" class="hide-if-no-js wp-switch-editor switch-tmce" onclick="switchEditors.switchto(this);">Visual</a>
</div>
<div id="wp-uniqueid-editor-container" class="wp-editor-container">
<textarea class="wp-editor-area theEditor" rows="10" cols="40" name="uniqueid" id="uniqueid"><p>initial content</p></textarea>
</div>
</div>
只有当我单击 "Visual" 选项卡时,我才能获得 CKEditor。只有这样它才看起来和我的常规管理页面(帖子和页面)中的完全一样。
所以,我的问题是我应该添加什么到我的自定义管理页面或我的自定义功能以使 CKEditor 出现在自定义管理页面上,就像它出现在 "edit post" 和 "edit page" 上一样页面,用户无需单击“可视化”选项卡即可显示编辑器及其内容?
或者,反过来说,为了让 CKEditor 正常显示,将哪些代码添加到常规 "edit post" 和 "edit page" 页面?
编辑: 我设法让它部分工作。还有一些事情困扰着我。 我在 wp_editor() 调用后添加了以下内容:
<script>
window.onload = function(){
CKEDITOR.replace( "uniqueid" );
};
</script>
现在看到小编了。
我遇到了同样的问题 wp_editor() 没有在 Wordpress 的自定义字段上显示多个 TinyMCE 编辑器,因为它们都有相同的 class - 所以我添加了两个 'wp_create_nonce($name)' 和 'wp_create_nonce($this->id)'
<?php wp_editor($value, 'editor-'. wp_create_nonce($name) . wp_create_nonce($this->id) .'', $settings = array('textarea_name' => $name)); ?>
随机数是根据当前时间、$action参数和当前用户ID生成的。