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

2015年10月26日12:46:46网站建设评论558

WordPress文本小工具可以添加任意的html及javascript代码,但是默认是不支持php代码的,如果要使你的Wordpress文本小工具支持php代码,可在当前主题的functions.php文件中加入以下代码:文章源自堕落的鱼-https://www.duoluodeyu.com/1890.html

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

常用正则表达式汇总 网站建设

常用正则表达式汇总

很多不太懂正则的朋友,在遇到需要用正则校验数据时,往往是在网上去找很久,结果找来的还是不很符合要求。所以我最近把开发中常用的一些正则表达式整理了一下,在这里分享一下。给自己留个底,也给朋友们做个参考。...
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定