Run PHP Code In Text Widget Do Not Use In WordPress Plugin
In wordpress text widget works is HTML only, I’m a coder, very useful text widget is a widget I use the most, it helps me make the site functions without using the plugin, but to queryto the database or the code loop or what conditions that the widget must run php code. It is a very important part in wordpress, to get a wordpress theme pretty light, correct and is not intended plugin.
At first I used to use this plugin to work, but that the less I use the plugin for my wordpress theme because it has so many shortcomings:
– It’s heavy and too much more than what I need.
– The more plugins means more risk gap to enter your site.
– No professional and left little impression Pro tell clients if you are using the plugin.
– Lines can be hidden, do not know how to do it. Most customers do not know the code, but they know the plugin.
not say, at the finances well, you copy the following code to paste into your functions.php file offline
add_filter('widget_text', 'enable_php_code', 99);
function enable_php_code ($text) {
if (strpos($text, '<' . '?') !== false) { ob_start(); eval('?' . '>' . $text);
$text = ob_get_contents();
ob_end_clean();
}
return $text;
}
Then, finish …
Too easy. You add a widget to the PHP code into a try, see if this works?
If you want to use the plugin, click here
Problem does not clear all of your comments below. The widget must mark “” okay.