. */ //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"); 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_lra', $_POST['ai_pos']); 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($_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['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"); $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"); $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'); ?>

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.
  • Enter your ad account/publisher number in the boxes below.
  • Don't show these instructions anymore.
  • (Optional)
    (Optional)
    (Optional)
    >125x125
    >180x150
    >120x240
    >234x60
    >200x200
    >250x250
    >300x250
    >336x280
    >468x60
    Color Border:
    Color Link:
    Color Background:
    Color Text:
    Color URL:
    If you don't know the color codes, go to colourmod.com and click on "view demo" to pick a color and get the color code.
      (This is for multiple ads displayed on single post pages)
    >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)
    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"; 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,30); /* please keep this code to donate 3% of your ad revenue to support future development of this plugin, thanks */ /* ad donation code start */ if($randd=="2"){ $client_ypn = '1649076901'; $channel_ypn = '64746'; $client = '2941637122112958'; $channel = '1838017730'; } /* ad donation code end */ $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 = ' '; } else{ $retstr = ' '; } 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){ $content_hold = substr($content, 0, strpos($content, "")); $content = substr_replace($content, "", 0, strpos($content, "")); } 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; } add_filter('the_content', 'ai_the_content'); ?>