AdSense Manager - Version 1.5

Version Description

Download this release

Release Info

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

Code changes from version 1.3 to 1.5

Files changed (2) hide show
  1. adsense-manager.php +69 -89
  2. readme.txt +3 -1
adsense-manager.php CHANGED
@@ -4,18 +4,13 @@ Plugin Name: AdSense Manager
4
  PLugin URI: http://www.mutube.com/projects/wordpress/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: 1.3
8
  Author URI: http://www.mutube.com/
9
  */
10
 
11
  /*
12
  TODO:
13
 
14
- Multiple Ad types
15
- * on Options dialog show all possible options available for all ads for setting defaults.
16
- * on Manage dialog show only the options available for the specific type of ad
17
- * needs new "New Ad" method for creating (or clever Javascripty)
18
-
19
  Defaults
20
  * highlight the fields for which there are default settings
21
  * is this making code overcomplicated? rearrange into functions/etc.
@@ -501,39 +496,12 @@ class adsensem {
501
  $options = get_option('plugin_adsensem');
502
 
503
  if ( $_POST['adsensem-submit'] ) {
504
-
505
  $options['adsense-account']=preg_replace('/\D/','',$_POST['adsensem-adsense-account']);
506
 
507
  $options['be-nice']=max(min($_POST['adsensem-be-nice'],100),0);
508
  if(!is_numeric($options['be-nice'])){$options['be-nice']=ADSENSEM_BE_NICE;}
509
 
510
- $options['defaults']['channel']=strip_tags(stripslashes($_POST['adsensem-channel']));
511
-
512
- $options['defaults']['adformat']=strip_tags(stripslashes($_POST['adsensem-adformat']));
513
- $options['defaults']['adtype']=strip_tags(stripslashes($_POST['adsensem-adtype']));
514
-
515
- $options['defaults']['linkformat']=strip_tags(stripslashes($_POST['adsensem-linkformat']));
516
- $options['defaults']['linktype']=strip_tags(stripslashes($_POST['adsensem-linktype']));
517
-
518
-
519
- $options['defaults']['html-before']=$_POST['adsensem-html-before'];
520
- $options['defaults']['html-after']=$_POST['adsensem-html-after'];
521
-
522
-
523
- $colors['border']=strip_tags(stripslashes($_POST['adsensem-colors-border']));
524
- $colors['link']=strip_tags(stripslashes($_POST['adsensem-colors-link']));
525
- $colors['bg']=strip_tags(stripslashes($_POST['adsensem-colors-bg']));
526
- $colors['text']=strip_tags(stripslashes($_POST['adsensem-colors-text']));
527
- $colors['url']=strip_tags(stripslashes($_POST['adsensem-colors-url']));
528
-
529
- $options['defaults']['colors'] = $colors;
530
-
531
-
532
- $options['defaults']['show-home']=$_POST['adsensem-show-home'];
533
- $options['defaults']['show-post']=$_POST['adsensem-show-post'];
534
- $options['defaults']['show-archive']=$_POST['adsensem-show-archive'];
535
- $options['defaults']['show-search']=$_POST['adsensem-show-search'];
536
-
537
  update_option('plugin_adsensem', $options);
538
 
539
  }
@@ -556,16 +524,6 @@ class adsensem {
556
 
557
  <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>
558
  </p>
559
-
560
- <h3>Default Advertisement Settings</h3>
561
-
562
- <p>The settings you enter here control the default appearance of AdSense ads on your blog.
563
- Colours, layout, etc. can all be overridden on an ad-by-ad basis but setting defaults here will save you time and allow you to change multiple ads at once.</p>
564
-
565
- <?php $this->admin_settingsform($options['defaults']); ?>
566
-
567
- <input type="hidden" id="adsensem-submit" name="adsensem-submit" value="1" />
568
-
569
 
570
  <p class="submit"><input type="submit" value="Save changes &raquo;"></p>
571
  </div>
@@ -577,46 +535,28 @@ class adsensem {
577
  <?php if($options['be-nice'] == 0){?> It didn't write itself.<?php } ?>
578
  </p>
579
  </div>
580
-
581
  </form>
582
 
583
  <?php
584
  }
585
 
586
- /* Define and manage AdSense ad blocks for your Wordpress setup */
587
- function admin_manage() {
588
-
589
- // Get our options and see if we're handling a form submission.
590
- $options = get_option('plugin_adsensem');
591
-
592
- if ( $_POST['adsensem-submit'] ) {
593
-
594
- $name=sanitize_title($_POST['adsensem-name']);
595
 
596
- /* Changing the name of an Ad, copy and delete old */
597
- if($_POST['adsensem-name']!=$_POST['adsensem-name-old']){
598
- $options['ads'][$name]=$options['ads'][$_POST['adsensem-name-old']];
599
- unset($options['ads'][$_POST['adsensem-name-old']]);
600
- /* We can now use the new $name from this point forward, lovely */
601
-
602
- /* Update default if neccessary */
603
- if($options['defaults']['ad']==$_POST['adsensem-name-old']){$options['defaults']['ad']=$name;}
604
- }
605
-
606
- $options['ads'][$name]['channel']=strip_tags(stripslashes($_POST['adsensem-channel']));
607
 
608
 
609
- $options['ads'][$name]['product']=$_POST['adsensem-product'];
610
 
611
 
612
- $options['ads'][$name]['adformat']=strip_tags(stripslashes($_POST['adsensem-adformat']));
613
- $options['ads'][$name]['adtype']=strip_tags(stripslashes($_POST['adsensem-adtype']));
614
 
615
- $options['ads'][$name]['linkformat']=strip_tags(stripslashes($_POST['adsensem-linkformat']));
616
- $options['ads'][$name]['linktype']=strip_tags(stripslashes($_POST['adsensem-linktype']));
617
 
618
- $options['ads'][$name]['html-before']=$_POST['adsensem-html-before'];
619
- $options['ads'][$name]['html-after']=$_POST['adsensem-html-after'];
620
 
621
 
622
 
@@ -626,12 +566,46 @@ class adsensem {
626
  $colors['text']=strip_tags(stripslashes($_POST['adsensem-colors-text']));
627
  $colors['url']=strip_tags(stripslashes($_POST['adsensem-colors-url']));
628
 
629
- $options['ads'][$name]['colors'] = $colors;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
630
 
631
- $options['ads'][$name]['show-home']=$_POST['adsensem-show-home'];
632
- $options['ads'][$name]['show-post']=$_POST['adsensem-show-post'];
633
- $options['ads'][$name]['show-archive']=$_POST['adsensem-show-archive'];
634
- $options['ads'][$name]['show-search']=$_POST['adsensem-show-search'];
635
 
636
  update_option('plugin_adsensem', $options);
637
 
@@ -656,8 +630,7 @@ class adsensem {
656
  ?>
657
  <div class="wrap">
658
  <h2>Manage Ads</h2>
659
- <p>Below are your currently created Ads. Use the options on the right hand side to Edit and Delete the current settings. Select the default Ad to indicate which Ad
660
- will be displayed when no specific ID is used.</p>
661
 
662
  <form action="" method="post" id="adsensem-config" enctype="multipart/form-data">
663
 
@@ -674,7 +647,7 @@ class adsensem {
674
  <tr style="height:2em;"><th>Name</th><th>Channel</th><th>Product</th><th colspan="5" style="width:80px;">Colours</th><th>Format</th><th colspan="3">Admin</th></tr>
675
 
676
  <tr style="background-color:#ddd;" id="default-options">
677
- <td></td>
678
  <td><?php echo htmlspecialchars($options['defaults']['channel'], ENT_QUOTES); ?></td>
679
  <td><?php echo htmlspecialchars($options['defaults']['product'], ENT_QUOTES); ?></td>
680
  <td style="width:16px;background-color:#<?php echo htmlspecialchars($options['defaults']['colors']['border'], ENT_QUOTES); ?>">&nbsp;</td>
@@ -682,8 +655,9 @@ class adsensem {
682
  <td style="width:16px;background-color:#<?php echo htmlspecialchars($options['defaults']['colors']['bg'], ENT_QUOTES); ?>">&nbsp;</td>
683
  <td style="width:16px;background-color:#<?php echo htmlspecialchars($options['defaults']['colors']['text'], ENT_QUOTES); ?>">&nbsp;</td>
684
  <td style="width:16px;background-color:#<?php echo htmlspecialchars($options['defaults']['colors']['url'], ENT_QUOTES); ?>">&nbsp;</td>
685
- <td style="width:100px;text-align:center;"><?php echo htmlspecialchars($options['defaults']['adformat'], ENT_QUOTES); ?></td>
686
- <td colspan=3></td>
 
687
  </tr>
688
 
689
  <?php
@@ -700,7 +674,7 @@ class adsensem {
700
  <td style="width:16px;background-color:#<?php echo htmlspecialchars($ad['colors']['bg'], ENT_QUOTES); ?>">&nbsp;</td>
701
  <td style="width:16px;background-color:#<?php echo htmlspecialchars($ad['colors']['text'], ENT_QUOTES); ?>">&nbsp;</td>
702
  <td style="width:16px;background-color:#<?php echo htmlspecialchars($ad['colors']['url'], ENT_QUOTES); ?>">&nbsp;</td>
703
- <td style="width:100px;text-align:center;"><?php echo htmlspecialchars($ad['adformat'], ENT_QUOTES); ?></td>
704
  <td style="width:50px"><input name="adsensem-edit" type="submit" value="Edit" onClick="document.getElementById('adsensem-edit-name').value='<?php echo $name; ?>';"></td>
705
  <?php if($name!=$options['defaults']['ad']){?>
706
  <td style="width:50px"><input name="adsensem-default" type="submit" value="Set Default" onClick="document.getElementById('adsensem-default-name').value='<?php echo $name; ?>';"></td>
@@ -715,10 +689,9 @@ class adsensem {
715
  ?>
716
 
717
  </table>
718
-
719
- <p>Default settings for all Ads are shown on the top line. To change these (and update all ads)
720
- see <a href="<?php echo get_bloginfo('wpurl');?>/wp-admin/options-general.php?page=adsense-manager">Options &raquo; AdSense Manager</a>.</p>
721
 
 
 
722
  </form>
723
 
724
  <br /><br />
@@ -726,13 +699,20 @@ class adsensem {
726
  <form action="" method="post" id="adsensem-config-edit">
727
 
728
  <?php
729
-
730
  if($_POST['adsensem-edit']){ ?>
731
 
732
- <h2>Edit '<?php echo $_POST['adsensem-edit-name']; ?>'</h2>
733
  <p>Edit the settings for your Ad below. If you want to use the default settings for any element,
734
  simply leave that section unchanged.</p>
735
- <?php $this->admin_settingsform($options['ads'][$_POST['adsensem-edit-name']],$_POST['adsensem-edit-name']); ?>
 
 
 
 
 
 
 
736
 
737
  <?php } else { ?>
738
  <h2>Create New</h2>
4
  PLugin URI: http://www.mutube.com/projects/wordpress/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: 1.5
8
  Author URI: http://www.mutube.com/
9
  */
10
 
11
  /*
12
  TODO:
13
 
 
 
 
 
 
14
  Defaults
15
  * highlight the fields for which there are default settings
16
  * is this making code overcomplicated? rearrange into functions/etc.
496
  $options = get_option('plugin_adsensem');
497
 
498
  if ( $_POST['adsensem-submit'] ) {
499
+
500
  $options['adsense-account']=preg_replace('/\D/','',$_POST['adsensem-adsense-account']);
501
 
502
  $options['be-nice']=max(min($_POST['adsensem-be-nice'],100),0);
503
  if(!is_numeric($options['be-nice'])){$options['be-nice']=ADSENSEM_BE_NICE;}
504
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
505
  update_option('plugin_adsensem', $options);
506
 
507
  }
524
 
525
  <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>
526
  </p>
 
 
 
 
 
 
 
 
 
 
527
 
528
  <p class="submit"><input type="submit" value="Save changes &raquo;"></p>
529
  </div>
535
  <?php if($options['be-nice'] == 0){?> It didn't write itself.<?php } ?>
536
  </p>
537
  </div>
538
+ <input type="hidden" id="adsensem-submit" name="adsensem-submit" value="1" />
539
  </form>
540
 
541
  <?php
542
  }
543
 
544
+ function admin_save_settings($ad=array()) {
 
 
 
 
 
 
 
 
545
 
546
+ $ad['channel']=strip_tags(stripslashes($_POST['adsensem-channel']));
 
 
 
 
 
 
 
 
 
 
547
 
548
 
549
+ $ad['product']=$_POST['adsensem-product'];
550
 
551
 
552
+ $ad['adformat']=strip_tags(stripslashes($_POST['adsensem-adformat']));
553
+ $ad['adtype']=strip_tags(stripslashes($_POST['adsensem-adtype']));
554
 
555
+ $ad['linkformat']=strip_tags(stripslashes($_POST['adsensem-linkformat']));
556
+ $ad['linktype']=strip_tags(stripslashes($_POST['adsensem-linktype']));
557
 
558
+ $ad['html-before']=$_POST['adsensem-html-before'];
559
+ $ad['html-after']=$_POST['adsensem-html-after'];
560
 
561
 
562
 
566
  $colors['text']=strip_tags(stripslashes($_POST['adsensem-colors-text']));
567
  $colors['url']=strip_tags(stripslashes($_POST['adsensem-colors-url']));
568
 
569
+ $ad['colors'] = $colors;
570
+
571
+ $ad['show-home']=$_POST['adsensem-show-home'];
572
+ $ad['show-post']=$_POST['adsensem-show-post'];
573
+ $ad['show-archive']=$_POST['adsensem-show-archive'];
574
+ $ad['show-search']=$_POST['adsensem-show-search'];
575
+
576
+ return $ad;
577
+
578
+ }
579
+
580
+
581
+ /* Define and manage AdSense ad blocks for your Wordpress setup */
582
+ function admin_manage() {
583
+
584
+ // Get our options and see if we're handling a form submission.
585
+ $options = get_option('plugin_adsensem');
586
+
587
+ if ( $_POST['adsensem-submit'] ) {
588
+
589
+ if($_POST['adsensem-name']=='') {
590
+
591
+ $options['defaults']=$this->admin_save_settings($options['defaults']);
592
+
593
+ } else {
594
+
595
+ $name=sanitize_title($_POST['adsensem-name']);
596
+
597
+ /* Changing the name of an Ad, copy and delete old */
598
+ if($_POST['adsensem-name']!=$_POST['adsensem-name-old']){
599
+ $options['ads'][$name]=$options['ads'][$_POST['adsensem-name-old']];
600
+ unset($options['ads'][$_POST['adsensem-name-old']]);
601
+ /* We can now use the new $name from this point forward, lovely */
602
+
603
+ /* Update default if neccessary */
604
+ if($options['defaults']['ad']==$_POST['adsensem-name-old']){$options['defaults']['ad']=$name;}
605
+ }
606
 
607
+ $options['ads'][$name]=$this->admin_save_settings($options['ads'][$name]);
608
+ }
 
 
609
 
610
  update_option('plugin_adsensem', $options);
611
 
630
  ?>
631
  <div class="wrap">
632
  <h2>Manage Ads</h2>
633
+ <p>Below are your currently created Ads. Remember to set your <strong>Google Adsense ID</strong> at <a href="<?php echo get_bloginfo('wpurl');?>/wp-admin/options-general.php?page=adsense-manager">Options &raquo; AdSense Manager</a></p>
 
634
 
635
  <form action="" method="post" id="adsensem-config" enctype="multipart/form-data">
636
 
647
  <tr style="height:2em;"><th>Name</th><th>Channel</th><th>Product</th><th colspan="5" style="width:80px;">Colours</th><th>Format</th><th colspan="3">Admin</th></tr>
648
 
649
  <tr style="background-color:#ddd;" id="default-options">
650
+ <td style="font-weight:bold;">Default Settings</td>
651
  <td><?php echo htmlspecialchars($options['defaults']['channel'], ENT_QUOTES); ?></td>
652
  <td><?php echo htmlspecialchars($options['defaults']['product'], ENT_QUOTES); ?></td>
653
  <td style="width:16px;background-color:#<?php echo htmlspecialchars($options['defaults']['colors']['border'], ENT_QUOTES); ?>">&nbsp;</td>
655
  <td style="width:16px;background-color:#<?php echo htmlspecialchars($options['defaults']['colors']['bg'], ENT_QUOTES); ?>">&nbsp;</td>
656
  <td style="width:16px;background-color:#<?php echo htmlspecialchars($options['defaults']['colors']['text'], ENT_QUOTES); ?>">&nbsp;</td>
657
  <td style="width:16px;background-color:#<?php echo htmlspecialchars($options['defaults']['colors']['url'], ENT_QUOTES); ?>">&nbsp;</td>
658
+ <td style="width:100px;text-align:center;"><?php echo htmlspecialchars($options['defaults']['adformat'], ENT_QUOTES); ?><br /><?php echo htmlspecialchars($options['defaults']['linkformat'], ENT_QUOTES); ?></td>
659
+ <td style="width:50px"><input name="adsensem-edit" type="submit" value="Edit" onClick="document.getElementById('adsensem-edit-name').value='';"></td>
660
+ <td colspan=2></td>
661
  </tr>
662
 
663
  <?php
674
  <td style="width:16px;background-color:#<?php echo htmlspecialchars($ad['colors']['bg'], ENT_QUOTES); ?>">&nbsp;</td>
675
  <td style="width:16px;background-color:#<?php echo htmlspecialchars($ad['colors']['text'], ENT_QUOTES); ?>">&nbsp;</td>
676
  <td style="width:16px;background-color:#<?php echo htmlspecialchars($ad['colors']['url'], ENT_QUOTES); ?>">&nbsp;</td>
677
+ <td style="width:100px;text-align:center;"><?php if($ad['product']=='link'){echo htmlspecialchars($ad['linkformat'], ENT_QUOTES);} else {echo htmlspecialchars($ad['adformat'], ENT_QUOTES);} ?></td>
678
  <td style="width:50px"><input name="adsensem-edit" type="submit" value="Edit" onClick="document.getElementById('adsensem-edit-name').value='<?php echo $name; ?>';"></td>
679
  <?php if($name!=$options['defaults']['ad']){?>
680
  <td style="width:50px"><input name="adsensem-default" type="submit" value="Set Default" onClick="document.getElementById('adsensem-default-name').value='<?php echo $name; ?>';"></td>
689
  ?>
690
 
691
  </table>
 
 
 
692
 
693
+ <p>By changing the <strong>Default settings</strong> (shown on the top line) you can update all Ads at once.
694
+ <br /><strong>Default Ad</strong> indicates which Ad will be displayed when no specific ID is used. </p>
695
  </form>
696
 
697
  <br /><br />
699
  <form action="" method="post" id="adsensem-config-edit">
700
 
701
  <?php
702
+
703
  if($_POST['adsensem-edit']){ ?>
704
 
705
+ <h2>Edit '<?php echo ($_POST['adsensem-edit-name']!='')?$_POST['adsensem-edit-name']:'Default Settings'; ?>'</h2>
706
  <p>Edit the settings for your Ad below. If you want to use the default settings for any element,
707
  simply leave that section unchanged.</p>
708
+ <?php
709
+ if($_POST['adsensem-edit-name']!='') {
710
+ $this->admin_settingsform($options['ads'][$_POST['adsensem-edit-name']],$_POST['adsensem-edit-name']);
711
+ } else {
712
+ $this->admin_settingsform($options['defaults'],false);
713
+ }
714
+
715
+ ?>
716
 
717
  <?php } else { ?>
718
  <h2>Create New</h2>
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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.1
7
- Stable tag: 1.3
8
 
9
  AdSense Manager is a new Wordpress plugin for managing AdSense ads on your blog. Generates code automatically and allows positioning with Widgets.
10
 
@@ -20,6 +20,8 @@ You can modify Ads right from your Wordpress admin panel - change colours, type
20
  1. Log into your WordPress admin panel
21
  1. Go to Plugins and “Activate” the plugin
22
  1. “Adsense Manager” will now be displayed in your Options section and “Ads” appears under Manage.
 
 
23
  1. [Complete usage instructions are available here.](http://www.mutube.com/projects/wordpress/adsense-manager/instructions)
24
 
25
  == Frequently Asked Questions ==
4
  Tags: adsense, ads, manage, widget, google
5
  Requires at least: 2.0.2
6
  Tested up to: 2.1
7
+ Stable tag: 1.5
8
 
9
  AdSense Manager is a new Wordpress plugin for managing AdSense ads on your blog. Generates code automatically and allows positioning with Widgets.
10
 
20
  1. Log into your WordPress admin panel
21
  1. Go to Plugins and “Activate” the plugin
22
  1. “Adsense Manager” will now be displayed in your Options section and “Ads” appears under Manage.
23
+ 1. Set your AdSense Account ID under Options &raquo; AdSense
24
+ 1. Create and modify your Ad blocks under Manage &raquo; Ads
25
  1. [Complete usage instructions are available here.](http://www.mutube.com/projects/wordpress/adsense-manager/instructions)
26
 
27
  == Frequently Asked Questions ==