Skip to content

Instantly share code, notes, and snippets.

@Giacomo92
Forked from CharlieEtienne/functions.php
Created February 15, 2022 12:30
Show Gist options
  • Save Giacomo92/e88fc24c6269bf45547a5c7a05942651 to your computer and use it in GitHub Desktop.
Save Giacomo92/e88fc24c6269bf45547a5c7a05942651 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