Make WordPress Core

Changeset 51262


Ignore:
Timestamp:
06/29/2021 06:23:30 PM (2 years ago)
Author:
desrosj
Message:

Script Loader: Use the provided block version when registering styles.

This updates register_block_style_handle() to use the version value provided in the $metadata parameter for non-Core blocks (when present). This removes the requirement to use filemtime() to generate a unique version.

When version is not defined within $metadata, the script version will fallback to using the current version of WordPress.

The block version should be considered similar to the one specified by plugin developers within the header of the main plugin file.

Props hellofromTonya, gziolo, jorbin, desrosj, walbo, aristath.
Fixes #53507.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks.php

    r51259 r51262  
    165165    $style_file     = realpath( "$block_dir/$style_path" );
    166166    $has_style_file = false !== $style_file;
    167     $version        = ! $is_core_block && $has_style_file ? filemtime( $style_file ) : false;
     167    $version        = ! $is_core_block && isset( $metadata['version'] ) ? $metadata['version'] : false;
    168168    $style_uri      = $has_style_file ? $style_uri : false;
    169169    $result         = wp_register_style(
Note: See TracChangeset for help on using the changeset viewer.