Wordpress插件推荐:Query Monitor

     0评论

文章目录[隐藏]

WordPress早已成为一个拥有庞大生态的CMS,我们经常要安装调试各种主题、插件,甚至自己开发主题、插件,要在这过程中发现、检查其运行的错误、慢点是比较困难的。Query Monitor是WordPress的开发人员工具面板,它支持调试数据库查询,PHP错误,挂钩和操作,块编辑器块,排队脚本和样式表,HTTP API调用等,可以为站点调优、插件开发提供很有用的信息,也是我们深入了解、WordPress的一个好用的工具。本文将插件页面的资料翻译呈现,希望对你有帮助。

前文解决WordPress主题的几个错误主要就是在Query Monitor的帮助下完成的。

安装Query Monitor

先通过下面的几张图片对其建立一些直观印象:

管理工具栏菜单:

管理工具栏菜单

按组件聚合数据库查询:

按组件聚合数据库查询

能力检查:

能力检查

数据库查询:

数据库查询

hooks and actions:

hooks and actions

http api请求:

http api请求

通过调用函数聚合数据库查询:

通过调用函数聚合数据库查询

↓↓↓以下是翻译的内容↓↓↓

描述

Query Monitor是WordPress的开发人员工具面板。它支持调试数据库查询,PHP错误,挂钩和操作,块编辑器块,排队脚本和样式表,HTTP API调用等。

它包括一些高级功能,例如调试Ajax调用,REST API调用和用户功能检查。它包括通过插件或主题缩小其大部分输出的能力,允许您快速确定性能不佳的插件,主题或功能。

Query Monitor重点关注以有用的方式呈现其信息,例如通过显示由负责它们的插件,主题或函数分组的聚合数据库查询。它添加了一个管理工具栏菜单,显示当前页面的概述,一旦您选择菜单项,就会在面板中显示完整的调试信息。

有关完整信息,请参阅查询监控网站

以下是每个页面加载显示内容的概述:

  • 数据库查询,包括慢速,重复或错误查询的通知。允许按查询类型(SELECTUPDATEDELETE等),负责组件(插件,主题,WordPress核心)和调用函数进行过滤,并为每个提供单独的聚合视图。
  • 模板文件名,完整的模板层次结构以及所有使用的模板部件的名称。
  • PHP错误与其负责的组件和调用堆栈以及管理工具栏中的可见警告很好地呈现在一起。
  • 使用WordPress 5.0+或Gutenberg插件时,帖子内容中的块和相关属性。
  • 匹配重写规则,关联查询字符串和查询变量。
  • 排队的脚本和样式表,以及它们的依赖项,依赖项和针对已损坏的依赖项的警报。
  • 每个文本域的语言设置和加载的翻译文件(MO文件)。
  • HTTP API请求,包括响应代码,负责组件和所用时间,以及针对失败或错误请求的警报。
  • 用户能力检查,以及传递给能力检查的结果和任何参数。
  • 环境信息,包括有关PHP,数据库,WordPress和Web服务器的详细信息。
  • 所有WordPress条件函数的值,例如is_single()is_home()等。
  • 已更新的瞬态。

另外:

  • 每当发生重定向时,Query Monitor都会添加一个包含调用堆栈的HTTP标头,因此您可以使用自己喜欢的HTTP检查器或浏览器开发人员工具来跟踪触发重定向的内容。
  • 页面上任何jQuery启动的Ajax请求的响应将在其标头中包含各种调试信息。 PHP错误也会输出到浏览器的开发人员控制台。
  • 经过身份验证的WordPress REST API请求的响应将在其标头中包含各种调试信息,只要经过身份验证的用户有权查看Query Monitor的输出。

默认情况下,只有单站点安装的管理员和多站点安装的超级管理员才会显示查询监视器的输出。

除此之外,您还可以设置一个身份验证cookie,允许您在未登录时查看查询监视器输出(或者如果您以非管理员身份登录)。有关详细信息,请参阅“设置”面板。

隐私声明

Query Monitor不会持久存储它收集的任何数据。它不会向任何第三方发送数据,也不包含任何第三方资源。

可以在此处找到Query Monitor的完整隐私声明

常见问题

谁可以看到Query Monitor的输出?

默认情况下,只有单站点安装的管理员和多站点安装的超级管理员才会显示查询监视器的输出。

除此之外,您还可以设置一个身份验证cookie,允许您在未登录时查看查询监视器输出(或者如果您以非管理员身份登录)。有关详细信息,请参阅“设置”面板。

Query Monitor本身是否会影响页面生成时间或内存使用量?

简短回答:是的,但只是一点点。

长答案:查询监视器对页面生成时间的影响很小,因为它以与其他插件相同的方式挂钩到WordPress。影响很小;通常在10毫秒到100毫秒之间,具体取决于您网站的复杂程度。

查询监视器的内存使用率通常约占用于生成页面的总内存的10%。

是否有任何用于Query Monitor的附加插件?

查询监视器的附加插件列表可以在这里找到。

此外,Query Monitor透明地支持Debug Bar插件的附加组件。如果您安装了任何Debug Bar加载项,只需停用Debug Bar,加载项将显示在Query Monitor的菜单中。

我可以在哪里推荐新功能或报告错误?

请使用查询监视器的GitHub回购上的问题跟踪器,因为它更容易跟踪那里的问题,而不是wordpress.org支持论坛。

WordPress.com VIP Go上是否提供了查询监视器?

是的!您只需要将define('WPCOM_VIP_QM_ENABLE', true);添加到vip-config/vip-config.php文件中。

我正在使用`wpdb`的多个实例。如何让我的其他实例显示在Query Monitor中?

您需要挂钩qm/collect/db_objects过滤器,并使用您的连接名称作为键并将wpdb实例添加到数组中价值。然后,您的wpdb实例将显示为单独的面板,查询时间和查询计数将单独显示在管理工具栏菜单中。聚合信息(来电者和组件的查询)不会分开。

我可以点击堆栈跟踪在我的编辑器中打开文件吗?

是的!您只需启用可点击即可堆栈跟踪

您接受捐款吗?

不,我不接受捐款。如果你喜欢这个插件,我很乐意为你留下评论。告诉所有朋友关于插件的信息!

↓↓↓以下是英文版原文↓↓↓

Description

Query Monitor is the developer tools panel for WordPress. It enables debugging of database queries, PHP errors, hooks and actions, block editor blocks, enqueued scripts and stylesheets, HTTP API calls, and more.

It includes some advanced features such as debugging of Ajax calls, REST API calls, and user capability checks. It includes the ability to narrow down much of its output by plugin or theme, allowing you to quickly determine poorly performing plugins, themes, or functions.

Query Monitor focuses heavily on presenting its information in a useful manner, for example by showing aggregate database queries grouped by the plugins, themes, or functions that are responsible for them. It adds an admin toolbar menu showing an overview of the current page, with complete debugging information shown in panels once you select a menu item.

For complete information, please see the Query Monitor website.

Here’s an overview of what’s shown for each page load:

  • Database queries, including notifications for slow, duplicate, or erroneous queries. Allows filtering by query type (SELECT, UPDATE, DELETE, etc), responsible component (plugin, theme, WordPress core), and calling function, and provides separate aggregate views for each.
  • The template filename, the complete template hierarchy, and names of all template parts used.
  • PHP errors presented nicely along with their responsible component and call stack, and a visible warning in the admin toolbar.
  • Blocks and associated properties in post content when using WordPress 5.0+ or the Gutenberg plugin.
  • Matched rewrite rules, associated query strings, and query vars.
  • Enqueued scripts and stylesheets, along with their dependencies, dependents, and alerts for broken dependencies.
  • Language settings and loaded translation files (MO files) for each text domain.
  • HTTP API requests, with response code, responsible component, and time taken, with alerts for failed or erroneous requests.
  • User capability checks, along with the result and any parameters passed to the capability check.
  • Environment information, including detailed information about PHP, the database, WordPress, and the web server.
  • The values of all WordPress conditional functions such as is_single(), is_home(), etc.
  • Transients that were updated.

In addition:

  • Whenever a redirect occurs, Query Monitor adds an HTTP header containing the call stack, so you can use your favourite HTTP inspector or browser developer tools to trace what triggered the redirect.
  • The response from any jQuery-initiated Ajax request on the page will contain various debugging information in its headers. PHP errors also get output to the browser’s developer console.
  • The response from an authenticated WordPress REST API request will contain various debugging information in its headers, as long as the authenticated user has permission to view Query Monitor’s output.

By default, Query Monitor’s output is only shown to Administrators on single-site installations, and Super Admins on Multisite installations.

In addition to this, you can set an authentication cookie which allows you to view Query Monitor output when you’re not logged in (or if you’re logged in as a non-Administrator). See the Settings panel for details.

Privacy Statement

Query Monitor does not persistently store any of the data that it collects. It does not send data to any third party, nor does it include any third party resources.

Query Monitor’s full privacy statement can be found here.

FAQ

Who can see Query Monitor’s output?

By default, Query Monitor’s output is only shown to Administrators on single-site installations, and Super Admins on Multisite installations.

In addition to this, you can set an authentication cookie which allows you to view Query Monitor output when you’re not logged in (or if you’re logged in as a non-Administrator). See the Settings panel for details.

Does Query Monitor itself impact the page generation time or memory usage?

Short answer: Yes, but only a little.

Long answer: Query Monitor has a small impact on page generation time because it hooks into WordPress in the same way that other plugins do. The impact is low; typically between 10ms and 100ms depending on the complexity of your site.

Query Monitor’s memory usage typically accounts for around 10% of the total memory used to generate the page.

Are there any add-on plugins for Query Monitor?

A list of add-on plugins for Query Monitor can be found here.

In addition, Query Monitor transparently supports add-ons for the Debug Bar plugin. If you have any Debug Bar add-ons installed, just deactivate Debug Bar and the add-ons will show up in Query Monitor’s menu.

Where can I suggest a new feature or report a bug?

Please use the issue tracker on Query Monitor’s GitHub repo as it’s easier to keep track of issues there, rather than on the wordpress.org support forums.

Is Query Monitor available on WordPress.com VIP Go?

Yep! You just need to add define( 'WPCOM_VIP_QM_ENABLE', true ); to your vip-config/vip-config.php file.

I’m using multiple instances of `wpdb`. How do I get my additional instances to show up in Query Monitor?

You’ll need to hook into the qm/collect/db_objects filter and add an item to the array with your connection name as the key and the wpdb instance as the value. Your wpdb instance will then show up as a separate panel, and the query time and query count will show up separately in the admin toolbar menu. Aggregate information (queries by caller and component) will not be separated.

Can I click on stack traces to open the file in my editor?

Yes! You just need to enable clickable stack traces.

Do you accept donations?

No, I do not accept donations. If you like the plugin, I’d love for you to leave a review. Tell all your friends about the plugin too!

-- EOF --

本文最后修改于1年前 (2019-05-09)

差评不太行一般挺好非常不错 (No Ratings Yet)
读取中...
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址