Skip to content

Instantly share code, notes, and snippets.

@CharlieEtienne
Created December 12, 2021 21:23
Show Gist options
  • Save CharlieEtienne/13619d58e7cc6629b5b9710ef9ac77c4 to your computer and use it in GitHub Desktop.
Save CharlieEtienne/13619d58e7cc6629b5b9710ef9ac77c4 to your computer and use it in GitHub Desktop.
Whitelist IPs in Elementor Maintenance Mode
<?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