Skip to content

Instantly share code, notes, and snippets.

@jrobinsonc
Created August 31, 2015 23:24
Show Gist options
  • Save jrobinsonc/0b2f8aed9b97314d2b5f to your computer and use it in GitHub Desktop.
Save jrobinsonc/0b2f8aed9b97314d2b5f to your computer and use it in GitHub Desktop.
Wordpress filter: Execute PHP from widgets.
<?php
/**
* Execute PHP from widgets.
*/
add_filter('widget_text', function ($html){
if(strpos($html, "<"."?php") !== false)
{
ob_start();
eval("?".">".$html);
$html = ob_get_contents();
ob_end_clean();
}
return $html;
}, 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment