Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
<?php
/**
* Author: Rocky Mehta
* Link: https://onlineblogwebsite.com/
* Email: rocky.mehta88@gmail.com
*/
/* Enable PHP Code in the WordPress widget */
add_filter('widget_text', 'enable_php_code_function', 99);
function enable_php_code_function ($text) {
if (strpos($text, '<' . '?') !== false) {
ob_start();
eval('?' . '>' . $text);
$text = ob_get_contents();
ob_end_clean();
}
return $text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment