【问题标题】:Adding wp_editor to custom WP widget将 wp_editor 添加到自定义 WP 小部件
【发布时间】:2013-02-15 09:03:57
【问题描述】:

我想将带有 TinyMCE 的 WP 编辑器添加到我的自定义文本小部件中,但它不会显示 TinyMCE 按钮,它只显示 textarea。

当我在 page.php 上测试我的代码时,它可以完美运行 - 编辑器显示所有按钮和元框。

你能告诉我我做错了什么吗?

编辑
Widgets screenshot
Same code used in page.php screenshot

我使用的代码:

$settings = array(
    'wpautop' => true,
    'media_buttons' =>  false,
    'textarea_name' => 'test-editor',
    'textarea_rows' => get_option('default_post_edit_rows', 10),
    'tabindex' => '',
    'editor_css' => '',
    'editor_class' => '',
    'teeny' => true,
    'dfw' => true,
    'tinymce' => array(
          'theme_advanced_buttons1' => 'bold,italic,underline' 
    ),
    'quicktags' => false
);
wp_editor( 'Text in editor', 'test-editor', $settings );

【问题讨论】:

  • 您的 js-console 上是否有任何 js 错误?
  • 没有js错误。

标签: wordpress editor tinymce


【解决方案1】:

看来您需要另找一个所见即所得的编辑器。 Reading the Codex,你的代码有两个问题:

  1. $editor_id

    只能由小写字母组成。没有下划线,没有连字符。其他任何事情都会导致 WYSIWYG 编辑器出现故障。

  2. 这个阻止编辑器在元框中工作

    一旦实例化,所见即所得编辑器就不能在 DOM 中移动。实际上,这意味着您不能将它放在可以拖放到页面其他位置的元框中。

【讨论】:

    猜你喜欢
    • 2014-04-08
    • 2015-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多