Last active
May 7, 2016 08:46
-
-
Save SiGaCode/27f8cc7f38fd27c21867c2c26fc511fc to your computer and use it in GitHub Desktop.
Use Shortcodes and PHP in Widgets Without a Plugin
By Carrie Dils: http://www.carriedils.com/extend-wordpress-widgets-without-plugin/
This file contains hidden or 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 shortcodes in widgets | |
| add_filter('widget_text', 'do_shortcode'); | |
| // Enable PHP in widgets | |
| // WARNING: Potential security vulnerability you open by enabling code execution from a widget! | |
| 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