WordPress强制阻止代码转义功能

function git_esc_html($content) {
    $regex = '/(<pres+[^>]*?classs*?=s*?[",'].*?prettyprint.*?[",'].*?>)(.*?)(</pre>)/sim';
    return preg_replace_callback($regex, 'git_esc_callback', $content);
}
function git_esc_callback($matches) {
    $tag_open = $matches[1];
    $content = $matches[2];
    $tag_close = $matches[3];
    $content = esc_html($content);
    return $tag_open . $content . $tag_close;
}
add_filter('the_content', 'git_esc_html', 2);
add_filter('comment_text', 'git_esc_html', 2);

评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注