跳转到主要内容

Write a check for asserting the value of a given option

One of the check types included in wp doctor is Option_Value, or the ability to assert that a given option is a specific value. The check type is in use by a couple of the default diagnostic checks, and you can use the Option_Value check type in your custom doctor.yml configuration file.

As an example, here are two checks using Option_Value, one which ensures the blog is public and the other which ensures users can't register:

option-blog-public:
  check: Option_Value
  options:
    option: blog_public
    value: 1
option-users-can-register:
  check: Option_Value
  options:
    option: users_can_register
    value: 0

Run together, you might see:

$ wp doctor check --config=option-value.yml --all
+---------------------------+---------+-------------------------------------------------+
| name                      | status  | message                                         |
+---------------------------+---------+-------------------------------------------------+
| option-blog-public        | error   | Site is private but expected to be public.      |
| option-users-can-register | success | Option 'users_can_register' is '0' as expected. |
+---------------------------+---------+-------------------------------------------------+

The Option_Value check type accepts the following options:

  • 'option': Name of the option.
  • 'value': Option is expected to be a specific value.

📖 来源:WP-CLI Handbook · 作者:WP-CLI 开发组与贡献者 · 许可:MIT · 同步自上游提交 264cb13(2025-06-25)· 改动:仅格式转换

本页由 cocobook 外部书同步自动生成,此处只读;要修改请到菲码书稿仓 CocoBook/external-books 的 overlay 目录提合并请求。