Monday, 23 July 2012

How to add existing WP Editor in custom plugin


<label style="color:#FF0000;">Package Description : </label>
                <?php

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"] = "package-description";
    $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 name="package-description" id="package-description" style="width:450px; height:100px;"><? echo $packageData->tPackageDescription?></textarea>

Put this code in to your required file it will reflect normal textarea  to WP Editor.

2 comments: