Call TinyMCE in a WordPress plugin

后端 未结 8 1340
悲哀的现实
悲哀的现实 2020-12-24 05:33

Is there a way to add TinyMCE into my own WordPress plugin?

I have a textarea in my back end script and want to make this area into a TinyMCE WYSIWYG editable field.

8条回答
  •  旧时难觅i
    2020-12-24 06:10

    The following example works for me. Just make sure to use the id of the textarea you want to select in the $a["elements"] variable.

    Assuming you have a textarea with the id of 'intro':

    // 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"] = "intro";
        $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);
    }
    

    ?>

提交回复
热议问题