Skip to content

Instantly share code, notes, and snippets.

@csbeck
Created November 20, 2013 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csbeck/7570548 to your computer and use it in GitHub Desktop.
Save csbeck/7570548 to your computer and use it in GitHub Desktop.
PHP code in WordPress widgets. Include this in the functions.php file.
// Add PHP functionality 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