Plugin / Ad Injection

reviewmylife

Frequently Asked Questions (FAQ)

I used to use the excellent Adsense Injection by Dax Herrera, but found I needed more features and flexibility. His plugin inspired this one.
One a basic level it can do the same job as Dax’s Adsense Injection. If you want it can just inject AdSense between paragraphs like his plugin does. I used to use his plugin, but found that I wanted a lot more features. Here are some of the extra features. Inject any type of advert from any ad provider. Restrict ad display by referrer (e.g. can restrict display to search engine visitors). Can prevent specific IP addresses from seeing adverts. Can define randomly positioned adverts, and adverts at the top, bottom and footer of the posts. Add adverts to the widget area. Adverts can be positioned anywhere in your theme template. Ad rotation / split testing. Restrict adverts by category, tag, author, post ID. Override ad positions for individual posts if necessary. Vary number of adverts based on post length. You can inject raw JavaScript and PHP. Include ads anywhere in the theme template if you edit your theme’s PHP. Define alternate content for users who are dynamically restricted from seeing ads. Compatible with the in-page tags from Adsense Injection to make migration easy. Compatible with in-page tags from Whydowork Adsense and Quick Adsense. Extra positioning options – for example you can force the first advert to be right after the first paragraph so that it will be ‘above the fold’. Thanks to Dax by the way for providing the inspiration for this plugin!
No! Absolutely not. Some ad plugins replace your publisher ID with their own for a certain percentage of adverts. Ad Injection does NOT do this. All your earnings are your own. Ad Injection makes no modifications to your ad code. What you paste into the ad boxes is what is injected into your pages.
As far as I can tell using this plugin should be legal for AdSense as long as you make sure the ad quantities/placements comply with their TOS. However it is up to you to make sure that your website complies. Ad Injection is designed as a generic plugin for injecting all types of adverts. It will not specifically check that the defined ad quantities or positions are in compliance of the AdSense TOS for you. For example Ad Injection will allow you to inject more ads than Google allows if you configure it to do so. Note that AdSense has limits as to the number of adverts you can include on a page. If you try to include more then you will end up with ‘blank boxes’ on your page. Be careful if you use the float left/right positioning options. These options could cause your AdSense adverts to appear under other elements of your page if you have also set a float value for them (e.g. floating images, and adverts together could be problematic). However the new ‘clear’ option should allow you to make sure this doesn’t happen. The best advice for any advert plugin is to manually check that you are happy with the advert quantities and positioning it produces, to ensure that you comply with the TOS for your ad program. You use this plugin at your own risk.
For testing your ad settings I’d recommend that you first disable any caching plugin, and then set Ad Injection to test mode so that 1) you can instantly see any changes you make to the settings and 2) so that only you will see the adverts. If you are unsure as to why ads are appearing (or aren’t) enable debug mode from the UI and look for the ‘ADINJ DEBUG’ tags in the HTML source of your webpage. When you are happy with the ad quantities / positions you can disable debug mode, re-enable your caching plugin, and set the Ad Injection mode to ‘On’. If you are testing the search engine referrer settings be aware that Ad Injection sets a one hour cookie when you visit via a site with a matching referrer. This means that after you have visited the site via the matching referrer the adverts will keep showing for the next hour. Clear your cookies to reset the behaviour. The Firefox ‘Cookie Monster’ plugin is very useful if you want to check the status of the cookie. Look for the ‘adinj’ cookie. Instead of clearing all your cookies you can just delete this one. Using a second browser in ‘privacy mode’ is also a good way of testing your site with a clean slate. A browser like Google Chrome will allow you to test your site with no cookies definied if you start a new private browsing session.
Note: mfunc mode is now deprecated – only use if you really understand what it does! No! All the features of this plugin will work with no caching plugin installed. But if you do have WP Super Cache the dynamic features (ad rotation and enabling ads based on IP address and referrer) will still work. And your blog will (probably) run a lot faster than with no caching plugin. Usually caching plugin prevent dynamic plugin features from working – but I’ve spent a lot of time creating a framework to allow this plugin’s dynamic features to work with some of the most common caching plugins. Just make sure you choose the mfunc dynamic insertion mode from the Ad Injection settings screen. WP Super Cache – 0.9.9.8+ using mod_rewrite mode. Note that mfunc tags were removed from later versions of WP Super Cache so I no longer recommend using Ad Injection’s mfunc mode. W3 Total Cache – Page Cache: ‘Disk (basic)’ mode. WP Cache – Just turn the caching on. Note: If you use a version of WP Super Cache prior to 0.9.9.8 it must be configured in ‘Legacy’ mode for the dynamic features to work. If you use WP Super Cache 0.9.9.8 or above you can use any of the caching modes (mod_rewrite and PHP are faster than legacy).
Note: mfunc mode is now deprecated – only use if you really understand what it does! The dynamic features will work with any caching program that supports the mfunc tag. At the moment that is WP Super Cache, W3 Total Cache, and WP Cache.
Note: mfunc mode is now deprecated – only use if you really understand what it does! Both WP Super Cache and W3 Total Cache are likely to be faster than WP Cache. If you aren’t using the dynamic features then the only way to find out which is best between WP Super Cache and W3 Total Cache is to measure the performance yourself, as the speed depends on many factors that will be unique to your web server and web site. If you are using dynamic features with mfunc mode then WP Super Cache (in mod_rewrite mode) and W3 Total Cache (in Page Cache: Disk (basic) mode) are likely to offer similar performance as they both return the dynamic files via PHP. Note that W3 Total Cache will not cache pages with mfunc tags if you use the Page Cache: Disk (enhanced) mode. The speed of your website does depend on more factors than just page serve time so other features that the caching plugins offer (such as CDN and minification support) may swing the advantage either way. WP Hyper Cache does not support mfunc tags so only use it if you don’t want to use any of the dynamic features. If using WP Hyper Cache set the Ad Injection mode to ‘direct’. For reference: dynamic features are ad rotation, and blocking ad views by IP and referrer.
Don’t worry – everything will still work except for: Filtering ads based on the IP address of the visitor. Filtering the ads based on the HTTP referrer of the visitor. If you aren’t interested in these features then it doesn’t matter! Just make sure you tick the box to say that you to use ‘Direct static ad insertion’ on the Ad Injection settings screen.
i.e. adverts on the home page, but not on single posts or pages. Yes you can do this, there are two ways. In the ‘Single posts and pages’ setting set the number of injected ads to 0. Then in the ‘Home page’ settings set the number of ads to whatever you want. Alternatively use the global exclude options at the top to exclude ads from all page types except the home page.
Ads will only appear if your front, home or archives page if you show the full post – not if you show excerpts*. *However if your theme leaves the HTML tags intact then you may in fact see the top ad in your excerpt. Whether you do or not depends on how your theme deals with excerpts.
To stop ads appearing on the contact page (or any other post/page) you have many of options. Here are 4 to choose from: Add a disable_adverts custom field to the post/page containing the contact form and set the value to 1 (the number one as a single digit). If you can’t see the custom fields click on ‘Screen Options’ at the top right on the post/page editing screen, and tick ‘Custom Fields. Add the post/page id to the post/page id ad filtering box. Add (copy and paste) into the content of the post/page with the contact form. Just edit the contact page and paste this in – it will be invisible to the reader. Add a tag to the page to mean that it shouldn’t have adverts, and then add that tag to the tag filtering condition in the global settings area of the plugin configuration page.
The top, random, bottom and footer ads can be placed into the category pages. Category pages are a type of archive. On the main settings page for Ad Injection just enter the number of adverts you want on these page types using the Archives column in the ‘Ad placement settings’ section. These ads will only appear on archives/category pages if you are showing the full post contents on these pages. They won’t work if you are showing excerpts. These restrictions don’t apply to widget ads.
You can try defining the ‘clear’ display setting so that multiple floated parts of your page do not overlap. If you always have a floated image at the top of the page you can set which paragraph the first random advert will start from. If you needed finer control over where the random adverts appear you can use the and tags in the page.
Check your style sheet to see if either the text or headings have the ‘clear’ attribute set. This may be preventing your text / headings from flowing around the advert.
This is because you have inserted adverts that are too wide for your site’s layout. The browser can no longer fit all the parts of your layout side-by-side. Try using ads that are less wide.
There aren’t any options to do this in the UI, but you can just put the layout tags into the ad box around your advert. e.g.
Your advert
Google’s AdSense TOS only allow allow three ad units, and three link units per page. If you have for example tried to insert four ad units on your page then Google will (probably) disable the forth one automatically. Read Google’s AdSense program policies for more info. You may find that your right sidebar ad doesn’t show if you have too many ads. Google renders the ads in the order that they are in the HTML, and your right sidebar will be at the bottom of HTML. If you need your right sidebar AdSense ad you will have to limit the number of ads on the rest of the page from the ‘Ad placement settings’.
I am planning on making a change to allow an arbitrary number of adverts – this will probably be in 2012. Until then you have these 3 options: Use PHP / JavaScript in the ad boxes to handle the rotation of the extra ads. Use an ad service such as OpenX or Google Ad Manager in conjunction with Ad Injection. Ad Injection can handle the ad placement, and the ad service can manage your ad pool. Hack Ad Injection to increase the limit (but be aware that if you upgrade your changes will be overwritten). I’d recommend 1 or 2.
If you want to show different ads for different categories using widgets you can set up filters for the different ads from the widget UI. If you want to show different top, random, or bottom adverts on different categories you can use some very simple PHP in the ad box (this will also work for the widgets as well if you don’t like the UI method). Example 1 – one category specific ad and a general ad. Japan advert General advert Example 2 – Two different ads in two different categories. Pages which aren’t in either category have no ads. Cheese advert Milk advert See https://codex.wordpress.org/Function_Reference/in_category for more information on in_category. You can do the same for tags using has_tag. See https://codex.wordpress.org/Function_Reference/has_tag for info. Note – this will only work in direct insertion mode.
In your plugins directory create a sub-directory called ‘ad-injection-ads’. e.g. /wordpress/wp-content/plugins/ad-injection-ads/ Create a text files in this folder for each of the categories that you want an ad for. The text files should be named [category nicename].txt The ‘nicename’ of the category is the category name with spaces and dots converted to ‘-‘ and apostrophes removed. e.g. Liverpool = liverpool.txt Manchester United = manchester-united.txt A.F.C Aldermaston = a-f-c-aldermaston.txt Bishop’s Stortford = bishops-stortford.txt Then put this code (from the starting ) into the ad box. It will load the text file ad matching the category name when the post is displayed. ID); foreach ($categories as $cat){ // nicename: spaces and dots are converted to ‘-‘ and apostrophes are removed $full_ad_path = $ad_dir.$cat->category_nicename.’.txt’; if (file_exists($full_ad_path)){ $ad = file_get_contents($full_ad_path); if ($ad === false) echo “\n”; echo $ad; break; // only show first category ad that matches } else { echo “\n”; } } } else { echo “\n”; } ?> Some extra information: * This code will load one text file ad per post. If for example you had a post with the categories ‘Liverpool’ and ‘Manchester United’ it would load which ever ad it found first. * If will ignore categories that have no text file in the directory. If you have a post with the categories ‘Liverpool’ and ‘Latest News’ then it will always load the liverpool.txt as long as you don’t create a ‘latest-news.txt’. * This code will only work in ‘direct’ ad insertion mode. It won’t work in ‘mfunc’ mode. Expansion ideas: * Show a default advert if no text file exists. * Create multiple text files for each category and then randomly select one – an implementation of this is shown on advancedhtml * Use different code for top, random or bottom ads. e.g. you could have liverpool_top.txt and liverpool_random.txt
This is something I hope to build into the UI at some point. But in the mean time you can use PHP in the ad code boxes to do this: e.g. This is John's Ad. This is Paul's Ad. Note this will only work in direct insertion mode. It won’t work in mfunc mode unless you also load in the WordPress database dependencies.
If you install the Country Filter plugin (with the IP database) then you can use the following code in the direct ad insertion modes. This will not work in mfunc mode! UK advert Global advert You can download the Country Filter plugin from https://wordpress.org/extend/plugins/country-filter/ You could also use the Geo IP functionality that CloudFlare offers (you can set it up for free if you are able to modify your DNS settings) http://support.cloudflare.com/kb/what-do-the-various-cloudflare-settings-do/how-does-cloudflare-ip-geolocation-work
If you set an ad with a tag restriction of ‘tag1’ and a category restriction of ‘cat1’, then it will only appear on pages that have BOTH the tag1 and cat1 property. A post in this category with that tag will have the ad. But if will not show in the ‘tag1’ archive or ‘cat1’ category. This is because the ‘tag1’ archive is not part of the ‘cat1’ category. A tag archive can’t be part of a category, and a category archive can’t be part of a tag. This means that if you add both a tag and a category restriction the ad won’t appear in the tag or category archives. If this restriction wasn’t in place then it would mean the category and tag archives would start showing all ads that were set to appear in the category/tag – which could be loads! And there would be no way to remove selected ones from the archives. Therefore if you are defining ads with both a category and a tag, you will need* to define a separate one for the category/tag archive. I know this might cause extra work for you, but having this restriction allows more precise control of where the ads appear. This is a deliberate design decision, rather than some random behaviour.
Yes – you can put adverts anywhere, if you are willing to edit your theme template. The adinj_print_ad function can be used anywhere in your theme to print the top, random, bottom or footer ad. It can also be used to load ads stored in text files in the ad-injection-data directory. For example this will print the random ad. The ad will be subject to same global and dynamic restrictions an ‘in content’ random ad, but it will not be subject to conditions relating to the post length, post tags, categories, or number of ads already inserted. Here are some more examples: Here is an example of how to load a text file ad from the ad-injection-data directory. They contents of the text file will be printed straight onto the page. The function_exists condition ensures that the ads will silently dissapear if the plugin is deactivated rather than generating an error. If you are using template ads with a compatible caching plugin you will need to include adshow.php (once on the page) using mfunc tags. You will need to alter the code below to include the correct path. If you look in the ‘Test ads’ section of the main settings page you should be able to find a version of this code customised for your web server.
These are advanced features which I have no plans for adding into the core Ad Injection. You might however be able to use Ad Injection with Google Ad Manager or OpenX Ad Server that should allow you to sell your own ads and track their clicks. If you are using a 3rd party ad provider (e.g. AdSense) then statistics such as ad clicks will be available from the ad provider.
WP Minify Problem: No ads appear when using mfunc mode. Note: mfunc mode is now deprecated – only use if you really understand what it does! If you use WP Minify and a caching plugin in combination with Ad Injection, you’ll need to turn off the HTML minification in WP Minify. This is because HTML minification strips out the mfunc tags that Ad Injection uses. You can leave the CSS and JavaScript minification on if you already use them. FeedWordPress Problem: Random, top and bottom ads don’t appear on syndicated posts. By default FeedWordPress prevents the syndicated post contents from being passed to ‘the_content’ hook which is where the random, top and bottom ads are added. There’s an easy fix: From the FeedWordPress settings page go to ‘Posts & Links’ and then in the ‘Formatting’ section set ‘Formatting filters’ to ‘Expose syndicated posts to formatting filters’. Shortcodes Ultimate Problem: Random ads don’t show. Reason: Shortcodes Ultimate disables the wpautop filter which adds the

tags to the page. It re-applies this filter at a priority of 99 which is after Ad Injection has run. Therefore when Ad Injection runs it can’t find any

tags which it needs to position the random adverts. Solution: Follow the below advice for the ‘theme conflicts’.
Ad Injection (when injecting random ads) works by looking for the end paragraph tags (

). Some themes override the wpautop filter and set it to run after the plugins. This means that Ad Injection can’t find the end paragraph tags, and so can’t inject any random ads. If this happens try changing the the_content filter priority from the Advanced tab in the Ad Injection UI. Try values of 100, and if that doesn’t work 200. Themes which I know have this issue include ‘Avenue’, ‘TheTravelTheme’, ‘Exciter Magazine’, ‘Vectors’, and ‘Canvas’ from Woothemes.
The multi-user version of WordPress are not supported – yet, however I have heard that some people have got it to work when using the ‘direct’ insertion mode. I hope to make it work properly with multi-blog versions of WordPress in the future.
Go to phpMyAdmin, either from your web hosts control panel, or by using the very convenient ‘Portable phpMyAdmin’ plugin for WordPress on the blog that has your Ad Injection settings configured. Open up the [yourdb]_options table. Either find the adinj_options and widget_adinj rows or use this query to help you: SELECT * FROM [yourdb]_options WHERE option_name LIKE ‘%adinj%’ Then copy these two options to your new blogs by using phpMyAdmin on the new blogs. If you aren’t using widgets then you can ignore the widget_adinj option, you need only the adinj_options value. You can use the ‘Insert’ tab on the new blog to do this.
Plugin stores all its settings in a single option (adinj_options). Uninstall support is provided to delete this option if you uninstall the plugin. Admin code is separated into a separate file so it is not loaded when your visitors view your pages. When used with a compatible caching plugin Ad Injection loads its dynamic settings from a static PHP file, and the ads from disk so no extra MySQL database queries are required. When mfunc mode (deprecated) is used the ads are saved as text files into the plugin folder. The plugin will therefore need write access to the plugins folder. The JavaScript for setting the referrer cookie is inserted using wp_enqueue_scripts. If there is anything I can do better please let me know – this is my first plugin so I still have a lot to learn!

Ratings

4.2
43 reviews

Rating breakdown

Details Information

Version

1.2.0.19

First Released

31 Jul, 2011

Total Downloads

471,660

Wordpress Version

2.8.6 or higher

Tested up to:

4.3.21

Require PHP Version:

-

Tags

Contributors

Languages

The plugin hasn't been transalated in any language other than English.

DIRECTORY DISCLAIMER

The information provided in this THEME/PLUGIN DIRECTORY is made available for information purposes only, and intended to serve as a resource to enable visitors to select a relevant theme or plugin. wpSocket gives no warranty of any kind, express or implied with regard to the information, including without limitation any warranty that the particular theme or plugin that you select is qualified on your situation.

The information in the individual theme or plugin displayed in the Directory is provided by the owners and contributors themselves. wpSocket gives no warranty as to the accuracy of the information and will not be liable to you for any loss or damage suffered by you as a consequence of your reliance on the information.

Links to respective sites are offered to assist in accessing additional information. The links may be outdated or broken. Connect to outside sites at your own risk. The Theme/Plugin Directory does not endorse the content or accuracy of any listing or external website.

While information is made available, no guarantee is given that the details provided are correct, complete or up-to-date.

wpSocket is not related to the theme or plugin, and also not responsible and expressly disclaims all liability for, damages of any kind, arising out of the use, reference to, or reliance on, any information or business listed throughout our site.

Keep Leading Your Followers!
Share it for them.