在WordPress 4.3之后,禁用wpautop的旧方法不再有效。是否有人发现了删除此函数的新方法?
remove_filter( \'the_content\', \'wpautop\', 99 );
remove_filter( \'the_excerpt\', \'wpautop\', 99 );
在WordPress 4.3之后,禁用wpautop的旧方法不再有效。是否有人发现了删除此函数的新方法?
remove_filter( \'the_content\', \'wpautop\', 99 );
remove_filter( \'the_excerpt\', \'wpautop\', 99 );
我想你根本不用它,那你为什么不把过滤器取下来呢?
remove_filter(\'the_content\', \'wpautop\');
remove_filter(\'the_excerpt\', \'wpautop\');
我在几分钟前(在WP 4.3上)对其进行了测试,效果良好。p、 我刚刚看到您使用了相同的函数。对此表示抱歉。您使用的是什么版本?这将禁用4.3上的wpautop。
在javascript方面,作为一种粗略的衡量标准,您可以替换wp.editor.autop
和wp.editor.removep
无操作:
add_action( \'admin_print_footer_scripts\', function () {
?>
<script type="text/javascript">
jQuery(function ($) {
if (typeof wp === \'object\' && typeof wp.editor === \'object\') {
wp.editor.autop = function (text) { return text; };
wp.editor.removep = function (text) { return text; };
}
});
</script>
<?php
}, 100 );
然而,在非常有限的测试中,虽然它似乎保留了标记,但它确实将所有标记放在了文本编辑器的一行上,这非常难看。。。这很有效。这是关于钩子的优先级:
add_filter( \'the_content\', \'njengah_remove_autop\', 0 );
function njengah_remove_autop($content) {
// remove autop
remove_filter( \'the_content\', \'wpautop\' );
return $content;
}