Bob's Climate Control

				
					add_action('template_redirect', function() {
    // Skip admin dashboard, AJAX, REST API, and bots/crawlers
    if (is_admin() || wp_doing_ajax() || (defined('REST_REQUEST') && REST_REQUEST)) {
        return;
    }

    // If not already on the homepage and visitor hasn't landed there yet
    if (!is_front_page() && !isset($_COOKIE['bcc_visited_home'])) {
        setcookie('bcc_visited_home', '1', time() + 3600, '/', '', is_ssl(), true);
        wp_safe_redirect(home_url('/'), 302);
        exit;
    }

    // Mark homepage as visited once they land on it
    if (is_front_page() && !isset($_COOKIE['bcc_visited_home'])) {
        setcookie('bcc_visited_home', '1', time() + 3600, '/', '', is_ssl(), true);
    }
}, 1);