A powerful WordPress plugin for conditional content swapping based on multiple criteria.
Create rules with multiple conditions using AND/OR logic:
- AND Logic: All conditions must be met
- OR Logic: At least one condition must be met
- Device is mobile phone
- Device is desktop
- Device is tablet
- Windows
- Mac
- Linux
- Android
- iOS
- Country detection (requires CloudFlare or geo-location service)
- User is logged in
- User is logged out
- User has specific role
- Date is after
- Date is before
- Day of week is
- Time is after
- Time is before
- URL parameter exists
- URL parameter equals specific value
- Referrer contains specific text
- Cookie exists
- Cookie equals specific value
- Go to WordPress Admin > Regulator
- Click Add New Rule
- Select a Source Page (the page where the rule will be applied)
- Regular pages
- 🏠 Front Page (for block themes)
- 📰 Blog Page (for block themes)
- Add one or more Conditions:
- Click "Add Condition" to add multiple conditions
- Select condition type from categorized dropdowns
- Enter values for conditions that require them
- Choose AND/OR logic for multiple conditions
- Select a Target Page (the content that will replace the source page)
- Both published and draft pages are available
- Draft pages are marked with (Draft) for easy identification
- Perfect for testing before publishing!
- Set Priority if you have multiple rules on the same page
- Enable/disable the rule with the Active checkbox
- Click Save Rule
Source Page: Homepage
Conditions:
- Device is mobile phone (AND)
- Country is United States
Logic: AND (match all)
Target Page: Mobile US Homepage
Source Page: Product Page
Conditions:
- Device is desktop (OR)
- Device is tablet
Logic: OR (match any)
Target Page: Desktop Product Page
Source Page: Landing Page
Conditions:
- Operating System: Windows (AND)
- Device is desktop (AND)
- Country is Canada
Logic: AND (match all)
Target Page: Canada Windows Landing Page
Country detection requires a geo-location service. The plugin supports:
- CloudFlare - Automatically detected via
HTTP_CF_IPCOUNTRYheader - Custom Headers - Supports common headers like:
HTTP_X_COUNTRY_CODEHTTP_GEOIP_COUNTRY_CODEHTTP_X_GEOIP_COUNTRY_CODE
If you're using CloudFlare, country detection works automatically. No additional setup needed.
Add a filter to integrate your geo-location service:
add_filter('regulator_check_country', function($result, $country_code) {
// Your custom geo-location logic here
$user_country = your_geo_service_get_country();
return strtoupper($user_country) === strtoupper($country_code);
}, 10, 2);Operating systems are detected via User Agent strings:
- Windows: Detects all Windows versions
- Mac: Detects macOS/Mac OS X
- Linux: Detects Linux (excluding Android)
- Android: Detects Android OS
- iOS: Detects iPhone, iPad, and iPod
Device types are detected using:
- Mobile: WordPress's
wp_is_mobile()function - Desktop: Inverse of mobile detection
- Tablet: Enhanced detection including iPad, Android tablets, etc.
When multiple rules exist for the same page:
- Rules are evaluated in order of priority (highest first)
- The first rule whose conditions are met will be applied
- No other rules are evaluated after a match
The plugin creates a wp_regulator_rules table with the following fields:
id: Unique rule identifiersource_page_id: The page where conditions are checkedtarget_page_id: The page content to displayconditions: JSON array of conditionscondition_logic: AND or ORis_active: Enable/disable the rulepriority: Evaluation order
// Add your condition check
add_filter('regulator_check_condition', function($result, $condition_type, $condition_value) {
if ($condition_type === 'custom_condition') {
// Your custom logic here
return true; // or false
}
return $result;
}, 10, 3);Modify the get_condition_types() method in the main plugin class to add new condition types.
- Initial release
- Multiple conditions support
- AND/OR logic
- Device type detection
- Operating system detection
- Country detection
- User conditions
- Date & time conditions
- Advanced URL and cookie conditions
If you're having trouble saving rules:
- Clear your browser cache - Press Ctrl+F5 (Windows) or Cmd+Shift+R (Mac) to hard refresh
- Check browser console - Open Developer Tools (F12) and check the Console tab for errors
- Ensure all fields are filled:
- Source Page must be selected
- At least one condition must be added
- Target Page must be selected
- Check permissions - Ensure you have admin/manage_options capability
If you upgraded from a previous version:
- Deactivate the plugin
- Reactivate the plugin (this will update the database schema)
The plugin requires a modern browser that supports:
- FormData API
- ES6 JavaScript features
- Recommended: Chrome, Firefox, Safari, or Edge (latest versions)
GPL v2 or later