Use NicEdit, a Text and HTML editor, in WordPress

NicEdit is a WYSIWYG editor for websites, which can substitute "textareas" in WordPress.

NicEdit in WordPress

It's very easy to apply this editor. You can just copy the code found at NicEdit's web-site at http://nicedit.com/ and paste it into a page, which will change "textareas" to "NicEdit."

-latest.js" type="text/javascript"></script>
<script type="text/javascript">bkLib.onDomLoaded(nicEditors.allTextAreas);</script>

I thought the code above will apply to textareas found in a specific page which contains this script, but all "textareas" will be replaced by NicEdit.  If you use the following script (for the second script above), only textareas with ID 'myNicEditor' will be changed to NicEdit.

<script type="text/javascript">
//<![CDATA[
bkLib.onDomLoaded(function() {
nicEditors.editors.push(
new nicEditor().panelInstance(
document.getElementById('myNicEditor')
)
);
});
//]]>
</script>

I changed 'myNicEditor' to 'comment' in order to use NicEdit in my WordPress comments system. The features are limited compared than other editors for HTML such as Ckeditor but it enables users to upload images. (Please refer to this web-page for additional text and HTML editor which can be used in WordPress.)


4 개 댓글

  1. If WordPress blocks tags such as span, img, etc, please try to add the following function to your theme’s functions.php file:

    add_filter( 'wp_kses_allowed_html', 'my_allowed_html', 10, 2 );
    function my_allowed_html( $tags, $context ){
    $tags['span'] = array(
    'style' => array(),
    'dir' => true,
    'align' => true,
    'lang' => true,
    'xml:lang' => true,
    'class' => array(),
    );
    return $tags;
    }

    If this code does not work, please correct the kses.php file located under the folder /wp-includes/ to add such tags to the allowed tags list.

  2. If Nicedit does not work in Google Chrome, please try the following scritp:

    var commentNicEditor = new nicEditor().panelInstance('comment');
    commentNicEditor.addEvent("blur", function () {
        commentNicEditor.instanceById('comment').saveContent();
    });

Leave a Comment

3s