Creating an Anti AdBlock Plugin for WordPress



Originally published at:

In this tutorial, we will create a WordPress plugin that can disable the website for users using AdBlock or display alternative ads to AdBlock users from the same domain as the website.

This plugin can be useful if your website is completely dependent on ads for generating revenue and where users consume a high amount of resources. For example, a video sharing site may want to ban a site from playing videos or display alternative ads for AdBlock installed users. One such example is, as shown above. You can see requests you to unblock ads for their site.

How Does AdBlock Work?

AdBlock maintains a list of various advertising network domain names and a list of advertising specific keywords.

AdBlock works by blocking image, iframe, script and Flash HTTP requests that match known advertiser domain or advertiser specific keywords that are on their list. After the requests are blocked, it also changes the CSS properties of the blocked HTHML elements to hide them.

AdBlock allows you to expand on what can be blocked by adding filters.

Continue reading this article on SitePoint


While I will empathise with webmasters/coders who rely on ads to generate the revenue necessary to keep a site afloat, the inarguable fact is that most of the ads being used, today, are bandwidth choking, or have something about them that makes it really difficult/slow to load the desired content.

You post a way to flout AdBlock. Someone will improve AdBlock to thwart that. Someone else will devise a way to cripple that. And so on.. and so on.. and so on..

Instead of propagating a war that will never be won by either side, how about implementing ads that are NOT intrusive, or don't impede the process of delivering the content that the user originally WANTS to view?

I especially hate ads that use video, and even more if the video plays automatically upon page load. The same purpose can be achieved with a simple, non-animated banner ad across the top of the page. But marketing gurus don't like that because it's not "in your face" enough.

Which is why third-party plugins like AdBlock were created, in the first place. I use AdBlock on my browsers, at home, and love it. What you are promoting will serve only to alienate much of the target demographic, and cause many users to avoid a website/page until another "solution" to block your solution is presented.




I just went to to see for myself

NO advertisements - and -
NO disabled site

Why? My guess is as WolfShade mentioned, that the advertisements are bandwidth heavy flash

So sites will need anti flash block as well?

I don't need to visit any site that insists upon abusing me.


@WolfShade @Mittineague

I agree that users don't like ads that are not related to the website topic and making the website load slower.

This issues only happens for poorly designed sites. But good sites sites like youtube do have flash ads but they have an option to skip it too.

Well designed sites like do have a lot of ads but they are relevent and are loaded asynchronously. The ads images and links changes on every visit but other things are cached. So it doesn't cause any big concern about bandwidth.

This plugin is not just to fight back adblock rather you can use it to request user to whitelist your site. And thats what I have shown in the demo.

Hope this makes sense. Thanks.


When going to YouTube using IE, I've NEVER seen an option for skipping the ad. When that happens, I close IE and open the same page in FF, and AdBlock skips the ad.

SitePoint has ads? I'm using my work computer (FF without AdBlock) and the only things that I see that can be considered "ads" are some of the articles that are then posted to the forums that will reference a specific SP book. Of course, 99.99% of the time I spend on SP is in the forums.

I'll admit that I didn't click the link to read your whole article. I stopped at the end of your original post. However, the picture that you included in your original post doesn't seem to display a link allowing the user to skip the ad; rather just a link for a "how to" on whitelisting the domain. I'll check the article more thoroughly.




I get it like once every 4 ads. It's annoying since it used to be more frequent.

Seems unless the ad is a few minutes long, I'm stuck.


I recently (last 3-4months) uninstalled AdBlock from all my browsers and I'm actually thinking about turning it back on JUST for YouTube because of this. The amount of ads with a skip button get less and less. It used to be every ad was skippable, then it was like 1 in 5, now it's about 50/50 and seems to be shrinking and the unskippable ads seem to be getting longer.

I'm actually one of the weird ones, I like page ads. Especially targeted ones. It's not a bad way to catch good deals on stuff, plus the site owner who displayed it gets a cut.


Found this extension; seems to work (several videos have given me no ads)


@RyanReese @WolfShade @mawburn

Regarding the youtube IE problem, I think you should report it to youtube not here.

But anyways everyone has a way of looking at the ads. For me ads are a source of information. Because of ads I come to know about various books, development tools, apis, web services, nearby conferences, discounts and many other things.

If you are using adblock then I would recommend you to whitelist those sites which you visit on regular basis and are helpful.


I keep everything whitelisted by default. It isn't until a website deserves it, that I will blacklist it.

I too find ads to be useful and often times I find neat stuff.


Good article mate, interesting read. I'm sure adblock wil advance itself to eventually counter this but its good to look at methods that bypass adblock (though since adblock looks to block all cross domain elements I assume having fallbacks to offsite adds will be blocked too)


Just read this post on Sophos' security blog, citing a report from PageFair:
"Not all ads are equally annoying: the study found that the majority of adblocker users are willing to view non-intrusive ad formats.

"In fact, if ads could manage to keep themselves from cartwheels, barking or blocking the content users are trying to view, instead choosing to quietly and unobtrusively advertise with text or image ads, 67% of adblock users said they'd be OK with it, PageFair found."

closed #14

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.