Skip to content

Instantly share code, notes, and snippets.

@Rocky-Mehta88
Last active November 27, 2019 04:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rocky-Mehta88/33e2ef6dba9a2a8b9d04f8a4791c6edf to your computer and use it in GitHub Desktop.
Save Rocky-Mehta88/33e2ef6dba9a2a8b9d04f8a4791c6edf to your computer and use it in GitHub Desktop.
<?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