RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.20% (5.24%*) • Home Loan Fixed: 5.48% (6.24%*) • Fixed: 5.48% (6.24%*) • Variable: 5.20% (5.24%*) • Investment IO: 5.78% (6.81%*) • Investment PI: 5.49% (6.32%*)

Execute PHP in WordPress Widgets

While it's a rather horrible idea, this code will permit you to execute PHP code in WordPress widgets. There's never a need to use it; use shortcodes instead. However, it may come in handy at some point.

1
<?php 
2
/*
3
 Execute PHP in WordPress Widgets
4
 http://www.beliefmedia.com/code/wp-snippets/execute-php-wordpress-widgets
5
*/
6
 
7
function beliefmedia_execute_php_widgets($html) {
8
  if (strpos($html, '<' . '?php') !==false) {
9
    ob_start();
10
    eval('?' . '>' . $html);
11
    $html = ob_get_contents();
12
    ob_end_clean();
13
  }
14
 
15
 return $html;
16
}
17
add_filter('widget_text', 'beliefmedia_execute_php_widgets', 100);

Again, use shortcodes and enable the widget_text filter as follows:

1
add_filter('widget_text', 'do_shortcode');

Download our 650-page guide on Finance Marketing. We'll show you exactly how we generate Billions in volume for our clients.

  E. Australia Standard Time [ UTC+10, Default ] [ CHECK TO CHANGE ]

  Want to have a chat?
 

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

Leave a comment