<?php 

class RsDebug{
    public static function init(): void 
    {
        if(get_option('rs_debug_routes') !== '1') return;
        add_action('parse_request', [self::class, 'log'], 0);
    }

    public static function log($wp): void
    {
        error_log('URL: ' . ($_SERVER['REQUEST_URI'] ?? ''));
        error_log('matched_rule: ' . ($wp->matched_rule ?? ''));
        error_log('matched_query: ' . ($wp->matched_query ?? ''));
        error_log('query_vars: ' . print_r($wp->query_vars, true));
    }
}