WordPress文本小工具怎样支持php代码

WordPress文本小工具可以添加任意的html及javascript代码,但是默认是不支持php代码的,如果要使你的Wordpress文本小工具支持php代码,可在当前主题的functions.php文件中加入以下代码:

add_filter('widget_text','execute_php',100);
function execute_php($html){
     if(strpos($html,"<"."?php")!==false){
          ob_start();
          eval("?".">".$html);
          $html=ob_get_contents();
          ob_end_clean();
     }
     return $html;
}

文章源自堕落的鱼-https://www.duoluodeyu.com/1890.html

添加后即可在文本小工具中添加并正常解析php代码函数。文章源自堕落的鱼-https://www.duoluodeyu.com/1890.html 文章源自堕落的鱼-https://www.duoluodeyu.com/1890.html

 
1Panel面板的删除方法 网站建设

1Panel面板的删除方法

1Panel 是一款现代化的 Linux 服务器运维管理面板,主打 轻量化、安全性和容器化管理,通过可视化界面帮助用户高效管理服务器环境。它基于 Docker 架构,支持应用一键部署、网站与数据库管理...
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证