Detecting Adblock on your WordPress site

Detecting Adblock on your WordPress site

Detecting Adblock on your WordPress site

Loved by some, hated by others, Ad blockers have become an important factor to consider when owning or developing a website. In this article, I’m demonstrating a few techniques which can be used in order to detect Ad blockers on a website or most specifically, a WordPress blog.


Should you do something against people visiting your site with an ad blocker on? That’s the question many site owners are asking themselves since a few years.

Since the web exists, advertising has been a way for webmasters and site owners to make money. As ads brought lots of money, many people abused the model, displaying video ads, ads blocking contents, popups, etc. Even today, visiting a download site or just watching YouTube videos without an ad blocker is a complete pain. Approximately ten years ago, some people bothered by advertising abuse started to fight back. Ad blockers were born.

Some websites decide to do nothing against ad blockers. People who are using ad blockers aren’t likely to click on ads anyways, so it kinda makes sense. Other websites choose a diplomatic approach, asking their readers to whitelist their site, or make a small donation. And finally, some site owners choose to fight back against what they consider a threat to their revenue, by disabling features to readers who are using an ad blocker.

This article aims to demonstrate a few techniques which can be used to detect ad blockers or hide content from visitors with an ad blocker on. The way you use it on your website is up to you.

Basic JavaScript Adblock detection

The first thing to do is to create a file named adframe.js. This file is using the blacklisted name “adframe” so we’re gonna fool Adblock and make it block the file, mistaking it for a genuine ad. In the file, simply put the following line:

adblock = false;

Now, put the following withing the <head> and </head> tags of your HTML document.
On a WordPress Theme, the head section is displayed in header.php.

<script type="text/javascript">
    var adblock = true;
<script type="text/javascript" src="adframe.js"></script>
<script type="text/javascript">
    if(adblock) {
          //adblock is installed

Hiding content from users with ad blockers on

Hiding content from users with an adblocker is definitely easy. The only thing you have to do is to pick up one class blocked by Adblock, and add it to the container of your choice.

In the example below I’ve used the class .bsarocks which is added by BuySellAds around their ad banners:

<div class="bsarocks">This won't be seen by Adblock users.</div>

WordPress plugin

While the code snippets shown above can definitely be useful, if you’re using WordPress, I definitely recommend using a plugin if you’re looking to detect/block Adblock. The main reason for favoring a plugin over a code snippet is that a plugin can be updated by its author as soon as there’s a change in the way Adblock works.

There’s a few plugins out here that specialize in Adblock (and other ad blockers) detection. The most interesting in my opinion is Ad Blocking Detector. Check out the demo on the plugin website. It detects ad blockers pretty well.


Ad Blocking Detector gives you the availability to create shortcodes to display alternative content if an ad is blocked by an ad blocker. This is especially interesting if you want to encourage your readers to disable their adblocker on your website in order to support it.

The plugin should be installed through the basic plugin installation procedure, ie. “Plugins” → “Add New” in your WordPress dashboard.

Detecting visitors with JavaScript off

Some users also choose to disable JavaScript by default, to prevent many things such as popups being open, etc. Just in case you don’t know, there’s a HTML tag call noscript which allows you to display a message to users with JavaScript off:

 For full functionality of this site please enable JavaScript.

Which approach should you adopt?

Well, it’s up to you. I personally think that things aren’t all black or all white. Sure thing, ads are an important source of income for web publishers and many websites wouldn’t exist without them. On the other hand, some ads are so annoying that people who use an ad blocker can definitely be understood.

The only sure thing is that, as a website owner, you shouldn’t display “aggressive” ads to your visitors. Pop unders, video or flash ads, etc, in my opinion those should be totally banished from a serious and professional website. On the other hand, I have no problem with related banners ads, as such as the ones you can purchase on

Using SQL to manage WordPress: The definitive guide

Using SQL to manage WordPress: The definitive guide

Using SQL to manage WordPress: The definitive guide

WordPress stores a lot of things in the database. Using SQL queries, you can easily perform tasks that would take a lot of time and hassle otherwise. In this article, I have compiled a guide as well as 15+ ready to use SQL queries for managing comments and users, batch editing your posts, cleaning up your database, and many more.


Once you’ve entered PhpMyAdmin, you first have to select your blog database, then click on SQL tab to display the page which allows you to run any kind of queries.

Another option is to use a plugin named SQL Executioner. As the name says, the aim of this plugin is to allow you to run SQL queries on your WordPress database from within the Dashboard.

Important things to note:

  • Always have a fresh backup of your database when applying those SQL queries. You can do so manually or use a WordPress plugin such as WP-DBManager.
  • This article uses default table prefix wp_. Make sure you change the prefixes to match the ones used by your database.

Delete all comments with a specific url

Spam is definitely a problem ith WordPress blogs, happily SQL is here to help.

DELETE from wp_comments WHERE comment_author_url LIKE "%spamurl%" ;

Source: WPRecipes

Delete all trackbacks

Most people, including me, think that trackbacks are useless. Clean up your blog database with that nifty query.

DELETE FROM wp_comments WHERE comment_type="trackback";

Source: Forums

Close trackbacks on all posts at once

Even better than deleting them, you can close all trackbacks at once with this query.

UPDATE wp_posts SET ping_status = 'closed';

Source: Dig WP

Bulk delete all unapproved comments

Too lazy to check all of your unapproved comments? This is the super fast way to delete them all at once.

DELETE from wp_comments WHERE comment_approved = '0';

Source: Forums

Bulk delete all comments marked as spam

Got 5400 spam comments and don’t want to go through dozen of pages to delete them? This query is for you.

DELETE FROM wp_comments WHERE wp_comments.comment_approved = 'spam';

Source: Dig WP

Delete all post revisions and associated data

Make your database lighter by removing post revisions and all associated data. A query I run on my blogs every 3-6 months.

DELETE a,b,c FROM wp_posts a LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id) WHERE a.post_type = 'revision';

Source: Solidly Stated

Remove unused shortcodes in post content

Shortcodes are really cool, but at some point you need to be able to remove the unused ones. Rather than editing each of your posts, run this simple query! Replace [tweet] by the unused shortcode to remove.

UPDATE wp_post SET post_content = replace(post_content, '[tweet]', '' ) ;

Source: WPRecipes

Replace a word by another in post content

This can be very useful to update a link, for example.

UPDATE wp_post SET post_content = replace(post_content, 'old_word', 'new_word' ) ;

Add a custom field to all posts

If you’re always using a specific custom field, you better add it on all posts at once rather than editing X amount of your posts. Here you go!

INSERT INTO wp_postmeta (post_id, meta_key, meta_value)
SELECT ID AS post_id, 'MyCustomField'
AS meta_key 'myvalue AS meta_value
(SELECT post_id FROM wp_postmeta WHERE meta_key = 'MyCustomField')
`` AND post_type = 'post';

Source: The Customize Windows

Delete very old posts

Are all your posts very outdated? Here’s an easy way to remove them. For optimal results, you should definitely use 301 redirections to redirect deleted posts to your homepage or updated versions of those posts.

DELETE FROM wp_posts WHERE post_date < '2010-01-01 00:00:00' AND post_status = 'publish'


Get a list of all commentators’ emails

Not really that you should use email of your commentators for anything (except with their consent) but here’s the way to get a list of all emails stored in the wp_comments table. Note the use of DISTINCT to make sure the query won’t return any duplicates.

SELECT DISTINCT comment_author_email FROM wp_comments;

Source: Dig WP

Assign posts to a new author

If for some reason you want to transfer posts from an author to another, this query is yours. You need to update this query with both the old author and new author IDs before running it.

UPDATE wp_posts SET post_author = 'new-author-id' WHERE post_author = 'old-author-id';

Source: WPRecipes

Update user password

Quick way to update any password. Don’t forget to replace username by the user name of the user you’d like to update the password.

UPDATE wp_users SET user_pass = MD5( 'new_password' ) WHERE user_login = 'username';

Source: WordPress Support

Batch disable all plugins

In case something goes wrong with your blog, it can be a good idea to deactivate all your plugins, in case one of those was the source of the problem. Here’s how you can batch disable them using a SQL query.

UPDATE wp_options SET option_value = '' WHERE option_name = 'active_plugins';

Source: WPRecipes

Downsize your database by removing transients

Transients are a simple and standardized way of temporarily storing cached data in the database by giving it a custom name and a timeframe after which it will expire and be deleted. But sometimes, transients set by WP and countless plugins can take a lot of space in your database. Good news, transients can be safely removed with this simple query.

DELETE FROM `wp_options` WHERE `option_name` LIKE ('%\_transient\_%');

Source: Stack Overflow

Get rid of unused tags

As your database is probably filled with lots of tags you don’t use anymore, you should consider cleaning it with the following:

DELETE FROM wp_terms wt
INNER JOIN wp_term_taxonomy wtt ON wt.term_id = wtt.term_id WHERE wtt.taxonomy = 'post_tag' AND wtt.count = 0;

Source: WPMU Dev

Change all your urls/domain names

WordPress stores absolute urls within the database. Which means that if you change your blog domain name, you’ll have to update every absolute url. Using SQL, this is extremelly simple to do. Just edit the three queries below and update the old and new domain names, then run it. Done!

UPDATE wp_options SET option_value = replace(option_value, '', '') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, '','');
UPDATE wp_posts SET post_content = replace(post_content, '', '');

Source: Smashing Magazine

WordPress: Super useful WP-config tips

WordPress: Super useful WP-config tips

WordPress: Super useful WP-config tips

The wp-config.php file is the heart of your WordPress website, where you can define a wide variety of options to control how your WordPress install works. Today, I’m sharing with you a list of super easy tips to take more control of your site using wp-config.php.

Keeping your database and site size small

On large websites, keeping your database small in size can be a challenge. WordPress tends to store a lot of data in your db, like transients or post revisions.

You can easily limit post revisions to a number of your choice (3 in this example) by adding the following in your wp-config.php file:

define('WP_POST_REVISIONS', 3);

If you don’t feel like using the post revision feature at all, you can simply disable it:

define( 'WP_POST_REVISIONS', false );

Also, WordPress stores in the database posts, pages, attachments and comments which have been moved to trash. You can control the number of days it will stay in the trash before being completely deleted. The default is set to 30, but I’ve set it to 1 in this example.

define( 'EMPTY_TRASH_DAYS', 1 );

By default, WordPress creates a new set of images every time you edit an image and when you restore the original, it leaves all the edits on the server. Defining IMAGE_EDIT_OVERWRITE as true changes this behavior.

define( 'IMAGE_EDIT_OVERWRITE', true );


If your web hosting plan supports SSL, you should definitely use that feature to add an extra layer of security to your site. Via wp-config.php, WordPress makes it easy to force SSL logins:

define('FORCE_SSL_LOGIN', true);

And same goes with the admin area of your site:

define('FORCE_SSL_ADMIN', true);

Secret keys are making your site harder to hack by adding random elements to the password. There are currently 4 secret keys and 4 salts that can be defined. To generate unique and secure secret keys, just use this handy generator. Don’t use those below!

define( 'AUTH_KEY',         't`DK%X:oxy|e-Z(BXb/f(Ur`8#~UzUQG-^_Cs_GHs5U-&Wb?pgn^p8(2@}IcnCa|' );
define( 'SECURE_AUTH_KEY',  'D&ovlU#|CvJ##uNq}bel+^MFtT&.b9{UvR]g%ixsXhGlRJ7q!h}XWdEC[BOKXssj' );
define( 'LOGGED_IN_KEY',    'MGKi8Br(&{H*~&0s;{k0tS(O:+f#WM+q|npJ-+P;RDKT:~jrmgj#/-,[hOBk!ry^' );
define( 'NONCE_KEY',        'FIsAsXJKL5ZlQo)iD-pt??eUbdc{_Cn)4!d~yqz))&B D?AwK%)+)F2aNwI|siOe' );
define( 'AUTH_SALT',        '7T-!^i!0,w)L#JK@pc2{8XE[DenYI^BVf{L:jvF,hf}zBf883td6D;Vcy8,S)-&G' );
define( 'SECURE_AUTH_SALT', 'I6`V|mDZq21-J|ihb u^q0F }F_NUcy`l,=obGtq*p#Ybe4a31R,r=|n#=]@]c #' );
define( 'LOGGED_IN_SALT',   'wu$4c$Hmd%/*]`Oom_(hdXW|0M=X={we6;Mpvtg+V.ol$|#_}qG(GaVDEsn,~*4i' );
define( 'NONCE_SALT',       'a|#h{c5|P &xWs4IZ20c2&%4!c(/uG}W:mAvyjI44`jAbup]t=]V7`}.py(wTP%%' );

For client sites

When using WordPress to build a site for a client, a developer is almost all the time concerned that the client won’t do something stupid to the site, requiring a lot of maintenance.

One common thing is a client trying to edit one of the site php files and ending up deleting something important, causing the website to be unavailable. You can actually prevent this to happen by disabling the built-in files editor in wp-config.php:

define('DISALLOW_FILE_EDIT', true);

Another “classic” client mistake is to never update the WordPress core, which leads to potential security breaches. You can force WordPress to update itself automatically by using the WP_AUTO_UPDATE_COREconstant in your wp-config.php file.

define('WP_AUTO_UPDATE_CORE', true);


If your WordPress install prompts you to fill in your FTP credentials each time you need to update a plugin, you can actually save a lot of time by using wp-config.php to memorize it. The three constants below will tell WordPress what are your FTP host, username and password. That way, you won’t have to submit the info each time.

define('FTP_HOST', '');
define('FTP_USER', 'Your_FTP_Username');
define('FTP_PASS', 'Your_FTP_password');

Most quality hosting companies provide SSL to their clients. If your host does, make sure you turn SSL FTP connections on for some extra security.

define('FTP_SSL', true);


When your website is unavailable or behaves strangely, you can make your maintenance work way easier by using wp-config.php and the debugging constants.

Enabling WP_DEBUG will cause all PHP errors, notices and warnings to be displayed.

define('WP_DEBUG', true);

As errors will be displayed on the site and accessible to visitors, a way more elegant way to debug is to use a log. Doing so in WordPress is easy: Once you have set WP_DEBUG to true, you can use WP_DEBUG_LOG, a constant that will make WordPress send all PHP errors and warning into a log located in your wp-content directory.

define( 'WP_DEBUG_LOG', true );

If your database is broken, you can actually repair it easily by accessing the script located at /wp-admin/maint/repair.php after setting WP_ALLOW_REPAIR to true:

define( 'WP_ALLOW_REPAIR', true );

Please note that those constants are intended to be used only when debugging a site. Once you found and fixed the problem, remember to set the values to false!


The wp-config.php file allows some tweaking to ensure a better performance by WordPress. One thing to start with is to increase the maximum memory allocated. Please note that this won’t work if your hosting provider limits the memory, which is often the case on shared hosting.
If you’re looking for a quality web host, I recommend VidahostWP Engine or InMotion Hosting.

define('WP_MEMORY_LIMIT', '96M');

You can also allow even more memory to administrative tasks (which requires more memory than just browsing the blog):

define( 'WP_MAX_MEMORY_LIMIT', '256M' );

WordPress has a built-in caching system, located in wp-content/advanced-cache.php. It can be activated using the WP_CACHE constant:

define( 'WP_CACHE', true );

Source By

Real Tradding World By Media Ads Labs

Real Tradding World By Media Ads Labs

Real Tradding World By Media Ads Labs

Hi hello, tanks for the recommendation.
Ok this app its stay in under development:
This is a server client Desktop application and the concept is it will have every weeks a new Topic lunched by the admin and wen they talk about this topic with others clients they will win precious stones, wood, food, gold, etc, then they use for example they can win Ready Jewelry and they can exchange them for btc, for the client to bee able to start they have to construct they places only after that they can start make btc, by sale the precious stones and gold , Jewelry , etc on our market place at the server side. lot of more options will bee add , at the moment its only the concept, its like i say its under development and maybe i can change some of this options until the final version. you can view the first impretion of the app.

And More i have just add the option what they rigth in the chat will bee posted to wordpress website so its easy to setup all the content generated on the game will bee automatic post to wordpress website i will show you how to install and edit the project or i will do that for you ok…

How to Promote your RSS feed on every post

How to Promote your RSS feed on every post

How to Promote your RSS feed on every post

Adding this snippet to the functions.php of your wordpress theme will add a link to your rss feed at the bottom of every post. If you are looking to get some new subscribers this is a great way to promote your feed.


function wps_promote_feed($content,$class = "promote") {
    echo $content;
    if (is_single()) {
        <div class="<?php echo $class; ?>">
            <h3>Enjoyed this article?</h3>
            <p>Please consider subscribing to our <a class="feed" href="<?php bloginfo('rss2_url'); ?>" title="Subscribe via RSS">RSS feed!</a></p>

( WordPress codex functions, hooks, in this snippet. )

the_content, bloginfo, is_single, add_filter, wp,