Hello! 欢迎来到盒子萌!

WordPress主题框架options-framework取消过滤不能使用script代码


最近在折腾主题,才发现主题框架options-framework 不能放 script JS代码。幸好本站和百度谷歌在不久之前达成战略合作伙伴,在谷歌上找了官方提供的解决方案,后面可以Ctrl+C

add_action('admin_init','optionscheck_change_santiziation', 100);
function optionscheck_change_santiziation() {
    remove_filter( 'of_sanitize_textarea', 'of_sanitize_textarea' );
    add_filter( 'of_sanitize_textarea', 'custom_sanitize_textarea' );
}
function custom_sanitize_textarea($input) {
    global $allowedposttags;
    $custom_allowedtags["embed"] = array(
        "src" => array(),
        "type" => array(),
        "allowfullscreen" => array(),
        "allowscriptaccess" => array(),
        "height" => array(),
        "width" => array()
      );
    $custom_allowedtags["script"] = array( "type" => array(),"src" => array() );
    $custom_allowedtags = array_merge($custom_allowedtags, $allowedposttags);
    $output = wp_kses( $input, $custom_allowedtags);
    return $output;
}

暂无评论

发表评论

相关阅读