Bricks editor not working with redirect code

I have added a site wide redirect bit of code to my functions.php file… but for some reason it seems to be blocking access to editing templates. The code is here:

add_action( 'template_redirect', function () {  

    /**
     * Determines whether the current request is NOT for an administrative interface page NOR a WordPress Ajax request.
     * Determines whether the query is NOT for the blog homepage NOR for the front page of the site.
     * 
     * is_admin() returns true for Ajax requests, since wp-admin/admin-ajax.php defines the WP_ADMIN constant as true.
     * @see https://developer.wordpress.org/reference/functions/is_admin/#comment-5755
     */
    if ( ! is_admin() && ! wp_doing_ajax() && ! is_home() && ! is_front_page() ) {

        /**
         * Performs a safe (local) redirect, using wp_redirect().
         * 
         * By default the status code is set to 302.
         * @see https://developer.wordpress.org/reference/functions/wp_safe_redirect/#parameters
         */
        wp_safe_redirect( home_url() );

        exit;

    };

} );

which works fine as a redirect, but doesn’t let me access the URL …/template/115/?bricks=run

Interestingly, it allows me to edit page templates as the URL is just …/?bricks=run so it doesn’t seem to be blocking that… Perhaps it’s blowing the /template/ directory, but I don’t think it should be…

Im posting here because Im not sure if its a bug or something I’m doing wrong, so some clarification, whichever way would be really helpful :slight_smile: Thanks for looking!!