• 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 into style-devel.css while I tweak it and fix things, and then style-YYYYMMDD.css when I’m satisfied everything works.

    Then in functions.php use add_filter('stylesheet_uri', 'foobar_fubar'); where foobar_fubar returns something like return 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?

    • This topic was modified 4 years, 9 months ago by Jan Dembowski.
Viewing 3 replies - 1 through 3 (of 3 total)
  • You can do whatever you want with your forked theme.
    The core WP keeps track of themes by the comment headers in style.css, so that must be there, but the styles can reside in any other files you want. No need to filter the stylesheet_uri either, because that will really mess things up. Just change the functions.php so that your real CSS is loaded instead of loading style.css. (WP doesn’t load the style.css for you; it is loaded in the theme’s functions.php.)

    Thread Starter pipfroschpress

    (@pipfroschpress)

    Okay thanks. I just saw that the style.css was being loaded by calling get_stylesheet_uri() which included the hardcoded style.css in it.

    So just ignore that function (don’t use it) and thus do not bother with a filter, that’s simpler.

    Thank you.

    Thread Starter pipfroschpress

    (@pipfroschpress)

    Once again, thank you for the advice!

    I looked into it some more and using that filter would have broken the ability to use a child theme with it. I don’t need a child theme but someone else may want to do it that way.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Changing filename of style.css in a forked theme’ is closed to new replies.