Skip to content

Instantly share code, notes, and snippets.

@adambradford
Created March 21, 2018 16:19
Show Gist options
  • Save adambradford/dc43c5d4ca050d2282c2de5e3dcdecb8 to your computer and use it in GitHub Desktop.
Save adambradford/dc43c5d4ca050d2282c2de5e3dcdecb8 to your computer and use it in GitHub Desktop.
Allow the standard WordPress text widget to execute PHP
<?php
//* Add this to your functions.php file. Do NOT include the opening php tag
//* Allow Standard WordPress Text widget to execute 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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment