WordPress教程

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

阿里云

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

  1. add_action('admin_init','optionscheck_change_santiziation', 100);
  2. function optionscheck_change_santiziation() {
  3.     remove_filter( 'of_sanitize_textarea', 'of_sanitize_textarea' );
  4.     add_filter( 'of_sanitize_textarea', 'custom_sanitize_textarea' );
  5. }
  6. function custom_sanitize_textarea($input) {
  7.     global $allowedposttags;
  8.     $custom_allowedtags["embed"] = array(
  9.         "src" => array(),
  10.         "type" => array(),
  11.         "allowfullscreen" => array(),
  12.         "allowscriptaccess" => array(),
  13.         "height" => array(),
  14.         "width" => array()
  15.       );
  16.     $custom_allowedtags["script"] = array( "type" => array(),"src" => array() );
  17.     $custom_allowedtags = array_merge($custom_allowedtags, $allowedposttags);
  18.     $output = wp_kses( $input, $custom_allowedtags);
  19.     return $output;
  20. }
也想出现在这里?联系我们
创客主机

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

已有 286 人购买
查看演示升级 VIP立刻购买

收藏
(0)

发表回复

热销模板

Ashade - 作品展示摄影相册WordPress汉化主题
LensNews

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!