Don't allow JavaScript in the content area

Is there any way to disable or remove JavaScript in the pagepost content area?So if there was any <script> tags i

Is there any way to disable or remove JavaScript in the page/post content area?

So if there was any <script> tags it would remove them or ignore them when outputting the_content();

Is there any way to disable or remove JavaScript in the page/post content area?

So if there was any <script> tags it would remove them or ignore them when outputting the_content();

Share Improve this question asked Nov 10, 2017 at 13:46 DesignMonkeyJimDesignMonkeyJim 3493 silver badges9 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

You could use the_content filter:

add_filter( 'the_content', 'remove_script_tag' );

function remove_script_tag( $content )
{
    return strip_tags( $content, '<script>' );
}

When you also want the content of the tag to be removed you could use this one:

add_filter( 'the_content', 'remove_script_tag_and_content' );

function remove_script_tag_and_content( $content )
{
    $striped_text =  preg_replace('@<script>.*?<\/script>@si', '', $content);
    return $striped_text;
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745169406a4614832.html

相关推荐

  • Don&#39;t allow JavaScript in the content area

    Is there any way to disable or remove JavaScript in the pagepost content area?So if there was any <script> tags i

    6小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信