This is an updated version of the AdSense revenue sharing widget for WordPress-MU (in beta).
Two things before we start:
- To stay updated please subscribe to my RSS feed.
- If you use this plugin it can make you a lot of money. Please consider a donation using the PayPal button on the right – thanks 🙂
The AdSense revenue sharing plugin for WordPress-MU will allow you, the owner of a WPMU site, to share Adsense revenue with your users. You can set the percentage of your share (default is 20%) and enter your AdSense publisher code via the ‘Site Admin‘ backend panel.
The user can enter his Adsense publisher code in the ‘Options‘ menu:
Download: adsense-share-mu-123.zip
Current version: 1.2.3 (view change log below)
Installation: extract the adsense-share-mu.php file and upload it to the mu-plugins directory.
How to use?
Go to ‘Site Admin‘ -> ‘Adsense share‘ and set your Adsense share and your Adsense publisher code.
There are two option to insert Google Adsense ads and they can be used together:
- allow users to insert an Adsense widget to their sidebar (that is the easy and simple way). All your users will have to do is drag the ‘Google Adsense‘ widget to the sidebar, click the configuration icon and enter their google_ad_client ID.
- hard code ads into the themes.
The second method needs some explanations. Since Google is constantly changing the structure of the ads script and adding new features, I decided that I will not deal with the ad code except for the google_ad_client which is the Adsense publisher code.
To insert ads to your themes you should log into your Google Adsense account and select the product, ad type, ad format and colors, corners style, channels and whatever Google allows you to select. Once you are done you will get a code looking something like this:
<script type="text/javascript"><!-- google_ad_client = "pub-01234567890"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; //2007-10-07: Demo google_ad_channel = "1234567890"; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
Simply copy this code and paste it wherever you want in your theme files. Note the second line starting with google_ad_client and ending with “pub-01234567890”;. The second part is your Adsense publisher code. If we don’t change that code you will get all the revenue from the ads and your user will not be happy. So we want to enter a piece of code that will iterate between the publishers codes. This is done by replacing the “pub-01234567890”; part with a simple line of code:
<?php get_adsense_code(); ?>;
if we want to be on the safe side we can add a check for the function:
<?php if (function_exists('get_adsense_code')) {get_adsense_code();} ?>;
So now the Adsense code looks like this:
<script type="text/javascript"><!-- google_ad_client = <?php if (function_exists('get_adsense_code')) {get_adsense_code();} ?>; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; //2007-10-07: Demo google_ad_channel = "1234567890"; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
If you want to ad the ads only to your themes and not allow the users to ad the widget, there is a little hack which involves editing the plugin file. Open the adsense-share-mu.php file and look at line 14. If you change the no_widgettruetrue parameter to ‘true‘ the widget will not be available.
Change log
1.2.3
Fix security issue (everybody upgrade). Thanks NK5.
1.2.2
Fix a minor php bug.
1.2.1
Added an “;” at the end of the php code.
Please report and issues in the comments below.
Did you find this post interesting? Please subscribe to my feed.
Comments 38