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

    r45081 r45213  
    317317
    318318    // Load our main stylesheet.
    319     wp_enqueue_style( 'twentyfourteen-style', get_stylesheet_uri() );
     319    wp_enqueue_style( 'twentyfourteen-style', get_stylesheet_uri(), array(), wp_get_theme()->get( 'Version' ) );
    320320
    321321    // Theme block stylesheet.
    322     wp_enqueue_style( 'twentyfourteen-block-style', get_template_directory_uri() . '/css/blocks.css', array( 'twentyfourteen-style' ), '20181230' );
     322    wp_enqueue_style( 'twentyfourteen-block-style', get_template_directory_uri() . '/css/blocks.css', array( 'twentyfourteen-style' ), wp_get_theme()->get( 'Version' ) );
    323323
    324324    // Load the Internet Explorer specific stylesheet.
    325     wp_enqueue_style( 'twentyfourteen-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentyfourteen-style' ), '20131205' );
     325    wp_enqueue_style( 'twentyfourteen-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentyfourteen-style' ), wp_get_theme()->get( 'Version' ) );
    326326    wp_style_add_data( 'twentyfourteen-ie', 'conditional', 'lt IE 9' );
    327327
     
    396396function twentyfourteen_block_editor_styles() {
    397397    // Block styles.
    398     wp_enqueue_style( 'twentyfourteen-block-editor-style', get_template_directory_uri() . '/css/editor-blocks.css', array(), '20181230' );
     398    wp_enqueue_style( 'twentyfourteen-block-editor-style', get_template_directory_uri() . '/css/editor-blocks.css', array(), wp_get_theme()->get( 'Version' ) );
    399399    // Add custom fonts.
    400400    wp_enqueue_style( 'twentyfourteen-fonts', twentyfourteen_font_url(), array(), null );
Note: See TracChangeset for help on using the changeset viewer.