【问题标题】:Unable to clear gettext cache无法清除 gettext 缓存
【发布时间】:2020-10-08 15:38:26
【问题描述】:

我在 WordPress 中使用 gettext 钩子并做了这样的事情:

add_filter("gettext", "test", 20, 3 );
function test($translation, $text, $domain) {
    return "hello world";
}

正如预期的那样,WordPress 仪表板中的许多菜单项都更改为“hello world”。现在我不能把它们改回来。这是我尝试过的:

  1. functions.php 中删除上面的代码块
  2. 正在重启php-fpm
  3. 正在重启nginx
  4. 重启服务器
  5. 清除 WordPress 缓存(WP Super Cache)

我不太确定还能尝试什么。一些菜单项仍显示为“hello world”。奇怪的是,并非所有菜单项都卡住了,而且它似乎只发生在前端显示管理栏时(我在后端看不到任何“hello world”项目)。有什么想法吗?

【问题讨论】:

  • 你能把问题截图吗?
  • 根据文档If there are functions hooked to this filter, they will always run. This could lead to a performance problem,您的代码中是否还有其他函数test

标签: php wordpress caching gettext


【解决方案1】:

您是否尝试过使用remove_filter 删除过滤器,代码如下:

// remove the filter 
remove_filter( 'gettext', 'test', 20, 3 ); 

如果一切顺利,请告诉我。

【讨论】:

  • 感谢您的回复!不幸的是,这没有奏效。我也试过remove_all_filters("gettext"),但没有任何改变。
  • 原来是插件问题。我正在使用 TranslatePress,显然当我创建该过滤器时,它导致在 wp_trp_gettext_en_us 中创建数据库条目。我在那里找到了我的“hello world”条目,等等。我刚刚删除了该表中的所有行。默认行会自动重新生成,所以一切都很好。
  • 很高兴你找到了解决方案@David
猜你喜欢
  • 2013-07-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-11
  • 2018-06-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多