Last active
September 11, 2024 01:32
-
-
Save khoipro/41f4bc8a9db24f7b53cbfdcefcf1aca4 to your computer and use it in GitHub Desktop.
Ninjafirewall : Whitelist admin actions and keep original IP with CloudFlare
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Ninjafirewall Custom Rules | |
* | |
* @package codetot-maintenance | |
* @author codetot | |
* @since 0.0.1 | |
**/ | |
if ( !empty($_POST['_wpnonce']) && strpos($_SERVER['SCRIPT_NAME'], '/wp-admin/post.php') !== FALSE ) { | |
return 'ALLOW'; | |
} | |
if ( !empty($_POST['_wpnonce']) && strpos($_SERVER['SCRIPT_NAME'], '/wp-admin/admin-ajax.php') !== FALSE ) { | |
return 'ALLOW'; | |
} | |
if (! empty($_SERVER["HTTP_CF_CONNECTING_IP"]) && | |
filter_var($_SERVER["HTTP_CF_CONNECTING_IP"],FILTER_VALIDATE_IP)) { | |
$_SERVER["REMOTE_ADDR"] = $_SERVER["HTTP_CF_CONNECTING_IP"]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment