• Resolved Guillaume Assire

    (@alphagolf_fr)


    I’d like to append a build number to the CSS and JS file names of my plugin, instead of ?ver=3.8, so that the latest version of the files are sent to the browser with new releases of my plugin.

    As per the Codex, I’m using this and it works fine, I do see the build number appended to my filename:
    wp_enqueue_script( 'wp-symposium-toolbar', plugins_url( 'js/wp-symposium-toolbar.js', __FILE__ ), array( 'jquery' ), $wpst_buildnr );

    But I’m using this and it doesn’t work:
    wp_enqueue_style( 'wp-symposium-toolbar_admin', $adminStyleUrl, array(), $wpst_buildnr );

    Note that these variables are correctly set. Any suggestion why it doesn’t work?

    Thanks

Viewing 1 replies (of 1 total)
  • Thread Starter Guillaume Assire

    (@alphagolf_fr)

    Because I registered the style beforehand with
    wp_register_style( 'wp-symposium-toolbar_admin', $adminStyleUrl );

    Simply do the wp_enqueue_style directly and the CSS file will get the plugin build nr as version number, just like the JS file, and be re-read by browsers regardless of caching, every time I increment that build number.

    My analysis is based on wp-includes/class.wp-dependencies:219…

Viewing 1 replies (of 1 total)

The topic ‘Adding a version number to CSS (and JS) files’ is closed to new replies.