Textarea to tinymce wysiwyg in wordpress plugin

Hi guys, today i have to create a plugin to wordpress. In that i have task to make text area into a tinymce wysiwyg editable field. I learned how to do. I thought of sharing to you guys.

add_action(“admin_print_scripts”, “js_libs”);
function js_libs() {
wp_tiny_mce( false , // true makes the editor “teeny”
“editor_selector” => “tinymce_data”

<script type=”text/javascript”>
jQuery(document).ready(function($) {
$(‘a.toggleVisual’).click(function() {
console.log(tinyMCE.execCommand(‘mceAddControl’, false, ‘tinymce_data’));
$(‘a.toggleHTML’).click(function() {
console.log(tinyMCE.execCommand(‘mceRemoveControl’, false, ‘tinymce_data’));

<form method=”post” action=””>
<span id=”submit”><input class=”button” type=”submit”></span>
<p id=”toggle” align=”right”><a class=”button toggleVisual”>Visual</a><a class=”button toggleHTML”>HTML</a></p>
<li><textarea style=”width:100%;” class=”tinymce_data” id=”tinymce_data” name=”tinymce_data”></textarea></li>


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s