Changing filename of style.css in a forked theme
-
Hi,
I’m forking the Simone theme for my own purposes. Theme will be (is) on a public github but I won’t ever try to get it into WordPress proper because that means commitment to fixing bugs that do not impact me.
For expires header purposes the way I do JSS/CSS filenames is different than what is typically done in WordPress and predates my current use of WordPress.
Basically this is what I do –
files that end in
\.(js|css)
expire in 7 days.
files that end in-devel\.(js|css)
expire when served.
files that end in-[0-9]{8}\.(js|css)
expire in one year.That means files added by core/plugins only get a week of cache but that’s not so bad, I don’t use many and my forked theme loads jQuery 3.5.1 instead of core jQuery anyway allowing me to name it so updated jQuery and jQuery-compat follow that scheme. Other core scripts that only get a week until they expire aren’t an issue, browsers usually ask if what they have is still valid after expiring anyway before redownloading.
Easy to implement this in my WordPress forked theme – except for the
style.css
file.Here’s what I want to do to resolve that but I want advice from gurus first:
1) Keep
style.css
in the theme directory but only containing the comment information that identifies the theme and version for the benefit of the admin panel that seems to gets its info from that specific file.2) The actual
style.css
CSS content will be moved intostyle-devel.css
while I tweak it and fix things, and thenstyle-YYYYMMDD.css
when I’m satisfied everything works.Then in
functions.php
useadd_filter('stylesheet_uri', 'foobar_fubar');
wherefoobar_fubar
returns something likereturn trailingslashit( get_template_directory_uri() ) . 'style-devel.css'
Obviously I would change the
-devel.css
to-YYYYMMDD.css
once I’m done hacking the style.Is there a reason why I shouldn’t do this, or a technical consideration I am missing?
Again, the is NOT a theme I plan on making available through WP itself, I suspect they wouldn’t be too fond of my doing that let alone loading a newer jQuery that doesn’t work with some older browsers. But since the name
style.css
seems hardcoded into core, is there something doing this would break?
- The topic ‘Changing filename of style.css in a forked theme’ is closed to new replies.