AdSense Manager - Version 4.0.3

Version Description

Download this release

Release Info

Developer Tzafrir@komoona.com
Plugin Icon wp plugin AdSense Manager
Version 4.0.3
Comparing to
See all releases

Code changes from version 4.0.2 to 4.0.3

Files changed (4) hide show
  1. adsense-manager.php +67 -58
  2. class-admin.php +32 -23
  3. images/favicon.ico +0 -0
  4. readme.txt +1 -1
adsense-manager.php CHANGED
@@ -4,10 +4,10 @@ Plugin Name: AdSense Manager
4
  PLugin URI: http://wordpress.org/extend/plugins/adsense-manager/
5
  Description: AdSense Manager lets you manage your ads from within WordPress. With support for AdSense, AdBrite and many more.
6
  Author: Martin Fitzpatrick
7
- Version: 4.0.2
8
  Author URI: http://www.mutube.com/
9
  */
10
- @define("ADSENSEM_VERSION", "4.0.2");
11
 
12
  @define("AM_BRAND_NAME", "AdSense Manager");
13
  @define("AM_BRAND_DEFAULT_NETWORK", "AdSense");
@@ -143,11 +143,11 @@ class adsensem {
143
 
144
  /* Default Ad widget */
145
  if(is_object($_adsensem['ads'][$_adsensem['default-ad']])){ adsensem::register_widget('default-ad',$args); }
146
-
147
  /* Loop through available ads and generate widget one at a time */
148
  if(is_array($_adsensem['ads'])){
149
  foreach($_adsensem['ads'] as $name => $ad){
150
- $args = array('name' => $name, 'height' => 80, 'width' => 300);
151
  adsensem::register_widget($name,$args);
152
  }
153
  }
@@ -157,58 +157,18 @@ class adsensem {
157
 
158
  function register_widget($name,$args){
159
 
160
- if(function_exists('wp_register_sidebar_widget')){
 
 
 
161
  //$id, $name, $output_callback, $options = array()
162
- wp_register_sidebar_widget('adsensem-' . $name,"Ad#$name", array('adsensem','widget'),$args,$name);
163
- wp_register_widget_control('adsensem-' . $name,"Ad#$name", array('adsensem','widget_control'), $args,$name);
164
- } else if (function_exists('register_sidebar_module') ){
165
- register_sidebar_module('Ad #' . $name, 'adsensem_sbm_widget', 'adsensem-' . $name, $args );
166
- register_sidebar_module_control('Ad #' . $name, array('adsensem','widget_control'), 'adsensem-' . $name);
167
  }
168
  }
169
 
170
 
171
- // This is the function that outputs adsensem widget.
172
- function widget($args,$n='') {
173
- // $args is an array of strings that help widgets to conform to
174
- // the active theme: before_widget, before_title, after_widget,
175
- // and after_title are the array keys. Default tags: li and h2.
176
- extract($args); //nb. $name comes out of this, hence the use of $n
177
- global $_adsensem;
178
-
179
- //If name not passed in (Sidebar Modules), extract from the widget-id (WordPress Widgets)
180
- if($n==''){ $n=substr($args['widget_id'],9); } //Chop off beginning adsensem- bit
181
- if($n!=='default-ad'){$ad = $_adsensem['ads'][$n];} else {$ad = $_adsensem['ads'][$_adsensem['default-ad']];}
182
-
183
- if($ad->show_ad_here()){
184
- echo $before_widget;
185
- if($ad->title!=''){ echo $before_title . $ad->title . $after_title; }
186
- echo $ad->get_ad(); //Output the selected ad
187
- echo $after_widget;
188
- $ad->counter_click();
189
- }
190
-
191
- }
192
 
193
- /* Widget admin block for each Ad element on the page, allows
194
- movement of them around the sidebar */
195
- function widget_control($name)
196
- {
197
- global $_adsensem;
198
-
199
- if ( $_POST['adsensem-' . $name . '-submit'] ) {
200
- global $_adsensem;
201
- // Remember to sanitize and format use input appropriately.
202
- $_adsensem['ads'][$name]->title = strip_tags(stripslashes($_POST['adsensem-' . $name . '-title']));
203
- update_option('plugin_adsensem', $_adsensem);
204
- }
205
-
206
- ?>
207
- <label for="adsensem-<?php echo $name; ?>-title" >Title:</label><input style="width: 200px;" id="adsensem-<?php echo $name; ?>-title" name="adsensem-<?php echo $name; ?>-title" type="text" value="<?php echo htmlspecialchars($_adsensem['ads'][$name]->title, ENT_QUOTES);?>" />
208
- <input type="hidden" name="adsensem-<?php echo $name; ?>-submit" value="1">
209
- <?php
210
-
211
- }
212
 
213
  function footer(){
214
  ?><!-- AdSense Manager v<?php echo ADSENSEM_VERSION;?> (<?php timer_stop(1); ?> seconds.) --><?php
@@ -251,10 +211,67 @@ class adsensem {
251
 
252
 
253
 
 
 
 
 
 
 
254
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
255
 
 
256
 
 
 
 
 
 
 
257
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
 
259
 
260
 
@@ -309,14 +326,6 @@ switch ($_POST['adsensem-mode'].':'.$_POST['adsensem-action']){
309
 
310
 
311
 
312
- /* SIDEBAR MODULES COMPATIBILITY FUNCTION */
313
- function adsensem_sbm_widget($args){
314
- global $k2sbm_current_module;
315
- adsensem::widget($args,$k2sbm_current_module->options['name']);
316
- }
317
- /* SIDEBAR MODULES COMPATIBILITY FUNCTION */
318
-
319
-
320
  add_action('plugins_loaded', array('adsensem','init'), 1);
321
  add_action('admin_menu', array('adsensem','init_admin'));
322
 
4
  PLugin URI: http://wordpress.org/extend/plugins/adsense-manager/
5
  Description: AdSense Manager lets you manage your ads from within WordPress. With support for AdSense, AdBrite and many more.
6
  Author: Martin Fitzpatrick
7
+ Version: 4.0.3
8
  Author URI: http://www.mutube.com/
9
  */
10
+ @define("ADSENSEM_VERSION", "4.0.3");
11
 
12
  @define("AM_BRAND_NAME", "AdSense Manager");
13
  @define("AM_BRAND_DEFAULT_NETWORK", "AdSense");
143
 
144
  /* Default Ad widget */
145
  if(is_object($_adsensem['ads'][$_adsensem['default-ad']])){ adsensem::register_widget('default-ad',$args); }
146
+
147
  /* Loop through available ads and generate widget one at a time */
148
  if(is_array($_adsensem['ads'])){
149
  foreach($_adsensem['ads'] as $name => $ad){
150
+ #$args = array('name' => $name, 'height' => 80, 'width' => 300);
151
  adsensem::register_widget($name,$args);
152
  }
153
  }
157
 
158
  function register_widget($name,$args){
159
 
160
+ if(function_exists('register_widget')){
161
+
162
+ $ad_widget = new AdSenseMWidget($_adsensem['ads']['name']);
163
+
164
  //$id, $name, $output_callback, $options = array()
165
+ register_widget('AdSenseMWidget');
166
+ #register_widget_control('adsensem-' . $name,"Ad#$name", array('adsensem','widget_control'), $args,$name);
 
 
 
167
  }
168
  }
169
 
170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
 
173
  function footer(){
174
  ?><!-- AdSense Manager v<?php echo ADSENSEM_VERSION;?> (<?php timer_stop(1); ?> seconds.) --><?php
211
 
212
 
213
 
214
+ class AdSenseMWidget extends WP_Widget {
215
+
216
+ function __construct() {
217
+ $widget_ops = array('classname' => 'widget_adsensem', 'description' => __('Show your AdSense Manager ads'));
218
+ parent::__construct('adsense-manager', __('AdSense Manager'), $widget_ops);
219
+ }
220
 
221
+ function widget( $args, $instance ) {
222
+ // $args is an array of strings that help widgets to conform to
223
+ // the active theme: before_widget, before_title, after_widget,
224
+ // and after_title are the array keys. Default tags: li and h2.
225
+ global $_adsensem;
226
+
227
+ extract($args);
228
+ $ad = $_adsensem['ads'][ $instance['ad'] ];
229
+
230
+ if($ad->show_ad_here()){
231
+
232
+ $title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
233
+ $text = apply_filters( 'widget_text', $instance['text'], $instance );
234
+ echo $before_widget;
235
+ if($title!=''){ echo $before_title . $title . $after_title; }
236
+ echo $ad->get_ad(); //Output the selected ad
237
+ echo $after_widget;
238
+ $ad->counter_click();
239
+ }
240
+ echo $after_widget;
241
 
242
+ }
243
 
244
+ function update( $new_instance, $old_instance ) {
245
+ $instance = $old_instance;
246
+ $instance['title'] = strip_tags($new_instance['title']);
247
+ $instance['ad'] = strip_tags($new_instance['ad']);
248
+ return $instance;
249
+ }
250
 
251
+ function form( $instance ) {
252
+ global $_adsensem;
253
+
254
+ $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) );
255
+ $i_title = strip_tags($instance['title']);
256
+ $i_ad = strip_tags($instance['ad']);
257
+
258
+ ?>
259
+ <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
260
+ <input id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($i_title); ?>" /></p>
261
+ <p><label for="<?php echo $this->get_field_id('ad'); ?>"><?php _e( 'Ad unit:' ); ?></label>
262
+ <select style="width: 200px;" id="<?php echo $this->get_field_id('ad'); ?>" name="<?php echo $this->get_field_name('ad'); ?>" class="widefat">
263
+ <?php
264
+ if(is_array($_adsensem['ads'])){
265
+ foreach($_adsensem['ads'] as $name => $ad){
266
+ ?><option value="<?php echo $name ?>" <?php selected( $i_ad, $name ); ?>><?php echo $name ?></option><?php
267
+ }
268
+ }
269
+ ?>
270
+ </select></p>
271
+ <?php
272
+
273
+ }
274
+ }
275
 
276
 
277
 
326
 
327
 
328
 
 
 
 
 
 
 
 
 
329
  add_action('plugins_loaded', array('adsensem','init'), 1);
330
  add_action('admin_menu', array('adsensem','init_admin'));
331
 
class-admin.php CHANGED
@@ -306,11 +306,8 @@ class adsensem_admin {
306
 
307
  // Get our options and see if we're handling a form submission.
308
  global $_adsensem, $_adsensem_networks;
309
-
310
  $update_adsensem=false;
311
- ;
312
- /* Submissions from the manage ads listing at the top of the page */
313
- //if ( $_POST['adsensem-submit']=='manage' ) {
314
  switch ($_POST['adsensem-mode'].':'.$_POST['adsensem-action']){
315
 
316
  case 'manage:copy unit':
@@ -335,6 +332,17 @@ class adsensem_admin {
335
  $_adsensem['default-ad']=$_POST['adsensem-default-name'];
336
  $update_adsensem=true;
337
  break;
 
 
 
 
 
 
 
 
 
 
 
338
 
339
  case 'save:edit new':
340
  $name=adsensem_admin::validate_name($_POST['adsensem-name']);
@@ -392,10 +400,13 @@ class adsensem_admin {
392
  break;
393
 
394
  case 'manage:edit unit': //Pass through stuff to switch modes between pages.
 
395
  case 'import:edit new':
396
  $_POST['adsensem-mode']='edit';
397
  break;
398
 
 
 
399
  default:
400
  $_POST['adsensem-mode']='manage';
401
  $_POST['adsensem-action']='';
@@ -463,17 +474,16 @@ class adsensem_admin {
463
  <?php if ($_adsensem_networks[$network]['www']!=''){ ?></a><?php } else { ?></span><?php } ?></td>
464
 
465
  <?php
466
- if($defaults['adformat']){?><td style="width:100px;text-align:center;"><?php echo htmlspecialchars($defaults['adformat'], ENT_QUOTES); ?><br /><?php echo htmlspecialchars($defaults['linkformat'], ENT_QUOTES); ?></td><?php } else { ?><td></td><?php }
467
 
468
- if(($defaults['slot'])||($defaults['channel'])){?><td style="text-align:center"><?php echo htmlspecialchars($defaults['slot'], ENT_QUOTES); ?><?php echo htmlspecialchars($defaults['channel'], ENT_QUOTES); ?></td><?php } else { ?><td></td><?php } ?>
469
 
470
- <td colspan="5"></td>
471
-
472
  <?php
473
-
474
- if($defaults['alternate-ad']){?><td style="text-align:center"><?php echo htmlspecialchars($defaults['alternate-ad'], ENT_QUOTES); ?></td><?php } else { ?><td></td><?php } ?>
475
- <td></td>
476
- <td class="network_admin" style="width:10px;" colspan="2"><?php if($_adsensem_networks[$network]['www-create']){?><a href="<?php echo $_adsensem_networks[$network]['www-create']; ?>" target="_blank" style="font-weight:normal;">Create New Ad...</a><?php } ?></td><td></td>
477
  </tr>
478
  <?php
479
  }
@@ -605,14 +615,21 @@ Note that the old <code>&lt;!--adsense#name--&gt;</code> style still works if yo
605
  // Get our options and see if we're handling a form submission.
606
  global $_adsensem, $_adsensem_networks;
607
 
608
-
609
  ?>
610
  <div class="wrap">
611
-
612
  <form action="#adsensem-config" method="post" id="adsensem-config" enctype="multipart/form-data">
613
 
614
  <?php //Default options for all situations
615
- if ($_POST['adsensem-action']=='edit unit'){
 
 
 
 
 
 
 
 
616
 
617
  $ad=$_adsensem['ads'][$_POST['adsensem-action-target']];
618
  $ad->name=$_POST['adsensem-action-target'];
@@ -678,18 +695,10 @@ Note that the old <code>&lt;!--adsense#name--&gt;</code> style still works if yo
678
 
679
  if ( $_POST['adsensem-submit'] ) {
680
 
681
- //$_adsensem['adsense-account']=preg_replace('/\D/','',$_POST['adsensem-adsense-account']);
682
-
683
- $_adsensem['be-nice']=max(min($_POST['adsensem-be-nice'],100),0);
684
- if(!is_numeric($_adsensem['be-nice'])){$_adsensem['be-nice'] = ADSENSEM_BE_NICE;}
685
-
686
  update_option('plugin_adsensem', $_adsensem);
687
 
688
  }
689
 
690
- // Here is our little form segment. Notice that we don't need a
691
- // complete form. This will be embedded into the existing form.
692
-
693
  ?>
694
 
695
  <div class="wrap">
306
 
307
  // Get our options and see if we're handling a form submission.
308
  global $_adsensem, $_adsensem_networks;
 
309
  $update_adsensem=false;
310
+
 
 
311
  switch ($_POST['adsensem-mode'].':'.$_POST['adsensem-action']){
312
 
313
  case 'manage:copy unit':
332
  $_adsensem['default-ad']=$_POST['adsensem-default-name'];
333
  $update_adsensem=true;
334
  break;
335
+
336
+ case 'save:edit defaults':
337
+ $temp = new $_POST['adsensem-action-target']; //temporary to access network-specific functions
338
+ $temp->save_settings();
339
+
340
+ $_adsensem['defaults'][$_POST['adsensem-action-target']]=$temp->p;
341
+
342
+ $_POST['adsensem-mode']='manage';
343
+ $_POST['adsensem-action']='';
344
+ $update_adsensem=true;
345
+ break;
346
 
347
  case 'save:edit new':
348
  $name=adsensem_admin::validate_name($_POST['adsensem-name']);
400
  break;
401
 
402
  case 'manage:edit unit': //Pass through stuff to switch modes between pages.
403
+ case 'manage:edit defaults':
404
  case 'import:edit new':
405
  $_POST['adsensem-mode']='edit';
406
  break;
407
 
408
+
409
+
410
  default:
411
  $_POST['adsensem-mode']='manage';
412
  $_POST['adsensem-action']='';
474
  <?php if ($_adsensem_networks[$network]['www']!=''){ ?></a><?php } else { ?></span><?php } ?></td>
475
 
476
  <?php
477
+ if($defaults['adformat']){?><td style="width:100px;text-align:center;"><?php echo htmlspecialchars($defaults['adformat'], ENT_QUOTES); ?><br /><?php echo htmlspecialchars($defaults['linkformat'], ENT_QUOTES); ?></td><?php } else { ?><td>&nbsp;</td><?php }
478
 
479
+ if(($defaults['slot'])||($defaults['channel'])){?><td style="text-align:center"><?php echo htmlspecialchars($defaults['slot'], ENT_QUOTES); ?><?php echo htmlspecialchars($defaults['channel'], ENT_QUOTES); ?></td><?php } else { ?><td>&nbsp;</td><?php } ?>
480
 
481
+ <td colspan="5">&nbsp;</td>
 
482
  <?php
483
+ if($defaults['alternate-ad']){?><td style="text-align:center"><?php echo htmlspecialchars($defaults['alternate-ad'], ENT_QUOTES); ?></td><?php } else { ?><td>&nbsp;</td><?php } ?>
484
+ <td>&nbsp;</td>
485
+ <td><input class="button" name="adsensem-edit" type="submit" value="Edit Defaults" onClick="document.getElementById('adsensem-action').value='edit defaults'; document.getElementById('adsensem-action-target').value='<?php echo $network?>';" title="Edit Defaults for <?php echo $_adsensem_networks[$network]['name']; ?> units"></td>
486
+ <td class="network_admin" style="width:10px;" colspan="2"><?php if($_adsensem_networks[$network]['www-create']){?><a href="<?php echo $_adsensem_networks[$network]['www-create']; ?>" target="_blank" style="font-weight:normal;">Create New Ad...</a><?php } ?>
487
  </tr>
488
  <?php
489
  }
615
  // Get our options and see if we're handling a form submission.
616
  global $_adsensem, $_adsensem_networks;
617
 
 
618
  ?>
619
  <div class="wrap">
620
+
621
  <form action="#adsensem-config" method="post" id="adsensem-config" enctype="multipart/form-data">
622
 
623
  <?php //Default options for all situations
624
+ if($_POST['adsensem-action']=='edit defaults'){
625
+
626
+ $ad=new $_POST['adsensem-action-target']; //Create temporary ad unit to access functions
627
+ $ad->p=$_adsensem['defaults'][$_POST['adsensem-action-target']]; //Load defaults into temporary ad
628
+
629
+ ?><h2>Edit Default Settings for '<span class="<?php echo $ad->network();?>"><?php echo $_adsensem_networks[$_POST['adsensem-action-target']]['name']; ?></span>' units</h2>
630
+ <p>Edit the default settings for your ads below.</p><?php
631
+
632
+ } else if ($_POST['adsensem-action']=='edit unit'){
633
 
634
  $ad=$_adsensem['ads'][$_POST['adsensem-action-target']];
635
  $ad->name=$_POST['adsensem-action-target'];
695
 
696
  if ( $_POST['adsensem-submit'] ) {
697
 
 
 
 
 
 
698
  update_option('plugin_adsensem', $_adsensem);
699
 
700
  }
701
 
 
 
 
702
  ?>
703
 
704
  <div class="wrap">
images/favicon.ico ADDED
Binary file
readme.txt CHANGED
@@ -3,7 +3,7 @@ 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, ad, link, referral, manage, widget, google, adbrite, cj, adpinion, shoppingads, ypn, widgetbucks
5
  Requires at least: 3.0.0
6
- Stable tag: 4.0.2
7
 
8
  AdSense Manager lets you manage your ads from within WordPress. With support for AdSense, AdBrite and many more.
9
 
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, ad, link, referral, manage, widget, google, adbrite, cj, adpinion, shoppingads, ypn, widgetbucks
5
  Requires at least: 3.0.0
6
+ Stable tag: 4.0.3
7
 
8
  AdSense Manager lets you manage your ads from within WordPress. With support for AdSense, AdBrite and many more.
9