getOpts(); } function getOpts() { if (isset($this->opts) AND !empty($this->opts)) {return;} $this->opts=get_option("adsenseinsert"); if (!empty($this->opts)) {return;} $this->opts=Array ( 'usertype' => '', 'gen_id' => '3148397990997156', 'don_id' => '3148397990997156', 'donate' => 15, 'overrule' => 1, 'adtest' => 1, 'adsection' => 1, 'gen_channel' => '4307128384', 'don_channel' => '2830395183', '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 ', 2=>''), 'size' => Array ( 1 => 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), 2 => 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 ), 3 => 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 ), 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 $content; if ($this->opts['adsection']) { $content = ''.$content.''; } 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,"")) return $content; if (strpos($content,"")) 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=''.$content; break; case "Bottom": $content=$content.''; break; case "Middle": $a= $this->findNodes($content); $cnt=round(count($a)/2); $pos=$a[$cnt-1][1]; $result= substr_replace($content, '', $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('', html_entity_decode($code), $content); } else { $content = str_replace('', '', $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=''.$content; break; case "Bottom": $content=$content.''; break; case "Middle": $a= $this->findNodes($content); $cnt=round(count($a)/2); $pos=$a[$cnt-1][1]; $result= substr_replace($content, '', $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, '', $pos, 0); $content=$result; break; case "tag": str_replace('', '', $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('', html_entity_decode($code), $content); } else { $content = str_replace('', '', $content); } } } return $content; } function findNodes($str) { $pattern='&\[gallery\]|\<\/p*\>|\
|\
|\
&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 = ""; if (!is_array($this->opts['size'][$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 .= '
'; 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 = ""; 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.='
'; return $code; } function prepare_ad_code($code, $align, $padding) { $code=html_entity_decode($code); $startdiv='
Options Updated!
|
| Tweet |
What kind of user are you ?
opts['usertype']=="") echo('checked');?>> Basic User. You just want to add Google Ads with minimum effort.You can set up to 8 different visual Types of Ads.
|
Type:
Corners:
Number of Links:
Margin around Ad:px
|
Click here to see examples of the different sizes. If you choose more than one, random size will be used. '); foreach($sizes as $key=>$size){ echo ('opts['size'][$i][$size['text']]) echo (' checked '); echo ('> '.$size['desc'].' '); } echo(''); echo(' '); foreach($lbsizes as $key=>$size){ echo ('opts['lbsize'][$i][$size['text']]) echo (' checked '); echo ('> '.$size['desc'].' '); if ($this->opts['col_border'][$i]=="") $this->opts['col_border'][$i]="336699"; if ($this->opts['col_link'][$i]=="") $this->opts['col_link'][$i]="0000FF"; if ($this->opts['col_bg'][$i]=="") $this->opts['col_bg'][$i]="FFFFFF"; if ($this->opts['col_text'][$i]=="") $this->opts['col_text'][$i]="000000"; if ($this->opts['col_url'][$i]=="") $this->opts['col_url'][$i]="008000"; ?>
'); } echo(' |
Choose Colors: Border: Link: Backgr.: Text:
URL: change to Palette |
Now do your settings where ads should be displayed within content area. For insertion into other Blog Parts you can use Widget or PHP function (see Plugin Page).
On single Pages where ONE Post is displayed in full length or on static pages.
| Ad Nr. | Ad Type | Position | Aligment | |
|---|---|---|---|---|
| Only show if article is longer than: characters. | ||||
opts['is_only_tagged']; ?> > Only use in articles which contain <!--adsenseopt-->: To use the Plugin only in distinct articles mark that box. If you want to use the Plugin to ad Ads generally uncheck this !
opts['is_omit_page']; ?>> Do not show Ads on static pages. If you don't want Ads on a special page you can use the <!--noad--> tag ! Checking this box will omit Ads for all static pages !!!
On pages showing more posts (full or excerpt) (archives, normal Homepage etc.).
| Ad Nr. | Ad Type | show with | Aligment |
|---|---|---|---|
| opts['is_omit_home']; ?>> | Home page | |
| opts['is_omit_search']; ?> > | Searchresult pages | |
| opts['is_omit_category']; ?> > | Category archives | |
| opts['is_omit_tag']; ?> > | Tag archives | |
| opts['is_omit_date']; ?> > | Date archives | |
| opts['is_omit_author']; ?> > | Author archives |
The direct Battle is used for optimizing the layout and positioning of your ads to get the best earning per visitor. If you are not actually trying to optimize your ads, you don't need this, just ignore.
Battle Ads are injected into single pages only. Define two types of ads. One of them will be injected into a single page by random. After enough Clicks you can compare the eCPM in your Adsense Admin Panel. Battle Ads will always be injected with priority, so if you define 3 Ads (no Linkblocks) in single view above, maximum 2 of them will be shown. (No need to worry about google terms. adsenseinsert automatically checks, that not more than 3 ads will be inserted!) For more details check the optimization page.
First battle type
|
VS. |
Second battle type
|
| opts['adtest']) echo ("checked "); ?>> | Add adtest=on when Admin is logged in | (to avoid clicks by admins) |
| opts['adsection']) echo ('checked '); ?>> | Add google-adsection tag before and after content. | (see google explanation of that feature) |
You can also insert Google Ads by using the widget or by adding the "adopt" function to your theme. (Further Details see Plugin Page)
If i helped you earn more with my plugin you can buy me a coffee, just press the donation button :)
| Number of generated Ads | '.$this->nrofads.' |
| Number of generated Linkblocks | '.$this->nroflb.' |
| Version of Plugin | '.$this->adopt_version.' |
| Subdirectory in which Plugin has to be | '.$this->adopt_menu.' |
| type of page | '); 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 (' |
| Words in Post | '.$this->postlen.' |
Title:
Ad Type: (1-5)
generateAd($type); if($code) { echo(html_entity_decode($code)); } else { echo(''); } } 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");')); ?>