Make WordPress Core


Ignore:
Timestamp:
04/16/2019 02:55:48 PM (5 years ago)
Author:
desrosj
Message:

Bundled Themes: Use the theme version when enqueuing theme specific stylesheets.

For many bundled theme related stylesheets, a version is either not specified, or specified as a hardcoded date string when enqueued. This is problematic when a stylesheet is updated and the version number is not (which has happened several times recently). This change ensures that all bundled theme related stylesheets use the theme’s version as the stylesheet version. This ensures cache busting for theme stylesheets every time a theme is updated and guarantees that users receive any new or updated styles included in the update when visiting the site for the first time after an update.

Props parsmizban, ianbelanger, dswebsme.
Fixes #39997.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyseventeen/functions.php

    r44500 r45213  
    447447
    448448    // Theme stylesheet.
    449     wp_enqueue_style( 'twentyseventeen-style', get_stylesheet_uri() );
     449    wp_enqueue_style( 'twentyseventeen-style', get_stylesheet_uri(), array(), wp_get_theme()->get( 'Version' ) );
    450450
    451451    // Theme block stylesheet.
    452     wp_enqueue_style( 'twentyseventeen-block-style', get_theme_file_uri( '/assets/css/blocks.css' ), array( 'twentyseventeen-style' ), '1.1' );
     452    wp_enqueue_style( 'twentyseventeen-block-style', get_theme_file_uri( '/assets/css/blocks.css' ), array( 'twentyseventeen-style' ), wp_get_theme()->get( 'Version' ) );
    453453
    454454    // Load the dark colorscheme.
    455455    if ( 'dark' === get_theme_mod( 'colorscheme', 'light' ) || is_customize_preview() ) {
    456         wp_enqueue_style( 'twentyseventeen-colors-dark', get_theme_file_uri( '/assets/css/colors-dark.css' ), array( 'twentyseventeen-style' ), '1.0' );
     456        wp_enqueue_style( 'twentyseventeen-colors-dark', get_theme_file_uri( '/assets/css/colors-dark.css' ), array( 'twentyseventeen-style' ), wp_get_theme()->get( 'Version' ) );
    457457    }
    458458
    459459    // Load the Internet Explorer 9 specific stylesheet, to fix display issues in the Customizer.
    460460    if ( is_customize_preview() ) {
    461         wp_enqueue_style( 'twentyseventeen-ie9', get_theme_file_uri( '/assets/css/ie9.css' ), array( 'twentyseventeen-style' ), '1.0' );
     461        wp_enqueue_style( 'twentyseventeen-ie9', get_theme_file_uri( '/assets/css/ie9.css' ), array( 'twentyseventeen-style' ), wp_get_theme()->get( 'Version' ) );
    462462        wp_style_add_data( 'twentyseventeen-ie9', 'conditional', 'IE 9' );
    463463    }
    464464
    465465    // Load the Internet Explorer 8 specific stylesheet.
    466     wp_enqueue_style( 'twentyseventeen-ie8', get_theme_file_uri( '/assets/css/ie8.css' ), array( 'twentyseventeen-style' ), '1.0' );
     466    wp_enqueue_style( 'twentyseventeen-ie8', get_theme_file_uri( '/assets/css/ie8.css' ), array( 'twentyseventeen-style' ), wp_get_theme()->get( 'Version' ) );
    467467    wp_style_add_data( 'twentyseventeen-ie8', 'conditional', 'lt IE 9' );
    468468
     
    508508function twentyseventeen_block_editor_styles() {
    509509    // Block styles.
    510     wp_enqueue_style( 'twentyseventeen-block-editor-style', get_theme_file_uri( '/assets/css/editor-blocks.css' ), array(), '1.1' );
     510    wp_enqueue_style( 'twentyseventeen-block-editor-style', get_theme_file_uri( '/assets/css/editor-blocks.css' ), array(), wp_get_theme()->get( 'Version' ) );
    511511    // Add custom fonts.
    512512    wp_enqueue_style( 'twentyseventeen-fonts', twentyseventeen_fonts_url(), array(), null );
Note: See TracChangeset for help on using the changeset viewer.