PHP in HTML Module

Hello, I would love to have PHP functionality inside the HTML module, I can get the Text widget to process PHP by adding a simple code to the functions file :

// Add PHP funtionality to Text 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;
}

How can I get the HTML module to process PHP?

Hey Carlos,

Sorry to say but this not currently possible with BB though there are plugins that let you process PHP in the text editor by wrapping them in a shortcode like this one but this is a security risk and we don’t recommend it. We would advise to make your own shortcode and use that in the text module instead.

https://codex.wordpress.org/Shortcode_API

Jun

I’m using this plugin to get PHP functionality in the HTML module so I can display Advanced Custom Fields in a BB Template. It’s still maintained and works well. https://wordpress.org/plugins/php-code-for-posts/

I understand there are potential security risks, though I’m not sure how it applies to displaying an ACF field as opposed to executing a function.

Doug

Thanks for jumping in, Doug. We appreciate it!

Jun