[短代码]侧边栏运行PHP


为了方便快捷的调用php在首页任意位置,而不去更改源代码。在functions.php中添加。之后你就可以在小工具下的文本工具中写入php并且能够运行。

//实现侧边栏文本工具运行PHP代码
add_filter('widget_text', 'php_text', 99);
function php_text($text) {
if (strpos($text, '<' . '?') !== false) {
ob_start();
eval('?' . '>' . $text);
$text = ob_get_contents();
ob_end_clean();
}
return $text;
}

 

版权声明:
作者:月宅
链接:https://blog.moetwo.com/7245.html
来源:月宅酱的博客
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>