Table of Contents
Introduction
The WordPress IP Cloaking plugin is meant to protect your website against unwanted bot and spam traffic. It is a WordPress plugin that allows you to serve different content to specific IP addresses. This plugin is useful for:
- Managing access to content based on IP addresses
- Serving different content to different visitors
- Implementing IP-based content restrictions
Requirements
- WordPress 5.0 or higher
- PHP 7.2 or higher
- MySQL 5.6 or higher
Installation
Manual Installation
- Download the plugin ZIP file
- Log in to your WordPress admin panel
- Navigate to Plugins → Add New
- Click the “Upload Plugin” button
- Choose the downloaded ZIP file
- Click “Install Now”
- After installation, click “Activate Plugin”
Directory Structure
ip-content-manager/
├── css/
│ └── seo-checker.css
├── ip-content-manager.php
└── README.txt
Getting Started
After installation, you’ll find a new menu item in your WordPress admin panel:
Settings → IP Content Manager
Initial Setup
- Navigate to the IP Content Manager settings page
- Add your first IP address
- Select a default alternate page for blocked IPs
- Save your settings
Configuration
General Settings
Adding IP Addresses
- Go to Settings → IP Content Manager
- In the “IP Management” section, enter the IP address
- Click “Add IP”
- The IP will appear in the list below
Selecting Alternate Content
- Use the dropdown menu to select any published page
- This page will be shown to visitors from blacklisted IPs
- Click “Save Changes”
Advanced Configuration
Managing Multiple IPs
- Use the bulk import feature for multiple IPs
- Each IP can be individually deleted using the “Delete” button
- IPs are automatically validated before being added
Usage
Basic Usage
Adding a Single IP
// Example format for adding IPs
123.45.67.89 // Single IP
192.168.1.1 // Local IP
Removing an IP
- Find the IP in the list
- Click the “Delete” button next to it
- Confirm the deletion
Content Management
Selecting Content
- Choose any published page from the dropdown
- The selected page will be shown to blacklisted IPs
- Regular visitors will see normal content
Testing Configuration
- Add your own IP for testing
- Visit your site in an incognito window
- Verify that you see the alternate content
- Remove your IP when testing is complete
Advanced Features
IP Validation
The plugin automatically validates IP addresses for:
- Correct format
- Valid ranges
- Proper syntax
Security Features
- IP addresses are sanitized before storage
- Database queries are prepared and escaped
- WordPress nonces are used for form submissions
Troubleshooting
Common Issues
Plugin Not Working
- Verify plugin activation
- Check IP format is correct
- Ensure alternate page is published
- Verify WordPress permissions
IPs Not Being Blocked
- Check IP format
- Clear site cache
- Disable other security plugins temporarily
- Verify server configuration
Error Messages
“Invalid IP Address”
- Ensure IP format is correct (xxx.xxx.xxx.xxx)
- Check for typos
- Verify IP is valid
“Could Not Save Settings”
- Check WordPress permissions
- Verify database connection
- Ensure WordPress is up to date
FAQ
General Questions
Q: Can I block IP ranges?
A: Currently, the plugin supports individual IP addresses only.
Q: Will this affect my site’s performance?
A: The plugin is lightweight and optimized for performance with minimal impact.
Q: Can I block multiple IPs at once?
A: Yes, using the bulk import feature.
Technical Questions
Q: Does this work with caching plugins?
A: Yes, but you may need to configure cache exclusions.
Q: Can I programmatically add IPs?
A: Yes, using the plugin’s PHP functions or WordPress hooks.
Technical Reference
Functions
// Check if an IP is blacklisted
isBotIP($ip)
// Add an IP to blacklist
ajax_add_blacklist_ip()
// Remove an IP from blacklist
ajax_delete_blacklist_ip()
// Modify content for blacklisted IPs
modify_content($content)
Hooks and Filters
// Filter content for blacklisted IPs
add_filter('the_content', array($this, 'modify_content'));
// Action for IP management
add_action('wp_ajax_add_blacklist_ip', array($this, 'ajax_add_blacklist_ip'));
add_action('wp_ajax_delete_blacklist_ip', array($this, 'ajax_delete_blacklist_ip'));
Database
The plugin uses WordPress options API:
icm_blacklisted_ips
: Array of blocked IPsicm_alternate_page_id
: ID of page shown to blocked IPs
Security Considerations
1. Input Validation
- All IP addresses are validated
- Form submissions use nonces
- Data is sanitized before storage
2. Output Escaping
- All output is escaped using WordPress functions
- HTML is properly sanitized
- SQL queries are prepared
3. Permissions
- Only administrators can manage settings
- Capabilities are checked for all admin actions