問題描述

我通過 Git 更新 WP 到版本 3.9.2(目前最新),工作正常。但是,在管理員中,它一直告訴我 「可用的新版本」 。經過一番挖掘,似乎與語言包相關。我已經將 WPLANG 設置為 nl_NL

wp-includes/update.php 文件中,wp_version_check()使用以下 URL 訪問 WordPress 服務器以獲取較新版本:

http://api.wordpress.org/core/version-check/1.7/?version=3.9.2&php=5.5.11&mysql=5.5.15&local_package=&blogs=1&users=2&multisite_enabled=0&locale=nl_NL

點擊它,你會注意到它提供了一個響應與狀態 「upgrade」,但版本是一樣的!如果最後刪除 locale 參數或將其留空 (URL 在下面),您將看到它將以 「latest」 的狀態值回答,因此不會觸發更新 nags 。

http://api.wordpress.org/core/version-check/1.7/?version=3.9.2&php=5.5.11&mysql=5.5.15&local_package=&blogs=1&users=2&multisite_enabled=0&locale=

我嘗試刷新 WP 緩存 (更新瞬態),但沒有更改。有人會在這裏發生什麼事嗎?謝謝。

最佳解決方案

問題是,local_package 在 URL 中沒有價值。

起初我以為這可能是一個 bug 。以前已經報道過類似的問題 (見 herehere

然後我在 comment in trac ticket 8729 上絆倒,用户 nbachiyski 解釋了本地化應該如何工作:

There are two ways to localize WordPress:

  1. Drop some translation files.
  2. Install localized package.

Whenever possible we try to enforce the 2nd way.

So, here is how the whole thing works:

  1. Both the current locale and the current localized package, installed, are sent to the API.
  2. If a localized package for the user’s locale is available and the user doesn’t have the localized package, the user is prompted to upgrade or to hide updgrade.

您可以使用 install the Dutch version of WordPress 或隱藏其更新 (/wp-admin/update-core.php> 隱藏此更新) 。

次佳解決方案

丹的答案讓我走上正確的道路。除了語言文件外,本地化 WP 包還會在 wp-includes/version.php 中創建 $wp_local_package 變量。如果設置了該變量,其值將被包含在版本檢查 URL 中,然後響應將正確地説您使用的是最新版本:

http://api.wordpress.org/core/version-check/1.7/?version=3.9.2&php=5.5.11&mysql=5.5.15&local_package=nl_NL&blogs=1&users=2&multisite_enabled=0&locale=nl_NL

由於我通過 Git 更新 WP,因此安裝本地化軟件包不是一個選擇。我手動更新語言文件。在這種情況下,為了擺脱更新,您可以在 wp-config.php 文件中自行定義 $wp_local_package 。這將使 WP 認為您始終運行最新的本地化軟件包:

define('WPLANG', 'nl_NL');
$wp_local_package = WPLANG; // Don』t forget to manually update the language files now

參考文獻

注:本文內容整合自 Google/Baidu/Bing 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。