插件开发文档

调试栏及其插件

💡 云策文档标注

概述

Debug Bar 是一个 WordPress 插件,它在管理栏中添加一个调试菜单,显示查询、缓存等调试信息。本文档介绍了 Debug Bar 及其多个插件,这些插件扩展了其功能,为开发者提供更详细的调试工具。

关键要点

  • Debug Bar 是核心插件,当 WP_DEBUG 启用时跟踪 PHP 警告和通知,当 SAVEQUERIES 启用时显示 MySQL 查询。
  • Debug Bar Console 插件允许运行任意 PHP 代码,便于测试变量内容。
  • Debug Bar Shortcodes 插件显示当前请求中注册的短代码及其详细信息,如调用函数、使用情况。
  • Debug Bar Constants 插件显示 WP 常量、WP 类常量和 PHP 常量。
  • Debug Bar Post Types 插件显示站点注册的文章类型的详细信息。
  • Debug Bar Cron 插件显示 WordPress 计划事件的信息,如事件数量、运行状态。
  • Debug Bar Actions and Filters Addon 插件显示当前请求中附加的钩子(动作和过滤器)。
  • Debug Bar Transients 插件显示 WordPress 瞬态信息,包括数量、列表和删除选项。
  • Debug Bar List Script & Style Dependencies 插件列出加载的脚本和样式及其依赖关系。
  • Debug Bar Remote Requests 插件显示通过 HTTP API 进行的远程请求的详细信息,如方法、URL 和时间。

📄 原文内容

The Debug Bar is a plugin that adds a debug menu to the admin bar that shows query, cache, and other helpful debugging information.

Debug Bar

This is the main plugin, adding the base functionality that is extended by the remaining plugins listed on this page.

When WP_DEBUG is enabled it also tracks PHP Warnings and Notices to make them easier to find.

When SAVEQUERIES is enabled the mysql queries are tracked and displayed.

Visit Debug Bar

Debug Bar Console

This plugin adds a console in which you can run arbitrary PHP.  This is excellent for testing the contents of variables, among many other uses.

Visit Debug Bar Console

Debug Bar Shortcodes

This plugin adds a new panel to the Debug Bar that displays the registered shortcodes for the current request.

Additionally it will show you:

  • Which function/method is called by the shortcode.
  • Whether the shortcode is used on the current post/page/post type and how (only when on singular).
  • Any additional information available about the shortcode, such as a description, which parameters it takes, whether or not it is self-closing.
  • Find out all pages/posts/etc on which a shortcode is used.

Visit Debug Bar Shortcodes

Debug Bar Constants

This plugin adds three new panels to the Debug Bar that display the defined constants available to you as a developer for the current request:

  • WP Constants
  • WP Class Constants
  • PHP Constants

Visit Debug Bar Constants

Debug Bar Post Types

This plugin adds a new panel to the Debug Bar that displays detailed information about the registered post types for your site.

Visit Debug Bar Post Types

Debug Bar Cron

This plugin adds a new panel in the Debug Bar displaying information about WordPress’ scheduled events.

Once installed, you will have access to the following information:

  • Number of scheduled events
  • If cron is currently running
  • Time of next event
  • Current time
  • List of custom scheduled events
  • List of core scheduled events
  • List of schedules

Visit Debug Bar Cron

Debug Bar Actions and Filters Addon

This plugin adds two more tabs in the Debug Bar to display hooks (Actions and Filters) attached to the current request. Actions tab displays the actions hooked to current request. Filters tab displays the filter tags along with the functions attached to it with respective priority.

Visit Debug Bar Actions and Filters Addon

Debug Bar Transients

This plugin adds information about WordPress transients to a new panel in the Debug Bar.

Once installed, you will have access to the following information:

  • Number of existing transients
  • List of custom transients
  • List of core transients
  • List of custom site transients
  • List of core site transients
  • An option to delete a transient

Visit Debug Bar Transients

Debug Bar List Script & Style Dependencies

This plugin lists scripts and styles that are loaded, in which order they’re loaded, and what dependencies exist.

Visit Debug Bar List Script & Style Dependencies

Debug Bar Remote Requests

This plugin will add a new panel to Debug Bar that will display and profile remote requests made through the HTTP API.

Once installed, you will have access to the following information:

  • Request method (GET, POST, etc)
  • URL
  • Time per request
  • Total time for all requests
  • Total number of requests

Optionally, you can add ?dbrr_full=1 to your URL to get additional information, including all request parameters and a full dump of the response with headers.

Visit Debug Bar Remote Requests