<?php
//asana-form-builder/task-comms/router-client-gateway.php
// Client Gateway – Viewer Route: /client-gateway/{token}
if (!defined('ABSPATH')) exit;

add_action('init', function () {
    add_rewrite_rule('^client-gateway/([^/]+)/?$', 'index.php?asana_comms_token=$matches[1]', 'top');
    add_rewrite_tag('%asana_comms_token%', '([^&]+)');
});

add_action('template_redirect', function () {
    $token = get_query_var('asana_comms_token');
    if ($token) { include plugin_dir_path(__FILE__) . 'pages/task-dashboard.php'; exit; }
});
