Snippets → WordPress
Allow PHP in WordPress text widgets
Paste the code in your functions.php file.
function php_text($text) {
if (strpos($text, '<' . '?') !== false) {
ob_start();
eval('?' . '>' . $text);
$text = ob_get_contents();
ob_end_clean();
}
return $text;
}
add_filter('widget_text', 'php_text', 99);
Source: http://www.binaryturf.com/php-text-widget-php-wordpress-text...
Nice snippet. Made a post myself about it on my tutorial blog.
Great to be able to use php in my text widgets!