[WordPress] 外掛分享: Kint Debugger

WordPress 外掛 Kint Debugger 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「Kint Debugger」是 2012-02-14 上架。 目前已經下架不再更新,不建議安裝使用。
  • 目前有 2000 個安裝啟用數。
  • 上一次更新是 2019-01-18,距離現在已有 2298 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 2.5 以上版本才可以安裝。
  • 有 14 人給過評分。
  • 論壇上目前有 1 個提問,問題解答率 0%

外掛協作開發者

cdillon27 | misternifty | chriswallace |

外掛標籤

kint | debug | print_r | debugger | var_dump |

內容簡介

此外掛正在等待領養。

Kint Debugger 是一個簡單的包裝工具,使用Kint,這是一個偵錯工具,可以輸出有關於變數和追踪的資訊,並以一個有樣式、可摺疊的格式呈現深層陣列和物件的內容,使它更容易了解。

不再需要在 print_r 或 var_dump 之前添加 PRE 標籤!

Kint Debugger 能與 Debug Bar 外掛配合良好,通過創建自己的面板以顯示您的調試結果。

基本使用

例子:

global $post;
$term_list = wp_get_post_terms( $post->ID, 'my_taxonomy', array( 'fields' => 'all' ) );
d( $term_list );
?>

Kint Debugger 還提供一些輔助函數,以更經常使用的方式顯示變量。

dump_wp_query()
dump_wp()
dump_post()
dump_this( $var, $inline = false ) – 下面有解釋

例子:

如果此外掛沒有啟用,呼叫輔助函數將會引起錯誤。

自訂函數

如果您在不同的位置輸出相同的資訊,考慮在主題的 functions.php 檔案或 mu-plugin 中編寫自己的輔助函數。例如:

function my_dump_terms() {
global $post;
$term_list = wp_get_post_terms( $post->ID, 'my_taxonomy', array( 'fields' => 'all' ) );
d( $term_list );
}
?>

然後在主題或外掛的戰略性點:

使用 Debug Bar

當 Debug Bar 外掛安裝且啟用時,Kint Debugger 會將 d() 輸出發送到其 Debug Bar 面板。

要改為行內輸出,就像未啟用 Debug Bar 一樣,請在您的 config.php 檔案(或實際上在您的 d() 呼叫之前的任何位置)中聲明常數 KINT_TO_DEBUG_BAR:

define( 'KINT_TO_DEBUG_BAR', false );

或者使用帶有參數 $inline 的輔助函數來印出特定的輸出。通用函數 dump_this() 接受 $inline 為第二個參數。

例子:

global $post;
$term_list = wp_get_post_terms( $post->ID, 'my_taxonomy', array( 'fields' => 'all' ) );
dump_this( $term_list , true );
?>

Kint Debugger 覆蓋 Kint 的 d() 函數以緩衝其輸出,以供 Debug Bar 使用。如果您已經有修改過的 d() 函數,則需要通過以下兩種方式之一來防止其被覆蓋。

將修改過的 d() 函數移到 mu-plugin 中。Kint Debugger 在聲明它之前檢查函數是否存在,因此把您的函數放在 mu-plugin 中是確保它存在的唯一方法。
如上述所述,聲明 KINT_TO_DEBUG_BAR。

限制輸出

要限制可見性,使用 kint_debug_display 篩選器。例如,要防止非管理員看到調試輸出:

add_filter( 'kint_debug_display', function( $allow ) { return is_super_admin(); } );

嘗試這些外掛

原文外掛簡介

This plugin is up for adoption.

Kint Debugger is a simple wrapper for Kint, a debugging tool to output information about variables and traces in a styled, collapsible format that makes understanding deep arrays and objects easier.
No more adding PRE tags before print_r or var_dump!
Kint Debugger works well with the Debug Bar plugin by creating its own panel to display your debug results.
Basic Usage

Examples:
ID, 'my_taxonomy', array( 'fields' => 'all' ) );
d( $term_list );
?>

Kint Debugger also provides some helper functions for dumping variables that are frequently needed.

dump_wp_query()
dump_wp()
dump_post()
dump_this( $var, $inline = false ) – explained below

Examples:

Obviously, if this plugin is not active, calls to the helper functions will cause errors.
Your Own Functions
If you are dumping the same information in different places, consider writing your own helper functions in your theme’s functions file or an mu-plugin. For example:
ID, 'my_taxonomy', array( 'fields' => 'all' ) );
d( $term_list );
}
?>

Then at strategic points in your theme or plugin:

With Debug Bar
By default, when Debug Bar is installed and active, Kint Debugger will send d() output to its Debug Bar panel.
To print debug output inline instead, as if Debug Bar was not active, declare the constant KINT_TO_DEBUG_BAR in your config.php (or really anywhere before your d() call):
define( 'KINT_TO_DEBUG_BAR', false );

Or to print a specific dump inline, use a helper function with the parameter $inline. The generic dump_this() takes $inline as the second parameter.
Examples:

ID, 'my_taxonomy', array( 'fields' => 'all' ) );
dump_this( $term_list , true );
?>

Kint Debugger overrides Kint’s d() function in order to buffer its output for Debug Bar. If you already have a modified d() function, you need to prevent the override in one of two ways.

Move your modified d() function to an mu-plugin. Kint Debugger checks if the function exists before declaring it so putting yours in an mu-plugin is the only way to ensure it exists first.
Declare KINT_TO_DEBUG_BAR as described above.

Restricting Output
To restrict visibility, use the kint_debug_display filter. For example, to prevent non-admins from seeing the debug output:
add_filter( 'kint_debug_display', function( $allow ) { return is_super_admin(); } );

Try these plugins too

What The File – Identify template files without fail.
Debug This – Peek under the hood with sixty debugging reports just one click away.

各版本下載點

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

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


1.2 | 1.1.1 | trunk |

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

  • WP Crontrol 》WP Crontrol 可以讓您查看和控制 WP-Cron 系統中正在發生的事件。從管理界面,您可以:, , 查看所有的 Cron 事件以及它們的參數、循環間隔時間、回撥函數以及...。
  • Query Monitor – The developer tools panel for WordPress 》ministrator user). This cookie can be set by defining QM_AUTH_KEY in your wp-config.php file., To learn more about how to use Query Monitor, please...。
  • P3 (Plugin Performance Profiler) 》這個外掛程式可以創建您 WordPress 網站的外掛程式效能概況,並且藉由測量這些外掛對網站載入時間的影響。通常WordPress網站由於過多或配置不佳的外掛程式而...。
  • Debug Bar 》在管理列上新增一個除錯選單,顯示查詢、快取及其他有用的除錯資訊。, 開發者必備的外掛!, 當啟用WP_DEBUG時,也會追蹤 PHP 的警告和注意事項,使它們更容易...。
  • WP Debugging 》此外掛在啟用時會在 wp-config.php 中設定以下偵錯常數,並在停用時移除它們。任何錯誤都會導致拋出 PHP Exception。偵錯常數請參考 WordPress 的「Debugging...。
  • My WP Customize Admin/Frontend 》這個外掛讓管理者和前端使用者都能輕鬆地進行自訂設定。許多自訂篩選器和操作,還包含開發者工具。, 示範網站在這裡:https://tastewp.com/new/?pre-installe...。
  • reBusted! 》這個外掛可以免去你問「你有清空快取嗎?」的問題。, 這是根據原本由 Paul Clark 開發的外掛更新,以符合今天的 WordPress 和 PHP。, 功能, , 在線上網站上安...。
  • Debug Log Manager 》Debug Log Manager 可以讓您:, , 單擊啟用 WP_DEBUG 以記錄 PHP、數據庫和 JavaScript 錯誤,不需要手動編輯 wp-config.php 文件,完成後再禁用。 , 在自訂...。
  • Code Profiler – WordPress Performance Profiling and Debugging Made Easy 》一個可以測量 WordPress 外掛與佈景主題效能的分析工具。, Code Profiler 可以協助您在 PHP 層面上測量您的外掛與佈景主題的效能,並快速找到任何潛在的 Word...。
  • Plugin Detective – Troubleshooting Conflicts 》Plugin Detective 可以幫助您快速且輕鬆地排除網站上的問題,並找出問題的原因。一旦找到罪犯,您可以快速停用有問題的外掛程式。甚至當您的網站出現白屏、致...。
  • Dashboard Widgets Suite 》插件名稱:Dashboard Widgets Suite(控制面板小工具套裝), , 該外掛提供 1 個插件與 9 個小工具,可簡化您的工作流程並提高工作效率。該套裝小工具包括以下...。
  • which template file 》想知道 WordPress 在前台顯示頁面時使用哪個模板嗎?, 這個外掛可以幫您達成這個目的。您可以在免費的模擬網站上嘗試使用:點此連結 => https://tastewp.c...。
  • Debug This 》Debug This是由友好Macho Themes團隊打造、維護和運營的獨立外掛程式。, 對於管理員、開發人員和支援人員,Debug This提供了大量的有關WordPress安裝的信息,...。
  • Debug Log – Manager Tool 》這是一個簡單的除錯日誌外掛程式,您可以在儀表板中檢查除錯日誌。透過一個點擊,您可以啟用或停用除錯功能(例如 ‘ WP_DEBUG’、‘WP_DEBUG...。
  • Debug 》Debug 可以透過編輯 wp-config.php 檔案,幫助您在 WordPress 網站中找到錯誤。您可以使用 Debug 外掛啟用錯誤報告功能,在 WordPress CMS/網站上啟用任何運...。

文章
Filter
Apply Filters
Mastodon