Strategy for style sheets with date in the file name
-
I’m using the Amazon CloudFront CDN to distribute some of the content on my site (images, CSS, JavaScript), and due to the way files are propagated and updates, my site style sheet has a date based file name (e.g.
style_08022010.1.css
).If I were juststyle.css
, any changes I make to it could take up to 24 hours to propagate.This means that I updated my
header.php
to load this new style sheet instead and have no more need for astyle.css
. That is, until I realized that the absence of astyle.css
causes WordPress to think a theme is broken, and if you go to the theme selector page or editor e.g., it realizes this and will disable it, saying ‘Stylesheet is missing’. So I needed one after all.My question evolves around the best way to handle this situation, with the least amount of work required whenever a style sheet is renamed.
At first I thought I’d simply add a symlink from
style.css
to the actual style sheet, but that would have to be updated every time I push out a new style sheet change on top of editing header.php. You can’t have a blankstyle.css
either, since the comments in the header of it need to contain the style sheet name/description/tags etc. I could add an@import
rule to the original style sheet, but then that has to be updated every time too.Ideally, I don’t want to even change the header. I’d love to have some kind of succinct way in PHP to say ‘include the first file matching ‘
style_*.css
‘, but you need to useopendir
/readir
for that and it’s a lot of overkill.So right now, I have a static
style.css
with no@import
rule and just the standard fields in the header comment. It doesn’t get loaded by anything from the site and exists only to keep WordPress happy. Whenever I push out a new style sheet change, I rename the old one and modifyheader.php
I did briefly look into using the
stylesheet_uri
filter to dynamically override what style sheet is loaded, but WordPress is still hard coded to look forstyle.css
or it thinks a theme is broken.Looking forward to hearing anyone else’s thoughts on this.
- The topic ‘Strategy for style sheets with date in the file name’ is closed to new replies.