Last active
November 27, 2019 04:26
-
-
Save Rocky-Mehta88/33e2ef6dba9a2a8b9d04f8a4791c6edf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Author: Rocky Mehta | |
* Link: https://rocky-mehta.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