Add TinyMCE to author description in Wordpress
Ok, second chance to me, after the Restrict authors access to edit comments plugin I did the second one.
I think that the name is quite explicative: I wanted to add the wysiwyg to the user description .
PHP:
-
<?php
-
/*
-
Plugin Name: Add TinyMce to Author Profile
-
Plugin URI: http://www.laboratoriocaffeina.it/development/2007/08/22/add-tinymce-to-author-description-in-wordpress.html
-
Description: Adds WYSIWYG to Author profile
-
Version: 0.1
-
Author: cedmax
-
Author URI: http://www.dioblog.it
-
*/
-
-
add_action('admin_head', 'add_tinymce');
-
}
-
-
remove_filter('pre_user_description', 'wp_filter_kses');
-
add_filter('pre_user_description', 'wpautop');
-
-
function add_tinymce() {?>
-
-
<script type="text/javascript" src="<?php echo get_settings('home'); ?>/wp-includes/js/tinymce/tiny_mce_gzip.php?ver=20070326"></script>
-
<script type="text/javascript">
-
//<![CDATA[
-
-
function brstonewline(element_id, html, body) {
-
html = html.replace(/<br\s*\/>/gi, '\n');;
-
return html;
-
}
-
-
function insertHTML(html) {
-
tinyMCE.execCommand('mceInsertContent',false, html);
-
}
-
-
tinyMCE.init({
-
mode : "exact",
-
elements : "description",
-
theme : "advanced",
-
theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,undo,redo,link,unlink",
-
force_p_newlines : false,
-
force_br_newlines : true,
-
gecko_spellcheck : true,
-
theme_advanced_buttons2 : "",
-
theme_advanced_buttons3 : "",
-
theme_advanced_toolbar_location : "top",
-
theme_advanced_toolbar_align : "left",
-
save_callback : "brstonewline",
-
height : "300",
-
extended_valid_elements : "a[name|href|title],font[face|size|color|style],span[class|align|style]"
-
});
-
//]]>
-
</script>
-
-
<?php } ?>
INSTRUCTION:
download v.0.1 and copy the file into wp-content/plugins.
activate it.
Now you should see in the edit user details the wysiwyg editor.
You can manage to modify TinyMCE script, following instruction
Hope you like it
tested on wordpress 2.2
IN ORDER TO LET IT WORK IN 2.5
replace this part of code:
PHP:
-
function add_tinymce() {?>
-
-
<script type="text/javascript" src="<?php echo get_settings('home'); ?>/wp-includes/js/tinymce/tiny_mce_gzip.php?ver=20070326"></script>
-
<script type="text/javascript">
-
//<![CDATA[
-
-
function brstonewline(element_id, html, body) {
-
html = html.replace(/<br\s*\/>/gi, '\n');;
-
return html;
-
}
-
-
function insertHTML(html) {
-
tinyMCE.execCommand('mceInsertContent',false, html);
-
}
-
-
tinyMCE.init({
-
mode : "exact",
-
elements : "description",
-
theme : "advanced",
-
theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,undo,redo,link,unlink",
-
force_p_newlines : false,
-
force_br_newlines : true,
-
gecko_spellcheck : true,
-
theme_advanced_buttons2 : "",
-
theme_advanced_buttons3 : "",
-
theme_advanced_toolbar_location : "top",
-
theme_advanced_toolbar_align : "left",
-
save_callback : "brstonewline",
-
height : "300",
-
extended_valid_elements : "a[name|href|title],font[face|size|color|style],span[class|align|style]"
-
});
-
//]]>
-
</script>
-
<?php } ?>
with this:
PHP:
-
function add_tinymce() {?>
-
-
<script type="text/javascript" src="<?php echo get_settings('home'); ?>/wp-admin/js/editor.js?ver=20080325"></script>
-
-
<script type="text/javascript" src="<?php echo get_settings('home'); ?>/wp-includes/js/tinymce/tiny_mce_config.php?ver=20080327"></script>
-
<script type="text/javascript">
-
//<![CDATA[
-
window.onload= function() {
-
tinyMCE.execCommand("mceAddControl", false, "description");
-
}
-
// ]]>
-
-
</script>
-
-
<?php } ?>

[...] Author TinyMCE enhances the author description field with the TinyMCE Editor. [...]
[...] Author TinyMCE enhances the author description field with the TinyMCE Editor. [...]
[...] Add TinyMCE to author description in Wordpress (tags: wordpress) [...]
[...] Add TinyMCE to author description in Wordpress | laboratorio caffeina [...]
[...] Add TinyMce to Author Profile 0.1 Advanced WYSIWYG Editort 0.2 (?????i???????) Audio player 1.2.3 BackUpWordPress 0.2.6 Disk Usage 2.0 Google Sitemaps 3.0b1 HTML Purified 0.2.4 ImageManager 2.4.1 LiveJournal Crossposter 1.5 (?????i???????) RusToLat 0.2 Search and Replace 1.6 Search Term HighLiter 1.0 Seo-Without-Category 1.0 Shutter Reloaded 1.1 Smilies Themer 0.2 Beta TheRussianDate 1.01 wp-comment-spam-stopper v1.1.1 [...]
[...] der Suche habe ich zwar ein Plugin gefunden, welches sogar verspricht den visuellen Editor innerhalb de Beschreibung einzubinden. Ich [...]
[...] Visit [...]
[...] Visit [...]
Thank you for this plugin its awesome. +1 geek point ^_^
Is there any chance of this being upgraded to work on wordpress 2.5?
The problem of this plugin with WP2.5 is that the editor TinyMCE is called with this code:
/wp-includes/js/tinymce/tiny_mce_gzip.php?ver=20070326">The file tiny_mce_gzip.php is not available in WP2.5 anymore respectively has a file size of 0 bytes (I dont know if this is correct or a bug of WP).
A workaround is to call TinyMCE directly, which means you have to change the line above into
/wp-includes/js/tinymce/tiny_mce.js">and it works again :-)
sorry for not updating the plugin (I’m a little busy here), but I’ve already got the solution:
change the function add_tinymce with this one:
function add_tinymce() {?>
<script type=”text/javascript” src=”< ?php echo get_settings('home'); ?>/wp-admin/js/editor.js?ver=20080325″></script>
<script type=”text/javascript” src=”< ?php echo get_settings('home'); ?>/wp-includes/js/tinymce/tiny_mce_config.php?ver=20080327″></script>
<script type=”text/javascript”>
//<![CDATA[
window.onload= function() {
tinyMCE.execCommand("mceAddControl", false, "description");
} // ]]></script>
< ?php } ?>
Thanx for the code - be aware that spaces in it are not shown correctly. I also had to change the quotes in order to get it working. If you just copy and paste the code above, it won´t work!
you’re right: I’d better put it in the post: comments aren’t the right place
Thanks for the example! I modified it just slightly to add a WYSIWYG editor to the category description field in the category editor, and it worked very well.
[...] Author TinyMCE enhances the author description field with the TinyMCE Editor. [...]
[...] Author TinyMCE enhances the author description field with the TinyMCE Editor. [...]
[...] Author TinyMCE enhances the author description field with the TinyMCE Editor. [...]
Hi,
any idea to let it works on wordpress 2.6.2 or higher?
many thanks
pablo
For wordpress 2.7, you’ll need to make the code look like this:
if ( (strpos($_SERVER['SCRIPT_NAME'], ‘wp-admin/user-edit.php’)) or (strpos($_SERVER['SCRIPT_NAME'], ‘wp-admin/profile.php’))) {
add_action(’admin_head’, ‘add_tinymce’);
}
remove_filter(’pre_user_description’, ‘wp_filter_kses’);
add_filter(’pre_user_description’, ‘wpautop’);
function add_tinymce() {
if (function_exists(’wp_tiny_mce’)) wp_tiny_mce(); ?>
//
Hi there, I’ve been trying to get this to work on 2.7 but haven’t been able to use the above suggestion - nothing happens :(
As a result I ended up doing a more basic TinyMCE init of which I’ve posted info here:
http://wordpress.org/support/topic/229882
I can’t work out the simpler way to do it and am in a bit of a rush, so I’ll have to come back to it.
I think this functionality should really be just included in the WP core..
:)
Make sure, you use the right inverted comas - I copied the code and had to change them from ´ to ‘ - then it worked!