未附加排队样式表版本号

Enqueued Stylesheet Version Number Not Being Appended

我对浏览器缓存的子主题样式表有疑问,我需要 dequeue/reregister,然后使用版本号的时间戳重新排队。出队然后重新入队工作正常,但无论我尝试什么,都没有附加版本号。我试图将 wp_enqueue_style() 的版本参数设置为 true 和字符串。不管怎样,都没有将版本号作为查询字符串添加到样式表 link href。我的完整代码片段如下。

function custom_dequeue_enqueue_child_styles() {

    wp_dequeue_style('mk-style');
    wp_deregister_style('mk-style');

    $cacheBuster = filemtime(get_stylesheet_directory() . '/style.css');

    wp_enqueue_style('jupiter-child-stylesheet', get_stylesheet_directory_uri() . '/style.css', array(), $cacheBuster, 'all');

}

add_action( 'wp_enqueue_scripts', 'custom_dequeue_enqueue_child_styles', 999999999);

事实证明,代码确实有效,版本号被删除的原因是隐藏的主题选项默认从所有 JS 和 CSS 文件中删除所有版本号.

这是在 Artbees 的 Jupiter WordPress 主题中,主题选项在主题选项 > 速度优化 > 来自静态文件的查询字符串中。默认情况下,它设置为 "off" 并删除版本号。将其设置为 "On" 会将版本号附加为查询字符串参数。这是一个默认启用的非常愚蠢的选项,但现在我们知道了。