• Resolved mercuryfenix

    (@mercuryfenix)


    I would like to write some sort of a hook to add a string to all of my CSS file URLs. Specifically, I would like to add

    https://reducisaurus.appspot.com/css?url=

    to the beginning of all CSS file URLs. The idea is to use Google’s Reducisaurus web service to compress all CSS files. You can read more about the service here:

    https://code.google.com/p/reducisaurus/

    If you know of a quick and easy way to do this with WordPress hooks, please let me know.

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • So you just go into your header.php file and change:

    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />

    to:

    <link rel="stylesheet" href="https://reducisaurus.appspot.com/css?url=<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />

    no need for hooks.

    Thread Starter mercuryfenix

    (@mercuryfenix)

    I’m not exactly sure what I’m doing here and could use some help. From my research on the issue, I would think it would look something like this:

    add_filter('wp_print_styles','reducisaurus_css',10,2);
    function reducisaurus_css($css_url)
    {
    	return "https://reducisaurus.appspot.com/css?url=" . $css_url;
    }
    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    The CSS files and such are only handled that way in the admin side of things, and they’re already optimized. Reducisaurus wouldn’t do anything. WordPress already combines and compresses and such for its admin pages.

    For the website viewer facing side of things, the theme controls that stuff entirely. You’ll have to edit the theme’s header.php file.

    Also, the notion of Reducisaurus is itself flawed. By making a compression service into a web service, you’re adding an extra step, not removing one. Reducisaurus will actually be slower in most cases than simply serving the files directly.

    Thread Starter mercuryfenix

    (@mercuryfenix)

    Upon further research of actions and filters, I came up with this: it works, although the result wasn’t worth the trouble.

    add_filter(‘style_loader_src’,’reducisaurus_css’,10,2);
    function reducisaurus_css($css_url, $handle)
    {
    return “https://reducisaurus.appspot.com/css?url=&#8221; . $css_url;
    }

    Thread Starter mercuryfenix

    (@mercuryfenix)

    Otto42, thanks for your advice. I realized from the beginning that this wasn’t a practical thing to do. I simply wanted to learn more about hooks ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Adding a string to all CSS file URLs’ is closed to new replies.