Created
December 12, 2021 21:23
-
-
Save CharlieEtienne/13619d58e7cc6629b5b9710ef9ac77c4 to your computer and use it in GitHub Desktop.
Whitelist IPs in Elementor Maintenance Mode
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 | |
function my_elementor_maintenance_mode_whitelist_ips() { | |
// IPs Whitelist | |
$whitelist = [ | |
'127.0.0.1', | |
'88.123.181.218', | |
]; | |
if ( | |
in_array( $_SERVER[ 'REMOTE_ADDR' ], $whitelist ) | |
&& method_exists( '\Elementor\Plugin', 'instance' ) | |
&& isset( \Elementor\Plugin::instance()->maintenance_mode ) | |
) { | |
remove_action( 'template_redirect', [ \Elementor\Plugin::instance()->maintenance_mode, 'template_redirect' ], 11 ); | |
} | |
} | |
add_action( 'template_redirect', 'my_elementor_maintenance_mode_whitelist_ips', 5 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment