How to execute PHP code in Text Widget without using Plugin. Sometimes we need to execute PHP scripts in text widget but by default WordPress doesn’t comes with this feature because of security issues.
<?php
function php_execute($html){
if(strpos($html,"<"."?php")!==false){
ob_start(); eval("?".">".$html);
$html=ob_get_contents();
ob_end_clean();
}
return $html;
}
add_filter('widget_text','php_execute',100);
?>