Nick Daugherty Description: This plugin uses Javascript to show ad widgets to users based on their country. Uses the awesome MaxMind GeoIP Javascript Web Service. 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, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA MaxMind's API is extremely fast, lightweight, and most of all, free. DISCLAIMER: The author of this plugin is in no way associated with MaxMind, and this plugin is not sanctioned or supported by MaxMind in any way. This plugin is offered with no warranties or guarantees, expressed or implied. The author of this plugin is in no way responsible for any results associated with the use of this plugin. Special thanks to Patrick Friedl for his WP-Geolocation plugin: http://wordpress.org/extend/plugins/wp-geolocation-js/ 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 2 of the License, or (at your option) any later version. */ ?> document.write(geoip_country_code());'; } function getCountryName() { return ''; } function getIPAddress() { return $_SERVER['REMOTE_ADDR']; } } } // end class WPGeoLocation // initialize the WPGeoLocation class if (class_exists("WPGeoLocation")) { $wp_geolocation = new WPGeoLocation(); global $geo_countrycode; global $geo_countryname; } //------------------------------------------------------------------------// //---Hooks-and-Shortcodes-------------------------------------------------// //------------------------------------------------------------------------// if (isset($wp_geolocation)) { // Actions add_action('wp_head', array(&$wp_geolocation, 'addHeaderCode'), 100); add_action( 'widgets_init', 'load_abc_widget' ); // Shortcodes add_shortcode('mmjs-countrycode', array(&$wp_geolocation, 'getCountryCode')); add_shortcode('mmjs-countryname', array(&$wp_geolocation, 'getCountryName')); add_shortcode('mmjs-ip', array(&$wp_geolocation, 'getIPAddress')); } //------------------------------------------------------------------------// //---Options Page---------------------------------------------------------// //------------------------------------------------------------------------// function skyrocket_abc_admin_menu() { $title = 'Ads By Country'; add_options_page($title, $title, 'manage_options', dirname(__FILE__) . '/options.php'); } add_action('admin_menu', 'skyrocket_abc_admin_menu'); //------------------------------------------------------------------------// //---Widget---------------------------------------------------------------// //------------------------------------------------------------------------// function load_abc_widget() { register_widget('AdsByCountryWidget'); } class AdsByCountryWidget extends WP_Widget { // Declares the AdsByCountryWidget class. function AdsByCountryWidget(){ $widget_ops = array('classname' => 'widget_adsbycountry', 'description' => __( "Configure and set up display rules on the Ads by Country administration page.") ); $this->WP_Widget('adsbycountry', __('Ads By Country'), $widget_ops); } // Display the Widget function widget($args, $instance){ extract($args); # User-selected Settings $title = apply_filters('widget_title', $instance['title']); # Before the widget echo $before_widget; # The title if ( $title ) echo $before_title . $title . $after_title; # Make the widget -- HTML CODE GOES HERE ?> '' ) ); $title = htmlspecialchars($instance['title']); # Output the options //Title echo '
'; echo '
'. sprintf( __('Configure and set up display rules on the Ads by Country settings page.'), admin_url('options-general.php?page=ads-by-country/options.php') ) .'
'; } } // END AdsByCountryWidget class ?>