Allow html comments with kses
How do I allow HTML comments (!-- HTML Comment --
) when outptutting with wp_kses_post
?
My current allow function is as follows:
function custom_wpkses_post_tags( $tags, $context ) {
$allowed_atts = array(
'align' = true,
'class' = true,
'type' = true,
'id' = true,
'dir' = true,
'lang' = true,
'style' = true,
'xml:lang' = true,
'src' = true,
'alt' = true,
'href' = true,
'rel' = true,
'rev' = true,
'target' = true,
'novalidate' = true,
'type' = true,
'value' = true,
'name' = true,
'tabindex' = true,
'action' = true,
'method' = true,
'for' = true,
'width' = true,
'height' = true,
'data' = true,
'data-*' = true,
'title' = true,
'for' = true
);
if ( 'post' === $context ) {
$tags['form'] = $allowed_atts;
$tags['label'] = $allowed_atts;
$tags['select'] = $allowed_atts;
$tags['option'] = $allowed_atts;
$tags['input'] = $allowed_atts;
$tags['textarea'] = $allowed_atts;
$tags['iframe'] = $allowed_atts;
$tags['script'] = $allowed_atts;
$tags['style'] = $allowed_atts;
$tags['strong'] = $allowed_atts;
$tags['small'] = $allowed_atts;
$tags['table'] = $allowed_atts;
$tags['span'] = $allowed_atts;
$tags['abbr'] = $allowed_atts;
$tags['code'] = $allowed_atts;
$tags['pre'] = $allowed_atts;
$tags['div'] = $allowed_atts;
$tags['img'] = $allowed_atts;
$tags['h1'] = $allowed_atts;
$tags['h2'] = $allowed_atts;
$tags['h3'] = $allowed_atts;
$tags['h4'] = $allowed_atts;
$tags['h5'] = $allowed_atts;
$tags['h6'] = $allowed_atts;
$tags['ol'] = $allowed_atts;
$tags['ul'] = $allowed_atts;
$tags['li'] = $allowed_atts;
$tags['em'] = $allowed_atts;
$tags['hr'] = $allowed_atts;
$tags['br'] = $allowed_atts;
$tags['tr'] = $allowed_atts;
$tags['td'] = $allowed_atts;
$tags['p'] = $allowed_atts;
$tags['a'] = $allowed_atts;
$tags['b'] = $allowed_atts;
$tags['i'] = $allowed_atts;
}
return $tags;
}