- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在维护一个使用 GeneratePress 主题的 wordpress 网站。 为了扩展,使用了一个子主题解决方案。它已经是一个相当发达的 child 主题(这样说是为了避免戏剧性的解决方案)。
一段时间以来,每次更新 CSS 时,我都会遇到 CSS 缓存问题。 style.css 子样式表提供缓存版本而不是修改后的版本。
我相信 GeneratePress 主题正在加载父 style.css + 子 style.css(如果存在)。
generatepress/functions.php
// Enqueue our CSS.
wp_enqueue_style( 'generate-style-grid', get_template_directory_uri() . "/css/unsemantic-grid{$suffix}.css", false, GENERATE_VERSION, 'all' );
wp_enqueue_style( 'generate-style', get_template_directory_uri() . '/style.css', array( 'generate-style-grid' ), GENERATE_VERSION, 'all' );
wp_enqueue_style( 'generate-mobile-style', get_template_directory_uri() . "/css/mobile{$suffix}.css", array( 'generate-style' ), GENERATE_VERSION, 'all' );
wp_add_inline_style( 'generate-style', generate_base_css() );
// Add the child theme CSS if child theme is active.
if ( is_child_theme() )
wp_enqueue_style( 'generate-child', get_stylesheet_uri(), true, filemtime( get_stylesheet_directory() . '/style.css' ), 'all' );
阅读这段代码...似乎如果检测到子主题,它应该已经清除了缓存 但是...对我来说它没有。 我没有得到一个带有 filemtime 结果作为版本参数的 url。
我的子主题 functions.php 没有排队任何“style.css”。尽管如此,它还是在父级 style.css 之后加载。
尝试 1我已经从 generatepress 阅读了添加 CSS 的部分 https://docs.generatepress.com/article/adding-css/ .
我不知道如何缓存子 style.css 文件。
尝试 2我第一次尝试解决此问题是基于在触发 wp_enqueue_scripts 时将样式表排入队列。
function theme_css(){
wp_enqueue_style( 'my-theme-style', get_stylesheet_directory_uri().'/style.css', 'generate-style', '1.1', 'all');
}
add_action( 'wp_enqueue_scripts', 'theme_css' );
我提到了 generate-style 因为在我看来它是父默认样式所依赖的(子 style.css 将在父 style.css 之后加载)。您可以在前面的代码片段中看到这一点。 它对我不起作用。子主题将首先加载,然后加载父主题样式表。 不幸的是,这会破坏 css。顺序应该相反(先是父 style.css,然后是子 style.css)。如前所述,依赖于generate-style 没有帮助。
尝试 3用另一个文件名创建样式表。 Generatepress 提示说,如果检测到 child_theme,它需要一个 style.css 样式表文件。我可以有一个带有空 style.css 和新样式表的子主题。问题是 style.css 缓存将为返回的用户提供。
我是 wordpress 的新手,所以我不知道它可能必须通过其他机制来解决这个问题。也许有一些更简单的解决方案可行?
最佳答案
如果您按照主题文档的建议使用 Autoptimize here ,那么您需要删除缓存,您的用户将看到更改。此引用来自该文档:
Installing Autoptimize
Reducing the amount of CSS and JS files being loaded on each page load will make a huge difference to your page speed.
Another perk with Autoptimize is it will bundle the CSS generated by your options in the Customizer into an external file, allowing your browser to cache it.
要删除和重置 Autoptimize 缓存:登录 wp-admin 并转到 Plugins/Autoptimize/Settings 以删除缓存,它会执行此操作并为您启动一个新的缓存。 wp-admin 的顶部菜单栏中还有一个 Autoptimize 项;这也很方便。
关于css - Wordpress - GeneratePress 主题 - 缓存破坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46538578/
我正在尝试完成撤消/重做。我正在使用loadFromJSON(...)从我存储在数组中的 Canvas 状态重新构建 Canvas 。基本上,我的想法是破坏现有的 Canvas 并重新构建 Canva
在某些情况下,我有一个在 iframe 中打开的网页。当它被加载到那个 iframe 中时,我需要它将窗口位置设置为资源以下载文件(所有这些都是为了更新 GreaseMonkey 脚本......所有
当我创建 Intent 时: Intent in = new Intent(this, myclass.class); this.startActivity(in); 我创建了一个新的 Intent
我正在我本地版本的 Wordpress 网站上为 Wordpress 创建新的短代码。 在 functions.php 中,我添加了例如: function shortTest() { re
我正在为机械网站制作 JavaScript 闪卡游戏。因为我想将方程写在卡片上,所以我需要使用 delta(Δ) 符号。 一张卡片可能有:一侧是“功率方程”,另一侧是“P=W/Δt”。如果卡片从第一面
我编写了以下代码: document.addEventListener("DOMContentLoaded", ()=>{ let menu = document.querySelector(
我的浏览器同步工作正常,但我仍然很难处理之前的 html 的缓存。即使选中了 Chrome 的“禁用缓存”,甚至在隐身模式下也是如此! 要加载页面更改,我总是必须“清除缓存并硬重新加载”。 我想知道,
我注意到每次打开和关闭(通过单击菜单项或单击菜单外的某个区域)时,上下文菜单 ( Ext.menu.Menu ) s 不会从 DOM 中删除,它们只是以某种方式变得不可见。 如何改变这个? 最佳答案
给定依赖记录类型: Record FinPath : Type := mkPath { fp_head : S i; fp_tail
在 Husdon/Jenkins 中,我可以在构建被破坏时设置通知,以向进行破坏构建的 checkin 的用户发送电子邮件。如何在 Teamcity 中执行此操作? 我知道个人用户可以通过 Teamc
我注意到每次打开和关闭(通过单击菜单项或单击菜单外的某个区域)时,上下文菜单 ( Ext.menu.Menu ) s 不会从 DOM 中删除,它们只是以某种方式变得不可见。 如何改变这个? 最佳答案
使用 MIMEMultipart('alternative') 发送 html 和 pain-text 时 将 html 转换为文本时,html 的 anchor 换行 http://127.0.0.
每当我的应用程序最小化时,我都会启动一个服务,该服务向我的 HTTP 服务器发送拉取请求以检查通知,当应用程序恢复时,服务将被终止(以及计划的可运行项)。一切正常,直到我决定终止该应用程序(将其从正在
我意识到该框架处于 alpha 阶段,但正在实现 jQuery Mobile破坏了我的omniauth 身份验证。当我尝试登录时,一旦我尝试点击/auth/twitter Controller ,jQ
我对 Angular 比较陌生,经过几个小时的调试,我发现添加 jquery 时存在一些不兼容性。该指令在没有 jquery 的情况下工作正常,但在使用 jquery 时会中断:/ 这是一个 plnk
我发现,因为我正在处理的所有表单都有一个包含“name =“submit””属性的提交按钮,所以当我单击应该触发表单提交的链接时,触发器提交会中断. 有谁知道我该如何解决这个问题。 下面的 JQuer
我遇到了一个问题:/我得到了一个 CSS 东西,它使悬停时背景位置发生变化。但是当我在 javascript 中运行一个改变悬停的函数后,CSS 停止工作。 这是函数: function tree()
谁能给出一个完整的例子来说明 qooxdoo 1.6 中的 dispose 和 destruct 是如何工作的? ,我在 qooxdoo 演示或文档中找不到任何好的示例。 谢谢你的建议。 最佳答案 处
我对 JFormattedTextField 有疑问(我将它用作我们所有文本字段的基类)。 今天我尝试向该字段的文档添加一个文档过滤器,它工作得很好,但前提是它没有设置格式化程序工厂。 问题是,当设置
我有一个点击事件 $('#ship_Move').click(function (event) { event.stopPropagation();
我是一名优秀的程序员,十分优秀!