PHP 禁用使用短代码自动格式化
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP 禁用使用短代码自动格式化相关的知识,希望对你有一定的参考价值。
function my_formatter($content) {   ÂÂ
$new_content = '';   ÂÂ
$pattern_full = '{(\[raw\].*?\[/raw\])}is';   ÂÂ
$pattern_contents = '{\[raw\](.*?)\[/raw\]}is';   ÂÂ
$pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);   ÂÂ
foreach ($pieces as $piece) {       ÂÂ
if (preg_match($pattern_contents, $piece, $matches)) {           ÂÂ
$new_content .= $matches[1];       ÂÂ
} else {           ÂÂ
$new_content .= wptexturize(wpautop($piece));       ÂÂ
}   ÂÂ
}   ÂÂ
return $new_content;
}
remove_filter('the_content', 'wpautop');
remove_filter('the_content', 'wptexturize');
add_filter('the_content', 'my_formatter', 99);
以上是关于PHP 禁用使用短代码自动格式化的主要内容,如果未能解决你的问题,请参考以下文章