最近在折腾主题,才发现主题框架 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;
}
专业提供WordPress主题安装、深度汉化、加速优化等各类网站建设服务,详询在线客服!