Thank you for this! It seems that by default, HTML in WordPress comments causes strange things. I just want people’s comments to be saved as is, regardless of what they type. Why isn’t the following a default function of WordPress?
function encode_code_in_comment($source) { return esc_html($source); } add_filter('pre_comment_content', 'encode_code_in_comment');