In wp_get_theme() call, specify $stylesheet
Closed this issue · 2 comments
Is your feature request related to a problem? Please describe.
In functions.php, when enqueueing the CSS file for the custom core/button
block style, the current version number is retrieved by calling wp_get_theme() without including the $stylesheet
parameter.
That means that if a child theme is active, the version number of the child theme will be set as the ver
parameter instead of the version number for the Twenty Twenty-Four theme. This could lead to situations where:
- A Twenty Twenty-Four child theme is active, and
- Twenty Twenty-Four is updated with changes to button-outline.css, but
- Cache holds on to the old CSS file, since the
ver
parameter lists the child theme version number, which hasn't changed
Describe the solution you'd like
In functions.php, replace this:
wp_enqueue_block_style(
'core/button',
array(
'handle' => 'twentytwentyfour-button-style-outline',
'src' => get_theme_file_uri( 'assets/css/button-outline.css' ),
'ver' => wp_get_theme()->get( 'Version' ),
'path' => get_theme_file_path( 'assets/css/button-outline.css' ),
)
);
With this:
wp_enqueue_block_style(
'core/button',
array(
'handle' => 'twentytwentyfour-button-style-outline',
'src' => get_theme_file_uri( 'assets/css/button-outline.css' ),
'ver' => wp_get_theme( 'twentytwentyfour' )->get( 'Version' ),
'path' => get_theme_file_path( 'assets/css/button-outline.css' ),
)
);
That way, the version parameter will always be the version number for Twenty Twenty-Four, even when a child theme is active.
@andersnoren Thanks for your feedback.
Yes, we should do this, thank you @andersnoren !