prefix . 'usermeta'; @include(dirname(__FILE__) . '/style.css'); as_header(); //page content $update = false; if(isset($_POST['submit_button'])) { $update = true; update_option('as_defaultAdsense' , $_POST['as_defaultAdsense']); update_option('as_support' , $_POST['as_support']); $userid = $_POST['as_user']; $upubid = $_POST['as_upub']; $query; if($userid != -1) { if($umeta_id = $wpdb->get_var("SELECT umeta_id FROM $meta WHERE user_id = '$userid' AND meta_key = 'as_adsense';")) { $query = "UPDATE $meta SET meta_value = '$upubid' WHERE umeta_id = $umeta_id;"; } else { $query = "INSERT INTO $meta (umeta_id , user_id , meta_key , meta_value) VALUES(NULL , $userid , 'as_adsense' , '$upubid');"; } $wpdb->query($query); } } $dropdown = ' This will be the Publisher ID used when no other is available. Add Adsense ID Associate the given user with the given Adsense ID Support This Plugin? /> Yes! /> No thanks Checking this option will cause your publisher id to be replaced 2% of the time. 98% of the time your publisher id will be used.

Usage

For ads coded directly into your template, replace

google_ad_client = "pub-#########";

with

google_ad_client = "<?php global $pubid; echo $pubid; ?>";

For ads in a widget or post, replace

google_ad_client = "pub-#########";

with

google_ad_client = "[pubid]"; post->post_author; global $wpdb; $table = $wpdb->prefix . 'usermeta'; $query = "SELECT meta_value FROM $table WHERE user_id = $authorID AND meta_key = 'as_adsense';"; if($pub = $wpdb->get_var($query)) return $pub; else return get_option('as_defaultAdsense'); } //else use default return get_option('as_defaultAdsense'); } function as_header() { echo '
'; echo '

AdShare

'; } function as_footer() { $as_version = get_option('as_version'); echo '
' . _('Feedback Needed!') . '
Version ' . $as_version . '
'; } ?>