Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

PHP Widget

Allow PHP In WordPress Widget Area Without Plugin. Gotten from http://www.downgraf.com/code-snippets/how-to-allow-php-in-wordpress-widget-area-without-plugin/.

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;
}