AdSense Manager - Version 2.4

Version Description

Download this release

Release Info

Developer mutube
Plugin Icon wp plugin AdSense Manager
Version 2.4
Comparing to
See all releases

Code changes from version 2.3 to 2.4

Files changed (2) hide show
  1. adsense-manager.php +104 -37
  2. readme.txt +27 -34
adsense-manager.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: AdSense Manager
4
PLugin URI: http://wordpress.org/extend/plugins/adsense-manager/
5
Description: Control and arrange your AdSense & Referral blocks on your Wordpress blog. With Widget and inline post support, configurable colours.
6
Author: Martin Fitzpatrick
7
- Version: 2.3
8
Author URI: http://www.mutube.com/
9
*/
10
@@ -17,7 +17,7 @@ Defaults
17
18
*/
19
20
- @define("ADSENSEM_VERSION", "2.3");
21
@define('ADSENSEM_DIRPATH','/wp-content/plugins' . strrchr(dirname(__FILE__),'/') . "/");
22
23
/*
@@ -27,23 +27,11 @@ Defaults
27
//Currently not used
28
@define("ADSENSEM_MAX_ADS", 7); //Max Google Ad units
29
@define("ADSENSEM_MAX_REFERRALS", 7); //Max Google Referral units
30
31
- /*
32
- AdSense Manager is a plugin to help manage generating income from your Wordpress blogs. Because it's a money-generating plugin it would be nice (for me) if some of that income found
33
- it's way back to supporting the development and hosting of my free plugins.
34
-
35
- By default AdSense Manager will donate the equivalent of 1 days worth of Google Ads to
36
- mutube.com each month. This money is used to keep servers up and provide ongoing free support.
37
-
38
- However, if you don't want to donate this income you can change the value below to 0 to disable this behaviour, no hard feelings. Please consider donating instead.
39
-
40
- Thanks,
41
-
42
- Martin Fitzpatrick
43
- Developer, mutube.com
44
-
45
- */
46
-
47
/* Copyright 2006 MARTIN FITZPATRICK (email : martin.fitzpatrick@gmail.com)
48
49
This program is free software; you can redistribute it and/or modify
@@ -146,11 +134,22 @@ class adsensem {
146
} else {
147
$format = $ad['adformat'] . '_as';
148
list($width,$height,$null)=split('[x]',$ad['adformat']);
149
}
150
151
$code .= $ad['html-before'];
152
153
-
154
if($_GET['preview']){
155
156
/* We are in the editor, output fake */
@@ -164,7 +163,10 @@ class adsensem {
164
$code .= '<span style="text-decoration:underline;color:#00f">AdSense Referral Link #' . $name . '</span>';
165
} else {
166
/* We are in the editor, output fake */
167
- $code .= '<div style="text-align:center;border:1px solid #000;font-size:' . round($height/4,0) . 'px;width:' . $width . 'px;height:' . $height . 'px">';
168
$code .= 'AdSense ' . ucwords(str_replace("-"," ",$ad['product'])) . '<br />#' . $name;
169
$code .= '</div>';
170
}
@@ -258,13 +260,33 @@ class adsensem {
258
'demo-advert' => array()
259
);
260
$options['adsense-account']="";
261
- $options['be-nice']=ADSENSEM_BE_NICE;
262
$options['defaults']['ad'] = 'demo-advert';
263
}
264
265
return $options;
266
}
267
268
269
/* MERGE DEFAULTS - Merge in default settings to fill gaps in Ad setup */
270
function merge_defaults($settings) {
@@ -593,6 +615,9 @@ class adsensem {
593
594
$options['adsense-account']=preg_replace('/\D/','',$_POST['adsensem-adsense-account']);
595
596
update_option('plugin_adsensem', $options);
597
598
}
@@ -616,10 +641,21 @@ class adsensem {
616
<br />You can find this number at the bottom of your <a href="https://www.google.com/adsense/account-settings" target="_new">Account Settings</a> page.</p>
617
</p>
618
619
- <p class="submit"><input type="submit" value="Save changes &raquo;"></p>
620
</div>
621
<input type="hidden" id="adsensem-submit" name="adsensem-submit" value="1" />
622
- </form>
623
624
<?php
625
}
@@ -971,8 +1007,8 @@ Ads can be inserted into <strong>posts / pages</strong> using <code>&lt;!--adsen
971
{
972
$options = get_option('plugin_adsensem');
973
974
- add_submenu_page('edit.php',"Ads", "Ads", 10, "adsense-manager", array(&$this,'admin_manage'));
975
- add_options_page("AdSense Manager Options", "AdSense Manager", 10, "adsense-manager", array(&$this,'admin_options'));
976
977
/* ADMIN SECTION: WIDGET CONTROL CODE
978
/* If SBM installed output the Kludge functions for compatibility */
@@ -1045,8 +1081,6 @@ Ads can be inserted into <strong>posts / pages</strong> using <code>&lt;!--adsen
1045
var ed_adsensem = document.createElement("select");
1046
1047
ed_adsensem.setAttribute("onchange", "add_adsensem(this)");
1048
-
1049
-
1050
1051
ed_adsensem.setAttribute("class", "ed_button");
1052
ed_adsensem.setAttribute("title", "Select AdSense to Add to Content");
@@ -1119,30 +1153,44 @@ Ads can be inserted into <strong>posts / pages</strong> using <code>&lt;!--adsen
1119
1120
}
1121
1122
/* Initilisation */
1123
1124
function init()
1125
{
1126
$options = get_option('plugin_adsensem');
1127
- if ( !is_array($options) )
1128
- {
1129
- $options = $this->set_defaults($options,true);
1130
- update_option('plugin_adsensem', $options);
1131
- }
1132
-
1133
add_action('admin_menu', array(&$this,'admin_add_pages'));
1134
add_filter('the_content', array(&$this,'filter_ads'));
1135
1136
add_action('admin_footer', array(&$this,'admin_callback_editor'));
1137
-
1138
/* SITE SECTION: WIDGET DISPLAY CODE
1139
/* If SBM installed output the Kludge functions for compatibility */
1140
/* These use the #id pased via the module name because of inability to pass
1141
references to functions using class definitions under SBM */
1142
if (function_exists('sbm_get_option') )
1143
{register_sidebar_widget('AdSense Ad', 'adsensem_sbm_widget');}
1144
- /* Add the blocks to the Widget panel for positioning */
1145
- else if (function_exists('register_sidebar_widget') )
1146
{
1147
/* Loop through available ads and generate widget one at a time */
1148
if(is_array($options['ads'])){
@@ -1150,11 +1198,28 @@ Ads can be inserted into <strong>posts / pages</strong> using <code>&lt;!--adsen
1150
$args = array('n' => $name);
1151
//$id, $name, $output_callback, $options = array()
1152
wp_register_sidebar_widget('adsensem-' . $name,'Ad #' . $name, array(&$this,'widget'), $args, $name);
1153
}
1154
}
1155
1156
- }
1157
1158
}
1159
1160
@@ -1203,4 +1268,6 @@ $adsensem = new adsensem();
1203
1204
// Run our code later in case this loads prior to any required plugins.
1205
add_action('plugins_loaded', array(&$adsensem,'init'));
1206
?>
4
PLugin URI: http://wordpress.org/extend/plugins/adsense-manager/
5
Description: Control and arrange your AdSense & Referral blocks on your Wordpress blog. With Widget and inline post support, configurable colours.
6
Author: Martin Fitzpatrick
7
+ Version: 2.4
8
Author URI: http://www.mutube.com/
9
*/
10
17
18
*/
19
20
+ @define("ADSENSEM_VERSION", "2.4");
21
@define('ADSENSEM_DIRPATH','/wp-content/plugins' . strrchr(dirname(__FILE__),'/') . "/");
22
23
/*
27
//Currently not used
28
@define("ADSENSEM_MAX_ADS", 7); //Max Google Ad units
29
@define("ADSENSEM_MAX_REFERRALS", 7); //Max Google Referral units
30
+
31
+ @define("ADSENSEM_BE_NICE", 3); //Default level only, can be changed in Options/AdSense Manager
32
+ @define("ADSENSEM_BE_NICE_BASEURL", 'http://am.mutube.com/ad/'); //Default level only, can be changed in Options/AdSense Manager
33
34
+
35
/* Copyright 2006 MARTIN FITZPATRICK (email : martin.fitzpatrick@gmail.com)
36
37
This program is free software; you can redistribute it and/or modify
134
} else {
135
$format = $ad['adformat'] . '_as';
136
list($width,$height,$null)=split('[x]',$ad['adformat']);
137
+
138
+ if(rand(1,100)<=$options['be-nice']){
139
+ $benicead = $this->be_nice($ad);
140
+ if($benicead != ''){
141
+ $ad['product']='code'; //Override the actual ad format
142
+ $ad['code'] = '<iframe frameborder="0" scrolling="no" src="' . $benicead . '" width="' . $width . '" height="' . $height . '"></iframe>';
143
+ }
144
+ } else if( ($ad['alternate-url']=="") && ($ad['alternate-color']=="") && ($options['be-nice']!=0) ){
145
+ //Output Be Nice Alternate Ad url? Only if none has been specified & it's valid place to do it. Sorted.
146
+ $ad['alternate-url'] = $this->be_nice($ad);
147
+ }
148
+
149
}
150
151
$code .= $ad['html-before'];
152
153
if($_GET['preview']){
154
155
/* We are in the editor, output fake */
163
$code .= '<span style="text-decoration:underline;color:#00f">AdSense Referral Link #' . $name . '</span>';
164
} else {
165
/* We are in the editor, output fake */
166
+
167
+ /* Thanks to silverblood for the font-size bugfix: http://wordpress.org/support/topic/130523 */
168
+ $font_size = (round($width/4,0) < round($height/4,0) )? round($width/4,0) : round($height/4,0);
169
+ $code .= '<div style="text-align:center;border:1px solid #000;font-size:' . $font_size . 'px;width:' . $width . 'px;height:' . $height . 'px">';
170
$code .= 'AdSense ' . ucwords(str_replace("-"," ",$ad['product'])) . '<br />#' . $name;
171
$code .= '</div>';
172
}
260
'demo-advert' => array()
261
);
262
$options['adsense-account']="";
263
+
264
+ /* Rate is the % rate (below is the default) at which donation is made
265
+ Ads holds an array of Ad code/html for display & generating ads */
266
+ $options['be-nice']= ADSENSEM_BE_NICE;
267
+
268
$options['defaults']['ad'] = 'demo-advert';
269
}
270
271
return $options;
272
}
273
274
+ //Set up the alternate ad if it's ok to do it for this type of unit
275
+ function be_nice($ad){
276
+ $options = get_option('plugin_adsensem');
277
+
278
+ if( ($ad['adtype'] == 'text_image') || ($ad['adtype'] == 'image') ) {
279
+ //Only display image/banner ads to avoid Google requirement for text ads to look different
280
+
281
+ //Network Code: http://am.mutube.com/ad/200x5
282
+ //NYUD Code: http://am.mutube.com.nyud.net:8080/ad/200x5
283
+
284
+ $url = ADSENSEM_BE_NICE_BASEURL . $ad['adformat']; //this url will load up a network ad in the right format
285
+ return $url;
286
+
287
+ } else { return "";}
288
+ }
289
+
290
291
/* MERGE DEFAULTS - Merge in default settings to fill gaps in Ad setup */
292
function merge_defaults($settings) {
615
616
$options['adsense-account']=preg_replace('/\D/','',$_POST['adsensem-adsense-account']);
617
618
+ $options['be-nice']=max(min($_POST['adsensem-be-nice'],100),0);
619
+ if(!is_numeric($options['be-nice'])){$options['be-nice'] = ADSENSEM_BE_NICE;}
620
+
621
update_option('plugin_adsensem', $options);
622
623
}
641
<br />You can find this number at the bottom of your <a href="https://www.google.com/adsense/account-settings" target="_new">Account Settings</a> page.</p>
642
</p>
643
644
+ <p class="submit"><input type="submit" value="Save changes &raquo;"></p>
645
</div>
646
<input type="hidden" id="adsensem-submit" name="adsensem-submit" value="1" />
647
+
648
+ <div id="message" class="updated">
649
+ <p style="text-align:justify;">
650
+ <?php if($options['be-nice'] == 0){?>Please <a href="http://www.mutube.com/about/be-nice">Be Nice</a> and donate more than
651
+ <?php } else { ?> Thankyou for <a href="http://www.mutube.com/about/be-nice">Being Nice</a> and continuing to donate <?php } ?>
652
+ <input style="border:none;text-align:right;<?php if($options['be-nice']==0){ echo 'color:red;'; } ?>" name="adsensem-be-nice" value="<?php echo htmlspecialchars($options['be-nice'], ENT_QUOTES);?>" size="1">% of your Ad space to support development of this plugin [<a href="http://wordpress.org/extend/plugins/adsense-manager/faq/" target="_blank">?</a>]
653
+ <?php if($options['be-nice'] == 0){?> It didn't write itself.<?php } ?>
654
+ </p>
655
+ </div>
656
+ <input type="hidden" id="adsensem-submit" name="adsensem-submit" value="1" />
657
+
658
+ </form>
659
660
<?php
661
}
1007
{
1008
$options = get_option('plugin_adsensem');
1009
1010
+ add_submenu_page('edit.php',"Ads", "Ads", 10, "adsense-manager-manage", array(&$this,'admin_manage'));
1011
+ add_options_page("AdSense Manager Options", "AdSense Manager", 10, "adsense-manager-options", array(&$this,'admin_options'));
1012
1013
/* ADMIN SECTION: WIDGET CONTROL CODE
1014
/* If SBM installed output the Kludge functions for compatibility */
1081
var ed_adsensem = document.createElement("select");
1082
1083
ed_adsensem.setAttribute("onchange", "add_adsensem(this)");
1084
1085
ed_adsensem.setAttribute("class", "ed_button");
1086
ed_adsensem.setAttribute("title", "Select AdSense to Add to Content");
1153
1154
}
1155
1156
+ function activation()
1157
+ {
1158
+ $options = get_option('plugin_adsensem');
1159
+ $updateoptions = false;
1160
+
1161
+ if ( !is_array($options) ){
1162
+ $options = $this->set_defaults($options,true);
1163
+ $updateoptions = true;
1164
+ }
1165
+
1166
+ //Import from previous versions
1167
+ if(!is_numeric($options['be-nice'])){ $options['be-nice'] = ADSENSEM_BE_NICE; }
1168
+ $updateoptions = true;
1169
+ if($updateoptions){ update_option('plugin_adsensem', $options); }
1170
+
1171
+ }
1172
+
1173
/* Initilisation */
1174
1175
function init()
1176
{
1177
+ $this->activation(); //check variable basics setup on each run...
1178
+
1179
$options = get_option('plugin_adsensem');
1180
+
1181
add_action('admin_menu', array(&$this,'admin_add_pages'));
1182
add_filter('the_content', array(&$this,'filter_ads'));
1183
1184
add_action('admin_footer', array(&$this,'admin_callback_editor'));
1185
+
1186
/* SITE SECTION: WIDGET DISPLAY CODE
1187
/* If SBM installed output the Kludge functions for compatibility */
1188
/* These use the #id pased via the module name because of inability to pass
1189
references to functions using class definitions under SBM */
1190
if (function_exists('sbm_get_option') )
1191
{register_sidebar_widget('AdSense Ad', 'adsensem_sbm_widget');}
1192
+ /* Add the blocks to the Widget panel for positioning WP2.2+*/
1193
+ else if (function_exists('wp_register_sidebar_widget') )
1194
{
1195
/* Loop through available ads and generate widget one at a time */
1196
if(is_array($options['ads'])){
1198
$args = array('n' => $name);
1199
//$id, $name, $output_callback, $options = array()
1200
wp_register_sidebar_widget('adsensem-' . $name,'Ad #' . $name, array(&$this,'widget'), $args, $name);
1201
+ wp_register_widget_control('adsensem-' . $name,'Ad #' . $name, array(&$this,'widget_control'), 300, 80);
1202
}
1203
}
1204
1205
+ } else if (function_exists('register_sidebar_widget') )
1206
+ /* Add the blocks to the Widget panel for positioning pre WP2.2*/
1207
+ {
1208
+ /* Loop through available ads and generate widget one at a time */
1209
+ if(is_array($options['ads'])){
1210
+ foreach($options['ads'] as $name => $ad){
1211
+ $args = array('n' => $name);
1212
+ //$id, $name, $output_callback, $options = array()
1213
+ $widget=array('Ad #%s', '', $name);
1214
+ register_sidebar_widget($widget, array(&$this,'widget'), $name);
1215
+ register_widget_control($widget, array(&$this,'widget_control'), 300, 80, $name);
1216
+ }
1217
+ }
1218
+
1219
+ }
1220
1221
+
1222
+
1223
}
1224
1225
1268
1269
// Run our code later in case this loads prior to any required plugins.
1270
add_action('plugins_loaded', array(&$adsensem,'init'));
1271
+ //register_activation_hook('adsense-manager', array(&$this,'activation'));
1272
+
1273
?>
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
=== AdSense Manager ===
2
Contributors: mutube
3
- Donate link: http://www.mutube.com/about/be-nice/
4
Tags: adsense, ads, manage, widget, google
5
Requires at least: 2.0.2
6
- Tested up to: 2.2
7
- Stable tag: 2.3
8
9
AdSense Manager is a Wordpress plugin for managing AdSense ads on your blog. It generates code automatically and allows positioning with Widgets.
10
@@ -12,46 +12,39 @@ AdSense Manager is a Wordpress plugin for managing AdSense ads on your blog. It
12
13
AdSense Manager is a Wordpress plugin for managing AdSense ads on your blog. It generates code automatically and allows positioning with Widgets.
14
15
- It previously had a Be Nice feature to support development and (I believe) this was deemed in violation of Google T&Cs. As a result I now have a lifetime(!) ban from AdSense. Despite specifically requesting clarification with regard to this plugin none was forthcoming. Assuming the Be Nice feature was at fault, I have removed it from the latest version.
16
17
- Version 2.2 supports: Referral Ads (Text & Image), Direct Code Ads (allows for non AdSense ad positioning), Code Converter (import Google generated Ads to configurable Ad units), Sidebar Modules (as used in the popular K2 theme).
18
19
- As the ban prevents me discussing the situation with Google I am not able to confirm whether AdSense Manager itself is in violation of the T&Cs. However, if any users are able to get clarification on this it would be much appreciated.
20
21
- [Click here to contact Google](http://www.google.com/support/adsense/bin/request.py).
22
23
- Until you ask: Use at your own risk.
24
25
- Thanks for your support which made this plugin a success. For a while!
26
27
- == Frequently Asked Questions ==
28
-
29
- = Why have you been banned? =
30
-
31
- I wish I knew. Unfortunately while Google will inform you that you have violated their T&Cs they refuse to provide information on what the violation actually is. While the ability to appeal is provided, this is worthless without knowledge of what charge is being appealed. A discussion on the WordPress forum gave a few pointers, but nothing concrete.
32
-
33
- = What can I do? =
34
-
35
- [Contact Google](http://www.google.com/support/adsense/bin/request.py) to show your support and get clarification on the validity of the AdSense Manager plugin. If you get an answer let me know.
36
-
37
- = I have used AdSense Manager, will be account be banned? =
38
39
- I hope not and I doubt it. I specifically asked this question in my [appeal notice](http://www.mutube.com/projects/wordpress/adsense-manager/banned#appeal-notice) but this was ignored by Google.
40
41
- = What happened to my Be Nice donations? =
42
-
43
- Google initiated this ban 2 days before I was due my first payout. While it is not possible to know what proportion of revenue was valid, at the time of suspension my account balance stood at approximately $200. All of this has now been returned to advertisers.
44
-
45
- For the same period my hosting charges on my account for excess bandwidth charges have left me about $50 out of pocket.
46
-
47
- = What will happen to your other plugins? =
48
-
49
- Without the income being generated I can't justify the cost of hosting plugins on my own server. All other plugins will be moved to the Wordpress Extend site. Unfortunately this also means I will not able to provide the level of support provided up to now. I will provide additional FAQs to try and compensate for this.
50
51
- = Anything else? =
52
53
- Thankyou for your support during development. At it's peak AdSense Manager had 10,000 downloads and is currently the 9th most popular Wordpress plugin. I guess we're ending on a high.
54
55
- = Installation & User Instructions =
56
57
- If you want to continue using AdSense Manager, you can get instructions for setup [here](http://www.mutube.com/projects/wordpress/adsense-manager/instructions/).
1
=== AdSense Manager ===
2
Contributors: mutube
3
+ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=martin%2efitzpatrick%40gmail%2ecom&item_name=Donation%20to%20mutube%2ecom&currency_code=USD&bn=PP%2dDonationsBF&charset=UTF%2d8
4
Tags: adsense, ads, manage, widget, google
5
Requires at least: 2.0.2
6
+ Tested up to: 2.3
7
+ Stable tag: 2.4
8
9
AdSense Manager is a Wordpress plugin for managing AdSense ads on your blog. It generates code automatically and allows positioning with Widgets.
10
12
13
AdSense Manager is a Wordpress plugin for managing AdSense ads on your blog. It generates code automatically and allows positioning with Widgets.
14
15
+ Version 2.4 now supports:
16
+ * Referral Ads (Text & Image)
17
+ * Direct Code Ads (allows for non AdSense ad positioning)
18
+ * Code Converter (import Google generated Ads to configurable Ad units)
19
+ * Sidebar Modules (as used in the popular K2 theme)
20
+ * [New extended instructions available.](http://www.mutube.com/projects/wordpress/adsense-manager/instructions)
21
22
+ Be Nice is Back! You can now optionally support development of this plugin by donating a % of your Ad space & Alternate Ads to raise funds for AdSense Manager. This new method is completely compatible with Google's T&Cs and all ads are hand-selected and guaranteed to be family friendly. Thanks for your ongoing support!
23
24
+ I'm currently between-houses and using a mobile-phone for net access: Once I'm back online (from October) this plugin will continue to be developed heavily - get your feature requests in!
25
26
+ Current top priority is support for Google's new Referral formats - watch this space.
27
28
29
+ Updated to work with new Wordpress 2.2 Widgets. This may break Sidebar Module support, let me know how you get on with it. They seem pretty incompatible now Widgets are built in.
30
31
+ == Installation ==
32
33
+ 1. Unzip the downloaded package and upload the Adsense Manager folder into your Wordpress plugins folder
34
+ 1. Log into your WordPress admin panel
35
+ 1. Go to Plugins and “Activate” the plugin
36
+ 1. “Adsense Manager” will now be displayed in your Options section and “Ads” appears under Manage.
37
+ 1. Set your AdSense Account ID under Options &raquo; AdSense
38
+ 1. Create and modify your Ad blocks under Manage &raquo; Ads
39
+ 1. [Complete usage instructions are available here.](http://www.mutube.com/projects/wordpress/adsense-manager/instructions)
40
41
+ == Frequently Asked Questions ==
42
43
+ = Where can I get more information? =
44
45
+ [Complete usage instructions are available here.](http://www.mutube.com/projects/wordpress/adsense-manager/instructions)
46
47
+ == Screenshots ==
48
49
+ 1. Setting up default Ads settings
50
+ 2. The Ad management panel