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.

UPDATE (see comment section for more details)

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.

Leave a Reply

2 Comment threads
3 Thread replies
Most reacted comment
Hottest comment thread
3 Comment authors
TimoKaiJoachim Recent comment authors
newest oldest most voted
Notify of

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:


Danke für den Tipp.


FYI: Your code example is unfortunately deprecated. The new code will look like this: class myNotBlockedAdrotateWidget extends ajdg_bnnrwidgets { public function __construct() { $widget = new WP_Widget( false, 'My not blocked AdRotate widget', ['description' => 'Show unlimited ads in the sidebar.'] ); $this->id_base = $widget->id; $this->name = $widget->name; $this->option_name = $widget->option_name; $this->widget_options = $widget->widget_options; $this->control_options = $widget->control_options; } } function registermyNotBlockedAdrotateWidget() { register_widget("myNotBlockedAdrotateWidget"); } add_action('widgets_init', 'registermyNotBlockedAdrotateWidget');


Thanks for the update, Kai!


thanks for the update!