What is this? From this page you can use the Social Web links to save Add TinyMCE to author description in Wordpress to a social bookmarking site, or the E-mail form to send a link via e-mail.

Social Web

E-mail

E-mail It
August 22, 2007

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:
  1. <?php
  2. /*
  3. Plugin Name: Add TinyMce to Author Profile
  4. Plugin URI: http://www.laboratoriocaffeina.it/development/2007/08/22/add-tinymce-to-author-description-in-wordpress.html
  5. Description: Adds WYSIWYG to Author profile
  6. Version: 0.1
  7. Author: cedmax
  8. Author URI: http://www.dioblog.it
  9. */
  10.  
  11. if ((strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/user-edit.php')) or (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/profile.php'))) {
  12.     add_action('admin_head', 'add_tinymce');
  13. }
  14.  
  15. remove_filter('pre_user_description', 'wp_filter_kses');
  16. add_filter('pre_user_description', 'wpautop');
  17.  
  18. function add_tinymce() {?>
  19.  
  20.     <script type="text/javascript" src="<?php echo get_settings('home'); ?>/wp-includes/js/tinymce/tiny_mce_gzip.php?ver=20070326"></script>
  21.     <script type="text/javascript">
  22.     //<![CDATA[
  23.  
  24.     function brstonewline(element_id, html, body) {
  25.         html = html.replace(/<br\s*\/>/gi, '\n');;
  26.         return html;
  27.     }
  28.  
  29.     function insertHTML(html) {
  30.         tinyMCE.execCommand('mceInsertContent',false, html);
  31.     }
  32.  
  33.     tinyMCE.init({
  34.         mode : "exact",
  35.         elements : "description",
  36.         theme : "advanced",
  37.         theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,undo,redo,link,unlink",
  38.         force_p_newlines : false,
  39.             force_br_newlines : true,
  40.         gecko_spellcheck : true,
  41.         theme_advanced_buttons2 : "",
  42.         theme_advanced_buttons3 : "",
  43.         theme_advanced_toolbar_location : "top",
  44.         theme_advanced_toolbar_align : "left",
  45.             save_callback : "brstonewline",
  46.             height : "300",
  47.         extended_valid_elements : "a[name|href|title],font[face|size|color|style],span[class|align|style]"
  48.     });
  49.     //]]>
  50.     </script>
  51.  
  52. <?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:
  1. function add_tinymce() {?>
  2.  
  3.     <script type="text/javascript" src="<?php echo get_settings('home'); ?>/wp-includes/js/tinymce/tiny_mce_gzip.php?ver=20070326"></script>
  4.     <script type="text/javascript">
  5.     //<![CDATA[
  6.  
  7.     function brstonewline(element_id, html, body) {
  8.         html = html.replace(/<br\s*\/>/gi, '\n');;
  9.         return html;
  10.     }
  11.  
  12.     function insertHTML(html) {
  13.         tinyMCE.execCommand('mceInsertContent',false, html);
  14.     }
  15.  
  16.     tinyMCE.init({
  17.         mode : "exact",
  18.         elements : "description",
  19.         theme : "advanced",
  20.         theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,undo,redo,link,unlink",
  21.         force_p_newlines : false,
  22.             force_br_newlines : true,
  23.         gecko_spellcheck : true,
  24.         theme_advanced_buttons2 : "",
  25.         theme_advanced_buttons3 : "",
  26.         theme_advanced_toolbar_location : "top",
  27.         theme_advanced_toolbar_align : "left",
  28.             save_callback : "brstonewline",
  29.             height : "300",
  30.         extended_valid_elements : "a[name|href|title],font[face|size|color|style],span[class|align|style]"
  31.     });
  32.     //]]>
  33.     </script>
  34. <?php } ?>

with this:

PHP:
  1. function add_tinymce() {?>
  2.  
  3.     <script type="text/javascript" src="<?php echo get_settings('home'); ?>/wp-admin/js/editor.js?ver=20080325"></script>
  4.  
  5. <script type="text/javascript" src="<?php echo get_settings('home'); ?>/wp-includes/js/tinymce/tiny_mce_config.php?ver=20080327"></script>
  6.     <script type="text/javascript">
  7.     //<![CDATA[
  8. window.onload= function() {
  9. tinyMCE.execCommand("mceAddControl", false, "description");
  10. }
  11.  // ]]>
  12.    
  13.     </script>
  14.  
  15. <?php } ?>


Return to: Add TinyMCE to author description in Wordpress