2011-08-05 55 views
1

我正在使用此代碼添加微小的MCE在我的插件網頁在WordPress 3.2.1添加的插件,網頁多微小的MCE編輯在WordPress

// 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編輯器中?

回答

1

我找到一個適當的解決方案:addinge所述第二ID的元素參數:

// 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); 
} 
2

嘗試the_editor($content, $id);其中$ content是您的HTML,$ id是您的表單名稱和id屬性。您可能需要調用後,如果有wp_tiny_mce()或編輯頁面上沒有其他情況下(如默認的內容編輯。)

---編輯爲清楚...

the_editor()輸出整個TinyMCE的/ HTML標籤編輯器部分。你可以根據需要多次調用它。

wp_tiny_mce()輸出TinyMCE初始化腳本標籤,所以應該每頁僅調用一次。

1

this article

「editor_selector」基於類屬性。

所以,只需要使用相同的類到所有你想使用TinyMCE的textareas。