Created
September 27, 2016 19:07
-
-
Save saroarhossain57/bed72ca24d4990d6dfe9bf445dd914f0 to your computer and use it in GitHub Desktop.
Enable shortcode and php code in widget
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
/* Enable Shortcode In Wordpress Widget Area */ | |
//Just Paste the code to functions.php file and use shortcode | |
add_filter('widget_text', 'do_shortcode'); | |
//Enable PHP code in Wordpress widget area | |
//just paste the code functions.php file and see the result | |
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment