WYSIWYG-editor maken van biografie tekstveld

VN:F [1.9.17_1161]
Rating: 0.0/5 (0 votes cast)

Als je de inhoud van het biografie veld, van je WordPress profiel, openbaar maakt is het handig om er HTML in te gebruiken om de teksten een beetje ‘op te leuken’ en beter leesbaar te maken.

En aangezien niet iedereen HTML kent (of zin heeft om dat allemaal uit te schrijven) zou het erg handig zijn als het een WYSIWYG-editor zou zijn. Gelukkig kan dat heel erg makkelijk.

Het enige dat je hoeft te doen is de volgende code aan de functions.php van je theme toe te voegen:

<?<a title="Zie ook De WYSIWYG editor bij je theme laten passen" href="http://hiranthi.nl/tutorials/wysiwyg-editor-theme/">php</a>

if ( (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/user-edit.<a title="Zie ook Maatwerk product aan winkelwagen toevoegen (Shopp 1.1.x)" href="http://hiranthi.nl/tutorials/maatwerk-product-aan-winkelwagen-toevoegen/">php</a>')) || (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/profile.<a title="Zie ook Colorbox uitschakelen in Shopp" href="http://hiranthi.nl/shopp-faq/colorbox-uitschakelen-shopp/">php</a>')))
{
  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_enqueue_script('editor');  // This is the key to make it work...
    do_action('admin_print_scripts'); // This prints it in the proper place in the <head>

    add_filter( 'teeny_mce_before_init', create_function( '$a', '
      $a["theme"] = "advanced";
      $a["skin"] = "wp_theme";
      $a["height"] = "420";
      $a["width"] = "400";
      $a["onpageload"] = "";
      $a["mode"] = "exact";
      $a["elements"] = "description";
      return $a;' ) );
    wp_tiny_mce( true );
  }
}

?>

En dat komt er dan zo ongeveer uit te zien:

Biografie - WYSIWYG editor

Hou er wel rekening mee dat als je de WYSIWYG-bewerking (helemaal bovenaan je profiel pagina) hebt uitstaan (ofwel: aangevinkt), je de WYSIWYG-editor niet te zien krijgt, maar gewoon het tekstveld.

Edit: Ik hoorde van [@rubenwoudsma] dat er ook een plugin voor is, mocht je dus liever een plugin installeren dan deze code in je functions.php toe te voegen, bekijk dan de Rich Text Biography plugin.

  • Facebook
  • Twitter
  • Delicious
  • Digg
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

One Response to WYSIWYG-editor maken van biografie tekstveld
  1. [...] las ik in een discussie tussen Hiranthi Molhoek en Joeke-Remkus de Fries dat het ook nog een tip om code... rubenwoudsma.nl/wordpress-gebruikersprofiel-uitbreiden

Geef een reactie

Your email address will not be published. Please enter your name, email and a comment.

*

De volgende HTML tags en attributen zijn toegestaan: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <div align="" class="" dir="" id="" lang="" style="" xml:lang=""> <pre class="">

CommentLuv badge