Settings → AdSense Now!, or use the "Settings" link on the right. Version: 1.37 Author: Manoj Thulasidas Author URI: http://www.thulasidas.com */ /* Copyright (C) 2008 www.thulasidas.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ if (!class_exists("adsNow")) { class adsNow { var $plugindir, $locale ; function adsNow() { //constructor } function init() { $this->getAdminOptions(); } //Returns an array of admin options function getAdminOptions($reset = false) { $mThemeName = get_settings('stylesheet') ; $mOptions = "adsNow" . $mThemeName ; $this->plugindir = get_option('siteurl') . '/' . PLUGINDIR . '/' . basename(dirname(__FILE__)) ; $locale = get_locale(); $this->locale = $locale ; if(!empty($this->locale) && $this->locale != 'en_US') { $moFile = dirname(__FILE__) . '/lang/' . $this->locale . '/easy-adsenser.mo'; if(@file_exists($moFile) && is_readable($moFile)) load_textdomain('easy-adsenser', $moFile); else { // look for any other similar locale with the same first three characters $foo = glob(dirname(__FILE__) . '/lang/' . substr($this->locale, 0, 2) . '*/easy-adsenser.mo') ; if (!empty($foo)>0) { $moFile = $foo[0] ; load_textdomain('easy-adsenser', $moFile); $this->locale = basename(dirname($moFile)) ; } } } $adsNowAdminOptions = array( 'info' => "\n", 'ad_text' => ' ', 'show_leadin' => 'float:right', 'show_midtext' => 'float:left', 'show_leadout' => 'float:right', 'kill_pages' => false, 'kill_home' => false, 'kill_front' => false, 'kill_cat' => false, 'kill_tag' => false, 'kill_archive' => false ); $adNwOptions = get_option($mOptions); if (empty($adNwOptions)) { // try loading the default from the pre 1.3 version, so as not to annoy // the dudes who have already been using adNwsenser $adminOptionsName = "adsNowAdminOptions"; $adNwOptions = get_option($adminOptionsName); } if (!empty($adNwOptions) && ! $reset) { foreach ($adNwOptions as $key => $option) $adsNowAdminOptions[$key] = $option; } update_option($mOptions, $adsNowAdminOptions); return $adsNowAdminOptions; } //Prints out the admin page function printAdminPage() { $mThemeName = get_settings('stylesheet') ; $mOptions = "adsNow" . $mThemeName ; $adNwOptions = $this->getAdminOptions(); if (isset($_POST['update_adsNowSettings'])) { if (isset($_POST['adsNowText'])) { $adNwOptions['ad_text'] = $_POST['adsNowText']; } if (isset($_POST['adsNowShowLeadin'])) { $adNwOptions['show_leadin'] = $_POST['adsNowShowLeadin']; } if (isset($_POST['adsNowShowMidtext'])) { $adNwOptions['show_midtext'] = $_POST['adsNowShowMidtext']; } if (isset($_POST['adsNowShowLeadout'])) { $adNwOptions['show_leadout'] = $_POST['adsNowShowLeadout']; } $adNwOptions['kill_pages'] = $_POST['adNwKillPages']; $adNwOptions['kill_home'] = $_POST['adNwKillHome']; $adNwOptions['kill_front'] = $_POST['adNwKillFront']; $adNwOptions['kill_cat'] = $_POST['adNwKillCat']; $adNwOptions['kill_tag'] = $_POST['adNwKillTag']; $adNwOptions['kill_archive'] = $_POST['adNwKillArchive']; $adNwOptions['info'] = $this->info() ; update_option($mOptions, $adNwOptions); ?>

getAdminOptions($reset); ?>

getAdminOptions($reset); $this->cleanDB('adsNow'); ?>

' . __("Error locating the admin page!\nEnsure admin.php exists, or reinstall the plugin.", 'easy-adsenser') . '' ; ?> \n"; return $str ; } var $nwMax = 3 ; function cleanDB($prefix){ global $wpdb ; $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '$prefix%'") ; } function plugin_action($links, $file) { if ($file == plugin_basename(dirname(__FILE__).'/adsense-now.php')){ $settings_link = "" . __('Settings', 'easy-adsenser') . ""; array_unshift( $links, $settings_link ); } return $links; } function contentMeta() { $ezAdOptions = $this->getAdminOptions(); global $post; $meta = get_post_custom($post->ID); $adkeys = array('adsense', 'adsense-top', 'adsense-middle', 'adsense-bottom') ; $ezkeys = array('adsense', 'show_leadin', 'show_midtext', 'show_leadout') ; $metaOptions = array() ; // initialize to ezAdOptions foreach ($ezkeys as $key => $optKey) { $metaOptions[$ezkeys[$key]] = $ezAdOptions[$optKey] ; } // overwrite with custom fields if (!empty($meta)) { foreach ($meta as $key => $val) { $tkey = array_search(strtolower(trim($key)), $adkeys) ; if ($tkey !== FALSE) { $value = strtolower(trim($val[0])) ; // ensure valid values for options if ($value == 'left' || $value == 'right' || $value == 'center' || $value == 'no') { if ($value == 'left' || $value == 'right') $value = 'float:' . $value ; if ($value == 'center') $value = 'text-align:' . $value ; $metaOptions[$ezkeys[$tkey]] = $value ; } } } } return $metaOptions ; } function adsNow_content($content) { $adNwOptions = $this->getAdminOptions(); if ($adNwOptions['kill_pages'] && is_page()) return $content ; if ($adNwOptions['kill_home'] && is_home()) return $content ; if ($adNwOptions['kill_front'] && is_front_page()) return $content ; if ($adNwOptions['kill_cat'] && is_catagory()) return $content ; if ($adNwOptions['kill_tag'] && is_tag()) return $content ; if ($adNwOptions['kill_archive'] && is_archive()) return $content ; global $nwCount ; if ($nwCount >= $this->nwMax) return $content ; if(strpos($content, "") !== false) return $content; $metaOptions = $this->contentMeta() ; if ($metaOptions['adsense'] == 'no') return $content; $show_leadin = $metaOptions['show_leadin'] ; $leadin = '' ; if ($show_leadin != 'no') { if ($nwCount < $this->nwMax) { $nwCount++; $leadin = stripslashes($adNwOptions['info'] . "\n" . '
' . $adNwOptions['ad_text'] . '
') ; } } $show_midtext = $metaOptions['show_midtext'] ; if ($show_midtext != 'no') { if ($nwCount < $this->nwMax) { $poses = array(); $lastpos = -1; $repchar = " $half) array_pop($poses); $pickme = $poses[floor(sizeof($poses)/2)]; $nwCount++; $midtext = stripslashes($adNwOptions['info'] . "\n" . '
' . $adNwOptions['ad_text'] . '
') ; $content = substr_replace($content, $midtext.$repchar, $pickme, 2); } } $show_leadout = $metaOptions['show_leadout'] ; $leadout = '' ; if ($show_leadout != 'no') { if ($nwCount < $this->nwMax) { $nwCount++; $leadout = stripslashes($adNwOptions['info'] . "\n" . '
' . $adNwOptions['ad_text'] . '
') ; } } return $leadin . $content . $leadout ; } } } //End Class adsNow $nwCount = 0 ; if (class_exists("adsNow")) { $nw_ad = new adsNow(); if (isset($nw_ad)) { //Initialize the admin panel if (!function_exists("adsNow_ap")) { function adsNow_ap() { global $nw_ad ; if (function_exists('add_options_page')) { add_options_page('AdSense Now!', 'AdSense Now!', 9, basename(__FILE__), array(&$nw_ad, 'printAdminPage')); } } } add_filter('the_content', array($nw_ad, 'adsNow_content')); add_action('admin_menu', 'adsNow_ap'); add_action('activate_' . basename(dirname(__FILE__)) . '/' . basename(__FILE__), array(&$nw_ad, 'init')); add_filter('plugin_action_links', array($nw_ad, 'plugin_action'), -10, 2); } } ?>