Change allowed HTML tags for comments
I've set up a HTML editor for WordPress comments, and I want to change the allowed HTML tags for comments accordingly.
Some of the HTML tags also have inline styling, or classes added. I only want to allow the styling and classes that I'm expecting, but I cannot get it to work.
I want to allow only these custom classes and styles.
span class="spoiler"This is spoilered text/span
span style="text-decoration: line-through;"This text has strikethrough/span
Non-working code:
function custom_allowed_tags_comment() {
global $allowedtags;
$allowedtags = array(
'p' = array(),
'b' = array(),
'strong' = array(),
'em' = array(),
'blockquote' = array(),
'ul' = array(),
'li' = array(),
'ol' = array(),
'span' = array(
'class' = array(
'spoiler'
),
'style' = array(
'text-decoration: line-through;'
)
)
);
} add_filter('comment_post', 'custom_allowed_tags_comment');
Topic allowedtags wp-kses comments Wordpress
Category Web