PHP Execution in Ad Box

Posted in: Newspaper
Post count: 3

Hi, is it possible to enable php execution within the Ad Box Widget?

Our ads server uses php remote read to serve ad groups to the site and at present the php is being commented out “<!–”

Thank you in advance.

Post count: 22421

Hello,

Our ad boxed will not support php code unfortunately. Php code can only be executed from the theme files for the moment. IF you need this on the front-end, you can try a plugin that can provide such functionality. We have not tested any though so I cannot offer any recommendations.

Thank you!

Post count: 3

Thank you for your response.

We would not require the modification to be supported on a support level by yourselves but would appreciate your input, from a technical standpoint, in achieving this within the ad box.

In a similar way to enabling php in the standard wordpress 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;
}

Thank you in advance.

Post count: 15

I agree that offering some sort of PHP enabling would be beneficial. In our case, we’ve used several services like OPenX, SmartAdServer, DFP, etc. combined with PHP for ad targeting specific states, regions, categories, tags, page ID’s, etc. Newspaper’s ad system works great for certain kinds of ad setups but not for others.

Post count: 22421

Hello,

By default wordpress will not allow php code to be inserted from anywhewre and we have not made any implementation in this regard. We did not change the wordpress functionality. If you want to do that you can follow this guide: http://www.wpbeginner.com/plugins/how-to-allow-php-in-wordpress-posts-and-pages/
It still needs a plugin to run though.

Thank you!

Post count: 15

I found a solution for my specific case involving inline ads. I was able to move td_module_single_base.php to my child theme and modify the $tds_inline_ad_align section with my php variables. I trigger the “case” by putting a comment in the theme ad box. <!– Inline ad code in td_module_single_base –>

Viewing 6 posts - 1 through 6 (of 6 total)
The forum ‘Newspaper’ is closed to new topics and replies.