Advertisement
shakil97bd

Enable PHP code in your theme widget

Feb 25th, 2015
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.55 KB | None | 0 0
  1. *********************************** Enable PHP code in your theme widget ***********************************************
  2.  
  3. //Just paste this code in your theme's function.php file to enable php code in widget
  4.  
  5.  
  6. add_filter('widget_text', 'enable_php_code', 99);
  7.  
  8. function enable_php_code ($text) {
  9. if (strpos($text, '<' . '?') !== false) {
  10. ob_start();
  11. eval('?' . '>' . $text);
  12. $text = ob_get_contents();
  13. ob_end_clean();
  14. }
  15. return $text;
  16. }
  17.  
  18.  
  19.  
  20. ************************************** THANK YOU *****************************************************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement