WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
Manually rewrite css link? (3 posts)

  1. Qcybb
    Member
    Posted 1 year ago #

    When the option "Rewrite URL structure" is enabled in the "Minify" tab, for some reason the plugin refuses to create the .css file.

    However with that option disabled, it saves the minified file without issues.

    What I would like to do is keep the option disabled - but rewrite the .css file link (in the header) myself. That way the plugin keeps working and I am able to use my CDN for the css file.

    What I have tried is :

    function change_stylesheet_loc($uri)
    {
        $uri = str_replace('example.com', 'cdn.example.com', $uri);
        $uri = str_replace('index.php?file=', '', $uri);
        return $uri;
    }
    add_filter('stylesheet_uri', 'change_stylesheet_loc', 20000);

    The code above should have change this :

    http://example.com/wp-content/w3tc/min/index.php?file=6fb9f/default.include.c95d49.css

    To this :

    http://example.com/wp-content/w3tc/min/6fb9f/default.include.c95d49.css

    Do I need to use a different filter hook than "stylesheet_uri"? Does W3 Total Cache have it's own filter hook I can use?

    http://wordpress.org/extend/plugins/w3-total-cache/

  2. amitbhatia
    Member
    Posted 1 year ago #

    Why don't you test it out and report back?

  3. Qcybb
    Member
    Posted 1 year ago #

    I did test it out - and it doesn't work.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic