Check if I am in the Admin Panel (wp-admin)?

You can use the is_admin function. By definition, it checks “Whether the current request is for an administrative interface page.”

You might also want to verify you are not doing an AJAX call by doing

if ( ! is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
    # code here...
}

Leave a Comment