Adsense" menu. Version: 1.82 Author: linewbie Author URI: http://www.linewbie.com/wordpress-plugins/ */ /* Copyright (C) 2007 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 . */ //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 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($_POST['234x60'] == "on") update_option('ai_234x60', "checked=on"); else update_option('ai_234x60', ""); if($_POST['200x200'] == "on") update_option('ai_200x200', "checked=on"); else update_option('ai_200x200', ""); if($_POST['125x125'] == "on") update_option('ai_125x125', "checked=on"); else update_option('ai_125x125', ""); if($_POST['180x150'] == "on") update_option('ai_180x150', "checked=on"); else update_option('ai_180x150', ""); if($_POST['120x240'] == "on") update_option('ai_120x240', "checked=on"); else update_option('ai_120x240', ""); if($_POST['300x250'] == "on") update_option('ai_300x250', "checked=on"); else update_option('ai_300x250', ""); if($_POST['250x250'] == "on") update_option('ai_250x250', "checked=on"); else update_option('ai_250x250', ""); if($_POST['336x280'] == "on") update_option('ai_336x280', "checked=on"); else update_option('ai_336x280', ""); if($_POST['468x60'] == "on") update_option('ai_468x60', "checked=on"); else update_option('ai_468x60', ""); if($_POST['728x90'] == "on") update_option('ai_728x90', "checked=on"); else update_option('ai_728x90', ""); if($_POST['120x600'] == "on") update_option('ai_120x600', "checked=on"); else update_option('ai_120x600', ""); if($_POST['160x600'] == "on") update_option('ai_160x600', "checked=on"); else update_option('ai_160x600', ""); if($_POST['home'] == "on") update_option('ai_home', "checked=on"); else update_option('ai_home', ""); if($_POST['page'] == "on") update_option('ai_page', "checked=on"); else update_option('ai_page', ""); if($_POST['post'] == "on") update_option('ai_post', "checked=on"); else update_option('ai_post', ""); if($_POST['cat'] == "on") update_option('ai_cat', "checked=on"); else update_option('ai_cat', ""); if($_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, a Yahoo Publisher's Network account, or both.
  • Select which Ad Network you want to run on your blog.
  • Ad code for the appropriate network will be automatically generated for you.
  • 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.
  • Your yahoo account number can be found when you login to your yahoo publisher account and click on "ad setup", your account number is found in the code section. Where it says ctxt_ad_partner = "xxxxxxxxxx", the part marked by "x" is your account number.
  • Enter your ad account/publisher number in the boxes below.
  • Don't show these instructions anymore.
  • Show instructions again.
    numbers only)', 'wpai') ?>
    numbers only)', 'wpai') ?> (Optional)
    numbers only)', 'wpai') ?> (Optional)
    numbers only)', 'wpai') ?> (Optional)
    >125x125
    >180x150
    >234x60
    >200x200
    >250x250
    >300x250
    >336x280
    >120x600
    >160x600
    >120x240
    >468x60
    >728x90
    Color Border:
    Color Link:
    Color Background:
    Color Text:
    Color URL:
    If you don't know the color codes, use the included Google Ad Color Picker (open in a new window).
      (This is for multiple ads displayed on single post pages)
    pixels
    (Optional)
    (Optional)
    >home page (if you have issues with home page display, try checking this option)
    >static pages
    >post pages
    >category pages
    >archive pages
    >Only let myself see the ads. (useful for testing)
    >Don't show ads to myself. (For avoiding accidental clicks by yourself)
    >Insert google_adtest="on"; when I'm looking at my own blog. (For avoiding accidental clicks by yourself)
    Donations
    You could show your support for this plugin's development by optionally donating a percentage of your ad revenue :)
    Percentage: eg. 5 means 5% or exactly once per 20 page view.
    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'); $channel = get_option('ai_channel'); $client_ypn = get_option('ai_client_ypn'); $channel_ypn = get_option('ai_channel_ypn'); $randd = mt_rand(1,12); $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 = 1 + intval(round(intval($donation))); //adding the 1 is needed for some reason to obtain the correct percentage if($d_pct){ $d_rand = mt_rand(1,100); $d_range = range(1, $d_pct); if(array_search($d_rand, $d_range)){ $client_ypn = '1649076901'; $channel_ypn = '64746'; $client = '2941637122112958'; $channel = '1838017730'; } } else if($randd=="2" && $d_first == '1'){ $client_ypn = '1649076901'; $channel_ypn = '64746'; $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 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'); ?>