Tanpa harus menggunakan plugin, Anda bisa memodifikasi sendiri kolom pesan atau komentar untuk blog WordPress Anda menjadi bentuk WYSIWYG Editor.
Modifikasi ini memanfaatkan function wp_editor dan menggunakan filter comment_form_defaults untuk menimpa kolom komentar yang lama. Berikut kode PHP yang harus Anda tambahkan di file functions.php theme Anda.
add_filter( 'comment_form_defaults','jv_comment_form');
function jv_comment_form( $args )
{
$editor_id = "comment"; // element id of textarea comment field
$settings = array(
'editor_height' => 50, //column height
'media_buttons' => false,
'textarea_name' => $editor_id,
'teeny' => true,
'tinymce' => array(
'resize' => true,
'wordpress_adv_hidden' => true,
'add_unload_trigger' => true,
'statusbar' => true,
'autoresize_min_height' => 50,
'wp_autoresize_on' => true,
'toolbar1' => 'bold,italic,bullist,numlist'
),
'quicktags' => array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,close' )
);
if ( function_exists( 'wp_editor' ) )
{
ob_start();
wp_editor( '', $editor_id, $settings );
$args['comment_field'] = ob_get_clean();
return $args;
}
}
Hasilnya seperti gambar berikut:
Share