Allowing more elements in comments via functions.php

I would like to allow certain HTML elements in my comments and have edited kses.php directly in the past.

However, I have been hacked recently and replaced all the core WordPress files and feel I would like to avoid editing those files.

Read More

Is it possible to allow more elements via the functions.php file?

Related posts

Leave a Reply

1 comment

  1. Here is an example how to allow a commenter to insert HTML5 video into the comment. Both <video> and <source> elements has two allowed attributes. preprocess_comment filter is applied when saving the comment to the DB.

    See /wp-includes/kses.php for $allowedtags array structure.

    function myAllowHtmlComments($comment) {
        global $allowedtags; 
        $allowedtags['video'] = array(
            'width' => true,
            'height' => true
        );
        $allowedtags['source'] = array(
            'src' => true,
            'type' => true
        );
        return $comment;
    }
    add_filter('preprocess_comment','myAllowHtmlComments');