= (USER_FREQUENCY + SYS_FREQUENCY)) { $ads_int_count_our_post = 1; update_option('ads_int_count_our_post', $ads_int_count_our_post); } $ads_int_count_our_post++; update_option('ads_int_count_our_post', $ads_int_count_our_post); } add_action('admin_menu', 'adsense_integrator_admin'); function adsense_integrator_admin() { global $ads_int_domain; add_submenu_page('options-general.php', __('AdSense Integrator', $ads_int_domain), __('AdSense Integrator', $ads_int_domain), 5, __FILE__, 'adsense_integrator_admin_interface'); } /**************************** POST OPTIONS FUNCTIONS ************************************/ add_action('edit_post', 'ads_int_edit_action'); add_action('publish_post', 'ads_int_edit_action'); add_action('save_post', 'ads_int_edit_action'); add_action('edit_page_form', 'ads_int_edit_action'); function ads_int_edit_action($id) { $ads_int_edit = $_POST["ads_int_edit"]; if (isset($ads_int_edit) && !empty($ads_int_edit)) { $ads_int_disable = $_POST["ads_int_disable"]; delete_post_meta($id, 'ads_int_disable'); if (isset($ads_int_disable) && !empty($ads_int_disable)) add_post_meta($id, 'ads_int_disable', $ads_int_disable); } } add_action('simple_edit_form', 'ads_int_edit_form_action'); add_action('edit_form_advanced','ads_int_edit_form_action'); function ads_int_edit_form_action() { global $post; $post_id = $post; if (is_object($post_id)) $post_id = $post_id->ID; $ads_int_disable = htmlspecialchars(stripcslashes(get_post_meta($post_id, 'ads_int_disable', false))); global $ads_int_domain; ?>

ADSense Integrator Option

/>
' . __('Settings', $ads_int_domain) . ''; array_unshift($links, $settings_link); } return $links; } //option panel function adsense_integrator_admin_interface() { global $ads_int_domain; global $ads_int_announcement; /* interface moment*/ ?>

Home
Post
Page
Category
Archive
Tag
Yes

IP filter/ban

Insert below the IP addresses to ban, each one in a separate row


alternative text/ad:


style="margin:0;padding:0;" /> > style="margin:0;padding:0;" />
style="margin:0;padding:0;" /> style="margin:0;padding:0;" />
style="margin:0;padding:0;" />
style="margin:0;padding:0;" /> style="margin:0;padding:0;" />
style="margin:0;padding:0;"/>
>Home
>Post
>Page
>Category
>Archive
>Tag
>yes

Credits

This plugin was developed to aid you inserting AdSense ads into your blog.
It represents a perfect solution to integrate Google Adsense into your WordPress blog. This plugin enables you to create different Adsense blocks and allows placing them within your template or individual posts. It was developed based on the last Google rules and AdSense updates, to use it please follow these steps.
It could be used as well for other types of campaigns, like AdBrite, Oxado, AffiliateBOT, Share A Sale, LinkShare, ClickBank, Commission Junction, Adpinion, AdGridWork, Adroll, CrispAds, ShoppingAds, Yahoo!PN and others, included custom campaigns (not tested yet).

Requirements and compatiblity:
» Requires WordPress 1.5+ (tested from WP 2.0.0 till 2.6.5)


Installation:
» Like most all WordPress plugins, just copy the "adsense-integrator" folder into wp-content/plugins
» Go to the plugins page of your WordPress blog and activate it
» For additional info see the readme.txt file included with the download

Usage:
1. Enter you Google Adsense account (or create one if you haven't)
2. Create an announcement and copy the code
3. Enter the plugin settings (this page)
4. Create a new ad with the desired options


You can create as many ads as you want, but remember that Google allows you to insert max 3 ads for each types (announcements and link groups). The plugin controls and stops ads if you exceed this number, but please pay attention if you inserted other ads in your themplate's code or in the widgets.
In the next release we will add the widget management to insert Google AdSense in every part of your blog, stay tuned!

Once created you can easily and quickly manage your existing ads modifying the options.
To pause your ad without deleting it, please set "Times" to "0" and the ad will disappear.

Features:
» Easy "Copy & Paste" your ads code for embedding AdSense ads in your WordPress posts
» Set the number and types of ads for page
» Select the section of your blog where to insert each ad (homepage, posts, pages, categories, archives and tags)
» All settings configured through WordPress Options interface (no knowledge of plugins or PHP required)
» Easily test different ad formats and positions modifying your existing ads
» Ads are excluded from RSS feeds

Notes:
AdSense Integrator was initially developed for our own use, after an exhaustive search for a similar instrument on anything properly.

Did you ever try to integrate Google AdSense into your WordPress blog? We did it since some time, pasting directly our adsense code in our templates and posts, manually. But it did not seem the best way to achieve our goals. We wanted some flexibility in deciding which places ads have to appear and the total control over the ad format that would be displayed in the blog posts.

In light of the new AdSense rules and announcements creation control panel, we developed this plugin which is given you for free.


Reward Author:
Please support us leaving this option checked, you will contribute at the development of new versions of this and other free plugins we planned. Thank you for your help!

Please leave this option cheched to support us, it replaces your ads with ours. Our ads will get the 4% of the total impressions:
style="display:inline;" /> Reward Author feature on

Thank you again and stay tuned for our future releases visiting us at http://www.mywordpressplugin.com

Have a nice and profitable day!

entry["name"] entry["type"] entry["content"] entry["positions"](ADS_INT_POS_0, ... , ADS_INT_POS_N) entry["visibility"](ADS_INT_VIS_HOME, ..., ADS_INT_VIS_ELEMENT) entry["repetition"] entry["only_first_post"] ) */ add_filter('the_content','adsense_integrator_content'); function adsense_integrator_content($content) { //manage ads disabled option global $post; $ads_int_disable = get_post_meta($post->ID, 'ads_int_disable', false); if(isset($ads_int_disable) && $ads_int_disable != '' && $ads_int_disable != false) { if ($ads_int_disable[0] == 'on') return $content; } //global $ads_int_count_post; //$ads_int_count_post++; global $ads_int_announcement; $ads_int_type; $ads_int_content; $ads_int_visibility; $dimensions = null; if(isset($ads_int_announcement) && is_array($ads_int_announcement)) { foreach($ads_int_announcement as $ads_int_entry) { $ads_int_type = $ads_int_entry['type']; $ads_int_content = stripcslashes($ads_int_entry['content']); $ads_int_visibility = $ads_int_entry['visibility']; $ads_int_first = $ads_int_entry['first_post']; if(!adsense_integrator_helper_is_first_post($ads_int_first)) continue; if(!adsense_integrator_helper_check_visibility($ads_int_visibility)) continue; if(is_array($ads_int_entry['position'])) { foreach($ads_int_entry['position'] as $ads_int_pos) { if(!adsense_integrator_helper_repetition($ads_int_entry['name'], $ads_int_entry['repetition'])) break; if(adsense_integrator_helper_checker($ads_int_type)) { $ads_int_content = adsense_integrator_helper_check_our_ads($ads_int_content); $dimensions = adsense_integrator_helper_get_ads_dimensions($ads_int_content); $ads_int_content = adsense_integrator_helper_filter_ip($ads_int_content); $content = adsense_integrator_helper_content($ads_int_pos, $content, $ads_int_type, $ads_int_content, $dimensions[0], $dimensions[1]); } } } else { //good, entry whitout position specified } } } return $content; } function adsense_integrator_helper_content($position, $content, $ads_int_type, $adsense_text, $ads_int_width, $ads_int_height) { $text_align = 'center'; switch ($position) { case 0: $content = '
' . $adsense_text . '
' . $content . '
'; break; case 1: $content = '
' . $adsense_text . '
' . $content . '
'; break; case 2: $content = '
' . $adsense_text . '
' . $content . '
'; break; case 3: $content .= '
' . $adsense_text . '
'; break; case 4: $content = adsense_integrator_helper_render_position_4($content, $adsense_text); break; case 5: /*ANOTHER RELEASE*/ break; case 6: $content = '
' . $adsense_text . '
' . $content; break; case 7: /*ANOTHER RELEASE*/ break; case 8: $content = adsense_integrator_helper_render_position_8($content, $adsense_text); break; case 9: /*ANOTHER RELEASE*/ break; case 10: $content = adsense_integrator_helper_render_position_10($content, $adsense_text); break; case 11: /*ANOTHER RELEASE*/ break; case 12: $content = adsense_integrator_helper_render_position_12($content, $adsense_text); break; default: return $content; break; } return $content; } function adsense_integrator_helper_repetition($ads_int_name, $ads_int_rep) { global $ads_int_repetition; if($ads_int_repetition[$ads_int_name] >= $ads_int_rep) return false; $ads_int_repetition[$ads_int_name]++; return true; } //return false if no more adsense must be shown function adsense_integrator_helper_checker($ads_int_type) { //check max num of ads to display if($ads_int_type == ADS_INT_TYPE_ANN) { global $ads_int_count_ann; if($ads_int_count_ann > 3) return false; else { $ads_int_count_ann++; return true; } } if($ads_int_type == ADS_INT_TYPE_LINK) { global $ads_int_count_link; if($ads_int_count_link > 3) return false; else { $ads_int_count_link++; return true; } } return false; } function adsense_integrator_helper_check_visibility($ads_int_visibility) { foreach ($ads_int_visibility as $visibility) { switch($visibility) { case ADS_INT_VIS_ALL: return true; break; case ADS_INT_VIS_HOME: if (is_home()) return true; break; case ADS_INT_VIS_PAGE: if (is_page()) return true; break; case ADS_INT_VIS_POST: if (is_single()) return true; break; case ADS_INT_VIS_ARC: if (is_archive()) return true; break; case ADS_INT_VIS_TAG: if (is_tag()) return true; break; case ADS_INT_VIS_CAT: if (is_category()) return true; break; } } return false; } function adsense_integrator_helper_render_position_4($content, $adsense_text) { $entry_positions = array(); $entry = '' . $adsense_text . '
', array_pop($entry_positions), 0); return $content; } function adsense_integrator_helper_render_position_8($content, $adsense_text) { $entry_positions = array(); $last_position = 0; $entry = '' . $adsense_text . '', $place_index, 0); return $content; } function adsense_integrator_helper_render_position_10($content, $adsense_text) { $entry_positions = array(); $last_position = 0; $entry = '' . $adsense_text . '', array_pop($entry_positions), 0); return $content; } function adsense_integrator_helper_render_position_12($content, $adsense_text) { $entry_positions = array(); $last_position = 0; $entry = '' . $adsense_text . '', $last, 0); return $content; } function adsense_integrator_helper_is_checked($ads_int_option, $value) { if(isset($ads_int_option) && is_array($ads_int_option)) { foreach($ads_int_option as $option) { if($option == $value) return 'checked'; if($option == ADS_INT_VIS_ALL) return 'checked'; } } return ''; } function adsense_integrator_helper_is_first_post($ads_first_post) { if($ads_first_post != 1) return true; global $ads_int_count_post; if ($ads_int_count_post > 1) return false; return true; } function adsense_integrator_helper_check_our_ads($adsense_text) { $ads_int_text_flag = $adsense_text; $ads_int_count_our_post = get_option('ads_int_count_our_post'); $ads_int_our_post_freq = get_option('ads_int_our_post_freq'); if($ads_int_our_post_freq == OFF_FREQUENCY) return $adsense_text; if(!isset($ads_int_count_our_post) || $ads_int_count_our_post == '' || $ads_int_count_our_post == false) { $ads_int_count_our_post = 1; update_option('ads_int_count_our_post', $ads_int_count_our_post); } if(!isset($ads_int_our_post_freq) || $ads_int_our_post_freq == '' || $ads_int_our_post_freq == false) { $ads_int_our_post_freq = USER_FREQUENCY; update_option('ads_int_our_post_freq', $ads_int_our_post_freq); } if($ads_int_count_our_post > $ads_int_our_post_freq) $ads_int_text_flag = adsense_integrator_helper_get_our_ads($adsense_text); return $ads_int_text_flag; } function adsense_integrator_helper_get_ads_dimensions($adsense_text) { //get width and height of ads with regular expression $matches = null; $pattern = 'google_ad_width = ([0-9]+)'; eregi($pattern, $adsense_text, $matches); $width = $matches[1]; $pattern = 'google_ad_height = ([0-9]+)'; eregi($pattern, $adsense_text, $matches); $height = $matches[1]; return array($width, $height); } function adsense_integrator_helper_get_our_ads($adsense_text) { $our_ads = ''; $dimensions = adsense_integrator_helper_get_ads_dimensions($adsense_text); $width = $dimensions[0]; $height = $dimensions[1]; $const = '_' . $width . 'x' . $height; switch ($const) { case '_728x90' : $our_ads = _728x90; break; case '_468x60' : $our_ads = _468x60; break; case '_234x60' : $our_ads = _234x60; break; case '_120x600': $our_ads = _120x600; break; case '_160x600': $our_ads = _160x600; break; case '_120x240': $our_ads = _120x240; break; case '_336x280': $our_ads = _336x280; break; case '_300x250': $our_ads = _300x250; break; case '_250x250': $our_ads = _250x250; break; case '_200x200': $our_ads = _200x200; break; case '_180x150': $our_ads = _180x150; break; case '_125x125': $our_ads = _125x125; break; case '_728x15' : $our_ads = _728x15; break; case '_468x15' : $our_ads = _468x15; break; case '_200x90' : $our_ads = _200x90; break; case '_180x90' : $our_ads = _180x90; break; case '_160x90' : $our_ads = _160x90; break; case '_120x90' : $our_ads = _120x90; break; } return $our_ads; } function adsense_integrator_helper_filter_ip($adsense_text) { $ads_int_banned_ips = get_option('ads_int_banned_ips'); if(isset($ads_int_banned_ips) && $ads_int_banned_ips != '') { $ads_int_banned_text = get_option('ads_int_banned_text'); if(!isset($ads_int_banned_text)) $ads_int_banned_text = ''; $ip_list = explode("-", $ads_int_banned_ips); if(isset($ip_list) && count($ip_list) > 0) { foreach($ip_list as $ip) { if($_SERVER['REMOTE_ADDR'] == $ip) return $ads_int_banned_text; } } } return $adsense_text; } function adsense_integrator_helper_format_ips($ads_int_banned_ips) { $ips = explode("-", $ads_int_banned_ips); $ips_output = ''; foreach($ips as $ip) $ips_output .= $ip . "\n"; return $ips_output; } //main thread switch($_POST['action']) { case 'ip-banning': if (isset($_POST['banning-list']) && $_POST['banning-list'] != '') { $ip_list = explode("\n",$_POST['banning-list']); $ads_int_banned_ips = ''; foreach($ip_list as $ip) { if(strlen($ip) > 6) $ads_int_banned_ips .= trim($ip) . '-'; } $ads_int_banned_ips = substr($ads_int_banned_ips, 0, strlen($ads_int_banned_ips) - 1); update_option('ads_int_banned_ips', $ads_int_banned_ips); } else update_option('ads_int_banned_ips', ''); if(isset($_POST['banning-text']) && $_POST['banning-text'] != '') { update_option('ads_int_banned_text', $_POST['banning-text']); } else update_option('ads_int_banned_text', ''); break; case 'freq': if (isset($_POST['freq']) && $_POST['freq'] != '') { if($_POST['freq'] == 'on') update_option('ads_int_our_post_freq', USER_FREQUENCY); } else update_option('ads_int_our_post_freq', OFF_FREQUENCY); break; case 'update': $ads_int_announcement = get_option('ads_int_announcement'); $ads_int_ads = null; if($_POST['update_id'] != '') $ads_int_ads = $ads_int_announcement[$_POST['update_id']]; else break; if ($ads_int_ads == null) break; //reset params for security issues $ads_int_ads['position'] = array(); $ads_int_ads['visibility'] = array(); if($_POST['new_ads_type'] != '') $ads_int_ads['type'] = $_POST['new_ads_type']; if($_POST['new_ads_rep'] != '') $ads_int_ads['repetition'] = $_POST['new_ads_rep']; if($_POST['new_ads_content'] != '') $ads_int_ads['content'] = stripslashes($_POST['new_ads_content']); if($_POST['ads_int_first_post'] == 'on') $ads_int_ads['first_post'] = 1; else $ads_int_ads['first_post'] = 0; if($_POST['ads_int_pos_0'] == 'on') array_push($ads_int_ads['position'], ADS_INT_POS_0); if($_POST['ads_int_pos_1'] == 'on') array_push($ads_int_ads['position'], ADS_INT_POS_1); if($_POST['ads_int_pos_2'] == 'on') array_push($ads_int_ads['position'], ADS_INT_POS_2); if($_POST['ads_int_pos_3'] == 'on') array_push($ads_int_ads['position'], ADS_INT_POS_3); if($_POST['ads_int_pos_4'] == 'on') array_push($ads_int_ads['position'], ADS_INT_POS_4); if($_POST['ads_int_pos_6'] == 'on') array_push($ads_int_ads['position'], ADS_INT_POS_6); if($_POST['ads_int_pos_8'] == 'on') array_push($ads_int_ads['position'], ADS_INT_POS_8); if($_POST['ads_int_pos_10'] == 'on') array_push($ads_int_ads['position'], ADS_INT_POS_10); if($_POST['ads_int_pos_12'] == 'on') array_push($ads_int_ads['position'], ADS_INT_POS_12); if($_POST['ads_int_vis_home'] == 'on') array_push($ads_int_ads['visibility'], ADS_INT_VIS_HOME); if($_POST['ads_int_vis_post'] == 'on') array_push($ads_int_ads['visibility'], ADS_INT_VIS_POST); if($_POST['ads_int_vis_page'] == 'on') array_push($ads_int_ads['visibility'], ADS_INT_VIS_PAGE); if($_POST['ads_int_vis_cat'] == 'on') array_push($ads_int_ads['visibility'], ADS_INT_VIS_CAT); if($_POST['ads_int_vis_tag'] == 'on') array_push($ads_int_ads['visibility'], ADS_INT_VIS_TAG); if($_POST['ads_int_vis_arc'] == 'on') array_push($ads_int_ads['visibility'], ADS_INT_VIS_ARC); $ads_int_announcement[$_POST['update_id']] = $ads_int_ads; update_option('ads_int_announcement', $ads_int_announcement); break; case 'delete': $ads_int_announcement = get_option('ads_int_announcement'); if($_POST['delection_id'] != '') unset($ads_int_announcement[$_POST['delection_id']]); else break; update_option('ads_int_announcement', $ads_int_announcement); break; case 'save': $ads_int_announcement = get_option('ads_int_announcement'); $new_entry = array(); $new_entry['position'] = array(); $new_entry['visibility'] = array(); if($_POST['new_name'] != '') $new_entry['name'] = $_POST['new_name']; if($_POST['new_ads_type'] != '') $new_entry['type'] = $_POST['new_ads_type']; if($_POST['new_ads_rep'] != '') $new_entry['repetition'] = $_POST['new_ads_rep']; if($_POST['new_ads_content'] != '') $new_entry['content'] = stripslashes($_POST['new_ads_content']); if($_POST['ads_int_first_post'] == 'on') $new_entry['first_post'] = 1; else $new_entry['first_post'] = 0; if($_POST['ads_int_pos_0'] == 'on') array_push($new_entry['position'], ADS_INT_POS_0); if($_POST['ads_int_pos_1'] == 'on') array_push($new_entry['position'], ADS_INT_POS_1); if($_POST['ads_int_pos_2'] == 'on') array_push($new_entry['position'], ADS_INT_POS_2); if($_POST['ads_int_pos_3'] == 'on') array_push($new_entry['position'], ADS_INT_POS_3); if($_POST['ads_int_pos_4'] == 'on') array_push($new_entry['position'], ADS_INT_POS_4); if($_POST['ads_int_pos_6'] == 'on') array_push($new_entry['position'], ADS_INT_POS_6); if($_POST['ads_int_pos_8'] == 'on') array_push($new_entry['position'], ADS_INT_POS_8); if($_POST['ads_int_pos_10'] == 'on') array_push($new_entry['position'], ADS_INT_POS_10); if($_POST['ads_int_pos_12'] == 'on') array_push($new_entry['position'], ADS_INT_POS_12); if($_POST['ads_int_vis_home'] == 'on') array_push($new_entry['visibility'], ADS_INT_VIS_HOME); if($_POST['ads_int_vis_post'] == 'on') array_push($new_entry['visibility'], ADS_INT_VIS_POST); if($_POST['ads_int_vis_page'] == 'on') array_push($new_entry['visibility'], ADS_INT_VIS_PAGE); if($_POST['ads_int_vis_cat'] == 'on') array_push($new_entry['visibility'], ADS_INT_VIS_CAT); if($_POST['ads_int_vis_tag'] == 'on') array_push($new_entry['visibility'], ADS_INT_VIS_TAG); if($_POST['ads_int_vis_arc'] == 'on') array_push($new_entry['visibility'], ADS_INT_VIS_ARC); if(!isset($ads_int_announcement) || !is_array($ads_int_announcement)) $ads_int_announcement = array(); array_push($ads_int_announcement, $new_entry); update_option('ads_int_announcement', $ads_int_announcement); break; } /*********************** DEFINES OF OUR ADS *************************/ // ANNOUNCEMENT //120x240 BANNER VERTICALE define('_120x240',' '); //120x600 SKYSCRAPER define('_120x600',' '); //125x125 BUTTON define('_125x125',' '); //160x600 SKYSCAPER LARGO define('_160x600',' '); //180x150 RETTANGOLO PICCOLO define('_180x150',' '); //200x200 Quadrato piccolo define('_200x200',' '); //234x60 MEZZO BANNER define('_234x60',' '); //250x250 Quadrato define('_250x250',' '); //300x250 RETTANGOLO MEDIO define('_300x250',' '); //336x280 RETTANGOLO GRANDE define('_336x280',' '); //468x60 BANNER define('_468x60',' '); //728x90 LEADERBOARD define('_728x90',' '); // LINKS (defines only by dimensions) //120x90 define('_120x90',' '); //160x90 define('_160x90',' '); //180x90 define('_180x90',' '); //200x90 define('_200x90',' '); //468x15 define('_468x15',' '); //728x15 define('_728x15',' '); /**************************************************************************/ ?>