editing kses.php file (5 posts)

  1. madivad
    Posted 4 years ago #

    I am trying to remove html tags in my comments. I've searched and tried a few solutions already, most don't work, or don't work as expected. From the codex's own answers page it tells you to just edit (or delete) the kses.php file.

    But what I want to know is that the best approach? Isn't this a part of the core code that will be updated in future updates of wordpress?


  2. madivad
    Posted 4 years ago #

    I thought I would add, I only want to change the $allowedtags content, where is the best place to do this? Can I add it to my theme's functions.php file somewhere? and how exactly would I do that?

  3. madivad
    Posted 4 years ago #

    I have done some experimenting, and after adding the following code to my own theme's functions.php file, it works perfectly as required. Commenters are now only able to bold and italicise there comments. I tried inserting <a href> tag and it was stripped....

    Now I just want to remove raw links, ie links that people enter by just entering the url without any tags what-so-ever...

    eg, http://google.com still get's rendered in the comment and is even clickable. I want to totally not even have it.

    I'm thinking of searching through the comment and finding any reference to http: and then just deleting everything from there up to the first space...

    I'm now open to ideas on how to achieve that.

    Oh, and the code I put in my functions.php file:

    $allowedtags = array(
    		'b' => array(),
    		'em' => array (), 'i' => array (),

    Is there a better place for it?

  4. popper
    Posted 4 years ago #

    You want to remove the links completely, or just disable the wordpress filter that makes them clickable automatically?

    To disable auto-links:

    remove_filter('comment_text', 'make_clickable', 9);

    To delete them completely, probably the best idea would be to add a filter to the comment_text pre save or pre display, and delete them using a regular expression. You should be able to find several examples of regex to detect urls easily on google.

  5. madivad
    Posted 4 years ago #

    remove completely... I'll implement that filter removal for the time being, but I'll work on your second part and post back my results. Thanks for your input

Topic Closed

This topic has been closed to new replies.

About this Topic