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/twentysixteen/functions.php

    r45126 r45213  
    368368
    369369    // Theme stylesheet.
    370     wp_enqueue_style( 'twentysixteen-style', get_stylesheet_uri() );
     370    wp_enqueue_style( 'twentysixteen-style', get_stylesheet_uri(), array(), wp_get_theme()->get( 'Version' ) );
    371371
    372372    // Theme block stylesheet.
    373     wp_enqueue_style( 'twentysixteen-block-style', get_template_directory_uri() . '/css/blocks.css', array( 'twentysixteen-style' ), '20181230' );
     373    wp_enqueue_style( 'twentysixteen-block-style', get_template_directory_uri() . '/css/blocks.css', array( 'twentysixteen-style' ), wp_get_theme()->get( 'Version' ) );
    374374
    375375    // Load the Internet Explorer specific stylesheet.
    376     wp_enqueue_style( 'twentysixteen-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentysixteen-style' ), '20160816' );
     376    wp_enqueue_style( 'twentysixteen-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentysixteen-style' ), wp_get_theme()->get( 'Version' ) );
    377377    wp_style_add_data( 'twentysixteen-ie', 'conditional', 'lt IE 10' );
    378378
    379379    // Load the Internet Explorer 8 specific stylesheet.
    380     wp_enqueue_style( 'twentysixteen-ie8', get_template_directory_uri() . '/css/ie8.css', array( 'twentysixteen-style' ), '20160816' );
     380    wp_enqueue_style( 'twentysixteen-ie8', get_template_directory_uri() . '/css/ie8.css', array( 'twentysixteen-style' ), wp_get_theme()->get( 'Version' ) );
    381381    wp_style_add_data( 'twentysixteen-ie8', 'conditional', 'lt IE 9' );
    382382
    383383    // Load the Internet Explorer 7 specific stylesheet.
    384     wp_enqueue_style( 'twentysixteen-ie7', get_template_directory_uri() . '/css/ie7.css', array( 'twentysixteen-style' ), '20160816' );
     384    wp_enqueue_style( 'twentysixteen-ie7', get_template_directory_uri() . '/css/ie7.css', array( 'twentysixteen-style' ), wp_get_theme()->get( 'Version' ) );
    385385    wp_style_add_data( 'twentysixteen-ie7', 'conditional', 'lt IE 8' );
    386386
     
    419419function twentysixteen_block_editor_styles() {
    420420    // Block styles.
    421     wp_enqueue_style( 'twentysixteen-block-editor-style', get_template_directory_uri() . '/css/editor-blocks.css', array(), '20181230' );
     421    wp_enqueue_style( 'twentysixteen-block-editor-style', get_template_directory_uri() . '/css/editor-blocks.css', array(), wp_get_theme()->get( 'Version' ) );
    422422    // Add custom fonts.
    423423    wp_enqueue_style( 'twentysixteen-fonts', twentysixteen_fonts_url(), array(), null );
Note: See TracChangeset for help on using the changeset viewer.