【问题标题】:Adding multiple tiny mce editors in plugin page in wordpress在 wordpress 的插件页面中添加多个微型 mce 编辑器
【发布时间】:2011-08-05 14:11:21
【问题描述】:

我正在使用此代码在 wordpress 3.2.1 的插件页面中添加小 mce

// attach the tiny mce editor to this textarea
if (function_exists('wp_tiny_mce')) {

  add_filter('teeny_mce_before_init', create_function('$a', '
    $a["theme"] = "advanced";
    $a["skin"] = "wp_theme";
    $a["height"] = "200";
    $a["width"] = "800";
    $a["onpageload"] = "";
    $a["mode"] = "exact";
    $a["elements"] = "mytextarea";
    $a["editor_selector"] = "mceEditor";
    $a["plugins"] = "safari,inlinepopups,spellchecker";

    $a["forced_root_block"] = false;
    $a["force_br_newlines"] = true;
    $a["force_p_newlines"] = false;
    $a["convert_newlines_to_brs"] = true;

    return $a;'));

 wp_tiny_mce(true);
}

如何在同一个插件管理页面中将另一个 textarea id=mytextarea2 更改为微型 mce 编辑器?

【问题讨论】:

    标签: wordpress plugins tinymce


    【解决方案1】:

    试试the_editor($content, $id);,其中 $content 是您的 HTML,$id 是您的表单名称和 id 属性。如果编辑页面上有或没有其他实例(如默认内容编辑器),您可能需要在此之后致电wp_tiny_mce()

    ---为清晰起见编辑...

    the_editor() 输出整个 TinyMCE/HTML 选项卡式编辑器部分。您可以根据需要多次调用它。

    wp_tiny_mce() 输出 TinyMCE 初始化脚本标签,因此每页只能调用一次。

    【讨论】:

      【解决方案2】:

      我找到了一个合适的解决方案:将第二个 id 添加到 elements 参数:

      // attach the tiny mce editor to this textarea
      if (function_exists('wp_tiny_mce')) {
      
        add_filter('teeny_mce_before_init', create_function('$a', '
          $a["theme"] = "advanced";
          $a["skin"] = "wp_theme";
          $a["height"] = "200";
          $a["width"] = "800";
          $a["onpageload"] = "";
          $a["mode"] = "exact";
          $a["elements"] = "mytextarea,mytextarea2";
          $a["editor_selector"] = "mceEditor";
          $a["plugins"] = "safari,inlinepopups,spellchecker";
      
          $a["forced_root_block"] = false;
          $a["force_br_newlines"] = true;
          $a["force_p_newlines"] = false;
          $a["convert_newlines_to_brs"] = true;
      
          return $a;'));
      
       wp_tiny_mce(true);
      }
      

      【讨论】:

        【解决方案3】:

        来自this article

        “editor_selector”是基于类属性的。

        所以,只需对所有要使用 TinyMCE 的文本区域使用相同的类。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-12-09
          • 2013-09-10
          • 1970-01-01
          • 2017-08-30
          相关资源
          最近更新 更多