Add TinyMCE to author description in Wordpress
Posted in: Programmazione
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 } ?>
Social Web