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
As trackback don’t seem to be published, I just post a special thanks for your work.
I setup the plugin last night, and everything was done in 5 min.
Just one thing : the made the next line of the google code to be on the same line… Nothing very important, in fact.
I keep you inform if I get a problem.
Posted 08 Oct 2007 at 3:47 pm ¶Hi,
Widget not work on my WordPress-MU:
Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/blogs/public_html/wp-content/mu-plugins/adsense-share-mu.php on line 22
Posted 08 Oct 2007 at 5:30 pm ¶indeepdark:
Didn’t understand the problem.
What php version do you have
Zup:
Posted 08 Oct 2007 at 6:29 pm ¶Did you ever use an older version of the plugin?
What php version do you have
php 5.2.0-8
After some test when adsense-share-mu.php is on FTP all widgets administration fail. When i remove the file, widgets administration work normaly.
Sorry for BAD English :p
Posted 08 Oct 2007 at 9:32 pm ¶Hi,
I was just wondering, as it is a bit hard to explain to all user the AdSense rules, why not add a feature that would not display ads from one user when visiting his blog ?
I don’t know how you can do that, maybe by checking if the user is logged in (but you may have problem if the user visit other blogs…), or maybe with a cookie….
Well, that’s just seems important to me at the moment, but I don’t know how to solve that.
Posted 21 Oct 2007 at 5:35 am ¶I get this same error below with the latest 121 version. It breaks my other widgets when installed. If i revert back to the older version, all functions well
Widget not work on my WordPress-MU:
Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/blogs/public_html/wp-content/mu-plugins/adsense-share-mu.php on line 22
Posted 23 Oct 2007 at 3:30 pm ¶Gordo, what version of PHP are you using?
Posted 23 Oct 2007 at 8:49 pm ¶hello
i am using PHP 5.2.3
Posted 25 Oct 2007 at 7:53 am ¶Same error! using PHP 5.1.6
Posted 26 Oct 2007 at 9:49 am ¶Hi,
Posted 12 Nov 2007 at 1:06 am ¶It doesnt show any “AdSense Publisher’ submenu in the options menu for a normal user who owns a wpmu subdomain. Only shows it when I login as admin.
Thanks for a great plugin
This works a treat until you have more than one google ad unit on a page.
If you have more than one ad unit in your template and each time it calls get_adsense_code() you could end up with two ad units u sing different publisher id’s which is against the Adsense ToC’s.
I am sure there are ways round this but thought it was worth pointing out.
Posted 27 Feb 2008 at 3:29 pm ¶Greg,
Before I started to work on the plugin I asked Google Adsense support about it. My question was:
“Can I place ads with two different publisher ids on the same page?”
Their answer:
“This does comply with our policies”
I have the writing on record if you want it.
Posted 27 Feb 2008 at 10:19 pm ¶Hey Greg, Elad,
A simple workaround to the problem would be to store the publisher’s code into a variable, ie.,
$pubcode=get_adsense_code();
then use $pubcode in replacement with get_adsense_code() function.
However, you’ll prob. need to get into get_adsense_code() function to return the publisher’s code, rather than echoing it out.
Will be implementing your plugin on my parenting tips website!
Posted 02 Mar 2008 at 12:45 am ¶Steve
I did exactly that – well almost.
I have modified the plugin so the user can enter an adsense channel aswell as their own colors, using a default set of colors if none are entered. I have then at the top of each template I call a routine in the plugin which sets some javascript vars and these are then applied to all adsense units used on the page.
I am neither a php or wordpresss expert hence my hack is not pretty so I have not gone public with it but it works for my needs.
Elad, I’m glad that is the case, I had heard that someone else had been told the same thing but knowing Google I tend to urge on the side of caution:)
Posted 04 Mar 2008 at 7:26 pm ¶I installed this plugin just now and i dont get that field where i can select how many % i want to share with my users.
Is this feature removed or am i missing something?
Posted 05 May 2008 at 10:54 pm ¶Please disregard my previous statement. I did not se the “adsense share” thingy in “Site Admin”.
This really sounds like a great plugin. I hope its all that and a bag of lard!
Thanks.
Posted 05 May 2008 at 11:00 pm ¶Just installed and I get:
“Fatal error: Call to undefined function get_site_option() in /home/[site/public_html/wp-content/plugins/adsense-share-mu.php on line 108″ Latest version of WP.
Any ideas? Thanks
Posted 04 Jun 2008 at 5:18 am ¶Dave,
Posted 04 Jun 2008 at 6:28 am ¶This plugin is for WordPress-MU and not the regular WP version.
This is a nice plugin.
So when I am a sideadmin, I have blog.com and I have a user that has user.blog.com and he uses my setup adsense, he get’s a share of this ?
Is this shown somewhere btw, what his share is over a month ?
Now it would be possible that such a users sets this own adsense in this blog, that is not nice ofcourse.
In such a case you need to add your adsense in the templates for sure, but a backwards compatible system where if the user adds adsense in a plugin way that the site admin get’s automaticly 20% of it ?
If that woukd be possible, it won’t I think, that would be ideal !
Keep up the good work
Posted 06 Jun 2008 at 2:41 am ¶Hello,
I’m trying this plugin in my new WordPress MU installation. But, only one widget is there namely “Google Adsense”. How to insert more than one AdUnit?
Please help …
Kaja.
Posted 07 Jun 2008 at 9:15 am ¶Mattz, the bloggers profits are not shown to the site admin. WordPress-Mu does not allow JS to be inserted so the bloggers can not place Adsense ads on their blogs.
Kaja, there is only one widget. You can add more ads by placing them within the themes code.
Posted 07 Jun 2008 at 9:03 pm ¶Elad, I want to start a free wordpress powered blog hosting with revenue sharing. I don’t want to code the themes directly. I want to give more freedom to the blog users, to select the placement & size of the Ad-Unit. Is there any way to increase the number of widgets?
Posted 08 Jun 2008 at 4:59 am ¶thanks a lot for this great script !
Posted 20 Jun 2008 at 7:58 pm ¶Hi,
I have 2 big errors:
1. PHP error
as a user, when i try to save the widgets after i added the Google Adsense widget, i get this error:
Fatal error: Call to undefined function array_key_s() in /var/www/html/site/wp-content/plugins/adsense-share-mu.php on line 69
2. JS error i think
as a user, when i press remove button, it takes me on a page (/wp-admin/widgets.php) that is loaded forever and it says Sign up for AdSense.
I have wordpress mu version: WordPress 2.5.1
Please help.
Thank you
Posted 25 Jul 2008 at 2:56 pm ¶Is this plugin compatible with WPMU 1.5.1?
I uploaded it fine and set everything up, but when I try to change the default 120 width and 240 height or anything for that matter in the backend, I get
“Fatal error: Call to undefined function: array_key_s() in /home/sportsbl/public_html/wp-content/mu-plugins/adsense-share-mu.php on line 68″
If i leave it alone and use the default settings it seems to work fine, but I’d really like to at least add a channel in adsense
Posted 01 Aug 2008 at 2:58 am ¶Hey, when a user adds the Adsense Widget, the sidebar widget when activated pops up a blank page widgets.php and it just cycles. Any idea of what that is?
Posted 26 Sep 2008 at 1:30 am ¶Please please please make the widget work on wpmu 2.5+
Posted 03 Oct 2008 at 9:01 pm ¶hopefully i’ll use this.
so you 20% set admin pubId, and the rest client(publisher) ID.
as You said “I will not deal with the ad code except for the google_ad_client which is the Adsense publisher code.”
this will be OK until google not change the other parts of a code.
when channels, or now, slots not from ad_client are.
what then?
i think you shoud exchange complete code.
and client(publisher) can tell whitch format he used.
you have all formats with you code in place. so use rigth this format.
thanks
Posted 20 Oct 2008 at 10:10 am ¶SF
Please make this compatible with WPMU version 2.6…
i have tried it to implement but on Firefox it goes blank and on IE it simply crashes (on both cases I have tried to add it from widget menu).
Posted 23 Oct 2008 at 1:44 pm ¶Hi all
I have found updated version for WPMU version 2.6
and working for me.
http://blog.hoofoo.net/index.php/category/wordpress-mu/
regards
Posted 25 Oct 2008 at 9:07 am ¶Gives error on line 118 when activated and crashes wp 2.6
$default_your_adsense_share = get_site_option(‘your_adsense_share’);
Posted 31 Dec 2008 at 7:37 pm ¶Does this not have a version out for 2.6+?
Posted 12 Jan 2009 at 2:55 am ¶I would love for this to work… Would pay for it.
Posted 15 Jan 2009 at 6:58 am ¶This plugin is against Adsense TOS:
Can I alter the AdSense ad code?
Our program policies do not permit the modification of the AdSense code. Your publisher account offers a number of options when generating the ad code, that we hope will allow you to create an ad layout that fits in with your site.
Please paste the AdSense ad code into your webpages without making any modifications.
Again, please note that modification of the AdSense code is a violation of the AdSense program policies. For example, publishers may not:
Alter the height or width of an ad unit from the standard options
Posted 20 Mar 2009 at 3:32 pm ¶Implement the AdSense ad code in a “floating box script” or in a way that otherwise covers content
Use any means to force the display of more than three AdSense ad units on a page
Manipulate the ad targeting using hidden keywords, IFRAMEs, or any other method
Distribute ads in emails or software
Tiswa, since the output code should be the same as the one one you get from Google I don’t see the problem.
Posted 22 Mar 2009 at 8:33 am ¶Plugin does NOT appear to work with WPMU 2.9.2 and BuddyPress (but see below for what does work).
Plugin activated OK, was able to take Adsense code, and appears in the list of widgets.
However, when you try to drag this widget to the sidebar the whole screen goes blank.
I’ve tried it a few times and it happens every time but only to this particular widget. In between I dragged other widgets to sidebar with no problem, so the problem is definately this plugin.
I deleted this Plugin because it doesn’t appear to work with the most recent setup.
I then uploaded the Plugin from http://blog.hoofoo.net/index.php/category/wordpress-mu/ This is the same Plugin with changes to make it work with the latest setup, and it appears to be working fine on my setup of WPMU 2.9.2 and BuddyPress.
Posted 13 Mar 2010 at 7:18 pm ¶I tried this pluging and had the same problem, the page went blank. i am trying to make this website with a partnership program like the one that youtube has. the only thing is that not everyone had a google adsense account as they live in other country’s where they can not obtain an account.
how can i do to have something that will use my adsense account, yet keep track of the earnings on the individual blogs. i can do it with channels but the owner of the blog doesn’t know how much money he has made or the info of the clicks, any helpful tips on what to do
thank you
Posted 02 May 2010 at 2:53 am ¶Did you drop support for this Plug in? As WP 3.0 get closer to release more and more people will be needing this great plug in for sharing Adsense.
Posted 16 Jun 2010 at 4:18 am ¶Trackbacks & Pingbacks 3
[...] dem Adsense Share for WPMU Plugin von Elad Salomons können mit Google Adsense erzielte Erträge mit anderen [...]
[...] have tried AdSense revenue sharing plugin for WordPress-MU developed by ringofblogs , it is wok for old versions and no updates for new [...]
[...] AdSense Revenue Sharing is a WordPress plugin that allows users to display ads in their posts via quicktags. This plugin allows easy sharing of Adsense impressions with friends and co-authors. Tags can be inserted anywhere in the post in order for the ads to be displayed. [...]
Post a Comment