Latest Tech and Tips

How to Disable HTML in WordPress Comments


By default, WordPress enables specific HTML tags within the comments such as << a> <> < em> <> < solid> > and so on If you observe a great deal of SPAM comments additionally consist of these tags. Most SPAM comments are made by crawlers and also manuscripts, which are making use of HTML tags. If you just disable HTML from your WordPress comments, it can stop a great deal of SPAM. In this tutorial we will certainly reveal you how you can disable HTML tags in your WordPress comments.

This tutorial will just disable energetic HTML tags. So a person can still upload something like:

<< a><> < em><> < solid>>

And it will certainly appear, yet the tags will certainly not be useful. So if a person utilizes the solid tag, it will not strong the message. Besides very few SPAM crawlers have time to do this due to the fact that in this manner uses up a great deal of time and also it is not useful for them.

All you have to do is just open your functions.php and also include the adhering to code:

// This will certainly take place when the remark is published.
feature plc_comment_post( $incoming_comment) {

// transform every little thing in a remark to show essentially.
$ incoming_comment['comment_content'] = htmlspecialchars($ incoming_comment['comment_content']);.

// the one exemption is solitary quotes, which can not be # 039; due to the fact that WordPress notes it as spam.
$ incoming_comment['comment_content'] = str_replace( "'"," ', $incoming_comment['comment_content'] );.

return( $incoming_comment );.

// This will certainly take place prior to a remark is shown.
feature plc_comment_display( $comment_to_display) {

// Put the solitary quotes backin
$ comment_to_display = str_replace(" ', "'", $comment_to_display );.

return $comment_to_display;.

If you do not desire to by hand include this code on your own, after that the initial writer additionally provides a plugin that you can download and install. Simply set up and also turn on Peter’s Literal Comments plugin.

The reason that in this manner is much better is due to the fact that it does not need you to transform the core documents. If you desire to modify your core documents after that you might go to wp-includes/kses. php and also modify the codes there. (This is not Recommended, yet it is right here for understanding. (WP Codex for even more information)