Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the spinupwp domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /sites/coreysalzano.com/files/wp-includes/functions.php on line 6121
Why Elementor Disobeys is_admin() – Corey Salzano

Why Elementor Disobeys is_admin()

I was surprised to learn that when editing a page using Elementor‘s page builder, is_admin() returns false. The reason for this is that Elementor is loading the page in an <iframe> element as if it were being viewed on the front-end.

Use code like this to detect when posts or pages are being edited in Elementor. Code like this is useful to me because sometimes I add a meta refresh element to automatically start a download, and I don’t want the redirect and download to happen while editing the page.

//don't do anything if we're editing in Elementor
if( \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
    return;
}

Here is other code that relies on a URL querystring parameter.

//don't do anything if we're editing post 1112 in Elementor
if( isset( $_GET['elementor-preview'] ) && '1112' == $_GET['elementor-preview'] ) {
    return;
}