Executing PHP code in a text widget

Sometimes you might have the need to execute PHP code in a text widget, for instance when linking to pages using bloginfo('url');

This function will enable the execution of PHP in text widgets:

function execute_php($html){
if(strpos($html,"<"."?php")!==false){ ob_start(); eval("?".">".$html);
return $html;

Code is courtesy of Emanuele Feronato

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>