Title: Tips on how to parse PHP code in Ad Blocking Widget?
Last modified: August 30, 2016

---

# Tips on how to parse PHP code in Ad Blocking Widget?

 *  Resolved [johnh10](https://wordpress.org/support/users/johnh10/)
 * (@johnh10)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/tips-on-how-to-parse-php-code-in-ad-blocking-widget/)
 * I’m currently using Otto’s [PHP Code Widget](https://wordpress.org/plugins/php-code-widget/)
   to display a random ad via some PHP code.
 * I’d like to use the Ad Blocking Widget to parse the PHP code if no Ad Blocker,
   and show text if there is.
 * Any tips or ideas on how to make this happen?
 * [https://wordpress.org/plugins/ad-blocking-detector/](https://wordpress.org/plugins/ad-blocking-detector/)

Viewing 1 replies (of 1 total)

 *  [John Morris](https://wordpress.org/support/users/jtmorris/)
 * (@jtmorris)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/tips-on-how-to-parse-php-code-in-ad-blocking-widget/#post-6305298)
 * I can’t think of an elegant way to make this work with the PHP Code Widget plugin.
   You could recreate what you’re looking for using Ad Blocking Detector’s [CSS](http://adblockingdetector.jtmorris.net/combine-css-ad-blocking-detector/)
   and [JavaScript](http://adblockingdetector.jtmorris.net/unleash-your-inner-geek-with-javascript/)
   targeting tools. You’d need to output a wrapper around the random advertisement
   in your PHP widget, then separately output the text with another wrapper, then
   add in CSS or JavaScript to selectively hide or display the appropriate content.
 * However, if you’re willing to use a different PHP plugin, this is very easy to
   do without all those wrappers and JavaScript/CSS. Basically, you need a plugin
   that generates a shortcode with PHP in it rather than a widget. Ad Blocking Detector
   parses shortcodes put into its fields. So, something like [Shortcode Exec PHP](https://wordpress.org/plugins/shortcode-exec-php/)
   will work beautifully (I just tested it to verify).
 * You create a PHP shortcode in that plugin, or one of the others in the plugin
   repository, then feed that shortcode into the No Ad Blocker field of Ad Blocking
   Detector, and your text in the Ad Blocker field. Then, use Ad Blocking Detector’s
   sidebar widget to display the Ad Blocking Detector shortcode you create.
 * Hope this helped!

Viewing 1 replies (of 1 total)

The topic ‘Tips on how to parse PHP code in Ad Blocking Widget?’ is closed to new
replies.

 * ![](https://s.w.org/plugins/geopattern-icon/ad-blocking-detector_466992.svg)
 * [Ad Blocking Detector](https://wordpress.org/plugins/ad-blocking-detector/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ad-blocking-detector/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ad-blocking-detector/)
 * [Active Topics](https://wordpress.org/support/plugin/ad-blocking-detector/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ad-blocking-detector/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ad-blocking-detector/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [John Morris](https://wordpress.org/support/users/jtmorris/)
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/tips-on-how-to-parse-php-code-in-ad-blocking-widget/#post-6305298)
 * Status: resolved