Skip to content

Instantly share code, notes, and snippets.

@nutsandbolts
Created November 7, 2013 10:55
Show Gist options
  • Save nutsandbolts/7352783 to your computer and use it in GitHub Desktop.
Save nutsandbolts/7352783 to your computer and use it in GitHub Desktop.
Enable PHP in WordPress widgets without a plugin
// Enable PHP in widgets
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment