<?php
class kavehdyanmicCss {
    public function __construct() {
        // Add hooks for enqueuing scripts and initializing rewrite rules
        add_action('wp_enqueue_scripts', array($this, 'enqueueDynamicCss'), 11);
        add_action('template_redirect', array($this, 'handleDynamicCssRequest'));
    }
    public function enqueueDynamicCss() {
        wp_enqueue_style('dynamic-css', home_url() . '/kavehcss/kavehcss' .'?action=kavehcss', '', '1.0');
    }
    public function handleDynamicCssRequest() {
        global $wp_query;
        $method = $wp_query->get('rewrite_kavehcss');
        if (!$method) {
            return;
        }
        if ($method === 'kavehcss') {
            require(get_template_directory() . '/custom.css.php');
            exit;
        }
    }

}




