Using WordPress Plugin AdRotate with AdBlock Plus

Lately I have tested the plugin AdRotate for one of our projects. The ratings are good, it gets updated frequently and there is even a pro version, what I like because I can take the developer(s) seriously.

But one thing freaked me out: After setting up everything, I could not see any output from the plugin’s sidebar widget. After a while I got it: The browser extension AdBlock Plus blocked the output of AdRotate in all of my test browsers (FF, Chrome, Safari, IE). Well, I had admit that’s no surprise. It does what an ad blocker should do: block ads, that’s fine. But in my case it is not really advertising, but rather an event note which I want the visitors to see.
If you think your AdRotate ads should not get blocked by ad blocker extensions, here is a little trick to achieve this. So far, it only works if you do not use AdRotate’s click tracker.

The problem with the shipped widget (in adrotate/adrotate-widget.php) is its classname “adrotate_widgets”. It is used as CSS classname by WordPress. AdBlock Plus is aware of that and hides all contents within something like <div id=”adrotate_widgets-4″ class=”widget widget_adrotate_widgets”>…</div>. What we need to do is to change the name and get rid of the containing “adrotate”.

The best way to change the behaviour of a plugin is always to not hack the original code. This keeps us safe for future updates. For this time the easiest way is to create our own widget class and extend it from the shipped adrotate_widgets. The functions.php file of your theme would be the easiest place to do so. First include the plugin’s file which includes the class we want to extend:

Than create your own class and add it to the widgets_init action. Remember that the classname will be used as CSS id, so change “My_Nicename_Rotator” to whatever you like. If you are using PHP5 (i hope), than call the method __construct. If not remember to call it the same as your class name. You also may change the string “My not blocked AdRotate widget” which appears as widget title on your WordPress widget admin page.

That’s it. If you now use your self-created widget and do not use click tracking (as mentioned above), your ads will appear in your sidebar although AdBlock Plus is active.

So far I like AdRotate. I will use it for some projects and purchase the Pro version maybe.

2 Responses to “Using WordPress Plugin AdRotate with AdBlock Plus”

  1. Joachim January 2, 2017 at 15:35 #

    Nutzt du Ad Rotate noch in der Pro-Version? Ich würde dir auf jeden Fall mal empfehlen, Advanced Ads auszuprobieren. Das kann in der kostenlosen Version wesentlich mehr als Ad Rotate und mit Pro bzw. diversen Add-ons lässt sich dieses Plugin mächtig aufbohren: https://wordpress.org/plugins/advanced-ads

    • Timo January 3, 2017 at 20:40 #

      Danke für den Tipp.

Leave a Reply

16 + 13 =