我无法阻止wpautop弄乱我的插件输出

时间:2013-02-16 作者:John Carter

我有一个插件,它嵌入了一些javascript。我已经尝试使用remove\\u filter()以各种建议的方式停止wpautop,但仍然无法让wordpress停止包装我的<script></script> 带有的标记<p> 像这样的标签<p><script></script></p>

我尝试将以下内容添加到短代码php和函数中。php

remove_filter( \'the_content\', \'wpautop\' );
remove_filter( \'the_excerpt\',     \'wpautop\' );

1 个回复
SO网友:birgire

Here is one idea

add_filter(\'the_content\',\'remove_stuff\',99,1);

function remove_stuff($content){
    $from=array("<p><script>","</script></p>");
    $to=array("<script>","</script>");
    $content=str_replace($from,$to,$content);
    return $content;
}
结束

相关推荐