[WordPress] 外掛分享: Debug Bar Custom Info

首頁外掛目錄 › Debug Bar Custom Info
10+
安裝啟用
★★★★★
5/5 分(1 則評價)
4278 天前
最後更新
問題解決
WordPress 3.8+ v1.0.2 上架:2014-06-12

內容簡介

這個外掛會在 Debug Bar 外掛中新增一個額外的面板,讓開發者能夠輸出自訂的偵錯資訊。

開發者可以記錄任何變數以查看其在 WordPress PHP 執行時的值。這對於開發者即時查看變數的實際值非常有幫助。它的運作方式就像瀏覽器中的 console.log()。

如何新增自訂偵錯資訊

在您想要偵錯變數的任何位置加入以下程式碼:

do_action( 'add_debug_info', $var, $label );

其中 $var 可以是任何資料型態。

如果 $var 是字串或任何簡單的值,其值會直接輸出。
如果 $var 是陣列或物件,輸出會與 print_r( $var ) 相同。

而 $label 是說明標籤(選擇性)。

如何瀏覽偵錯資訊

按下管理列右上方的 Debug Bar
選擇 Custom Info 面板(參見 螢幕截圖)

專案首頁 | 回報問題 | 捐款

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.0.2) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Debug Bar Custom Info」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

This plugin adds an extra panel to Debug Bar plugin that allows developers to output custom debug info.
Developers can log any variable to see its value when running PHP in WordPress. This helps developers see the real-time values of variables. It works exactly like console.log() in browsers.
How to add custom debug info
Add the following code wherever you want to debug a variable:
do_action( 'add_debug_info', $var, $label );

where $var can has any data type.

If $var is a string or any simple value, the value is outputted directly.
If $var is an array or object, the output is the same as print_r( $var ).

And $label is the description label (optional).
How to view debug info

Click on Debug Bar in the top right of the admin bar
Select Custom Info panel (see screenshots)

Project Homepage | Report Bugs | Donate

延伸相關外掛

文章
Filter
Mastodon