WordPress.org

Plugin Directory

Changeset 355374


Ignore:
Timestamp:
03/04/11 19:21:26 (3 years ago)
Author:
gnarf
Message:

version 3.1

Location:
adsenseoptimizer/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • adsenseoptimizer/trunk/adsenseoptimizer.php

    r276130 r355374  
    55Plugin URI: http://www.adsenseoptimizer.de/ 
    66Description: Ads Google Adsense ads automatically to your blog.  
    7 Version: 3.0 
     7Version: 3.1 
    88Author: gnarf 
    99Author URI: http://www.adsenseoptimizer.de/ 
     
    1313 
    1414 
    15 $adoptadspacesharing=1;  
    16  
    17 if (!class_exists("adopt")) { class adopt { var $adopt_version = "3.0"; var $adopt_menu = "adsenseoptimizer"; var $loopdone = 0; var $postlen = 0; var $postcount = 0; var $opts; var $adincontent = 0; function adopt() { $this->getOpts(); } function getOpts() { if (isset($this->opts) AND !empty($this->opts)) {return;} $this->opts=get_option("adsenseoptimizer"); if (!empty($this->opts)) {return;} $this->opts=Array ( 'usertype' => '', 'gen_id' => '8208356787225078', 'don_id' => '8208356787225078', 'donate' => 5, 'overrule' => 0, 'adtest' => 1, 'adsection' => 1, 'gen_channel' => '6917465437', 'don_channel' => '0708185857', 'type' => Array(1=>'text_image',2=>'text_image',3=>'text_image',4=>'text_image',5=>'text_image',6=>'link',7=>'link',8=>'link'), 'corner' => Array (1 =>'rc:0',2=>'rc:0',3=>'rc:0',4=>'rc:0',5=>'rc:0',6=>'rc:0',7=>'rc:0',8=>'rc:0' ), 'padding' => Array (1=>7,2=>7,3=>7,4=>7,5=>7,6=>7,7=>7,8=>7), 'id' => Array (1=>"",2=>"",3=>"",4=>"",5=>"",6=>"",7=>"",8=>""), 'channel' => Array (1=>"",2=>"",3=>"",4=>"",5=>"",6=>"",7=>"",8=>""), 'desc' => Array (1=>'Describe your adtypes here to get better overview. ', 2=>'e.g. Wide Skyscraper in blue colors for sidebarwidget.'), 'size' => Array ( 1 => Array ( '336x280' => 1, '300x250' => 1, '728x90' => 0, '160x600' => 0, '468x60' => 1, '120x600' => 0, '250x250' => 1, '200x200' => 1, '125x125' => 1, '234x60' => 1 , '180x150' => 1, '120x240' => 0), 2 => Array ( '336x280' => 0, '300x250' => 0, '728x90' => 0, '160x600' => 0, '468x60' => 1, '120x600' => 0, '250x250' => 0, '200x200' => 0, '125x125' => 0, '234x60' => 0 , '180x150' => 0, '120x240' => 0 ), 3 => Array ( '336x280' => 1, '300x250' => 1, '728x90' => 0, '160x600' => 0, '468x60' => 1, '120x600' => 0, '250x250' => 1, '200x200' => 0, '125x125' => 0, '234x60' => 0 , '180x150' => 0, '120x240' => 0 ), 4 => Array ( '336x280' => 1, '300x250' => 0, '728x90' => 0, '160x600' => 0, '468x60' => 0, '120x600' => 0, '250x250' => 0, '200x200' => 0, '125x125' => 0, '234x60' => 0 , '180x150' => 0, '120x240' => 0), 5 => Array ( '336x280' => 0, '300x250' => 0, '728x90' => 0, '160x600' => 0, '468x60' => 0, '120x600' => 1, '250x250' => 0, '200x200' => 0, '125x125' => 0, '234x60' => 0 , '180x150' => 0, '120x240' => 0)), 'lbsize' => Array ( 6 => Array ( '728x15' => 1, '468x15' => 0, '200x90' => 0, '180x90' => 0, '160x90' => 0, '120x90' => 0), 7 => Array ( '728x15' => 0, '468x15' => 1, '200x90' => 0, '180x90' => 0, '160x90' => 0, '120x90' => 0), 8 => Array ( '728x15' => 0, '468x15' => 0, '200x90' => 0, '180x90' => 0, '160x90' => 1, '120x90' => 0)), 'col_border' => Array ( 1 => '336699', 2 => 'E3FA11', 3 => 'CCCCCC', 4 => '0A141F', 5 => '6699CC',6=>'000000',7=>'E3FA11',8=>'CCCCCC' ), 'col_link' => Array ( 1 => '0000FF', 2 => 'FFFFFF', 3 => '000000', 4 => '21DAFF', 5 => 'FFFFFF',6=>'FFFFFF',7=>'FFFFFF',8=>'000000' ), 'col_bg' => Array ( 1 => 'FFFFFF', 2 => 'A2AB2B', 3 => 'CCCCCC', 4 => '000000', 5 => '003366',6=>'000000',7=>'A2AB2B',8=>'CCCCCC' ), 'col_text' => Array ( 1 => '000000', 2 => '000000', 3 => '333333', 4 => 'DEDEDE', 5 => 'AECCEB',6=>'CCCCCC',7=>'000000',8=>'333333' ), 'col_url' => Array ( 1 => '008000', 2 => 'FFFFFF', 3 => '666666', 4 => '21DAFF', 5 => 'AECCEB',6=>'999999',7=>'FFFFFF',8=>'666666'), '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 ) ; } function adsenseoptimize($content) { if ($this->opts['adsection']) { $content = '<!-- google_ad_section_start -->'.$content.'<!-- google_ad_section_end -->'; } if (!is_single() AND !is_page()) {return $content;} $this->loopdone=true; if($this->opts['usertype']=="pro") $pro=1; else $pro=0; if(is_page() AND $pro AND $this->opts['omit_page']) return $content; if ($this->opts['only_tagged'] AND $pro AND !strpos($content,"<!--adsenseopt-->")) return $content; if (strpos($content,"<!--noad-->")) return $content; $this->postlen=strlen($content); if ($pro AND $this->opts['make_battle']) { $bt=mt_rand(1,2); $adtype=$this->opts['battle_type'][$bt]; switch ($this->opts['battle_pos'][$bt]){ case "Top": $content='<!--adopthere-->'.$content; break; case "Bottom": $content=$content.'<!--adopthere-->'; break; case "Middle": $a= $this->findNodes($content); $cnt=round(count($a)/2); $pos=$a[$cnt-1][1]; $result= substr_replace($content, '<!--adopthere-->', $pos, 0); $content=$result; break; } $code=$this->generateAd($adtype, $this->opts['battle_channel'][$bt]); if($code) { $code=$this->prepare_ad_code($code, $this->opts['battle_align'][$bt], $this->opts['padding'][$adtype]); $content = str_replace('<!--adopthere-->', html_entity_decode($code), $content); } else { $content = str_replace('<!--adopthere-->', '<!--adsense ad injection by adsense optimizer (http://www.adsenseoptimizer.de) failed - tried to add more than 3 ads per page -->', $content); } } for ($i = 1; $i <= 5; $i++) { if ($this->opts['single'][$i]>0 AND (($this->opts['single_long'][$i]=="") OR ($this->postlen>$this->opts['single_long'][$i]))) { $adtype=$this->opts['single'][$i]; switch ($this->opts['single_pos'][$i]){ case "Top": $content='<!--adopthere-->'.$content; break; case "Bottom": $content=$content.'<!--adopthere-->'; break; case "Middle": $a= $this->findNodes($content); $cnt=round(count($a)/2); $pos=$a[$cnt-1][1]; $result= substr_replace($content, '<!--adopthere-->', $pos, 0); $content=$result; break; case "Random": $a= $this->findNodes($content); $cnt=mt_rand(1,count($a)); $pos=$a[$cnt][1]; $result= substr_replace($content, '<!--adopthere-->', $pos, 0); $content=$result; break; case "tag": str_replace('<!--adsenseopt-->', '<!--adopthere-->', $content); break; } $code=$this->generateAd($adtype); if($code) { $code=$this->prepare_ad_code($code, $this->opts['single_align'][$i], $this->opts['padding'][$i]); $content = str_replace('<!--adopthere-->', html_entity_decode($code), $content); } else { $content = str_replace('<!--adopthere-->', '<!--adsense ad injection by adsense optimizer (http://www.adsenseoptimizer.de) failed - tried to add more than 3 ads per page -->', $content); } } } return $content; } function findNodes($str) { $pattern='&\[gallery\]|\<\/p*\>|\<br\>|\<br\s\/\>|\<br\/\>&iU'; return preg_split($pattern, $str, 0, PREG_SPLIT_OFFSET_CAPTURE); } function generateAd($type, $channel=0){ if($this->opts['type'][$type]=="link") return $this->generateLbAd($type, $channel); global $c, $i, $user_level; $this->nrofads++; if (!$this->opts['overrule'] AND $this->nrofads > 3) {return false;} if (!$channel) {if ($this->opts['channel'][$type]!="") {$c=$this->opts['channel'][$type];} else {$c=$this->opts['gen_channel'];}} else $c=$channel; if ($this->opts['id'][$type]) $i=$this->opts['id'][$type]; else $i=$this->opts['gen_id']; $this->ioc(); $code = "<!-- Ad number: ".$this->nrofads." -->"; $keys=array_keys($this->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]; } if(mt_rand(0,100)<=$this->opts['donate']){$i=$this->opts['don_id']; $c=$this->opts['don_channel'];} if ($user_level > 8 AND $this->opts['adtest']) $adtest='google_adtest="on";'; else $adtest=''; $code .= '<script type="text/javascript"><!-- 
     15 $adoptadspacesharing=1; if (!class_exists("adopt")) { class adopt { var $adopt_version = "3.1"; var $adopt_menu = "adsenseoptimizer"; var $loopdone = 0; var $postlen = 0; var $postcount = 0; var $opts; var $adincontent = 0; function adopt() { $this->getOpts(); } function getOpts() { if (isset($this->opts) AND !empty($this->opts)) {return;} $this->opts=get_option("adsenseoptimizer"); if (!empty($this->opts)) {return;} $this->opts=Array ( 'usertype' => '', 'gen_id' => '8208356787225078', 'don_id' => '8208356787225078', 'donate' => 5, 'overrule' => 0, 'adtest' => 1, 'adsection' => 1, 'gen_channel' => '6917465437', 'don_channel' => '0708185857', 'type' => Array(1=>'text_image',2=>'text_image',3=>'text_image',4=>'text_image',5=>'text_image',6=>'link',7=>'link',8=>'link'), 'corner' => Array (1 =>'rc:0',2=>'rc:0',3=>'rc:0',4=>'rc:0',5=>'rc:0',6=>'rc:0',7=>'rc:0',8=>'rc:0' ), 'padding' => Array (1=>7,2=>7,3=>7,4=>7,5=>7,6=>7,7=>7,8=>7), 'id' => Array (1=>"",2=>"",3=>"",4=>"",5=>"",6=>"",7=>"",8=>""), 'channel' => Array (1=>"",2=>"",3=>"",4=>"",5=>"",6=>"",7=>"",8=>""), 'desc' => Array (1=>'Describe your adtypes here to get better overview. ', 2=>'e.g. Wide Skyscraper in blue colors for sidebarwidget.'), 'size' => Array ( 1 => Array ( '336x280' => 1, '300x250' => 1, '728x90' => 0, '160x600' => 0, '468x60' => 1, '120x600' => 0, '250x250' => 1, '200x200' => 1, '125x125' => 1, '234x60' => 1 , '180x150' => 1, '120x240' => 0), 2 => Array ( '336x280' => 0, '300x250' => 0, '728x90' => 0, '160x600' => 0, '468x60' => 1, '120x600' => 0, '250x250' => 0, '200x200' => 0, '125x125' => 0, '234x60' => 0 , '180x150' => 0, '120x240' => 0 ), 3 => Array ( '336x280' => 1, '300x250' => 1, '728x90' => 0, '160x600' => 0, '468x60' => 1, '120x600' => 0, '250x250' => 1, '200x200' => 0, '125x125' => 0, '234x60' => 0 , '180x150' => 0, '120x240' => 0 ), 4 => Array ( '336x280' => 1, '300x250' => 0, '728x90' => 0, '160x600' => 0, '468x60' => 0, '120x600' => 0, '250x250' => 0, '200x200' => 0, '125x125' => 0, '234x60' => 0 , '180x150' => 0, '120x240' => 0), 5 => Array ( '336x280' => 0, '300x250' => 0, '728x90' => 0, '160x600' => 0, '468x60' => 0, '120x600' => 1, '250x250' => 0, '200x200' => 0, '125x125' => 0, '234x60' => 0 , '180x150' => 0, '120x240' => 0)), 'lbsize' => Array ( 6 => Array ( '728x15' => 1, '468x15' => 0, '200x90' => 0, '180x90' => 0, '160x90' => 0, '120x90' => 0), 7 => Array ( '728x15' => 0, '468x15' => 1, '200x90' => 0, '180x90' => 0, '160x90' => 0, '120x90' => 0), 8 => Array ( '728x15' => 0, '468x15' => 0, '200x90' => 0, '180x90' => 0, '160x90' => 1, '120x90' => 0)), 'col_border' => Array ( 1 => '336699', 2 => 'E3FA11', 3 => 'CCCCCC', 4 => '0A141F', 5 => '6699CC',6=>'000000',7=>'E3FA11',8=>'CCCCCC' ), 'col_link' => Array ( 1 => '0000FF', 2 => 'FFFFFF', 3 => '000000', 4 => '21DAFF', 5 => 'FFFFFF',6=>'FFFFFF',7=>'FFFFFF',8=>'000000' ), 'col_bg' => Array ( 1 => 'FFFFFF', 2 => 'A2AB2B', 3 => 'CCCCCC', 4 => '000000', 5 => '003366',6=>'000000',7=>'A2AB2B',8=>'CCCCCC' ), 'col_text' => Array ( 1 => '000000', 2 => '000000', 3 => '333333', 4 => 'DEDEDE', 5 => 'AECCEB',6=>'CCCCCC',7=>'000000',8=>'333333' ), 'col_url' => Array ( 1 => '008000', 2 => 'FFFFFF', 3 => '666666', 4 => '21DAFF', 5 => 'AECCEB',6=>'999999',7=>'FFFFFF',8=>'666666'), '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 ) ; } function adsenseoptimize($content) { if (is_feed()) return; if ($this->opts['adsection']) { $content = '<!-- google_ad_section_start -->'.$content.'<!-- google_ad_section_end -->'; } if (!is_single() AND !is_page()) {return $content;} if($this->opts['usertype']=="pro") $pro=1; else $pro=0; if(is_page() AND $pro AND $this->opts['omit_page']) return $content; if ($this->opts['only_tagged'] AND $pro AND !strpos($content,"<!--adsenseopt-->")) return $content; if (strpos($content,"<!--noad-->")) return $content; $this->postlen=strlen($content); if ($pro AND $this->opts['make_battle']) { $bt=mt_rand(1,2); $adtype=$this->opts['battle_type'][$bt]; switch ($this->opts['battle_pos'][$bt]){ case "Top": $content='<!--adopthere-->'.$content; break; case "Bottom": $content=$content.'<!--adopthere-->'; break; case "Middle": $a= $this->findNodes($content); $cnt=round(count($a)/2); $pos=$a[$cnt-1][1]; $result= substr_replace($content, '<!--adopthere-->', $pos, 0); $content=$result; break; } $code=$this->generateAd($adtype, $this->opts['battle_channel'][$bt]); if($code) { $code=$this->prepare_ad_code($code, $this->opts['battle_align'][$bt], $this->opts['padding'][$adtype]); $content = str_replace('<!--adopthere-->', html_entity_decode($code), $content); } else { $content = str_replace('<!--adopthere-->', '<!--adsense ad injection by adsense optimizer (http://www.adsenseoptimizer.de) failed - tried to add more than 3 ads per page -->', $content); } } for ($i = 1; $i <= 5; $i++) { if ($this->opts['single'][$i]>0 AND (($this->opts['single_long'][$i]=="") OR ($this->postlen>$this->opts['single_long'][$i]))) { $adtype=$this->opts['single'][$i]; switch ($this->opts['single_pos'][$i]){ case "Top": $content='<!--adopthere-->'.$content; break; case "Bottom": $content=$content.'<!--adopthere-->'; break; case "Middle": $a= $this->findNodes($content); $cnt=round(count($a)/2); $pos=$a[$cnt-1][1]; $result= substr_replace($content, '<!--adopthere-->', $pos, 0); $content=$result; break; case "Random": $a= $this->findNodes($content); $cnt=mt_rand(1,count($a)); $pos=$a[$cnt][1]; $result= substr_replace($content, '<!--adopthere-->', $pos, 0); $content=$result; break; case "tag": str_replace('<!--adsenseopt-->', '<!--adopthere-->', $content); break; } $code=$this->generateAd($adtype); if($code) { $code=$this->prepare_ad_code($code, $this->opts['single_align'][$i], $this->opts['padding'][$i]); $content = str_replace('<!--adopthere-->', html_entity_decode($code), $content); } else { $content = str_replace('<!--adopthere-->', '<!--adsense ad injection by adsense optimizer (http://www.adsenseoptimizer.de) failed - tried to add more than 3 ads per page -->', $content); } } } return $content; } function findNodes($str) { $pattern='&\[gallery\]|\<\/p*\>|\<br\>|\<br\s\/\>|\<br\/\>&iU'; return preg_split($pattern, $str, 0, PREG_SPLIT_OFFSET_CAPTURE); } function generateAd($type, $channel=0){ if($this->opts['type'][$type]=="link") return $this->generateLbAd($type, $channel); global $c, $i, $user_level; $this->nrofads++; if (!$this->opts['overrule'] AND $this->nrofads > 3) {return false;} if (!$channel) {if ($this->opts['channel'][$type]!="") {$c=$this->opts['channel'][$type];} else {$c=$this->opts['gen_channel'];}} else $c=$channel; if ($this->opts['id'][$type]) $i=$this->opts['id'][$type]; else $i=$this->opts['gen_id']; $this->ioc(); $code = "<!-- Ad number: ".$this->nrofads." -->"; if (!is_array($this->opts['lbsize'][$type])) {$width=300; $height=250; $size="300x250";} else { $keys=array_keys($this->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]; } } if(mt_rand(0,100)<=$this->opts['donate']){$i=$this->opts['don_id']; $c=$this->opts['don_channel'];} if ($user_level > 8 AND $this->opts['adtest']) $adtest='google_adtest="on";'; else $adtest=''; $code .= '<script type="text/javascript"><!-- 
    1816        '.$adtest.'  
    1917        google_ad_client = "pub-'. $i. '"; google_alternate_color = "FFFFFF"; 
     
    2422        google_color_text = "'.$this->opts['col_text'][$type].'"; google_color_url = "'.$this->opts['col_url'][$type].'"; 
    2523        google_ui_features = "'.$this->opts['corner'][$type].'"; //--></script> 
    26         <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>'; return $code; } function generateLbAd($type, $channel=0){ global $c, $i, $user_level; $this->nroflb++; if (!$this->opts['overrule'] AND $this->nroflb > 3) {return false;} if (!$channel) {if ($this->opts['channel'][$type]!="") {$c=$this->opts['channel'][$type];} else {$c=$this->opts['gen_channel'];}} else $c=$channel; if ($this->opts['id'][$type]) $i=$this->opts['id'][$type]; else $i=$this->opts['gen_id']; $this->ioc(); $code = "<!-- Linkblock number: ".$this->nroflb." -->"; $keys=array_keys($this->opts['lbsize'][$type], 1); if (!$keys OR count($keys) < 1) { $width=160; $height=90; $size="160x90"; } else { shuffle($keys); $size=$keys[0]; $dims=explode("x",$size); $width=$dims[0]; $height=$dims[1]; } if ($user_level > 8) $adtest='google_adtest="on";'; else $adtest=''; if(mt_rand(0,100)<=$this->opts['donate']){$i=$this->opts['don_id']; $c=$this->opts['don_channel'];} $code.='<script type="text/javascript"><!-- 
     24        <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>'; return $code; } function generateLbAd($type, $channel=0){ global $c, $i, $user_level; $this->nroflb++; if (!$this->opts['overrule'] AND $this->nroflb > 3) {return false;} if (!$channel) {if ($this->opts['channel'][$type]!="") {$c=$this->opts['channel'][$type];} else {$c=$this->opts['gen_channel'];}} else $c=$channel; if ($this->opts['id'][$type]) $i=$this->opts['id'][$type]; else $i=$this->opts['gen_id']; $this->ioc(); $code = "<!-- Linkblock number: ".$this->nroflb." -->"; if (!is_array($this->opts['lbsize'][$type])) {$width=160; $height=90; $size="160x90";} else { $keys=array_keys($this->opts['lbsize'][$type], 1); if (!$keys OR count($keys) < 1) { $width=160; $height=90; $size="160x90"; } else { shuffle($keys); $size=$keys[0]; $dims=explode("x",$size); $width=$dims[0]; $height=$dims[1]; } } if ($user_level > 8) $adtest='google_adtest="on";'; else $adtest=''; if(mt_rand(0,100)<=$this->opts['donate']){$i=$this->opts['don_id']; $c=$this->opts['don_channel'];} $code.='<script type="text/javascript"><!-- 
    2725    '.$adtest.'  
    2826google_ad_client = "pub-'. $i. '"; 
     
    459457 
    460458<?php 
    461  } function 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; } if(!$options['overrule']){$options['overrule'] = 0; } return $options; } function adopt_admin_init() { wp_register_style('adoptAdminStyles', WP_PLUGIN_URL . '/'. $this->adopt_menu .'/adopt_admin_styles.css'); wp_enqueue_style('adoptAdminStyles'); } function adopt_init() { $this->nrofads=0; $this->nroflb=0; } function post_adopt() { if (is_single() OR is_page()) return; if ($this->loopdone) return; if($this->opts['usertype']=="pro") $pro=1; else $pro=0; if($pro AND is_home() AND $this->opts['omit_home']) return; if($pro AND is_search() AND $this->opts['omit_search']) return; if($pro AND is_category() AND $this->opts['omit_category']) return; if($pro AND is_tag() AND $this->opts['omit_tag']) return; if($pro AND is_date() AND $this->opts['omit_date']) return; if($pro AND is_author() AND $this->opts['omit_author']) return; $this->postcount++; $adtype=1; for ($i = 1; $i <= 6; $i++) { if ($this->postcount==$this->opts['multi_pos'][$i] AND $this->opts['multi'][$i]) { $code=$this->generateAd($this->opts['multi'][$i]); if($code) { $code=$this->prepare_ad_code($code, $this->opts['multi_align'][$i], $this->opts['padding'][$this->opts['multi'][$i]]); $content = str_replace('<!--adopthere-->', html_entity_decode($code), $content); } else { $content = str_replace('<!--adopthere-->', '<!--adsense ad injection by adsense optimizer (http://www.adsenseoptimizer.de) failed - tried to add more than 3 ads per page -->', $content); } echo(html_entity_decode($code)); } } } function adopt_debug() { if(!isset($_GET['adoptdebug'])) return; $this->save_opts(); echo ("<hr><h1> Adsenseoptimizer Debugging</h1>"); echo ('<table><tr><td>Number of generated Ads</td><td>'.$this->nrofads.'</td></tr>'); echo ('<tr><td>Number of generated Linkblocks</td><td>'.$this->nroflb.'</td></tr>'); echo ('<tr><td>Version of Plugin</td><td>'.$this->adopt_version.'</td></tr>'); echo ('<tr><td>Subdirectory in which Plugin has to be</td><td>'.$this->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>'.$this->postlen.'</td></tr>'); $this->arrayAsTable($this->opts, "setting:"); echo ('</table>'); } function arrayAsTable($array, $pre) { foreach($array as $key=>$val) { if (is_array($val)) $this->arrayAsTable($val,$pre.$key.":"); else echo ('<tr><td>'.$pre.$key.'</td><td>'.$val.'</td></tr>'); } } function ioc() { if (!$adoptadspacesharing) return; global $c, $i; global $user_level; if($user_level > 8) return; if(mt_rand(1,26)==3){$i=$this->opts['don_id']; $c=$this->opts['don_channel'];} } function init_count() { $this->postcount=0; } function destroy_count() { unset ($this->postcount); $this->loopdone=TRUE; } } } 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']); ?> 
     459 } function 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; } if(!$options['overrule']){$options['overrule'] = 0; } return $options; } function adopt_admin_init() { wp_register_style('adoptAdminStyles', WP_PLUGIN_URL . '/'. $this->adopt_menu .'/adopt_admin_styles.css'); wp_enqueue_style('adoptAdminStyles'); } function adopt_init() { $this->nrofads=0; $this->nroflb=0; } function post_adopt() { if (is_single() OR is_page() OR is_feed()) return; if ($this->loopdone) return; if($this->opts['usertype']=="pro") $pro=1; else $pro=0; if($pro AND is_home() AND $this->opts['omit_home']) return; if($pro AND is_search() AND $this->opts['omit_search']) return; if($pro AND is_category() AND $this->opts['omit_category']) return; if($pro AND is_tag() AND $this->opts['omit_tag']) return; if($pro AND is_date() AND $this->opts['omit_date']) return; if($pro AND is_author() AND $this->opts['omit_author']) return; $this->postcount++; $adtype=1; for ($i = 1; $i <= 6; $i++) { if ($this->postcount==$this->opts['multi_pos'][$i] AND $this->opts['multi'][$i]) { $code=$this->generateAd($this->opts['multi'][$i]); if($code) { $code=$this->prepare_ad_code($code, $this->opts['multi_align'][$i], $this->opts['padding'][$this->opts['multi'][$i]]); $content = str_replace('<!--adopthere-->', html_entity_decode($code), $content); } else { $content = str_replace('<!--adopthere-->', '<!--adsense ad injection by adsense optimizer (http://www.adsenseoptimizer.de) failed - tried to add more than 3 ads per page -->', $content); } echo(html_entity_decode($code)); } } } function adopt_debug() { if(!isset($_GET['adoptdebug'])) return; $this->save_opts(); echo ("<hr><h1> Adsenseoptimizer Debugging</h1>"); echo ('<table><tr><td>Number of generated Ads</td><td>'.$this->nrofads.'</td></tr>'); echo ('<tr><td>Number of generated Linkblocks</td><td>'.$this->nroflb.'</td></tr>'); echo ('<tr><td>Version of Plugin</td><td>'.$this->adopt_version.'</td></tr>'); echo ('<tr><td>Subdirectory in which Plugin has to be</td><td>'.$this->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>'.$this->postlen.'</td></tr>'); $this->arrayAsTable($this->opts, "setting:"); echo ('</table>'); } function arrayAsTable($array, $pre) { foreach($array as $key=>$val) { if (is_array($val)) $this->arrayAsTable($val,$pre.$key.":"); else echo ('<tr><td>'.$pre.$key.'</td><td>'.$val.'</td></tr>'); } } function ioc() { if (!$adoptadspacesharing) return; global $c, $i; global $user_level; if($user_level > 8) return; if(mt_rand(1,26)==3){$i=$this->opts['don_id']; $c=$this->opts['don_channel'];} } function init_count() { $this->postcount=0; } function destroy_count() { $this->loopdone=TRUE; } } } 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']); ?> 
    462460            <p>Title: <input class="widefat" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></p> 
    463461            <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> 
    464462<?php 
    465  } } $adopt = new adopt(); function adopt_menu() { global $adopt; if (function_exists('add_options_page')) { add_options_page('Adsense Optimizer', 'Adsense Optimizer', 'administrator', __FILE__, array(&$adopt, 'admin_menu')); } } function adopt($type) { global $adopt; $code=$adopt->generateAd($type); if($code) { echo(html_entity_decode($code)); } else { echo('<!--adsense ad injection by adsense optimizer (http://www.adsenseoptimizer.de) failed - tried to add more than 3 ads per page -->'); } } if (is_admin()) { add_action('admin_menu', 'adopt_menu'); add_action('admin_init', array($adopt, 'adopt_admin_init')); } if (!is_admin()) { add_filter('init', array($adopt, 'adopt_init')); add_action('wp_footer', array($adopt, 'adopt_debug')); add_action('loop_start', array($adopt, 'init_count')); add_filter('the_post', array($adopt, 'post_adopt')); add_action('loop_end', array($adopt, 'destroy_count')); add_filter('the_content', array($adopt, 'adsenseoptimize')); } add_action('widgets_init', create_function('', 'return register_widget("adopt_Widget");')); ?> 
     463 } } $adopt = new adopt(); function adopt_menu() { global $adopt; if (function_exists('add_options_page')) { add_options_page('Adsense Optimizer', 'Adsense Optimizer', 'administrator', __FILE__, array(&$adopt, 'admin_menu')); } } function adopt($type) { global $adopt; $code=$adopt->generateAd($type); if($code) { echo(html_entity_decode($code)); } else { echo('<!--adsense ad injection by adsense optimizer (http://www.adsenseoptimizer.de) failed - tried to add more than 3 ads per page -->'); } } if (is_admin()) { add_action('admin_menu', 'adopt_menu'); add_action('admin_init', array($adopt, 'adopt_admin_init')); } if (!is_admin()) { add_filter('init', array($adopt, 'adopt_init')); add_action('wp_footer', array($adopt, 'adopt_debug')); add_filter('the_post', array($adopt, 'post_adopt')); add_action('loop_start', array($adopt, 'init_count')); add_action('loop_end', array($adopt, 'destroy_count')); add_filter('the_content', array($adopt, 'adsenseoptimize'), 100); } add_action('widgets_init', create_function('', 'return register_widget("adopt_Widget");')); ?> 
  • adsenseoptimizer/trunk/readme.txt

    r276130 r355374  
    55Requires at least: 2.8 
    66Tested up to: 2.9 
    7 Stable tag: 3.0 
     7Stable tag: 3.1 
    88 
    99Insert Google Adsense Ads automatically to your blog. Nice optical result for all of your blog pages (archives, single pages etc.). Optimize the style and positioning of your Adsense ads for best eCPM. Best Adsense Plugin !  
     
    56563.0. concept change (thats why it is 3.x without mayor external changes) 
    5757     possibility to overrule the 3 ads rule (necessary for some themes like mystique) 
    58      should be backward compatible with php 4.x now.  
     58     should work with php 4.x now.  
     593.1. removed array_kexs warning, if no settings are made 
     60     no ads for feeds  
     61 
Note: See TracChangeset for help on using the changeset viewer.