options-framework框架官方版由于安全机制,会自动过滤掉js,object等代码,所以主题设置中是不能添加js类统计和相关js代码的,这样操作会被认定不安全,默认过滤。所以我们要取消这一限制
做法如下:
将以下代码添加到inc/options-framework.php文件最下边
- //允许脚本和嵌入标签,设置中可以加入js统计代码
- 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;
- }
- 我的微信
- 有问题可随时与我联系
-
- 微信小程序
- 随时随地查看文章
-