=== GeoIP Content Switcher === Contributors: pathakhrkinc Tags: geoip, country detection, woocommerce, geolocation, content switcher Requires at least: 5.8 Tested up to: 6.9 Requires PHP: 7.4 Stable tag: 1.0.5 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html Automatically switches content, payments, shipping, and products based on visitor's country using GeoIP detection. == Description == GeoIP Content Switcher is a professional WordPress plugin that automatically detects your visitor's country and dynamically switches content, payments, shipping methods, and products accordingly. Perfect for international WooCommerce stores and multi-country websites. = Key Features = **Automatic Country Detection** * MaxMind GeoLite2 Database integration * Cloudflare CF-IPCountry header support * Session caching for optimal performance * Accurate IP-based geolocation **Subdomain Redirection** * Automatic redirect to country-specific subdomains * Example: US visitors → us.yoursite.com * Geo-lock option to prevent manual country switching * Seamless cross-subdomain session management **WooCommerce Integration** * Filter payment gateways by country * Filter shipping methods by country * Hide products or categories by country * Full WooCommerce HPOS compatibility **Content Switching** * Country-specific homepage * Custom header content per country * Custom footer content per country * Full Elementor and page builder support **Performance Optimized** * Session caching with configurable duration * Cloudflare integration * Compatible with WP Rocket, LiteSpeed Cache, W3 Total Cache * Minimal server resource usage **Security Features** * Database files protected from direct access * Input sanitization and validation * Nonce verification for all forms * Capability checks for admin functions * Secure session handling **Developer Friendly** * Clean, well-documented code * Shortcodes for displaying country info * Hooks and filters for customization * PSR-4 autoloading = Shortcodes = * `[geoip_country]` - Display visitor's country name * `[geoip_country format="code"]` - Display country code (e.g., US, UK, IN) * `[geoip_ip]` - Display visitor's IP address = Requirements = * WordPress 5.8 or higher * PHP 7.4 or higher (compatible with PHP 8.0, 8.1, 8.2, 8.3) * WooCommerce 5.0 or higher (optional, for e-commerce features) * MaxMind GeoLite2 Country Database (free download) = Use Cases = * International e-commerce stores * Multi-country business websites * Region-specific content delivery * Localized payment and shipping options * Country-based product catalogs * Geo-targeted marketing campaigns = Compatibility = **Themes:** * Woodmart (fully tested) * Astra * Divi * Elementor * Any WordPress theme **Cache Plugins:** * WP Rocket * LiteSpeed Cache * W3 Total Cache * WP Super Cache * Cloudflare **Page Builders:** * Elementor * WPBakery * Beaver Builder * Divi Builder == Installation == = Automatic Installation = 1. Log in to your WordPress admin panel 2. Navigate to Plugins → Add New 3. Search for "GeoIP Content Switcher" 4. Click "Install Now" and then "Activate" 5. Follow the setup wizard to complete configuration = Manual Installation = 1. Download the plugin ZIP file 2. Log in to your WordPress admin panel 3. Navigate to Plugins → Add New → Upload Plugin 4. Choose the ZIP file and click "Install Now" 5. Click "Activate Plugin" = Post-Installation Setup = **Step 1: Install MaxMind GeoLite2 Database** 1. Sign up for a free MaxMind account at https://www.maxmind.com/en/geolite2/signup 2. Download the GeoLite2 Country database (MMDB format) 3. Extract the `GeoLite2-Country.mmdb` file 4. Upload it to: `/wp-content/plugins/geoip-content-switcher/database/` **Step 2: Configure Plugin Settings** 1. Go to WordPress Admin → GeoIP Switcher 2. Select your active countries 3. Set a default fallback country 4. Configure subdomain mappings (if using subdomains) 5. Set up payment and shipping rules per country 6. Configure product visibility rules 7. Save settings **Step 3: Test the Setup** 1. Use a VPN or proxy to test from different countries 2. Verify subdomain redirects work correctly 3. Check payment and shipping methods display correctly 4. Test product visibility per country = Composer Dependencies (Advanced) = If you're installing manually and the vendor folder is missing: 1. Ensure Composer is installed on your server 2. Navigate to the plugin directory 3. Run: `composer install --no-dev` Note: The plugin package includes all dependencies pre-installed. == Frequently Asked Questions == = Does this plugin work without WooCommerce? = Yes! The plugin works with any WordPress site. WooCommerce integration is optional and only activates if WooCommerce is installed. = Where do I get the MaxMind GeoLite2 database? = You can download it for free from MaxMind: 1. Sign up at https://www.maxmind.com/en/geolite2/signup 2. Download the GeoLite2 Country database (MMDB format) 3. Place the file in the plugin's `database/` folder = Is the MaxMind database included? = No, due to MaxMind's license terms, you must download it separately. It's free and takes just a few minutes to set up. = Is this plugin compatible with caching plugins? = Yes! It's fully compatible with: * WP Rocket * LiteSpeed Cache * W3 Total Cache * WP Super Cache * Cloudflare The plugin uses session-based caching to work seamlessly with page caching. = Does it work with Cloudflare? = Yes! The plugin automatically detects and uses Cloudflare's CF-IPCountry header for faster and more accurate country detection. = Can I use this without subdomains? = Absolutely! Subdomain redirection is optional. You can use the plugin just for content switching, payment filtering, or product visibility without any subdomain setup. = Does it support PHP 8? = Yes! Fully tested and compatible with: * PHP 7.4 * PHP 8.0 * PHP 8.1 * PHP 8.2 * PHP 8.3 = Will this slow down my website? = No! The plugin is highly optimized: * Country detection is cached in sessions * Minimal database queries * Cloudflare integration for instant detection * Compatible with all major caching plugins = Can I customize which payment methods show per country? = Yes! The admin panel lets you select which payment gateways are available for each country. = Can I hide specific products for certain countries? = Yes! You can hide entire product categories per country through the admin settings. = Does it work with Elementor? = Yes! The plugin is fully compatible with Elementor and other page builders. You can create country-specific pages and assign them as homepages. = Is it GDPR compliant? = Yes! The plugin: * Only stores country code in sessions (no personal data) * Uses IP addresses only for geolocation (not stored) * Doesn't use cookies for tracking * Complies with GDPR requirements = Can I display the visitor's country on my site? = Yes! Use these shortcodes: * `[geoip_country]` - Shows country name * `[geoip_country format="code"]` - Shows country code * `[geoip_ip]` - Shows IP address = Does it support WooCommerce HPOS? = Yes! The plugin is fully compatible with WooCommerce High-Performance Order Storage (HPOS). = Can I test it locally? = Yes, but country detection won't work on localhost (127.0.0.1). You'll need to: * Use a VPN to test different countries * Deploy to a staging server * Or manually set a test country in the code = How do I update the MaxMind database? = MaxMind updates their database monthly. To update: 1. Download the latest GeoLite2 Country database 2. Replace the old `GeoLite2-Country.mmdb` file in the `database/` folder 3. Clear your site cache = Can I use this for currency switching? = Currently, the plugin focuses on content, payments, and shipping. Currency switching is planned for a future version. = Does it work with multisite? = The plugin is designed for single-site installations. Multisite compatibility is not officially supported at this time. = Where can I get support? = For support, please use the WordPress.org support forum for this plugin. For priority support or custom development, contact the developer. == Screenshots == 1. Main settings dashboard - Configure countries and default settings 2. Country configuration - Select active countries and set defaults 3. Subdomain redirect settings - Map countries to subdomains 4. Payment method filtering - Choose payment gateways per country 5. Shipping method filtering - Select shipping methods per country 6. Product visibility control - Hide categories by country 7. Homepage switcher - Assign custom homepage per country 8. Header/Footer customization - Add country-specific content == Changelog == = 1.0.5 = * Initial public release * Country detection via MaxMind GeoLite2 database * Cloudflare CF-IPCountry header support * Subdomain redirection with geo-lock * WooCommerce payment gateway filtering * WooCommerce shipping method filtering * Product visibility control by country * Homepage switching per country * Header/footer content customization * Session-based caching * Cache plugin compatibility * WooCommerce HPOS compatibility * Elementor and page builder support * Security hardening and input validation * Shortcodes for country display * Cross-subdomain session handling * Admin settings interface * PHP 7.4 - 8.3 compatibility == Upgrade Notice == = 1.0.5 = Initial release of GeoIP Content Switcher. Install the MaxMind GeoLite2 database after activation for full functionality. == Additional Information == = About MaxMind GeoLite2 = This plugin uses the free GeoLite2 database created by MaxMind, available from https://www.maxmind.com. The database provides country-level IP geolocation data. = Privacy Policy = This plugin: * Detects visitor country using IP address * Stores only country code in PHP sessions (temporary) * Does not store IP addresses in the database * Does not share data with third parties * Does not use tracking cookies = Credits = * MaxMind GeoLite2: https://www.maxmind.com/ * GeoIP2 PHP Library: https://github.com/maxmind/GeoIP2-php = Developer = Developed by RAJ PATHAK Email: Rajpathak.engineer@gmail.com = Support the Plugin = If you find this plugin helpful, please: * Rate it 5 stars on WordPress.org * Share it with others who might need it * Report bugs or suggest features in the support forum == Technical Details == = System Requirements = * WordPress 5.8+ * PHP 7.4+ (8.0, 8.1, 8.2, 8.3 supported) * MySQL 5.6+ or MariaDB 10.0+ * WooCommerce 5.0+ (optional) * MaxMind GeoLite2 Country Database = File Structure = * `/includes/` - Core plugin classes * `/assets/` - CSS and JavaScript files * `/database/` - MaxMind database location * `/vendor/` - Composer dependencies * `/languages/` - Translation files = Hooks and Filters = Developers can extend the plugin using WordPress hooks and filters. Documentation available in the code comments. = License = This plugin is licensed under the GPL v2 or later. 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. 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.