Black Bar

外掛說明

Black Bar 是專為 WordPress 開發者設計的 Debug Bar 外掛的擴充功能,它會收集並顯示錯誤訊息、已執行的 SQL 查詢、造成網站遲緩的動作及勾點、佈景主題範本、全域變數並提供分析工具。

這個外掛協助開發者開發的方式:

  • 使用主控台對程式碼進行偵錯
  • 檢查 COOKIE、GET、POST、SERVER、SESSION、WP_Screen 等全域變數
  • 使用分析工具測量程式碼效能
  • 在主控台檢視載入頁面時發生的 PHP 錯誤
  • 檢視包含執行時間及反向追蹤的已執行 MySQL 查詢
  • 檢視目前使用的佈景主題依據載入順序的範本檔案
  • 檢視依據優先順序的回呼的 50 個最慢動作及篩選器勾點

安裝方式

如果未曾安裝過 WordPress 外掛,請參考這份官方說明文件

常見問題集

如何在主控台新增項目?

如需將項目新增至主控台,請在程式碼中的任何位置插入以下 PHP 程式碼:

do_action('console', 'Enter something to debug here');

也可以如下所示般加入選用記錄層級:

do_action('console', 'Enter something to debug here', 'error');

可用的記錄層級:debuginfonoticewarningerrorcriticalalertemergency

如何使用分析工具?

如需使用分析工具,請在要進行分析的程式碼的前方後方插入對應的 PHP 程式碼:

程式碼前方:

do_action('timer:start', 'Enter a description of what you are profiling here');

程式碼後方:

do_action('timer:stop');

如何為非網站管理員啟用這個外掛?

依照預設,僅有網站管理員可以使用 Black Bar;如需為全部登入使用者啟用這個外掛,請使用以下程式碼片段:

add_filter('blackbar/enabled', 'is_user_logged_in');

如何變更最慢的勾點顯示數量?

依照預設,Black Bar 會顯示 50 個最慢的動作/篩選器勾點;如需顯示全部勾點,請使用以下程式碼片段:

add_filter('blackbar/hooks/all', '__return_true');

使用者評論

2024 年 4 月 25 日
Was wondering why my wordpress installation was unbearably slow. This plugin helped me discover the massive amount of SQL queries generated by 2 conflicting plugin settings. Problem solved!
2023 年 2 月 4 日
nice. thanks for updating. i prefer this extension for debugging.
2019 年 7 月 23 日 1 則留言
Thank you for giving new life to BlackBox Debug Bar! Not only the usefulness of this plugin, but the beautiful PHP coding leads me to write this review. I have learnt a lot from your code.
閱讀全部 8 則使用者評論

參與者及開發者

以下人員參與了開源軟體〈Black Bar〉的開發相關工作。

參與者

〈Black Bar〉外掛目前已有 2 個本地化語言版本。 感謝全部譯者為這個外掛做出的貢獻。

將〈Black Bar〉外掛本地化為台灣繁體中文版

對開發相關資訊感興趣?

任何人均可瀏覽程式碼、查看 SVN 存放庫,或透過 RSS 訂閱開發記錄

變更記錄

4.1.4 (2024-05-08)

  • Added “blackbar/hooks/all” filter hook
  • Added highlighting of major WordPress hooks
  • Added support for static callables used for hook callbacks in Site Reviews
  • Change minimum PHP version to 7.4
  • Change minimum WordPress version to 6.1

4.1.3 (2024-05-08)

  • Added “blackbar/hooks/all” filter hook
  • Added highlighting of major WordPress hooks
  • Added support for static callables used for hook callbacks in Site Reviews
  • Change minimum PHP version to 7.4
  • Change minimum WordPress version to 6.1

4.1.2 (2024-05-08)

  • Added “blackbar/hooks/all” filter hook
  • Added highlighting of major WordPress hooks
  • Added support for static callables used for hook callbacks in Site Reviews
  • Change minimum PHP version to 7.4
  • Change minimum WordPress version to 6.1

4.1.1 (2024-05-08)

  • Added “blackbar/hooks/all” filter hook
  • Added highlighting of major WordPress hooks
  • Added support for static callables used for hook callbacks in Site Reviews
  • Change minimum PHP version to 7.4
  • Change minimum WordPress version to 6.1

4.1.0 (2024-05-08)

  • Added “blackbar/hooks/all” filter hook
  • Added highlighting of major WordPress hooks
  • Added support for static callables used for hook callbacks in Site Reviews
  • Change minimum PHP version to 7.4
  • Change minimum WordPress version to 6.1

4.0.3 (2023-10-11)

  • Fixed debugging of non-scalar values
  • Fixed display of console values with an Unknown log level

4.0.2 (2023-09-18)

  • Fixed PHP 7 support
  • Fixed console values which include HTML

4.0.1 (2023-03-04)

  • Added cache busting to enqueued assets
  • Added console level filter counts
  • Added HTTP_COOKIE value to INPUT_SERVER globals

4.0.0 (2023-02-13)

  • Added console level filters
  • Added sorting to Action/Filter Hooks
  • Added syntax highlighting to console entries
  • Added trace information to SQL queries
  • Beautified SQL formating
  • Changed Profiler usage (use the “timer:start” and “timer:stop” hooks)
  • Improved Profiler, it is now also more accurate
  • Refreshed UI
  • Requires PHP >= 7.3

See changelog for all versions.