[WordPress] 外掛分享: WP Debugging

WordPress 外掛 WP Debugging 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「WP Debugging」是 2019-02-02 上架。
  • 目前有 10000 個安裝啟用數。
  • 上一次更新是 2024-12-02,距離現在已有 152 天。
  • 外掛最低要求 WordPress 5.2 以上版本才可以安裝。
  • 外掛要求網站主機運作至少需要 PHP 版本 5.6 以上。
  • 有 19 人給過評分。
  • 論壇上目前有 3 個提問,問題解答率 67% ,不低,算是個很有心解決問題的開發者團隊了!

外掛協作開發者

afragen |

外掛標籤

debug | support | wp-config |

內容簡介

此外掛在啟用時會在 wp-config.php 中設定以下偵錯常數,並在停用時移除它們。任何錯誤都會導致拋出 PHP Exception。偵錯常數請參考 WordPress 的「Debugging in WordPress」頁面。
預設設定如下:
define( 'WP_DEBUG_LOG', true );
define( 'SCRIPT_DEBUG', true );
define( 'SAVEQUERIES', true );

啟用此外掛時也會設置 `@ini_set( 'display_errors', 1 )`。當此外掛首次運行時,`WP_DEBUG` 會設置為 true;之後便可在設定中關閉。
使用者可以在設定頁面中設置以下項目:
define( 'WP_DEBUG', true ); //(設定此項目)初始安裝時為預設值。
define( 'WP_DEBUG_DISPLAY', false ); //(未指定時的預設值為)true。
define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true ); //WordPress 5.2 白屏處理。

當停用此外掛時,會盡力恢復先前存在的常數為其原狀。啟用此外掛時,會恢復預設值和任何已保存的設定。
此外掛使用 wp-cli/wp-config-transformer 命令將常數寫入 wp-config.php。
隨附此外掛的 Andrew Norcross 的「Debug Quick Look」有助於讀取 debug.log 檔案。若已安裝該外掛,但 WP 偵錯未啟用,應刪除它。
「Query Monitor」和「Debug Bar」外掛是可選依賴關係,有助於除錯和疑難排解。若已忽略安裝通知,45 天後會再次提醒。
如您的 wp-config.php 檔案位於非標準位置,可以使用 wp_debugging_config_path 過濾器來返回您的安裝檔案路徑。
wp_debugging_add_constants 過濾器可讓使用者向 wp-config.php 添加常數。
過濾器返回一個陣列,其中鍵是常數名稱,而值是包含作為字符串和指示是否應傳遞而不帶引號的布林值的數據陣列。
$my_constants = [
'my_test_constant' =>
[
'value' => 'abc123',
'raw' => false,
],
'another_test_constant' => [ 'value' => 'true' ],
];

value 選項包含常數的值作為字符串。
raw 選項表示,不是將值作為字符串放入 config 中,而是不加引號地放入。預設值為 true。對於非布林值,可將其設為 false。
例如:
add_filter(
'wp_debugging_add_constants',
function( $added_constants ) {
$my_constants = [
'my_test_constant' => [
'value' => '124xyz',
'raw' => false,
],
'another_test_constant' => [ 'value' => 'true' ],
];
return array_merge( $added_constants, $my_constants );
},
10,
1
);

這將創建以下常數:
define( 'MY_TEST_CONSTANT', '124xyz' );
define( 'ANOTHER_TEST_CONSTANT', true );

開發中。

原文外掛簡介

This plugin sets the following debug constants in wp-config.php on plugin activation and removes them on plugin deactivation. Any errors will result in a PHP Exception being thrown. Debug constants per Debugging in WordPress.
Default settings:
define( 'WP_DEBUG_LOG', true );
define( 'SCRIPT_DEBUG', true );
define( 'SAVEQUERIES', true );

 
@ini_set( ‘display_errors’, 1 ); is set when the plugin is active. WP_DEBUG is set to true when the plugin is first run, thereafter it can be turned off in the Settings.
The Settings page allows the user to set the following.
define( 'WP_DEBUG', true ); // Default on initial plugin installation.
define( 'WP_DEBUG_DISPLAY', false ); // Default when not declared is true.
define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true ); // WordPress 5.2 WSOD Override.

When the plugin is deactivated best efforts are made to re-add pre-existing constants to their former state. When the plugin is activated the default settings and any saved settings are restored.
This plugin uses the wp-cli/wp-config-transformer command for writing constants to wp-config.php.
Debug Quick Look from Andrew Norcross is included with this plugin to assist in reading the debug.log file. If you already have this plugin installed you should delete it when WP Debugging is not active.
Query Monitor and Debug Bar plugins are optional dependencies to aid in debugging and troubleshooting. The notice for installation will recur 45 days after being dismissed.
If you have a non-standard location for your wp-config.php file you can use the filter wp_debugging_config_path to return the file path for your installation.
The filter wp_debugging_add_constants allows the user to add constants to wp-config.php.
The filter returns an array where the key is the name of the constant and the value is an array of data containing the value as a string and a boolean to indicate whether or not the value should be passed without quotes.
$my_constants = [
'my_test_constant' =>
[
'value' => 'abc123',
'raw' => false,
],
'another_test_constant' => [ 'value' => 'true' ],
];

The value option contains the constant’s value as a string.
The raw option means that instead of placing the value inside the config as a string it will become unquoted. The default is true. Set as false for non-boolean values.
Example:
add_filter(
'wp_debugging_add_constants',
function( $added_constants ) {
$my_constants = [
'my_test_constant' => [
'value' => '124xyz',
'raw' => false,
],
'another_test_constant' => [ 'value' => 'true' ],
];
return array_merge( $added_constants, $my_constants );
},
10,
1
);

This will create the following constants.
define( 'MY_TEST_CONSTANT', '124xyz' );
define( 'ANOTHER_TEST_CONSTANT', true );

Development
PRs are welcome against the develop branch on GitHub.

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「WP Debugging」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


2.2.0 | 2.3.0 | 2.4.0 | 2.4.1 | 2.4.2 | 2.4.3 | 2.5.0 | 2.5.1 | 2.5.3 | 2.5.4 | 2.5.5 | 2.5.6 | 2.5.7 | 2.5.8 | 2.6.0 | 2.6.1 | 2.7.0 | 2.7.1 | 2.7.2 | 2.8.0 | 2.9.0 | 2.9.1 | 2.9.2 | trunk | 2.10.0 | 2.10.1 | 2.10.2 | 2.11.0 | 2.11.1 | 2.11.2 | 2.11.3 | 2.11.4 | 2.11.5 | 2.11.6 | 2.11.7 | 2.11.8 | 2.11.9 | 2.12.0 | 2.12.1 | 2.12.2 | 2.11.10 | 2.11.11 | 2.11.12 | 2.11.13 | 2.11.14 | 2.11.15 | 2.11.16 | 2.11.17 | 2.11.18 | 2.11.19 | 2.11.20 | 2.11.21 | 2.11.22 | 2.11.23 | 2.11.24 |

延伸相關外掛(你可能也想知道)

  • Update Unique Keys 》為了增強 WordPress 網站的安全性,此外掛會使用 WordPress 提供的獨特 Key 生成器,更新 wp-config.php 檔案中的下列 Key / Salt 內容:, , AUTH_KEY, SECUR...。
  • Developer Debug Tools 》這是一個 WordPress 外掛,提供開發者進行網站開發和疑難排解時的除錯和測試工具。, , 直接在管理區中查看 debug.log 和錯誤日誌(應用程式紀錄),便於閱讀...。
  • Protect WP Config File from Phishing Attacks 》** 此外掛已經不再更新。歡迎大家繼續使用並支持這個專案! **, 當使用者嘗試在網頁瀏覽器中載入 wp-config 檔案(或其備份)時,此外掛將會顯示一個空白的白...。
  • WP Configuration and Status 》WP Configuration and Status 是一個簡單的外掛,啟用後可以輕鬆存取 WordPress 安裝中的重要組態參數。, 主要特點, , 顯示 php.info 內容, 顯示 .htaccess ...。
  • WP Marvelous Debug 》此外掛可在儀表板上檢視日誌檔案(debug.log)並編輯來自 wp-config.php 的除錯常數,它還提供了其他針對除錯功能的特色。, 使用/SplFileObject類別載入日誌...。
  • WP Config Constants 》此外掛會顯示你的 wp-config.php 檔案中所定義的常數值。如果你需要快速檢查資料庫和偵錯設定等,這將非常有用。出於安全考慮,此外掛會將 DB_PASSWORD 常數...。
  • Wordless Extender 》Wordless 是由 weLaika 開發並使用的 WP 主題框架。, 如同我們在 Wordless 的 README 中所寫:, 「Wordless 不是一個臃腫、內含所有工具的工具。, 因此,我們...。
  • Shared User Table Roles 》在使用相同資料庫的多個 WordPress 安裝中分享使用者和使用者元數據表時,給予使用者的任何角色僅對單個 WordPress 安裝有效。, 此外掛程式確保使用者角色、...。
  • Debug Log Tool 》總結:Debug Log Tool 是一款整潔、極簡的外掛程式,能夠幫助 WordPress 開發者更有效地進行網站除錯。透過少數點擊,您可以在 WordPress 儀表板上啟用/停用 ...。
  • DebugMe 》DebugMe是一款方便且可搜索的WordPress日誌查看外掛,可編輯您的伺服器設定。專為調試而設計的超棒外掛。, 有時候讀取並搜尋 debug.log 檔案很困難。這就是 D...。
  • All-in-One Debug Lab 》這款「All-in-One Debug Lab」外掛可輕鬆協助搜尋並定位 WordPress 中的錯誤。, 查看「debug.log」檔案, 透過此外掛,您可以查看「debug.log」檔案。, 切換偵...。

文章
Filter
Apply Filters
Mastodon