Shailan.com Version: 1.4 Author: Matt Say Author URI: http://shailan.com */ if(!class_exists('stf_adsense')){ class stf_adsense extends WP_Widget { function stf_adsense() { $widget_ops = array('classname' => 'stf-adsense', 'description' => __( 'Google adsense widget' ) ); $this->WP_Widget('stf-adsense', __('Adsense'), $widget_ops); $this->alt_option_name = 'stf_adsense'; $this->widget_defaults = array( 'title' => '', 'slot' => '', 'channel' => '', 'type' => 'banner', 'content' => 'text_image' ); $this->content_types = array( 'text', 'image', 'text_image' ); $this->ad_types = array( 'leaderboard' => array( 'name'=>'Leaderboard (728 x 90)', 'key'=>'leaderboard', 'classname'=>'leaderboard', 'script'=>' google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; ' ), 'banner' => array( 'name'=>'Banner (468x60)', 'key'=>'banner', 'classname'=>'banner', 'script'=>' google_ad_width = 468; google_ad_height = 60; google_ad_format = "468x60_as"; ' ), 'half-banner' => array( 'name'=>'Half Banner (234x60)', 'key'=>'half-banner', 'classname'=>'half_banner', 'script'=>' google_ad_width = 234; google_ad_height = 60; google_ad_format = "234x60_as"; ' ), 'button' => array( 'name'=>'Button (125x125)', 'key'=>'button', 'classname'=>'button', 'script'=>' google_ad_width = 125; google_ad_height = 125; google_ad_format = "125x125_as"; ' ), 'skyscraper' => array( 'name'=>'Skyscraper (120x600)', 'key'=>'skyscraper', 'classname'=>'skyscraper', 'script'=>' google_ad_width = 120; google_ad_height = 600; google_ad_format = "120x600_as"; ' ), 'wide-skyscraper' => array( 'name'=>'Wide Skyscraper (160x600)', 'key'=>'wide-skyscraper', 'classname'=>'wide_skyscraper', 'script'=>' google_ad_width = 160; google_ad_height = 600; google_ad_format = "160x600_as"; ' ), 'vertical-banner' => array( 'name'=>'Vertical Banner (120 x 240)', 'key'=>'vertical-banner', 'classname'=>'vertical_banner', 'script'=>' google_ad_width = 120; google_ad_height = 240; google_ad_format = "120x240_as"; ' ), 'small-rectangle' => array( 'name'=>'Small Rectangle (180x150)', 'key'=>'small-rectangle', 'classname'=>'small_rectangle', 'script'=>' google_ad_width = 180; google_ad_height = 150; google_ad_format = "180x150_as"; ' ), 'small-square' => array( 'name'=>'Small Square (200 x 200)', 'key'=>'small-square', 'classname'=>'small_square', 'script'=>' google_ad_width = 200; google_ad_height = 200; google_ad_format = "200x200_as"; ' ), 'square' => array( 'name'=>'Square (250 x 250)', 'key'=>'square', 'classname'=>'square', 'script'=>' google_ad_width = 250; google_ad_height = 250; google_ad_format = "250x250_as"; ' ), 'medium-rectangle' => array( 'name'=>'Medium Rectangle (300 x 250)', 'key'=>'medium-rectangle', 'classname'=>'medium_rectangle', 'script'=>' google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; ' ), 'large-rectangle' => array( 'name'=>'Large Rectangle (336 x 280)', 'key'=>'large-rectangle', 'classname'=>'large_rectangle', 'script'=>' google_ad_width = 336; google_ad_height = 280; google_ad_format = "336x280_as"; ' ), 'links728' => array( 'name'=>'Link Unit 728x15', 'key'=>'links728', 'classname'=>'links_728x15', 'script'=>' google_ad_width = 728; google_ad_height = 15; google_ad_format = "728x15_0ads_al"; ' ), 'links468' => array( 'name'=>'Link Unit 468x15', 'key'=>'links468', 'classname'=>'links_468x15', 'script'=>' google_ad_width = 468; google_ad_height = 15; google_ad_format = "468x15_0ads_al"; ' ), 'links200' => array( 'name'=>'Link Unit 200x90', 'key'=>'links200', 'classname'=>'links_200x90', 'script'=>' google_ad_width = 200; google_ad_height = 90; google_ad_format = "200x90_0ads_al"; ' ), 'links180' => array( 'name'=>'Link Unit 180x90', 'key'=>'links180', 'classname'=>'links_180x90', 'script'=>' google_ad_width = 180; google_ad_height = 90; google_ad_format = "180x90_0ads_al"; ' ), 'links160' => array( 'name'=>'Link Unit 160x90', 'key'=>'links160', 'classname'=>'links_160x90', 'script'=>' google_ad_width = 160; google_ad_height = 90; google_ad_format = "160x90_0ads_al"; ' ), 'links120' => array( 'name'=>'Link Unit 120x90', 'key'=>'links120', 'classname'=>'links_120x90', 'script'=>' google_ad_width = 120; google_ad_height = 90; google_ad_format = "120x90_0ads_al"; ' ) ); } function widget($args, $instance) { extract( $args ); $widget_options = wp_parse_args( $instance, $this->widget_defaults ); extract( $widget_options, EXTR_SKIP ); $msg = ''; $ads_id = get_option('shailan_adsense_id'); if(empty($ads_id)){ $msg = "
Please enter your google ads id in the Adsense Widget Options Panel.
"; $ads_id = "pub-7680110371269676"; } echo $before_widget; if (!empty($instance['title'])) echo $before_title . apply_filters('widget_title', $instance['title']) . $after_title; if(!empty($slot) && $slot != ""){ $ad_slot = ' google_ad_slot = "'.$slot.'"; '; } else { $ad_slot = "\n\t /* ad slot is empty */ "; // If slot is empty use template colors $ad_colors = get_option('shailan_adsense_colors'); if(empty($ad_colors)){ $ad_colors = "/* adcolors not defined */"; } } if(!empty($channel)){ $ad_channel = ' google_ad_channel = "'.$channel.'"; '; } else { $ad_channel = "/* ad channel is empty */"; } $ad_type = ' google_ad_type = "'.$content.'"; '; $ad = $this->ad_types[$type]; $ad_class = $ad['classname']; $ad_size = $ad['script']; // Echo adsense code echo "
" . $msg; echo $after_widget; } function update($new_instance, $old_instance) { return $new_instance; } function form($instance) { $widget_options = wp_parse_args( $instance, $this->widget_defaults ); extract( $widget_options, EXTR_SKIP ); if (!empty($instance['title'])) $title = esc_attr($instance['title']); if (!empty($instance['type'])): $type = $instance['type']; else: $type = null; endif ?>




Slot id for the ad you created.( Eg. 1234567890 )


Your channel id.( Eg. 1234567890 )


Powered by Shailan.com | Get more..

" size="44" /> Your unique Adsense ID. (?)

Latest headlines from Shailan.com

'http://shailan.com', 'url' => 'http://feeds.feedburner.com/shailan', 'title' => 'Shailan.com', 'items' => 5, 'show_summary' => 0, 'show_author' => 0, 'show_date' => 0, 'before' => 'text' ); wp_widget_rss_output( $rss_options ); ?>

My latest tweets

Adsense widget by shailan.

'none', 'type' => 'banner', 'slot' => '', 'channel' => '' ), $atts)); if($channel==""){ $channel = get_option('shailan_adsense_shortcode_channel'); } // Open adsense layer $adcode = "\n
"; ob_start(); $args = array( 'title' => '', 'type' => $type, 'slot' => $slot, 'channel' => $channel ); the_widget('stf_adsense', $args); $widget_code = ob_get_contents(); ob_end_clean(); $adcode .= $widget_code; // Close the layer $adcode .= "\n
\n"; return $adcode; }; add_shortcode('adsense', 'stf_adsense_shortcode'); } // class exist check