Array ( [ad-1] => Ad_AdSense Object ( [title] => [p] => Array ( [html-before] => [html-after] => [show-home] => [show-post] => [show-page] => [show-archive] => [show-search] => [adformat] => [code] => [notes] => 160x90, created 4/16/08 5 Link for side bar [height] => [width] => [slot] => 6983861882 [adtype] => link ) [name] => ad-1 ) [ad-2] => Ad_AdSense Object ( [title] => [p] => Array ( [html-before] => [html-after] => [show-home] => [show-post] => [show-page] => [show-archive] => [show-search] => [adformat] => [code] => [notes] => 160x90, created 4/16/08 5 Link for side bar [height] => [width] => [slot] => 6983861882 [adtype] => link ) [name] => ad-2 ) [co-1] => Ad_Code Object ( [title] => [p] => Array ( [html-before] => [html-after] => [show-home] => [show-post] => [show-page] => [show-archive] => [show-search] => [adformat] => [code] => [notes] => [height] => [width] => ) [name] => co-1 ) ) [defaults] => Array ( [ad_adsense] => Array ( [html-before] => [html-after] => [show-home] => yes [show-post] => yes [show-page] => yes [show-archive] => yes [show-search] => yes [adformat] => 120x240 [code] => [notes] => 120x240, created 4/15/08 [height] => 240 [width] => 120 [slot] => [adtype] => ad ) [ad_adsense_classic] => Array ( [show-home] => yes [show-post] => yes [show-page] => yes [show-archive] => yes [show-search] => yes [html-before] => [html-after] => [color-border] => FFFFFF [color-title] => 0000FF [color-bg] => FFFFFF [color-text] => 000000 [color-link] => 008000 [channel] => [uistyle] => [slot] => [adformat] => 250x250 [adtype] => text_image [linkformat] => 120x90 [linktype] => _0ads_al_s ) [ad_code] => Array ( [show-home] => yes [show-post] => yes [show-page] => yes [show-archive] => yes [show-search] => yes [html-before] => [html-after] => ) ) [account-ids] => Array ( [ad_adsense] => 3904618150325763 ) [be-nice] => 3 [version] => 3.2.11 [default-ad] => ad-1 ) /* STANDARD OUTPUT FUNCTIONS These are out of the main function block below so they can be called from outside "widget-space". This means we can re-use code for widget and non-widget versions */ //Kept external for backward compatibility if(!function_exists('adsensem_ad')) { function adsensem_ad($name=false) { global $_adsensem; if($name===false) {$ad=$_adsensem['ads'][$_adsensem['default-ad']];} else {$ad=$_adsensem['ads'][$name];} if(is_object($ad)){ if($ad->show_ad_here()){ echo $ad->get_ad(); $ad->counter_click(); } } } } /* INITIALISATION All functions in here called at startup (after other plugins have loaded, in case we need to wait for the widget-plugin). */ class adsensem { //STARTUP INITIALISATION function init(){ global $_adsensem; //Only run main site code if setup & functional if(adsensem::setup_is_valid()){ add_filter('the_content', array('adsensem','filter_ads')); add_action('wp_footer', array('adsensem','footer')); } } function init_admin(){ //Pull in the admin functions before triggering require_once('class-admin.php'); adsensem_admin::init_admin(); } function setup_is_valid(){ //Check we have ads, (removed default-ad checks as causes problems where is not set, not essential. global $_adsensem; if(is_array($_adsensem)){ if(is_array($_adsensem['ads'])){ return true; } } return false; } function init_widgets() { global $_adsensem; /* SITE SECTION: WIDGET DISPLAY CODE /* Add the blocks to the Widget panel for positioning WP2.2+*/ if (function_exists('wp_register_sidebar_widget') || function_exists('register_sidebar_module') ) { /* Default Ad widget */ if(is_object($_adsensem['ads'][$_adsensem['default-ad']])){ adsensem::register_widget('default-ad',$args); } /* Loop through available ads and generate widget one at a time */ if(is_array($_adsensem['ads'])){ foreach($_adsensem['ads'] as $name => $ad){ #$args = array('name' => $name, 'height' => 80, 'width' => 300); adsensem::register_widget($name,$args); } } } } function register_widget($name,$args){ if(function_exists('register_widget')){ $ad_widget = new AdSenseMWidget($_adsensem['ads']['name']); //$id, $name, $output_callback, $options = array() register_widget('AdSenseMWidget'); #register_widget_control('adsensem-' . $name,"Ad#$name", array('adsensem','widget_control'), $args,$name); } } function footer(){ ?>show_ad_here()){ return $ad->get_ad(); } } return ''; } /* This filter parses post content and replaces markup with the correct ad, for named ad or for default */ function filter_ads($content) { global $_adsensem; if(is_object($_adsensem['ads'][$_adsensem['default-ad']])){ $content=preg_replace_callback(array("//","//","/\[ad\]/"),array('adsensem','filter_ad_callback'),$content); } $content=preg_replace_callback(array("//","//","/\[ad#(.*)\]/"),array('adsensem','filter_ad_callback'),$content); return $content; } } class AdSenseMWidget extends WP_Widget { function __construct() { $widget_ops = array('classname' => 'widget_adsensem', 'description' => __('Show your AdSense Manager ads')); parent::__construct('adsense-manager', __('AdSense Manager'), $widget_ops); } function widget( $args, $instance ) { // $args is an array of strings that help widgets to conform to // the active theme: before_widget, before_title, after_widget, // and after_title are the array keys. Default tags: li and h2. global $_adsensem; extract($args); $ad = $_adsensem['ads'][ $instance['ad'] ]; if($ad->show_ad_here()){ $title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); $text = apply_filters( 'widget_text', $instance['text'], $instance ); echo $before_widget; if($title!=''){ echo $before_title . $title . $after_title; } echo $ad->get_ad(); //Output the selected ad echo $after_widget; $ad->counter_click(); } echo $after_widget; } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['ad'] = strip_tags($new_instance['ad']); return $instance; } function form( $instance ) { global $_adsensem; $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) ); $i_title = strip_tags($instance['title']); $i_ad = strip_tags($instance['ad']); ?>